Skip to content

ui-react: a markup editor for markup-guided image edits #3975

Closed

Description

@schlessera

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, and handleRequestImageMask, 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. Its read helper 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, and ImageMaskFallback, 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 in packages/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. Keep request_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

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 with brain 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 and markupProblem returns 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 image failure 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

Blocked by #3785 and #3983

#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

  1. schlessera commented on Nov 11, 2026

    @schlessera
    OwnerAuthor

    Design needed. Settled already: brain image --markup exists (#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.

    You are designing the chat UI's markup-guided image edit flow for brain-kit, a file-first personal knowledge base operated by a coding agent. Use the Odysseus example world (Ithaca harbour, the raft, the cast in docs/decisions/example-corpus.md) for every example and mock.
    
    Read first:
    - The issue this prompt is posted on, and #3785 (the `brain image --markup` CLI flag) with its PR #3972.
    - packages/module-images/src/markup.ts — `markupProblem`: what a valid layer is (PNG signature, alpha channel, same width and height as the first --ref after EXIF orientation, ≤16,777,216 px, ≤50 MB).
    - packages/ui-react/src/components/images/mask-editor.tsx:28-252 — `MaskEditor`, the existing paint-over editor this would sit beside or extend.
    - packages/ui-react/src/components/chat/tool-cards/image-mask-card.tsx:162 — `ImageMaskResultCard`, and docs/decisions/design-feedback.md:1337 ("request_image_mask — a receipt, not a path").
    - docs/decisions/design-kit/overlays.md:24 — the `fullscreen` overlay kind the mask editor uses.
    - docs/decisions/design-kit/components-and-interactions.md:1272 — 44px `md` icon controls in the mask editor's toolbar.
    - packages/ui-sdk/src/tool-contracts/bridge.ts:328-350 — the mask tool's name, description and input schema.
    - docs/integration-contract/mcp.md:446-469 — the mask application route's rules (filename, byte cap, hash rechecks).
    - docs/decisions/voice-permission.md:262 — why the mask editor is excluded from voice turns.
    
    The problem: a user wants to edit an image by pointing, e.g. "move the raft to where the arrow points, and make the circled sail red". OpenAI's GPT Image 2.6/2.5 edits take a separate transparent PNG annotation layer the exact size of the source. Today the user would have to draw that elsewhere at exactly the right size. The mask editor paints an editable region instead, which is a different instruction: a mask says where, markup says what.
    
    Design — answer each:
    1. One editor or two? A "Mark up" mode inside the mask editor, or a separate flow and tool. Say what the agent sees in each case (one tool with a mode argument, or two tools), and how a user who opened the wrong one recovers.
    2. Tools: which of freehand stroke, arrow, circle/ellipse, rectangle and text note ship first. Colour choice: fixed high-contrast, or a small palette. Stroke width. Undo/redo and clear. What each looks like at 320px with a thumb, and on desktop with a pointer.
    3. Text notes: typed text is rasterised into the PNG. Decide the font, size relative to the image, the placement interaction, and editing a note after placing it.
    4. Zoom and pan on a large source at 320px without losing the drawing: what gestures, and how drawing and panning are told apart.
    5. The instruction line: how the agent's `instruction` ("mark what should move and where") is shown while drawing.
    6. Submit, decline and dismissal: the confirm affordance, what an empty layer does (refuse? warn?), and the failure facts shown afterwards, in the receipt style of design-feedback.md §2.
    7. The receipt card: the source thumb with the markup over it, and the rows (layer path, size, stroke count?), as the receipt rule asks. What it shows when the subsequent `brain image` edit failed.
    8. The byte cap and filename: the mask route caps at 8,388,608 bytes and uses a backend-specific mask filename. Propose the markup filename rule (e.g. `<name>-markup.png`), and whether 8 MB is enough at the 16.7 MP limit, or what to do when a layer exceeds it.
    
    Requirements to hold:
    - The layer is exactly the source's displayed width and height (after EXIF orientation), fully transparent except the marks, never flattened onto the photo.
    - Server-owned application only: hash, lock, authority, traversal and symlink rechecks as for masks. Voice and no-grant turns cannot open it.
    - Accessible names on every control, 44px touch targets, legible at 320px, light and dark themes from the kit tokens; visual baselines asserted in CI.
    - `request_image_mask`'s name, input and result do not change. A design that needs them to change says so explicitly, because that is a breaking contract change needing a maintainer ruling.
    - Provider history is append-only (docs/decisions/provider-history.md): nothing the editor shows enters the model conversation except the tool's result.
    - No personal data in any mock.
    
    Acceptable outcomes include "a mode of the mask editor" and a documented "no UI; the agent describes the change instead", if argued.
    
    Deliverable: a design comment (or a docs/plans/ entry if large) answering 1–8, with ASCII mocks of the editor at 320px and at desktop width, the toolbar states, the empty-layer and decline states, and the receipt card at both widths; plus the tool name, input schema and result shape you propose.
    
  2. added
    type: featA new capability or a change in user-visible behaviour.
    area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    area: ui-reactReact chat/files/voice components, stores, WebSocket transport.
    area: ui-kitThe presentational design kit: components, tokens, Storybook, visual baselines.
    area: backendsAgentBackend implementations and the seam they share.
    needs: designBlocked on a design drop or a visual answer.
    blockedWaiting on another issue or an upstream dependency. Say which in the body.
    on Nov 11, 2026
  3. schlessera commented on Nov 11, 2026

    @schlessera
    OwnerAuthor

    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_mask stays 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

    Mode inside the mask editor Separate tool (recommended)
    Agent sees request_image_mask with mode: "mask" | "markup" request_image_mask and request_image_markup, each with its own description
    Contract Changes the mask tool's input and result. Breaking, so it needs a ruling. Additive
    Output Two opposite PNG conventions behind one flag (a mask is alpha holes on opaque white; markup is opaque marks on transparency) One convention per tool
    Toolbar Brush only vs. five tools; a mode switch at 320 px costs a row Each toolbar fits its own job
    • Recovery when the agent opened the wrong one. The editor never switches into the other tool. The user closes it, the tool returns the refusal "The user closed the markup editor", and the user says what they meant in chat.
    • The descriptions do the routing:
      • mask: "…where pixels may change"
      • markup: "…what to change: arrows, circles and notes. Use with brain image --markup, never with --mask."
    • Extracting the shell. Moving 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.

    • Colour: three fixed swatches, red #FF3B30 (default), yellow #FFD60A and 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.
    • Stroke width: three steps, thin, medium (default) and thick. They are 0.4 %, 0.8 % and 1.4 % of the image's short edge, so they look the same on a phone and in the 4K export.
    • History: Undo, Redo and Clear. Clear asks for confirmation only when there are 3 or more marks.
    • Arrow: drag from tail to head. The head is sized from the stroke width.
    • Ellipse: drag a bounding box. Shift (desktop) gives a circle.
    • Selection: none in v1. Undo is the edit path. The exception is text notes (see 3).

    3. Text notes

    • Font: the kit's bundled UI sans at weight 600, rasterised with the same 1 px halo. It is bundled so the PNG is deterministic across browsers; system fonts are never used.
    • Size: 3.5 % of the image's short edge, with no user size control. On the 3024 px edge that is about 106 px in the PNG.
    • Placing a note: choose Text and tap the image. An inline field opens at that point (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.
    • Editing a note: tap a placed note while the Text tool is active. The field reopens with Place and Delete. Notes stay objects until export.
    • Agent visibility: the note texts are also returned in the tool result (notes[]), so the agent doesn't have to read them from pixels.

    4. Zoom and pan

    Touch (320 px) Pointer (desktop)
    Draw One finger, with a drawing tool active Primary button
    Pan Two fingers (always), or one finger with Hand Space + drag, or Hand
    Zoom Pinch Ctrl/⌘ + wheel or trackpad pinch; + / − keys
    Fit Fit button 0 key
    • Telling drawing from panning: if a second touch arrives within 120 ms of the first, the gesture becomes pan/zoom and the half-started stroke is discarded.
    • Zoom range: 1× (fit) to 8×.
    • Coordinates: marks are stored in image coordinates, so zooming never moves or loses them.

    5. 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

    • Submit: the primary button "Send markup", the same kit Button as the mask editor's "Use this area".
    • Empty layer: refused. "Send markup" is disabled and the hint below it reads "Draw at least one mark." An empty layer is never written.
    • Dismissal (X, Esc or the overlay's onClose):
      • with no marks, it closes at once;
      • with marks, it first asks "Discard 4 marks?" with Discard / Keep drawing.
      • Either way the tool returns the refusal "The user closed the markup editor".
    • Voice turns and no-grant turns: the tool returns a refusal and the editor never opens.
    • Afterwards: the kit's red boxed mono Callout, built from the result's own words, as in ImageMaskFallback:
      no markup drawn on photos/raft-at-ithaca.jpg · The user closed the markup editor
    • Over the size cap at submit: the editor stays open with the red line "This markup is 9.1 MB; the limit is 8 MB. Remove some freehand marks." Nothing is sent.

    7. The receipt card

    The kit Surface, tone teal, label "Markup drawn", meta "by you".

    • Thumb: the hatched source placeholder (no remote image loads inline) with the markup PNG drawn over it. If the PNG doesn't load, it shows the mono line markup not rendered, the same rule as the mask card.
    • Rows (kit Receipt):
      • marks 2 arrows · 1 ellipse · 1 note
      • notes "move the raft here" (each note quoted, up to 3, then "+2 more")
      • size 3024 × 4032 px · matches source
      • source photos/raft-at-ithaca.jpg
      • layer .brain/scratch/markup/raft-at-ithaca.3f9a1c2e.markup.png · 212 KB
    • When the later brain image edit fails: this card doesn't change. The receipt records what the user drew. The failure belongs to the brain image tool card, which already states its own error.

    8. Filename and byte cap

    • Filename: .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.
    • Rechecks: the route checks the hash, lock, authority, traversal and symlinks exactly as the mask route does. It also enforces this filename pattern.
    • Cap: a new 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)

    // tool: mcp__brain-ui__request_image_markup
    input:  { imagePath: string;            // repo-relative, an image in the brain
              instruction?: string }        // ≤ 200 chars, shown as "Agent asks:"
    result: { imagePath: string;
              markupPath: string;           // repo-relative PNG
              width: number; height: number; // = the source's displayed size
              bytes: number;
              marks: { pen: number; arrow: number; ellipse: number; text: number };
              notes: string[] }             // note texts, in placement order
    refusals (isError): closed by the user · voice turn · no grant · source changed · over the cap

    Bridge: BackendBridge.applyImageMarkup?, sitting next to applyImageMask? with the same rechecks, the filename rule above and BRAIN_MARKUP_MAX_BYTES. docs/integration-contract/mcp.md gets a section beside the mask rules.


    Mocks

    Editor, 320 px (fullscreen overlay, dark media chrome):

    ┌──────────────────────────────┐
    │ Mark up the image        [✕] │
    │ Agent asks: mark what should │
    │ move and where…              │
    ├──────────────────────────────┤
    │                              │
    │   ┌──────────────────────┐   │
    │   │     ~~~ sea ~~~      │   │
    │   │  ◯ sail       ──────►│   │
    │   │  "make it red"   ↑   │   │
    │   │   [raft]   "move here"   │
    │   └──────────────────────┘   │
    │                       [Fit]  │
    ├──────────────────────────────┤
    │ [✎][↗][◯][T][✋]             │  ← tools, 44 px each, active one filled
    │ [●▾][═▾]   [↶][↷][⌫]         │  ← colour, width, undo, redo, clear
    │ [        Send markup       ] │
    └──────────────────────────────┘
    

    Editor, desktop:

    ┌──────────────────────────────────────────────────────────────────────┐
    │ Mark up the image                                                [✕] │
    │ Agent asks: mark what should move and where                          │
    ├──────────────────────────────────────────────────────────────────────┤
    │        ┌──────────────────────────────────────────┐                  │
    │        │  ◯ sail "make it red"                    │                  │
    │        │           [raft] ─────────────►  "here"  │                  │
    │        └──────────────────────────────────────────┘     [−] 100% [+] [Fit]
    ├──────────────────────────────────────────────────────────────────────┤
    │ [✎ Pen][↗ Arrow][◯ Ellipse][T Text][✋ Hand] │ ● ● ● │ ─ ═ ━ │ [↶][↷][⌫]   [Send markup] │
    └──────────────────────────────────────────────────────────────────────┘
    

    Toolbar states:

    idle, no marks : [✎*][↗][◯][T][✋]  [↶ disabled][↷ disabled][⌫ disabled]  [Send markup disabled]
                     "Draw at least one mark."
    drawing        : tools stay; Send enabled once one mark is committed
    text placing   : ┌─────────────────────────┐
                     │ move the raft here|     │ [Place]   ← field at the tap point
                     └─────────────────────────┘
    text editing   : [Place] [Delete]
    over the cap   : ✕ This markup is 9.1 MB; the limit is 8 MB. Remove some freehand marks.
    

    Discard confirmation (dismissal with marks):

    ┌──────────────────────────────┐
    │ Discard 4 marks?             │
    │ [Discard]   [Keep drawing]   │
    └──────────────────────────────┘
    

    Decline receipt (chat):

    ┌───────────────────────────────────────────────────────────┐
    │ no markup drawn on photos/raft-at-ithaca.jpg · The user   │  red boxed mono Callout
    │ closed the markup editor                                  │
    └───────────────────────────────────────────────────────────┘
    

    Receipt card, 320 px (thumb stacked above rows):

    ┌ ✓ Markup drawn ─────── by you ┐
    │ ┌──────────────────────────┐  │
    │ │░░ hatch + markup PNG ░░░░│  │
    │ └──────────────────────────┘  │
    │ marks   2 arrows · 1 ellipse  │
    │         · 1 note              │
    │ notes   "move the raft here"  │
    │ size    3024 × 4032 px ·      │
    │         matches source        │
    │ source  photos/raft-at-ithaca │
    │         .jpg                  │
    │ layer   .brain/scratch/markup │
    │         /raft-at-ithaca.3f9a… │
    │         · 212 KB              │
    └───────────────────────────────┘
    

    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.

    ┌ ✓ Markup drawn ──────────────────────────────────────── by you ┐
    │ ┌──────────────────────────────┐                               │
    │ │░░░ hatch + markup PNG ░░░░░░░│                               │
    │ └──────────────────────────────┘                               │
    │ marks   2 arrows · 1 ellipse · 1 note                          │
    │ notes   "move the raft here"                                   │
    │ size    3024 × 4032 px · matches source                        │
    │ source  photos/raft-at-ithaca.jpg                              │
    │ layer   .brain/scratch/markup/raft-at-ithaca.3f9a1c2e.markup.png · 212 KB │
    └────────────────────────────────────────────────────────────────┘
    

    ui-kit inventory (Storybook first)

    • Reused unchanged: Overlay (fullscreen), Button, IconButton (md, 44 px), Callout, Surface, Receipt.
    • Extracted: ImageEditorFrame, the shell of MaskEditor (header with title and instruction, stage, toolbar slot, error line). No visual change; the existing mask baselines must pass unchanged.
    • New (presentational, props and callbacks only):
      • 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.
      • MarkupNoteField
      • MarkupResultCard and MarkupFallback
    • Stories (each at 320 px and desktop, light and dark):
      • MarkupToolbar: 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.
      • Editor (in the frame): idle, a long instruction collapsed and expanded, the discard confirmation, and over the cap.
      • MarkupResultCard: rendered, not rendered, more than 3 notes, and a long path.
      • MarkupFallback: closed, voice refused, and source changed.
      • Reduced motion (no zoom easing).
    • Accessibility:
      • every tool gets an aria-pressed toggle with a name ("Pen", "Arrow", "Ellipse", "Text note", "Pan");
      • swatches are a radiogroup named "Mark colour", with colour names, not colour alone;
      • the canvas has role="img" and a live summary, "4 marks: 2 arrows, 1 ellipse, 1 note";
      • focus stays inside the overlay, and Esc dismisses;
      • every target is at least 44 px.

    Open questions for the maintainer

    • M1. Two tools rather than one with a mode, as recommended in 1. Confirm, so request_image_mask stays untouched.
    • M2. The byte cap: 8 MB with a check in the editor (recommended), or a higher markup-only cap.
    • M3. Scratch only (recommended), or should "next to the image" stay an option?
    • M4. Rectangle deferred, and a fixed three-colour palette. OK for v1?
    • M5. Should the issue split into a ui-kit issue (the frame extraction, the new components and stories, labelled area: ui-kit) that blocks this one? This issue would then carry the tool, the route and the integration.
    • M6. Design sign-off on the stories once built.
  4. added
    needs: decisionBlocked on a maintainer or designer ruling, not on code.
    and removed
    needs: designBlocked on a design drop or a visual answer.
    on Nov 11, 2026
  5. schlessera commented on Nov 11, 2026

    @schlessera
    OwnerAuthor

    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: decision and blocked are retained for now.

  6. schlessera commented on Nov 11, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-11): All markup choices are settled.

    • M1: separate request_image_markup tool/editor, sharing the mask editor’s shell. Preserve the existing mask contract and behavior.
    • M2: allow the CLI’s full “50 MB” layer limit. Verified at PR feat(module-images): markup-guided image edits with --markup #3972 head 38a822df0370e980aaeae7f5b252f09013f49d1f: MARKUP_LIMITS.maxBytes is 50 * 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.
    • M3: write only under .brain/scratch/markup/, with server-owned safe filenames/source binding and the existing scratch rules.
    • M4: ship Pen, Arrow, Ellipse, Text and Hand/pan, three colors and widths, undo/redo/clear; defer rectangles and a free color picker.
    • M5/M6, already selected: a separate ui-kit prerequisite, with agent verification of the agreed design/stories/browser checks and no mandatory separate human sign-off.

    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, add agent-ready, contract and unscheduled priority: p2, and retain blocked for #3785 and #3983. The split component issue owns area: ui-kit; integration remains under the SDK/server/React/backends areas.

  7. added
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 11, 2026
  8. 3 remaining items

  9. added
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    on Nov 11, 2026
  10. schlessera commented on Nov 16, 2026

    @schlessera
    OwnerAuthor

    Unblocked: #3785, #3983 are closed, so scripts/sync-project.ts is removing the blocked label.

  11. removed
    blockedWaiting on another issue or an upstream dependency. Say which in the body.
    on Nov 16, 2026
  12. self-assigned this
    on Nov 16, 2026
  13. schlessera commented on Nov 16, 2026

    @schlessera
    OwnerAuthor

    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.

  14. added this to the 0.45.0 milestone on Nov 16, 2026
  15. schlessera commented on Nov 17, 2026

    @schlessera
    OwnerAuthor

    Delivered in #4104, squash 141c2437a02c840a9fd8558b196406ea98c33d88, milestone 0.45.0.

    request_image_markup lets 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 for brain image --ref <image> --markup <layer>.

    • Host-owned end to end (BackendBridge.requestImageMarkup). The worker never holds the layer's bytes or names a destination, and a host without the operation refuses.
    • Bounded upload. POST /api/markup/:requestId accepts up to 52,428,800 bytes, inclusive; the request's own principal and exact turnId are required. A 13.3 MB layer is proven over real HTTP. GET /api/markup/:requestId/source serves the bound source, beyond the 10 MiB file route. The mask's 8 MiB cap and the 12,000,000-byte frame are unchanged.
    • Application.
      • Binds the source hash and displayed size, with the CLI's own header reader, now in brain-common.
      • Refuses opaque, mismatched, fabricated or fully transparent layers.
      • Links each layer onto a fresh server-derived name and never overwrites; the published inode is bound to the validated bytes.
      • Rechecks source, topology, protection, authority and membership under the lock.
    • Delivery. Only to the turn principal's connections that declared imageMarkup. Losing the last of them, cancellation or shutdown rejects the request.
    • Backends. Both register the tool in their stable roster and refuse it on voice and no-grant turns. The provider-history guard passes on both.
    • App. The kit's MarkupEditor opens for a request and uploads the layer, and requests queue. The transcript shows MarkupResultCard or MarkupFallback.
    • Proof. 28 mutations were killed by their named tests. A real-browser test covers EXIF orientation 6. A fresh gpt-6-astra review found 8 issues, all fixed. The contract is documented in mcp.md, wire.md, package-api.md and http-api.md, and the change shipped under a CONTRACT: commit with a changeset.

    Post-merge. Main went red at 141c243 on 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:

    • The pi worker-RPC branch is proven by reading, not a runtime test.
    • A saved layer over 10 MiB reports correctly, but its receipt thumbnail shows "markup not rendered", because it still loads through the 10 MiB file route.
    • The React host's refusal-keeps-open behaviour is proven in the kit's browser tests, not in happy-dom.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: backendsAgentBackend implementations and the seam they share.area: ui-reactReact chat/files/voice components, stores, WebSocket transport.area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.contractTouches the integration contract: CONTRACT: commit, contract doc updated in the same commit.priority: p2Wanted, not scheduled. Pulled in when a milestone has room.type: featA new capability or a change in user-visible behaviour.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions