Skip to content

Hand the agent a mockup's file, not a picture of it - #199

Merged
Jing-yilin merged 2 commits into
mainfrom
fix/board-attach-by-path
Sep 28, 2026
Merged

Jing-yilin merged 2 commits into
mainfrom
fix/board-attach-by-path

Conversation

@Jing-yilin

@Jing-yilin Jing-yilin commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Pressing + on a mockup (a canvas-file board) had the server shoot it, and that PNG went to the agent as an image block ([Image #n] slug/file.html + base64 image; Codex got the PNG's path). The mockup is an HTML file the agent reads, so the extra image only cost tokens.

Fix

  • canvasAttach.tsx marks a board's attach page: true. Pictures and the person's own shapes are unchanged.
  • ChatPanel.tsx keeps the flag on the tile and posts it with the image. The shot is still taken and kept, because the composer tile and the transcript thumbnail draw it.
  • server/agent.ts validates the flag and resolves <slug>/<file>.html to the board's absolute path with folderOf (project or app canvases). For a community project it keeps the name sp fetch finds it by.
  • agents.ts: for a page, Claude gets only the text [Image #n] <path>, with no image block. Codex gets that path instead of the PNG's.

Test

agents.test.ts covers a mockup for both agents. tsc -b and vitest run pass.

🤖 Generated with Claude Code


Devin Review

The + on a board shot it and sent the PNG as an image block beside its
path. The file is what the agent reads and edits, so the shot now stays
the tile's and the transcript's, and the agent gets only
"[Image #n] <absolute path to the .html>". Pictures, and the person's own
shapes, still go as images.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Deploying super-prototyping with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2ed1ab8
Status: ✅  Deploy successful!
Preview URL: https://107400db.super-prototyping.pages.dev
Branch Preview URL: https://fix-board-attach-by-path.super-prototyping.pages.dev

View logs

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

Devin Review

Comment thread canvas/server/agent.ts Outdated
Comment on lines +503 to +507
return community === undefined &&
rest.length === 0 &&
SAFE_NAME.test(slug) &&
SAFE_NAME.test(file ?? "")
? path.join(folderOf(boards, examplesDir, slug), file)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Attached mockup points at another project

After a tab switch, pageOf resolves an attached mockup against the project open at send time. The attachment keeps only slug/file.html, so the agent reads another project's board or a nonexistent file.

Learn more

A 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 shop/01-home.html in project A, switch to project B, and send "tighten #1". The agent receives B's board if B has the same slug and filename; otherwise it receives a path to a nonexistent board.

Recommended fix: Preserve the board's source project at attachment time and resolve the file from that project, including for queued messages.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2ed1ab8.

window.location.href,
).href;
return dispatchAttach({ kind: "board", name, src });
return dispatchAttach({ kind: "board", name, src, page: true });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 ## Unreleased for user-visible changes, but this PR adds none.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2ed1ab8.

Comment thread canvas/server/agent.ts Outdated
Comment on lines +501 to +509
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)
: name;
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Inline the single-use path helper

pageOf has one call site in the adjacent image mapping. Repository rules ask for single-use helpers to be inlined.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2ed1ab8.

The panel is one across tabs, so a tile attached in one project can be
sent from another; it now carries where it was attached and the server
resolves the file there. Inline the one-use helper, and add the release
note.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7d54b5d320

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread canvas/server/agent.ts Outdated
// 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) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Inline the single-use page resolver

This newly added helper has only one call site (pageOf(i.name) in the held mapping), 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 👍 / 👎.

@Jing-yilin
Jing-yilin merged commit d1b1b6a into main Sep 28, 2026
10 checks passed
@Jing-yilin
Jing-yilin deleted the fix/board-attach-by-path branch September 28, 2026 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant