Repository navigation
Hand the agent a mockup's file, not a picture of it #199
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -310,6 +310,8 @@ export function createAgentServer(options: { | |
| !/^[A-Za-z0-9+/]*={0,2}$/.test(i.data) | ||
| ) | ||
| return send(400, "bad image data"); | ||
| if (i.page !== undefined && i.page !== true) | ||
| return send(400, "bad image page"); | ||
| } | ||
| // The body cap above is the panel's limit in base64; a client that is not the | ||
| // panel meets the limit itself here, in the bytes the files come out as. | ||
|
|
@@ -493,15 +495,34 @@ export function createAgentServer(options: { | |
| const id = randomUUID(); | ||
| fs.mkdirSync(keptOf(id), { recursive: true }); | ||
| const imagesDir = images.length ? keptOf(id) : ""; | ||
| // A mockup's picture is kept for the panel, and the agent is pointed at its file, | ||
| // `<slug>/<file>.html` in whichever canvases folder holds that slug. A community | ||
| // project's is not on this machine, so it keeps the name `sp fetch` finds it by. | ||
| const pageOf = (name: string) => { | ||
| const [slug, file, ...rest] = name.split("/"); | ||
| return community === undefined && | ||
| rest.length === 0 && | ||
| SAFE_NAME.test(slug) && | ||
| SAFE_NAME.test(file ?? "") | ||
| ? path.join(folderOf(boards, examplesDir, slug), file) | ||
|
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. 🔴 Attached mockup points at another project After a tab switch, Learn moreA mockup is attached before its message is sent. attach sends only its slug and file name, while post sends whichever project is open when the message goes out. Resolving this name under the currently open project points to another file after switching projects. Example: Attach Recommended fix: Preserve the board's source project at attachment time and resolve the file from that project, including for queued messages. Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
Author
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. Fixed in 2ed1ab8. |
||
| : name; | ||
| }; | ||
|
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. 🔍 Inline the single-use path helper
Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
Author
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. Fixed in 2ed1ab8. |
||
| const held: AgentImage[] = images.map( | ||
| (i: { n: number; name: string; type: string; data: string }) => ({ | ||
| (i: { | ||
| n: number; | ||
| name: string; | ||
| type: string; | ||
| data: string; | ||
| page?: true; | ||
| }) => ({ | ||
| ...i, | ||
| path: picture( | ||
| id, | ||
| `image-${i.n}`, | ||
| i.type, | ||
| Buffer.from(i.data, "base64"), | ||
| ), | ||
| page: i.page && pageOf(i.name), | ||
| }), | ||
| ); | ||
| const c = command( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ async function attach(editor: Editor, target: TLShape) { | |
| `&w=${Math.max(1, Math.round(w * scale))}&h=${Math.max(1, Math.round(h * scale))}`, | ||
| window.location.href, | ||
| ).href; | ||
| return dispatchAttach({ kind: "board", name, src }); | ||
| return dispatchAttach({ kind: "board", name, src, page: true }); | ||
|
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. 🔍 Add an Unreleased note for mockup attachments The agent now receives a mockup's HTML file instead of its picture. Contributing rules require a line under Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
Author
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. Fixed in 2ed1ab8. |
||
| } | ||
| // One of the person's own: whatever it is, the agent gets a picture of it, named by where it | ||
| // reads the thing itself (canvasContent.ts). | ||
|
|
||
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.
This newly added helper has only one call site (
pageOf(i.name)in theheldmapping), contrary to the repository's explicit rule that one-call helpers be inlined; move this resolution directly into the mapping to avoid the unnecessary jump and follow the mandated structure.AGENTS.md reference: AGENTS.md:L128-L129
Useful? React with 👍 / 👎.