Repository navigation
composer: a nonce on each send, repeated on a retry (#314) - #317
Merged
Merged
Conversation
# Conflicts: # web/dist/blocks.js
…the draft changes (#314)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
values.nonceon every send, queue and steer from the box: 32 hex chars fromcrypto.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.Outboxholds the send'sUUID().uuidStringnonce. The composer posts throughacted(the async, success-reporting act thatMoreandImportalready 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. Withoutactedit posts fire-and-forget as before and counts that as landed.ActionandComposerdoc lines (soschema/blocks.schema.jsonandskill/blocks/kinds/composer.mdviajust gen), and a paragraph indocs/schema/blocks.md.Decisions:
nonce.getRandomValues, notcrypto.randomUUID():randomUUIDonly exists in a secure context. On the test page (isSecureContextfalse) it is undefined, and a send threw. An app served over plain http would break the same way.steerwith{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
Actiona composer sends now hasvalues.nonce, a string. Store a send keyed on it: a retry sends the samenonce. The schema change is additive (a doc line only;valueswas already open).What I could not verify / limits
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.textwith no nonce. The AC names HTML, React and SwiftUI only, and std Rust has no random source short of a new dependency (getrandomoruuid), 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.shon this body exits 0. At dd86e6f, re-run after the Swift retry fix:just swift0 (incl.ComposerTests),just arch0,just cap0. That commit changes onlyswift/. The web, Rust and guard rows below are from 9ecdccd and cover files that have not changed since.just web(tsc, lint, node tests, incl.web/test/kind/composer.test.tsnonce/retry test)npm --prefix web run test:react(incl. the new React nonce/retry test, and the HTML/React parity test minus the nonce)just swift(incl.ComposerTests)just testjust clippyjust fmtjust archjust capjust guardFixtures and snapshots are unchanged. The HTML/React parity test now drops
noncebefore 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.