Skip to content

CONTRACT: feat(ui-react): show the draft's save state as a compact indicator beside Attach (#3155) - #3776

Merged
schlessera merged 7 commits into
mainfrom
feat/3155-draft-indicator
Nov 9, 2026
Merged

schlessera merged 7 commits into
mainfrom
feat/3155-draft-indicator

Conversation

@schlessera

@schlessera schlessera commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Refs #3155

What changed

The composer now shows the draft's save state as the #3281 StatusIndicator beside Attach, in place of the persistent save line (rev 4 §1, the D2 ruling, a scoped amendment to D52).

  • Success means this exact revision. The indicator shows success only when the host acknowledged this exact edit, with every original file bound and nothing still uploading. An acknowledgement of an older revision never shows success.
  • The other rev 4 §1 states:
    • saving, which is the only state that animates;
    • waiting for an upload: "Not saved yet: {name} is still uploading. Your text is kept in this tab.";
    • offline, with the last saved time or "never";
    • couldn't confirm, with Check again;
    • upload failed or unconfirmed;
    • refused for space, with Open Storage.
  • Old line states carried over. The former too-large, full and no-drafts states are now indicator states. Compare drafts and Open other version remain as details actions.
  • Empty draft. It hides the control but keeps its slot, so nothing shifts.
  • Details. Opening them makes no request. Focus returns to the indicator, and reduced motion keeps the glyph still.
  • Check again (rev 5 §1, case 21) is BrainUiConnection.drafts.checkSave(draftId). It makes one GET /api/drafts/:draftId and compares revision, text, images, files[].fileId and snapshots with the save whose answer was lost. It never sends a PUT.
  • Reload notice (rev 5 §1, case 20). The device-kept work context records the names, never the bytes, of files still uploading. After a reload their chips are gone and the composer says "{name} was still uploading when the page closed. It isn't attached. Choose it again to attach it." It can be dismissed and makes no claim about storage or cleanup.
  • Leave guards are unchanged.
  • Kit. Composer gains an optional status slot. DraftSaveLine stays exported and is still used by the voice conversation strip.

Open visual question, for the human visual review

Indicator placement. Rev 4 §1 places the draft indicator in the composer tool row, in the order attach · indicator · model label · send. This slice puts it beside Attach inside the existing field row (attach · indicator · field · mic · send) and leaves the model label in the hint row below. Moving the model label into that row would be a broader composer redesign, which #3155's scope excludes. The indicator's box is 44 px and touches its neighbours' boxes without overlapping, and Attach and Send keep their current kit sizes. The maintainer referred this to the reserved human visual review: please confirm this placement or ask for rev 4's order. Screenshots: packages/ui-react/.vitest-attachments/draft-indicator/{dark,light}-{320,1280}.png.

Why this shape

  • Success is tied to the edit generation. The indicator derives success from the edit generation the host acknowledged, not from any acknowledgement. The case 17 mutation shows the difference.
  • Check again is read-only. It never resends, so it cannot become another save (rev 4 correction).
  • The notice uses names only. It reads uploading names from the device-kept work context, so a reload can say what wasn't attached without keeping any bytes.

Choices the rulings leave open, made conservatively

  1. The indicator passes announce={false}. The old line was silent, and upload outcomes keep the composer's own announcement.
  2. Saving shows at once, with no 600 ms delay, including during the 800 ms pause before a save goes out.
  3. A save with no answer while the socket is connected shows "couldn't confirm", because fetch cannot tell "never arrived" from "answer lost". Offline means only that the browser or the socket is down.
  4. New copy for states rev 4 does not define:
    • a file carried from another draft: attention, "Not saved yet: 1 file isn't attached…";
    • a transient or unknown not-saved state, and a device-only draft: attention, "Draft not saved yet.";
    • draft storage full: refused, with no Storage action;
    • a not-saved result of Check again: a "Checked" fact.
  5. The reload notice matches the draft by id, or by session when the id changed. A held snapshot's uploads are left out, because its bubble already says so.

Proof

Unit tests:

  • draft-indicator.test.ts 11 pass;
  • Check again cases in draft-client.test.ts 5 pass;
  • an upload-names case in draft-files.test.ts;
  • the kit's composer-status.test.tsx 3 pass.

With the other draft suites, 87 pass and the kit composer tests 7 pass.

Real browser (pinned Chromium 1243, keyless and offline): draft-indicator.offline.tsx passes 8 of 8.

  • Case 17: active while a save is held, then success; after an edit, active then success; an older acknowledgement shows active, not success.
  • Case 18: opening details makes no request; Check again makes one read; focus returns to the indicator; under reduced motion the glyph's opacity stays 1.
  • Case 20: the chip is gone and the notice copy matches exactly. The fixture host's own references put the never-bound file under the one-hour rule, asserted from the fixture's state, not the copy.
  • Case 21: exactly one GET, no PUT, then success.
  • Layout at 320 and 1280 px, dark and light: a 44 × 44 indicator, no overlap, no change in field height.

Updated existing suites now assert the same facts through data-draft-save and data-draft-summary: session-drafts.pointer (fine and coarse), draft-branches.offline, review-dialogs.layout, composer-files.offline and outgoing-snapshots.offline.

Failing first. Against the base src, all 8 new browser cases fail for want of an indicator (Cannot read properties of null, expected null to be 'success').

Mutations. Each was applied, shown failing, then restored:

Mutation Case Assertion
Show success for an older acknowledgement (drop the d.host.edit !== d.edit check) 17 expected 'success' to be 'active'
Make Check again save (an api.save before the GET) 21 no PUT: expected 1 to be +0
Notice claims the file was stored 20 expected 'harbor-permit-2026.pdf was stored bef…' to be 'harbor-permit-2026.pdf was still uplo…'

On this branch, rebased onto main a12515e35 (which includes #3758 and #3742):

  • Rebase conflicts were resolved by keeping both sides: composer-view.tsx keeps CONTRACT: feat(ui-kit): let the composer host the hold-to-talk MicButton #3742's micTip/micUnavailable beside status, and one citation was re-anchored.
  • Main had moved draft-files.test.ts onto vi.useFakeTimers(), so the reload-names case's Bun.sleep(10) never resolved. It now uses the file's turn(). I bisected it: it passes with every source file from the rebased head and fails only with that test file.
  • Build, tsc and lint pass, and the API report is unchanged after the rebase.
  • Browser, in one run: draft-indicator, outgoing-snapshots, composer-files, draft-branches, review-dialogs and composer-attachments, 178 of 178.
  • Runtime suites against the real host: connection-continuity 15 of 15, draft-runtime 3 of 3 and local-work-runtime 10 of 10. The latter two need a prebuilt tree on this host: their setup hook's stale-package rebuild took longer than 180 s otherwise.

Hosted candidate proof 1 (run 42616704987, head cf2ae0f): failed, diagnosed, fixed

  • layout (1), a test regression from this PR. 21 cases failed in three files that ran later in the same shard: handoff-sheet (the dialog measured 476.38 px, not 480), agent-orbit, and turn-time (no time stamp or speaker found to measure).
  • Cause. The new draft-indicator.offline.tsx reset the page to prefers-reduced-motion: no-preference after each case. The pinned runner starts with reduce, so the later files measured mid-animation layouts.
  • Reproduced. Run alone, the three files pass. Run after draft-indicator.offline.tsx in one process, they fail exactly as hosted.
  • Fix. The file now restores the preference it found, and case 18 sets no-preference itself before checking that active work animates. The same four files in shard order now pass 45 of 45.
  • Same class elsewhere. No other browser file added by ui-react: offer a generic file picker with honest attachment lifecycle states #3155 changes the motion preference. The two other files that set no-preference belong to other features.

Collisions

At head d586c1566, bun scripts/collisions.ts --json --pr 3776 found 5 textual overlaps, all with draft PRs:

The rest are closure-only.

bun run check:pr --base origin/main

Merge-only refresh: main (81f1240dd) is merged into this branch. The merged commits touch none of this PR's files, so the check:pr receipt below is from the last real change and was not rerun.

{"version":1,"kind":"brain-check-pr-receipt","head":"ac4e664e25db9c750d6c01e7c483decaec035fb5","base":"origin/main","mode":"focused","startedAt":"2026-11-09T12:56:08.803Z","finishedAt":"2026-11-09T12:58:00.190Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":19251.933677999998},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":517.5382279999976},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":1016.1940309999991},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":32.16358500000206},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":90541.232323}]}

Checklist

  • Focused local preflight and behavioral receipts passed. Hosted proof is requested through integrate.ts confirm.
  • Acceptance criteria from the issue are all met. Not all: this is a Refs slice; see below.
  • The PR and ui-react: offer a generic file picker with honest attachment lifecycle states #3155 carry milestone 0.45.0.
  • Changeset: ui-react and ui-kit minor.
  • No personal data; Odysseus fixtures only.
  • Contract: package-api.md and the integration-contract.md index are updated in the CONTRACT: commit. The additions are Composer.status and BrainUiConnection.drafts.checkSave. The API reports are updated.
  • Docs: the chat-attachments decision record, plus a scoped D52 amendment saying the indicator replaces the persistent line.
  • Provider history: nothing on a turn's path changed.

Anything left open

🤖 Generated with Claude Code

schlessera and others added 3 commits November 9, 2026 09:40
…dicator beside Attach (#3155)

The composer's draft status is now the kit StatusIndicator, beside Attach
(rev 4 §1, E1 A), in place of D52's persistent line under the field. It
shows success only when the host acknowledged this exact edit with every
original bound and nothing of it still uploading. An older revision's
acknowledgement never shows success. The other states come from rev 4 §1:
active, queued, offline, unconfirmed, upload failed or unconfirmed, and
space refusal with Open Storage. D52's too large, full and unavailable
become indicator states. Compare drafts and Open other version are detail
actions. An empty draft keeps the slot with no control.

A save whose answer was lost reads as unconfirmed. Check again
(BrainUiConnection.drafts.checkSave) reads the draft once and compares
revision, text, images, files[].fileId and snapshots with that save. It
never sends a PUT.

The kit Composer gains an optional status slot: a 44px box that takes a
28px place in the row, so the field keeps its height.

A reload names files that were still uploading instead of restoring their
chips. The device-kept work context records their names, never bytes, and
the composer shows a dismissible notice with no claim about storage or
cleanup.

Docs: package-api and integration-contract index, the chat-attachments
record, and the scoped D52 amendment. Re-anchors one draft-client citation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e clock (#3155)

Main moved draft-files.test.ts onto vi.useFakeTimers(); the reload-names
case's Bun.sleep(10) never resolved there. It now uses the file's turn().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 9, 2026
@schlessera schlessera added type: feat A new capability or a change in user-visible behaviour. area: ui-react React chat/files/voice components, stores, WebSocket transport. area: ui-kit The presentational design kit: components, tokens, Storybook, visual baselines. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. labels Nov 9, 2026
@uploads-sh

uploads-sh Bot commented Nov 9, 2026

Copy link
Copy Markdown

No uploads on this PR yet

This PR changes UI files (packages/ui-kit/src/chrome/Composer.tsx, packages/ui-kit/tests/composer-status.test.tsx, packages/ui-react/src/components/chat/composer-view.tsx and 7 more). Screenshots help reviewers see what changed.

  • From the CLI: uploads put before.png after.png --pr 3776
  • From an agent: ask it to attach screenshots with uploads.sh
  • By hand: drag images into the PR description and they're imported automatically
Tips for agents

Label each shot so reviewers know what they're seeing. Labels apply to every file in a call, so run one put per shot:

uploads put after.png --pr 3776 --meta path=/settings --state after --caption "Saved settings toast"
uploads put chat.png --pr 3776 --app ios --screen "Chat" --state after

No CLI? With the Uploads MCP, call sign_upload_url for files on disk (or put) with repo, pr: 3776 and the same screen, state and caption fields.

This comment updates with each upload, so you don't need to post the images yourself. A shot or two in the PR description is still welcome. Check what's attached with uploads list --pr 3776. More in the github-screenshots skill or the agent docs.

Workspace admins can turn this comment off in Settings → GitHub · docs

@schlessera
schlessera marked this pull request as ready for review November 9, 2026 12:24
schlessera and others added 2 commits November 9, 2026 12:55
#3155)

draft-indicator.offline.tsx reset the page to prefers-reduced-motion:
no-preference after each case. The pinned runner starts with reduce, so
later files in the same layout shard (handoff-sheet, agent-orbit,
turn-time) measured mid-animation layouts and failed. The file now
restores the preference it found, and case 18 sets its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera
schlessera marked this pull request as draft November 9, 2026 13:18
@schlessera
schlessera marked this pull request as ready for review November 9, 2026 13:18
@schlessera
schlessera merged commit f3490fb into main Nov 9, 2026
43 of 55 checks passed
schlessera added a commit that referenced this pull request Nov 9, 2026
…ison

#3776 put the save indicator beside Attach; no dictation story draws it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
schlessera added a commit that referenced this pull request Nov 10, 2026
…heet (#3772)

* feat(ui-react): tap the composer mic to dictate, hold it to open Start

The composer's resting mic is now the kit's MicButton in the Composer
micControl slot (#3727). A tap, Enter or Space dictates through the
existing path. A press fills the ring from elapsed time; at 0.6 s (V1)
a light haptic fires and the existing Start disclosure opens, or the
S4 notice where live conversation is not available (V4). An earlier
release is a tap, and leaving the mic cancels the hold. Shift+Enter and
the "Talk live..." action open Start from a keyboard or screen reader.
A hold starts a timer and a frame loop only: no microphone, provider or
history work.

The offline "Record on this device" mic has no hold (M1). Dictating, a
recording in progress, an undecided mic, and a host with neither
dictation nor live conversation keep the kit's own mic.

The attach menu's "Live conversation" row and its naming are removed,
with their tests; the D37 note records the move. A new rail-* browser
test presses the real mic with mouse and touch input and instruments
getUserMedia and the network to prove a hold, or a cancelled one,
captures nothing.

Refs #3693

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

* fix(ui-kit): let a Composer's micControl come and go without a margin fault

The textarea set `margin: 0` and, with micControl, `marginBottom` beside
it. A mounted field that drops micControl (the app does, on dictating)
made React remove the longhand under the shorthand: the bottom margin
went unset, and React warned, which the capture gate reports as a
browser fault. One shorthand now carries the lift; the pixels are the
same.

Refs #3693

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

* feat(ui-react): dictate in the voice field and remove the dictation sheet

Dictation is drawn with the signed-off kit components, unchanged (#3694,
stories from #3738). The capture states (Dc connecting, D2 asking for the
microphone, D3 listening, D4 quiet, D5 finishing) replace the composer with
the compact VoiceField, naming the destination in the label meta. D0, Dx,
D7 and D8 are VoiceNotices above the composer. D6 puts what a take heard
into the draft as plain editable text, caret at the end, and the mic reads
"Dictate more". A take stops itself after 30 s without speech (V3).

The dictation sheet and review card are removed, with their CSS.

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

* test(ui-react): drive every dictation state of the voice field in Chromium

The dictation project's suite now runs D0 to D8, Dc and Dx through the real
composer with a local speech double, and compares each state with its kit
story. The notice suite covers D7 and D8 through the shipped clients. Suites
that drove the old sheet or review card follow the field, and the failure
screenshots committed with the old suite are removed.

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

* docs(ui-react): describe dictation in the voice field

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

* test(ui-react): follow dictated and reviewed voice text into the draft

The runtime and offline suites that read the removed review card or
pressed Done now finish with "Finish dictation" and read the composer's
draft: external speech, dictation selection, local work, draft branches
and the live conversation's "Review in composer" transfers. The resting
and D6 mics name the next take's service ("Dictate more · <service>").

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

* test(ui-kit): leave the draft's save state out of the D6 story comparison

#3776 put the save indicator beside Attach; no dictation story draws it.

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

* fix(ui-react): say what happens to the audio per service on the first-take card

Gemini keeps "The audio isn't kept." Deepgram, browser speech and any
other service can't be verified here, so D0 says that service's own
retention policy applies instead (maintainer decision on #3694,
2026-11-09). Same VoiceNotice; only its body text differs.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui-kit The presentational design kit: components, tokens, Storybook, visual baselines. area: ui-react React chat/files/voice components, stores, WebSocket transport. contract Touches the integration contract: CONTRACT: commit, contract doc updated in the same commit. type: feat A new capability or a change in user-visible behaviour.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant