Skip to content

composer: a nonce on each send, repeated on a retry (#314) - #317

Merged
jirathip-k merged 6 commits into
stagingfrom
issue-314
Nov 21, 2026
Merged

jirathip-k merged 6 commits into
stagingfrom
issue-314

Conversation

@jirathip-k

@jirathip-k jirathip-k commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #314

For humans

Each message sent from the chat box now carries a random id. Trying again after a failed send reuses the same id, and a new message gets a new one, so an app can store a retried message once instead of twice.

What changed

  • HTML and React composers put values.nonce on every send, queue and steer from the box: 32 hex chars from crypto.getRandomValues, one helper (web/src/core/nonce.ts) shared by both. The draft holds it until the send succeeds. The retry button reuses it. Typing, attaching or editing a queued message clears it, so the next send gets a fresh one.
  • SwiftUI composer: an Outbox holds the send's UUID().uuidString nonce. The composer posts through acted (the async, success-reporting act that More and Import already use) when the app provides it. A failed send keeps the draft and the nonce, so pressing send again repeats it. A successful send, or any edit to the draft, clears it. Without acted it posts fire-and-forget as before and counts that as landed.
  • Docs: the Action and Composer doc lines (so schema/blocks.schema.json and skill/blocks/kinds/composer.md via just gen), and a paragraph in docs/schema/blocks.md.

Decisions:

  • Field name nonce.
  • getRandomValues, not crypto.randomUUID(): randomUUID only exists in a secure context. On the test page (isSecureContext false) it is undefined, and a send threw. An app served over plain http would break the same way.
  • The queued row's "send now" (steer with {q}) carries no nonce: it re-sends a message that was already stored, under its own nonce, when it was queued.

For apps

For apps: the Action a composer sends now has values.nonce, a string. Store a send keyed on it: a retry sends the same nonce. The schema change is additive (a doc line only; values was already open).

What I could not verify / limits

  • The SwiftUI test drives Outbox, the state the composer view uses, not the view itself: same nonce after a failed send, a new one after a success or an edit, and one on a queue. Clicking through a hosted SwiftUI view in XCTest is not set up in this repo.
  • egui: staging now has an egui composer that sends text with no nonce. The AC names HTML, React and SwiftUI only, and std Rust has no random source short of a new dependency (getrandom or uuid), which needs approval. Left for a follow-up issue.

Evidence

Head c104cb0 is an empty commit (after empty b130d58, whose run read the old body) over dd86e6f that re-runs CI after the For apps line fix; sh scripts/for-apps.sh on this body exits 0. At dd86e6f, re-run after the Swift retry fix: just swift 0 (incl. ComposerTests), just arch 0, just cap 0. That commit changes only swift/. The web, Rust and guard rows below are from 9ecdccd and cover files that have not changed since.

command exit
just web (tsc, lint, node tests, incl. web/test/kind/composer.test.ts nonce/retry test) 0
npm --prefix web run test:react (incl. the new React nonce/retry test, and the HTML/React parity test minus the nonce) 0
just swift (incl. ComposerTests) 0
just test 0
just clippy 0
just fmt 0
just arch 0
just cap 0
just guard 0

Fixtures and snapshots are unchanged. The HTML/React parity test now drops nonce before it compares, since the two renderers' nonces differ by design.

src/ net +8 counted by the cap (+14 with the React composer, which the cap does not count); no budget given. The extra lines are the shared helper and the Swift send values.

@jirathip-k
jirathip-k merged commit 2cfa0a0 into staging Nov 21, 2026
17 checks passed
@jirathip-k
jirathip-k deleted the issue-314 branch November 21, 2026 12:42
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