Repository navigation
Jump from a reply to the boards it made or changed, and a theme switch #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c080498
A Vercel-style theme switch: system, light or dark
Jing-yilin d070c20
Buttons under a reply for the boards it made or changed, which find t…
Jing-yilin 7a59a17
Find a reply's board by its path, and fold its buttons to three rows
Jing-yilin 854319c
Merge the theme switch into jump-to, which it now depends on
Jing-yilin 7f55b72
Review fixes: board hashes skip non-files, jump buttons off in anothe…
Jing-yilin 84944df
Merge remote-tracking branch 'origin/main' into jump-to
Jing-yilin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,10 +3,41 @@ | |
| * `/__sp/index.json`. The server scans on every request, and the build writes the same shape | ||
| * into `dist` once. `src/canvasIndex.ts` declares the shape the client reads. | ||
| */ | ||
| import { createHash } from "node:crypto"; | ||
| import fs from "node:fs"; | ||
| import path from "node:path"; | ||
| import { svgSignature } from "../src/svgSignature.ts"; | ||
|
|
||
| export const boardHash = (file: string) => | ||
| createHash("sha1").update(fs.readFileSync(file)).digest("hex"); | ||
|
|
||
| /** | ||
| * What each board in a boards directory holds, by `<slug>/<file>.html`: a generator writes every | ||
| * board on each run, and only the ones whose bytes changed are news. An unreadable or missing | ||
| * folder holds none, and a dot-file or a folder named like a board is no board. | ||
| */ | ||
| export function hashBoards(canvasesDir: string) { | ||
| const list = (dir: string) => { | ||
|
Comment on lines
+19
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| try { | ||
| return fs.readdirSync(dir); | ||
| } catch { | ||
| return []; | ||
| } | ||
| }; | ||
| const hashes = new Map<string, string>(); | ||
| for (const slug of list(canvasesDir)) | ||
| for (const name of list(path.join(canvasesDir, slug))) { | ||
| const file = path.join(canvasesDir, slug, name); | ||
| if ( | ||
| name.endsWith(".html") && | ||
| !name.startsWith(".") && | ||
| fs.statSync(file, { throwIfNoEntry: false })?.isFile() | ||
| ) | ||
| hashes.set(`${slug}/${name}`.normalize("NFC"), boardHash(file)); | ||
| } | ||
| return hashes; | ||
| } | ||
|
|
||
| /** | ||
| * A project's boards: this folder under it, one subfolder per canvas. The same folder under the | ||
| * plugin root is the examples every project is shown beside its own. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 New projects lose board jump buttons
When a first turn names an unnamed project, named moves its folder before the end event.
hashBoards(before.dir)then sees no boards at the old path, so the reply has no jump buttons.Learn more
An unnamed project starts in an Untitled folder. On a successful run, the child close handler calls named before it finishes the run. named moves the entire project folder, while
before.dirstill names the oldcanvasesdirectory.hashBoardstreats the missing directory as empty, and the end event loses all created or updated boards.Example: Start a new Untitled project and ask the agent to name it and make
canvases/launch/01-home.htmlon the first turn. The folder becomes its new project name, but the reply has no01 Homebutton.Recommended fix: Compute the after-hashes before calling
named, or update the run's tracked directory whennamedmoves it. Preserve the original before-hashes for the comparison.Was this helpful? React with 👍 or 👎 to provide feedback.