Repository navigation
Description
Context
A mask marks where pixels may change; markup explains what should change using arrows, circles and short notes. The maintainer requests a browser editor so an owner can point at changes without building an exactly sized PNG in another application.
The CLI support is a real prerequisite, not delivered on inspected main: #3785 / open PR #3972. At reviewed PR head 38a822df0370e980aaeae7f5b252f09013f49d1f, MARKUP_LIMITS in packages/module-images/src/markup.ts:15 defines 16,777,216 pixels and 50 * 1024 * 1024 = 52,428,800 bytes. markupProblem requires a separate transparent PNG exactly matching the first reference’s displayed dimensions, after EXIF orientation, and refuses combination with --mask. This issue consumes that CLI behavior after it lands; it does not claim it is on current main.
Source checked at main 40dbae0a2f332eb20c52c2a967611894ca30d289:
REQUEST_IMAGE_MASK_TOOL_NAME,packages/ui-sdk/src/tool-contracts/bridge.ts:328, andhandleRequestImageMask,packages/ui-sdk/src/server/bridge-tools/mask.ts:47, show the shared bridge-tool pattern.MaskEditor,packages/ui-react/src/components/images/mask-editor.tsx:28, is the existing full-screen drawing flow.createMaskApplication,packages/ui-server/src/brain/mask-application.ts:95, owns hash/lock/path/authority rechecks. Itsreadhelper at :31 and mask-specific caps must not inadvertently impose 8 MiB on markup.MAX_CLIENT_FRAME_BYTES,packages/ui-sdk/src/schemas.ts:179, is 12,000,000; a 50 MiB layer cannot fit that current general client-frame envelope, especially as base64.ImageMaskResultCard,packages/ui-react/src/components/chat/tool-cards/image-mask-card.tsx:162, andImageMaskFallback, the same file at :202, establish receipt/failure presentation.- Backend entry points:
createMaskTool,packages/ui-backend-claude/src/mask-tool.ts:23, and the mask handling inpackages/ui-backend-pi/src/bridge-tools.ts.
Binding records: docs/decisions/design-feedback.md (receipt, not a path), docs/decisions/design-kit/overlays.md, docs/decisions/design-kit/components-and-interactions.md, docs/decisions/voice-permission.md, docs/decisions/provider-history.md, and docs/decisions/proportionate-containment.md.
Decisions — maintainer, 2026-11-11
These rulings supersede conflicting portions of the earlier proposed design comment.
- M1 — separate tool/editor:
request_image_markup/MarkupEditor, sharing a presentational shell with the mask editor. Keeprequest_image_mask’s name, input, result, visible behavior and 8 MiB cap unchanged. Tool descriptions distinguish “where pixels may change” (mask) from “what to change” (markup). - M2 — full CLI cap: the markup UI and server accept up to 52,428,800 bytes (50 MiB), matching the CLI’s value called “50 MB”. Measure actual PNG bytes before submission and enforce the same bound server-side. The former 8 MiB recommendation and its copy are superseded. A layer over the cap stays in the editor with a clear size reason and writes nothing.
- M3 — scratch only: server-owned output under
.brain/scratch/markup/; no beside-source destination option. Use a safe filename derived from the source with source-hash binding and collision-safe resubmissions. No arbitrary worker/client-selected destination. Standard scratch-retention/cleanup rules apply; a deliberate later copy can retain the layer as content. - M4 — compact v1: Pen, Arrow, Ellipse, Text and Hand/pan; fixed red/yellow/cyan palette, three widths, undo/redo/clear. Defer rectangles and a free color picker. Keep the original proposed note placement/editing, image-coordinate storage, touch/pointer gestures, Fit/zoom and receipt states, subject to the selected cap/storage rules.
- M5 — split: ui-kit: add markup drawing components and shared image-editor shell #3983 supplies the shared shell, drawing/note/toolbar/receipt/fallback components and stories; this issue then owns the tool, upload/application route, backend registration and app integration.
- M6 — verification: the implementing agent verifies the agreed design and stories with browser/accessibility checks. There is no mandatory separate maintainer visual sign-off before integration.
The full phone/desktop editor and receipt mocks in the existing design comment remain the visual specification, amended by the rulings above. In particular, replace its 8 MiB limit/copy with the exact selected 50 MiB bound; do not implement a mask-editor mode or beside-source writes.
Out of scope
brain image/--markupvalidation or provider routing changes, owned by modules: markup-guided image edits (--markup) #3785.- New image providers; markup on Gemini; JSON-body image edits.
- Changes to the existing mask contract, behavior or byte limits; only the behavior-preserving shell extraction in ui-kit: add markup drawing components and shared image-editor shell #3983 is allowed.
- Voice-turn/no-grant markup, source cropping/resizing, image layers/filters, rectangles and free color selection.
- Raising general client/server frame limits or other binary/Markdown limits to accommodate one markup feature.
Scope
- Add the shared additive bridge tool
mcp__brain-ui__request_image_markup, with input{ imagePath, instruction? }and a bounded description directing the agent to use its returned PNG withbrain image --ref <image> --markup <path>, never with--mask. - Consume ui-kit: add markup drawing components and shared image-editor shell #3983’s editor/components. Produce a transparent annotation layer at the source’s displayed dimensions, never flattened onto the source image.
- Provide a bounded markup-specific upload/application path that can carry the full selected cap. Preserve the existing general frame bounds; do not route a 50 MiB layer through an envelope that only accepts a small fraction of it. Reuse existing authority/turn ownership and cancellation boundaries, without creating a general arbitrary-binary write facility.
- Add a server-owned application callback, following
BackendBridge.applyImageMask?’s trust/recheck pattern, writing only the authorized editor-returned bytes under.brain/scratch/markup/. Recheck source hash, destination/topology, policy, lock, current turn authority and membership immediately before commit; record only committed effects and real cleanup results. - Register on both interactive backends with the existing stable tool-roster rule; refuse voice/no-grant turns before opening an editor or writing. No internal labels/receipts/limits are injected into provider-facing conversation history.
- Return the proposed receipt data: repo-relative source/layer paths, dimensions, bytes, mark counts and note text. A later image-edit failure is separate from the receipt for successfully drawn markup.
Acceptance criteria
- The approved ui-kit prerequisite ui-kit: add markup drawing components and shared image-editor shell #3983 is delivered and the editor follows the final design at 320px/desktop, light/dark and reduced motion. Existing mask behavior, baselines and 8 MiB cap remain unchanged.
- The agent can request markup, the user can draw/submit, and the tool returns the saved repo-relative scratch PNG plus the agreed receipt metadata. A keyless test proves
brain image --ref <source> --markup <layer>accepts the exported PNG andmarkupProblemreturns null after modules: markup-guided image edits (--markup) #3785 delivers. - A JPEG with EXIF orientation 6 yields the correctly rotated displayed dimensions. The PNG has an alpha channel, contains the annotation marks/text and transparent background, and is never a flattened copy of the source. Source and layer obey the CLI pixel/dimension requirements.
- Enforce 52,428,800 bytes inclusively, reject one byte over, and use unambiguous byte/MiB copy. Exercise a valid markup upload above the old mask/WS-envelope threshold through the actual chosen transport, plus the exact cap/over-cap paths. Browser, schema/transport, callback, decoder and file-read limits must agree; no hidden inherited 8 MiB or 12,000,000-byte bottleneck may defeat the advertised cap. Keep unrelated limits unchanged.
- The server chooses and confines output to
.brain/scratch/markup/, retains source-hash binding, handles repeated submissions without corrupting earlier receipt artifacts, and respects scratch prerequisites/retention. A caller cannot choose an outside destination or forge which editor bytes/turn/source are being applied. - Empty markup, decline/dismissal, cancellation, voice and no-grant turns refuse and write no file. Changed source, invalid PNG/dimensions/alpha, traversal, symlinks/hardlinks, changed directory topology, revoked/held authority and wrong turn membership refuse under the existing narrow containment rules. Each relevant guard has behavioral proof and a restored mutation receipt.
- Both interactive backends share the declared tool name/schema/handler behavior and preserve their tool rosters and append-only provider history. Unsupported hosts return an explicit refusal rather than trying another write path.
- The receipt shows actual source/layer, dimensions/bytes, marks and notes, or an honest not-rendered state; failures use the result’s real reason. A later
brain imagefailure does not rewrite the successful markup receipt. - New tool, input/result, capability/callback, upload/application bounds and public exports are inventoried in the relevant integration-contract components in the same
CONTRACT:commit, with a minor changeset and appropriate usage/docs updates.
Verification
Keyless/offline SDK, server, app and both-backend tests must cover real tool/editor/transport/application integration, the selected size boundary and safety refusals. Run real-browser drawing/text/pan/zoom/export tests, including phone dimensions and EXIF, and preserve existing mask/browser/visual baselines. Prove no writes on refusal and correct effect/receipt attribution; include focused failing-first evidence and restored mutations of source-hash, dimension and authority/isolation checks. No real image-provider calls in tests.
Run the applicable focused checks (bun run test packages/ui-sdk packages/ui-server packages/ui-react packages/ui-kit packages/ui-backend-claude packages/ui-backend-pi, typecheck, lint and bun run check:pr --base origin/main). Run the provider-history guard because the tool is on the turn path. Hosted proof follows the existing PR/runtime rules; do not count an unmerged CLI or missing/skipped proof as delivery.
Contract impact
Additive bridge tool, input/result and a bounded markup application/upload capability; update docs/integration-contract/mcp.md and any affected wire/package API components. Keep mask and general frame/Markdown contracts intact. New literal sizes, schema/transport limits and the result shape must agree across both backends. The selected scope is additive; a breaking proposal requires its own maintainer ruling first.
Dependencies
#3785 supplies the CLI layer contract; #3983 supplies the shared shell and markup components. The component task can proceed independently, but this integration issue remains dependency-blocked until both deliver.
Wanted but unscheduled (priority: p2); no release milestone is committed. Standalone, preserving the issue’s current lack of a native parent.
2026-11-11: folded all M1–M6 maintainer rulings into the current specification, split the approved kit prerequisite, corrected the CLI-on-main claim and exact byte/transport requirements, and finalized acceptance/verification. Implementation remains open.
Activity
schlessera commentedon Nov 11, 2026
Design needed. Settled already:
brain image --markupexists (#3785), and the mask flow gives this a working pattern for every layer. That pattern is a bridge tool, a full-screen editor, a server-owned PNG application route with hash and lock rechecks, a receipt card, and voice exclusion. Left open is everything the user sees and does: whether markup is a mode of the mask editor or its own flow, which drawing tools it offers (arrows, circles, freehand, text notes), how text is rendered into the PNG, and what the receipt shows. The code can't settle these: each answer changes the editor's toolbar, its touch behaviour at 320px, and what the agent is told to do.schlessera commentedon Nov 11, 2026
Design: markup editor for markup-guided image edits
Summary. Markup gets its own tool and editor (
request_image_markup,MarkupEditor), not a mode of the mask editor. Both editors share one extracted ui-kit shell (header, stage, toolbar slot), so they look and behave the same.request_image_maskstays unchanged: name, input, result and visible behaviour. Examples use the raft in Ithaca harbour,photos/raft-at-ithaca.jpg, 3024 × 4032 after EXIF orientation 6.1. One editor or two → two tools, one shell
request_image_maskwithmode: "mask" | "markup"request_image_maskandrequest_image_markup, each with its own description"The user closed the markup editor", and the user says what they meant in chat.brain image --markup, never with--mask."MaskEditor's frame into the kit is a code move. It changes nothing visible, and its existing baselines prove that.2. Tools
Shipping first: Pen (freehand), Arrow, Ellipse, Text, Hand (pan). Rectangle is deferred, because "circle this" covers it and it would cost a sixth slot at 320 px.
#FF3B30(default), yellow#FFD60Aand cyan#32D2F5. Every mark is rasterised with a 1 px dark halo, so it reads on both light and dark photos. No free colour picker.3. Text notes
aria-label="Note text", up to 80 characters, one line). Enter or Place commits it; Esc or tapping elsewhere with an empty field cancels it.notes[]), so the agent doesn't have to read them from pixels.4. Zoom and pan
+/−keys0key5. The instruction line
Shown in the header below the title, prefixed "Agent asks:", as plain text that is never rendered as markup. It is clamped to two lines; tapping it expands it, with
aria-expanded. With no instruction the header shows the image path. The title is fixed: "Mark up the image".6. Submit, decline, dismissal, empty layer
Buttonas the mask editor's "Use this area"."The user closed the markup editor".Callout, built from the result's own words, as inImageMaskFallback:no markup drawn on photos/raft-at-ithaca.jpg · The user closed the markup editor7. The receipt card
The kit
Surface, tone teal, label "Markup drawn", meta "by you".markup not rendered, the same rule as the mask card.Receipt):marks2 arrows · 1 ellipse · 1 notenotes"move the raft here" (each note quoted, up to 3, then "+2 more")size3024 × 4032 px · matches sourcesourcephotos/raft-at-ithaca.jpglayer.brain/scratch/markup/raft-at-ithaca.3f9a1c2e.markup.png · 212 KBbrain imageedit fails: this card doesn't change. The receipt records what the user drew. The failure belongs to thebrain imagetool card, which already states its own error.8. Filename and byte cap
.brain/scratch/markup/<source-stem>.<sha8-of-source>.markup.png. It goes in scratch and never next to the image, so a markup layer never becomes brain content. The source hash in the name means a second markup on a changed image never overwrites the first.BRAIN_MARKUP_MAX_BYTES= 8,388,608, the same value as masks. Sparse marks on transparency compress well: a 16.7 MP layer with typical markup is well under 1 MB, and only dense freehand approaches the cap. The browser measures the PNG before sending and refuses in the editor (see 6), and the route enforces the cap again. Raising the cap to 50 MB would mean base64 bodies of up to about 67 MB through the bridge, which isn't worth it.Proposed contract (additive)
Bridge:
BackendBridge.applyImageMarkup?, sitting next toapplyImageMask?with the same rechecks, the filename rule above andBRAIN_MARKUP_MAX_BYTES.docs/integration-contract/mcp.mdgets a section beside the mask rules.Mocks
Editor, 320 px (fullscreen overlay, dark media chrome):
Editor, desktop:
Toolbar states:
Discard confirmation (dismissal with marks):
Decline receipt (chat):
Receipt card, 320 px (thumb stacked above rows):
Receipt card, desktop: the same rows and order as at 320 px; the thumb stays above the rows, keeping the mask card's truncation rule.
ui-kit inventory (Storybook first)
Overlay(fullscreen),Button,IconButton(md, 44 px),Callout,Surface,Receipt.ImageEditorFrame, the shell ofMaskEditor(header with title and instruction, stage, toolbar slot, error line). No visual change; the existing mask baselines must pass unchanged.MarkupCanvas: draws marks, handles gestures, zoom/pan and Fit. It stores marks in image coordinates and has an export helper.MarkupToolbar: tools, swatches, widths, undo/redo/clear, submit.MarkupNoteFieldMarkupResultCardandMarkupFallbackMarkupToolbar: each tool active, the disabled state with no marks, and with marks.MarkupCanvas: each mark type, text placing, text editing, zoomed 4× with pan, and the Fit button.MarkupResultCard: rendered, not rendered, more than 3 notes, and a long path.MarkupFallback: closed, voice refused, and source changed.aria-pressedtoggle with a name ("Pen", "Arrow", "Ellipse", "Text note", "Pan");role="img"and a live summary, "4 marks: 2 arrows, 1 ellipse, 1 note";Open questions for the maintainer
request_image_maskstays untouched.area: ui-kit) that blocks this one? This issue would then carry the tool, the route and the integration.schlessera commentedon Nov 11, 2026
Decision (maintainer, 2026-11-11): M5 — create a separate ui-kit prerequisite issue for this feature’s shared editor shell, markup components and stories, then integrate here. M6 — let the implementing agent verify those stories against the agreed design and browser/accessibility checks; no mandatory separate maintainer visual sign-off.
These choices were made together with the equivalent voice-preview workflow choices on #3974. The body now records them. M1–M4 remain to be answered, and #3785 remains the CLI prerequisite;
needs: decisionandblockedare retained for now.schlessera commentedon Nov 11, 2026
Decision (maintainer, 2026-11-11): All markup choices are settled.
request_image_markuptool/editor, sharing the mask editor’s shell. Preserve the existing mask contract and behavior.38a822df0370e980aaeae7f5b252f09013f49d1f:MARKUP_LIMITS.maxBytesis50 * 1024 * 1024, exactly 52,428,800 bytes (50 MiB). The issue now requires this cap end to end through a markup-specific bounded transport; the current general client-frame limit is only 12,000,000 bytes. Do not enlarge unrelated frame or mask limits..brain/scratch/markup/, with server-owned safe filenames/source binding and the existing scratch rules.Created #3983 for the shared shell, markup controls and stories. This issue now owns integration and retains its real CLI prerequisite #3785, whose PR is still open. The final body replaces the earlier proposal’s 8 MiB cap and any beside-source/mask-mode alternatives, corrects source navigation, and makes verification explicit.
Remove
needs: decision, addagent-ready,contractand unscheduledpriority: p2, and retainblockedfor #3785 and #3983. The split component issue ownsarea: ui-kit; integration remains under the SDK/server/React/backends areas.3 remaining items
CONTRACT: feat(ui-kit): markup editor parts and the shared image-edit…
schlessera commentedon Nov 16, 2026
Unblocked: #3785, #3983 are closed, so
scripts/sync-project.tsis removing theblockedlabel.schlessera commentedon Nov 16, 2026
Claimed for implementation. Claim token:
claim-8671d3f3. Branch:feat/3975-request-image-markup.No direct path collisions; only test-closure overlap with open draft PRs.
CONTRACT: feat(ui-sdk,ui-server,ui-react,backends): request_image_mar…
CONTRACT: feat(ui-sdk,ui-server,ui-react,backends): request_image_mar…
CONTRACT: feat(ui-sdk,ui-server,ui-react,backends): request_image_mar…
CONTRACT: feat(ui-sdk,ui-server,ui-react,backends): request_image_mar…
CONTRACT: feat(ui-sdk,ui-server,ui-react,backends): request_image_mar…
test(ui-react): give the hygiene review's polls and the picker focus-…
schlessera commentedon Nov 17, 2026
Delivered in #4104, squash
141c2437a02c840a9fd8558b196406ea98c33d88, milestone 0.45.0.request_image_markuplets the agent ask the user to draw what an image edit should change. The host saves a transparent PNG at the source's displayed size, after EXIF orientation, under.brain/scratch/markup/. The tool returns the path, size, mark counts and notes forbrain image --ref <image> --markup <layer>.BackendBridge.requestImageMarkup). The worker never holds the layer's bytes or names a destination, and a host without the operation refuses.POST /api/markup/:requestIdaccepts up to 52,428,800 bytes, inclusive; the request's own principal and exactturnIdare required. A 13.3 MB layer is proven over real HTTP.GET /api/markup/:requestId/sourceserves the bound source, beyond the 10 MiB file route. The mask's 8 MiB cap and the 12,000,000-byte frame are unchanged.brain-common.imageMarkup. Losing the last of them, cancellation or shutdown rejects the request.MarkupEditoropens for a request and uploads the layer, and requests queue. The transcript showsMarkupResultCardorMarkupFallback.mcp.md,wire.md,package-api.mdandhttp-api.md, and the change shipped under aCONTRACT:commit with a changeset.Post-merge. Main went red at
141c243on two browser timing flakes in tests the change does not touch; one reproduced without it. Incident #4125 was fixed by #4135. Main run https://github.com/schlessera/brain-kit/actions/runs/44001979141 is green and cleared the record.Known gaps, also listed in the PR: