Skip to content

Mark up screenshots with pins, drawing and crop before sending them to the agent (#460) - #1663

Merged
currentbits merged 2 commits into
mainfrom
coder/screenshot-markup-pin-and-draw-then-send-c1ca72
Oct 18, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/screenshot-markup-pin-and-draw-then-send-c1ca72

Conversation

@currentbits

Copy link
Copy Markdown
Owner

"The padding on this card is wrong" is quicker to show with a circle on a screenshot than to describe in a paragraph. Clicking an attached image's thumbnail in the composer now opens a markup editor. What you mark gets drawn into the image, so every provider sees it. Closes #460.

Changes

  • Pin: click to drop a numbered red pin; a note field opens beside the image and takes focus. Draw: drag to draw freehand. Crop: drag to keep a region. Undo and Clear are in the toolbar.
  • Save markup produces a single PNG with the markup drawn in and the crop applied. It replaces the original chip in place and goes through the existing pasted-image save, so nothing changed on the electron side.
  • Pin notes are added to the prompt as editable text, e.g. Markup on shot.png (numbered red pins):\n1. Title should be 24px.

Verification

  • npm run typecheck passes, npx vite build passes, and all 231 tests in test/composer*.test.tsx pass after rebasing onto current main.
  • New render test runs the real editor (jsdom Image/canvas faked): drop a pin, type a note, save. It then checks the uploaded data URL, that the chip was swapped in place, and the exact prompt text. Plus a unit test for crop-rect normalization.
  • Ran it in Chromium against the vite dev server, with a local-only patch so the dev bridge can save and load images (not committed). The saved PNG was cropped to 720×420 with the pins and stroke drawn in, and the notes landed in the prompt.

Notes for reviewers


claude-opus-5-5 via Claude Code

🤖 Generated with Claude Code

#460)

Clicking an image chip's thumbnail opens a markup editor: numbered pins
with optional notes, freehand strokes and a crop region. Save flattens
the markup into a PNG that replaces the chip, so every provider sees it,
and appends the pin notes to the draft as text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T19:58:55.962000Z 5b242f8 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 5b242f8456

ℹ️ 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".

/** The flattened PNG replaces its chip; pin notes go into the draft. */
const saveMarkup = (dataUrl: string, notes: string) => {
const source = markup?.attachment;
setMarkup(null);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve markup until image persistence succeeds

When onSaveAttachmentImage rejects or returns null—for example, electron/attachments.js rejects PNGs over its 20 MB limit or a disk write fails—this immediately destroys the editor and all strokes, crop, and notes before the outcome is known. The failure handlers only display an error, so the user cannot retry without recreating the markup; while the promise is pending, an existing prompt can also be sent with the unmodified attachment. Keep the editor open in a saving state and close it only after the replacement succeeds.

Useful? React with 👍 / 👎.

Comment on lines +293 to +295
if (e.key === "Enter") {
e.preventDefault();
save();

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 Ignore Enter while a pin note is composing

For users entering a pin note through an IME, Enter is used to commit the current composition and arrives with nativeEvent.isComposing. This handler treats that event as Save, closing the dialog before the composed text is committed and potentially omitting or truncating the note. Guard the shortcut with !e.nativeEvent.isComposing, as the main composer already does.

Useful? React with 👍 / 👎.

Comment on lines +241 to +242
disabled={marks.length === 0}
onClick={() => setMarks((prev) => prev.slice(0, -1))}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include crop changes in the undo history

When the latest edit is a crop, Undo only removes the last mark; if the crop is the only edit it is disabled entirely, and if strokes or pins exist it undoes an older action instead of the crop. Track crop changes alongside marks or explicitly restore the previous crop before slicing the mark list so Undo reverses the most recent visible edit.

Useful? React with 👍 / 👎.

@currentbits
currentbits merged commit ff71e9c into main Oct 18, 2026
6 checks passed
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.

Screenshot markup: pin and draw, then send as prompt context

1 participant