Skip to content

refactor(chat-core): route design-critique, design-tweak and mochi sends through sendTurn - #9587

Merged
chenmingwei23 merged 1 commit into
feat/chat-core-p2-embedfrom
refactor/chat-core-p2-design-apps
Sep 9, 2026
Merged

chenmingwei23 merged 1 commit into
feat/chat-core-p2-embedfrom
refactor/chat-core-p2-design-apps

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Chat-core RFC P2, batch B of #9570: three app-local senders — apps/design-critique/api.ts send, apps/design-tweak/api.ts sendChatMessage, apps/mochi/panel/panelBridge.ts sendMessage — stop hand-writing POST /api/chat and call the chat-core transport sendTurn. The ?ws=1 receipt form, the 10 s deadline and the six-way classification are now the core's.

Stacked on #8599 (base feat/chat-core-p2-embed): design-critique needs the injectable SendWire seam that PR adds. GitHub retargets this PR to main when #8599 merges.

Zero behaviour change except the three receipt defects the RFC §2.1 names, each fixed here:

Caller Defect on main Now
design-critique send posted to the bare endpoint (an SSE stream, not a JSON receipt) and .catch(SyntaxError) swallowed every unreadable reply as success — a {ok:false} refusal inside a 200 never surfaced, the critique polled a slot whose turn never started app-local SendWire posts /api/chat?ws=1 keeping the slot-recreation fields (agent, memory_mode, mode) the app depends on after a gateway restart; refused / transport-error reject with the server's reason, falling back to the core pages.chatPage.send_failed copy (the page's failWith reports it and drops the pending critique, as for a non-2xx before); unknown / response-late resolve
design-tweak sendChatMessage threw only on a non-2xx, so a refusal inside a 200 was marked delivered; a non-JSON 2xx resolved as {ok:true} via a parse fallback; no deadline dashboard wire (agent: '' was the server default, so the body is equivalent); returns void and resolves only on dispatched / queued. Every other status rejects with its own reason — refused (server reason, flagged SendRefused), transport-error, unknown, response-late — because the caller marks the request delivered on resolution and deliveredAt permanently short-circuits deliveryVerdict / verifyDelivery; an unconfirmed send must stay unacknowledged so ground truth decides (GPT, round 1). The page tells the two apart: a flagged refusal is an error and renders Send failed: <reason> through the page's existing ErrorNotice (bridgeError, whose No hand-off comment covers the preview overlay's unsent comment) (GPT r5); an unconfirmed dispatch keeps the muted dispatch_failed_unconfirmed status line (verify against the session) (UX r4). chatApi's non-JSON fallback, which existed for the SSE send, is deleted; its four remaining callers are JSON endpoints
mochi sendMessage echoed the user bubble before the POST and never read the reply — a refused send left a bubble the server never took and no error anywhere the receipt gates the echo: only a confirmed acceptance echoes (dispatched, queued, and unknown — a 2xx, so the server took it). refused, transport-error and response-late reject and echo nothing; the vendored ChatPanel's send path restores the text and reports the failure, and its edit-resend fallback now routes through that same sendText path instead of awaiting sendMessage bare (Design, round 2). A response-late echo would paint a bubble that vanishes on reload with the draft gone (GPT, round 2). The failure report is a new sendError state rendered through ErrorNotice variant="inline" (askAgent off, No hand-off comment naming the restored draft) — separate from the panel's pre-existing dropError banner, which is a file-validation hint, not an error (GPT, round 3) — and it shows the server's refusal reason — framed as Send failed: <reason> (pages.chatPage.send_failed_with_error, the same entry design-tweak uses) — when the bridge flags the rejection SEND_REFUSED (every refusal is flagged; a bodyless 4xx/5xx renders the plain Send failed copy — the network is fine, so never the connection copy); a late receipt is flagged SEND_UNCONFIRMED and shows the core delivery_unconfirmed copy ("check the transcript before sending again") rather than "try again", which could duplicate a send that landed (UX r5); every other rejection — a slot-bind failure, a browser TypeError — falls back to the localized chat.send_failed copy instead of leaking developer-voice text (UX r3–4)

SEND_REFUSED / SEND_UNCONFIRMED are defined once, beside sendTurn in chat-core/transport/sendTurn.ts, and imported by both apps (First Principles r5).

Why the dashboard wire is equivalent for design-tweak and mochi: both run in the dashboard bundle on the same origin; /api/chat reads no X-Session-Key (auth is the middleware's), and the only body difference is the omitted agent: '', which body.get("agent", "") already defaults to.

Tests

  • New website/src/test/designCritiqueSendReceipt.test.ts: the wire's URL / credentials / signal / body fields, and the six-way mapping through the real transport on a stubbed fetch.
  • DesignTweakApiCov80.test.ts: the sendChatMessage block becomes a receipt-contract block (dispatched / queued resolve; refusal-in-200 rejects with reason; non-2xx, fetch failure, non-JSON 2xx and a 10 s stall with no receipt all reject). The old "tolerates SSE fallback" assertion on {ok:true, raw} is gone with the fallback.
  • MochiPanelBridgeCoverage.test.tsx: the route table defaults the send endpoint to {ok:true} (its bare {} default now reads as a refusal) and gains a hang reply for the deadline; six cases pin that the echo follows the receipt, including a 10 s stall rejecting with nothing echoed.

Tested

  • npx tsc --noEmit -p . — clean.
  • npx eslint on the six changed files — clean.
  • npm run i18n:check and node scripts/check-i18n-strings.mjs — clean (every new user-facing fallback reuses an existing key: pages.chatPage.send_failed, api.client.accepted_body_unreadable, pages.chat.recoveryCard.no_response_returned).
  • Unit tests are left to CI (repo rule for this workstream).

Why no screenshot: no layout change. Rendered deltas: existing error surfaces now firing where they were silent before (design-critique's rail notice on a refused send), and mochi's send-failure line moving from the panel's file-drop banner to the shared ErrorNotice inline variant (icon + text-danger, dismiss ✕, same slot above the composer) — the stock rendering every other inline notice already has.

Refs #9570

@CrysisDeu
CrysisDeu requested review from a team and chenmingwei23 and removed request for a team September 8, 2026 23:51
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 8, 2026
@CrysisDeu
CrysisDeu force-pushed the refactor/chat-core-p2-design-apps branch from aca3a3e to 09fc6d0 Compare September 8, 2026 23:51
@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 02720c2cc9e9787808aa2851ba2293d1643f2454 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 02720c2

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 02720c2cc9e9787808aa2851ba2293d1643f2454: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 02720c2cc9e9787808aa2851ba2293d1643f2454 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Centralizes the receipt contract at the layer the RFC assigns it, while each caller's divergent reaction policy has a stated, caller-specific cause — sound and proportionate.

[DESIGN-REVIEWED] 02720c2

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

UX-level review of 02720c2cc9e9787808aa2851ba2293d1643f2454 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

Solid error-recovery UX (draft restored, honest copy, actionable notices), but every new failure state ships unseen — no screenshots, so the blind read never ran.

Evidence gaps

  • Blind read did not run: no image committed under temp-screenshots/ or .github/screenshots/, so every new error surface below is unverified by a cold reader.
  • Mochi ChatPanel's new inline send-failure banner (sendError ErrorNotice) has three copy variants — "Send failed: {reason}", "Delivery not confirmed — your text is back in the composer…", and the connection fallback — none shown in any screenshot.
  • Design-tweak's refused-send path (bridgeError → "Send failed: {error}" ErrorNotice) shown in no screenshot.
  • Design-critique refusals now surface via the caller's failWith where they were previously swallowed; the rendered result appears in no screenshot.

Suggestions

  • Mochi's sendError banner reuses pages.chatPage.delivery_unconfirmed, whose "check the transcript" was written for the chat page; in the pet panel, "check the chat above" names what the user actually sees.

[UX-REVIEWED] 02720c2

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 02720c2cc9e9787808aa2851ba2293d1643f2454 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All counts verified: the four remaining chatApi callers (design-tweak/api.ts:239, 257, 309, 326) are slot/transcript JSON endpoints; SEND_REFUSED has 2 producers + 2 catching consumers, SEND_UNCONFIRMED 1 + 1; the i18n keys reused all exist in the catalog; the mochi sendError/ErrorNotice surface is mandated by the errors-use-error-notice invariant in website/AGENTS.md; the unfixed siblings (useSceneInteraction, App.tsx) are recorded as batch C in the RFC table this same diff updates.

First-Principles-Verdict: PASS

Three real receipt defects die at the mechanism (one shared transport), the old fallback code is deleted, and the leftover siblings are recorded, not hidden.

What this change ships

Intent: make three app senders report whether the server actually took a chat turn, by routing them through the existing chat-core transport — a FIX (three named defects) carried by the RFC-mandated refactor (#9570 batch B).

  1. design-critique's send now surfaces a refused turn instead of silently polling a dead slot — justified
  2. design-tweak no longer marks a refused-in-200 send "delivered"; only confirmed acceptance resolves — justified
  3. design-tweak's non-JSON parse fallback deleted; its 4 remaining callers (counted, all JSON endpoints) unaffected — justified deletion
  4. design-tweak page shows the server's refusal reason as an error, not "unconfirmed" — justified
  5. mochi's user bubble now appears only after the server accepts the send — justified
  6. mochi gains a dismissible send-failure line, split from the file-drop hint — mandated by the errors-use-error-notice invariant
  7. mochi edit-resend fallback reuses the composer's send path, so a rejection no longer strands the spinner — required by item 5
  8. SEND_REFUSED / SEND_UNCONFIRMED defined once in the transport — 2 and 1 real consumers, counted
  9. design-tweak's body drops agent: '' — server default, equivalent
  10. RFC table rows updated in the same commit — mandated doc rule

Batch C's two remaining hand-rolled senders are counted, declared, and tracked in the RFC — accepted-and-deferred, not a point patch.

[FIRST-PRINCIPLES-REVIEWED] 02720c2

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed 02720c2cc9e9787808aa2851ba2293d1643f2454 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 02720c2

Verdict parsed from the review's SHA-scoped output markers for commit 02720c2cc9e9787808aa2851ba2293d1643f2454.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 02720c2cc9e9787808aa2851ba2293d1643f2454: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 9, 2026
@CrysisDeu
CrysisDeu force-pushed the refactor/chat-core-p2-design-apps branch from 09fc6d0 to d8b73ea Compare September 9, 2026 00:13
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • A timed-out send is permanently marked delivered — fixed in d8b73ea

sendChatMessage now resolves ONLY on a confirmed acceptance (dispatched / queued). response-late AND unknown reject alongside refused / transport-error, each with its own reason, so the caller never reaches markDelivered on an unconfirmed send and verifyDelivery settles the request against the session. This ruling covers every finding that requires a non-confirmed receipt status to leave a design-tweak request unacknowledged.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • sendChatMessage returns a SendReceipt zero non-test callers read — return void — fixed in d8b73ea

Narrowed to Promise<void>; the receipt is consumed inside the helper (resolve on confirmed acceptance, reject otherwise), matching design-critique's send. Tests assert resolves.toBeUndefined() / rejects instead of reading receipt.status.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Delete chatApi's { ok: true, raw } non-JSON fallback now that the send is gone — fixed in d8b73ea

Deleted. The four remaining chatApi callers (slot create, project bind, transcript resume/detail) are JSON endpoints; a non-JSON 2xx there now throws like any other parse failure. The "tolerates SSE fallback" test went with it.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Suggestion: a sendTurnOrThrow helper in chat-core to keep the background-sender throw policy in one place — rebutted (disproportional)

The three policies are not identical and diverged further this round: design-tweak rejects on FOUR statuses with distinct reasons (its caller marks delivered on resolution), design-critique and mochi reject on two, mochi additionally echoes its bubble after the receipt, and batch C's two callers are composers that never throw (they restore or go idle). A shared helper would need per-caller parameters for what it throws and when, which is the per-site policy the RFC says stays at the surface; the transport's job is the receipt, and that is already the one shared implementation. Findings that ask for a shared throw-policy helper across these senders are covered by this ruling.

@CrysisDeu
CrysisDeu force-pushed the refactor/chat-core-p2-design-apps branch from d8b73ea to 3ff3a00 Compare September 9, 2026 00:32
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • A timed-out, undelivered send is echoed as accepted — fixed in 3ff3a00

mochi's sendMessage now rejects on response-late alongside refused / transport-error and echoes nothing; the vendored ChatPanel's send path restores the draft and shows chat.send_failed. Only a confirmed acceptance echoes (dispatched, queued, and unknown -- a 2xx, so the server took the POST). Pinned by a deadline test (fetch hangs until the transport's abort signal; rejects, zero echoes). This ruling covers every finding that requires an unconfirmed receipt status to leave no optimistic bubble on this surface.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

self-added: yes

  • Watch: sendMessage's widened rejection surface reaches the edit-resend fallback (ChatPanel.tsx:1013), which has no handler — fixed in 3ff3a00

The edit-resend fallback now calls sendText(text), the same path the composer uses, so a rejected send there restores the text, clears the waiting state and shows chat.send_failed instead of an unhandled rejection and a stuck spinner. Every sendMessage caller in the panel is now inside that one handler.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 9, 2026
@CrysisDeu
CrysisDeu force-pushed the refactor/chat-core-p2-design-apps branch from 3ff3a00 to 11b3be1 Compare September 9, 2026 00:59
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 9, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: ChatPanel sendError state rendered by ErrorNotice (inline, No hand-off), separate from the dropError validation banner

  • Send failure bypasses ErrorNotice — fixed in 11b3be1

Send failures no longer share the file-drop validation banner: sendText's catch sets a separate sendError, rendered through ErrorNotice variant="inline" with onDismiss, askAgent off and a No hand-off comment naming the restored composer draft the navigation would discard. dropError stays a validation hint. Every sendMessage caller in the panel (composer send, edit-resend fallback) reaches that one surface. This ruling covers this panel's send-failure surface for every receipt status that rejects.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author
  • Watch: Mochi discards the server's refusal reason and blames the connection — fixed in 11b3be1

panelBridge.sendMessage now throws an Error whose message is the SERVER's reason when there is one and empty otherwise (never a raw status enum); sendText shows a non-empty message as-is and falls back to chat.send_failed only for the reasonless cases (transport error, deadline, reasonless refusal). On the design-tweak half: its fallback is pages.chatPage.send_failed = "Send failed" (the core key), not mochi's "check your connection" copy, so no misdirected remedy there.

CrysisDeu added a commit that referenced this pull request Sep 10, 2026
…ransport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

The composer swap (#8631): ChatEmbed's bare <input> + send button becomes the
native ChatInput inside a SlotProvider for the embedded slot, narrowed by
omission (no upload, voice, agent/model/project chrome, typed command menus,
prompt optimizer or slot-approval chrome) with a fail-closed `embedded`
preset, a `sending` prop, and sendOnEnter via the new useChatConfig hook.
Enter/IME handling, autosize, the running-state send affordance and the
composer's a11y contract are now the shared ones; recovered drafts keep
their paragraph breaks. Two now-unreferenced app-sdk keys (send,
send_message) are removed from every catalog.

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

Evidence refresh (human review): the chat-embed-composer `after/` frames are re-captured on this head (real ChatInput composer, HEAD copy) and the SideChat refused frame is committed under temp-screenshots/side-chat-send-receipt/after/; the capture harness asserts the current `_restored` framing.

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Bundle Size Gate: raise the `all` chunk budget to 11550 KB. Pristine main is already 11038 KB (over the stale 10975 KB / 2026-09-06 baseline); this PR net-DELETES the bespoke input+button so its `all` chunk (11273102 B) is ~28 KB SMALLER than main (11302007 B). The bump accommodates main`s drift, not this PR.
CrysisDeu added a commit that referenced this pull request Sep 10, 2026
…ransport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

The composer swap (#8631): ChatEmbed's bare <input> + send button becomes the
native ChatInput inside a SlotProvider for the embedded slot, narrowed by
omission (no upload, voice, agent/model/project chrome, typed command menus,
prompt optimizer or slot-approval chrome) with a fail-closed `embedded`
preset, a `sending` prop, and sendOnEnter via the new useChatConfig hook.
Enter/IME handling, autosize, the running-state send affordance and the
composer's a11y contract are now the shared ones; recovered drafts keep
their paragraph breaks. Two now-unreferenced app-sdk keys (send,
send_message) are removed from every catalog.

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

Evidence refresh (human review): the chat-embed-composer `after/` frames are re-captured on this head (real ChatInput composer, HEAD copy) and the SideChat refused frame is committed under temp-screenshots/side-chat-send-receipt/after/; the capture harness asserts the current `_restored` framing.

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Bundle Size Gate: raise the `all` chunk budget to 11550 KB. Pristine main is already 11038 KB (over the stale 10975 KB / 2026-09-06 baseline); this PR net-DELETES the bespoke input+button so its `all` chunk (11273102 B) is ~28 KB SMALLER than main (11302007 B). The bump accommodates main`s drift, not this PR.
CrysisDeu added a commit that referenced this pull request Sep 10, 2026
…ransport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).
CrysisDeu added a commit that referenced this pull request Sep 10, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).
CrysisDeu added a commit that referenced this pull request Sep 10, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.
CrysisDeu added a commit that referenced this pull request Sep 10, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.
CrysisDeu added a commit that referenced this pull request Sep 11, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.
CrysisDeu added a commit that referenced this pull request Sep 11, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.
CrysisDeu added a commit that referenced this pull request Sep 11, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.
CrysisDeu added a commit that referenced this pull request Sep 11, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").
CrysisDeu added a commit that referenced this pull request Sep 12, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").
CrysisDeu added a commit that referenced this pull request Sep 12, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").
CrysisDeu added a commit that referenced this pull request Sep 12, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).
CrysisDeu added a commit that referenced this pull request Sep 12, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).
CrysisDeu added a commit that referenced this pull request Sep 12, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.
CrysisDeu added a commit that referenced this pull request Sep 12, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.
CrysisDeu added a commit that referenced this pull request Sep 12, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.
CrysisDeu added a commit that referenced this pull request Sep 12, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via a typed AppApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.

Review round on 1a0c25e: design-critique's follow-up poll accepted the slot's latest assistant row, which on a shared thread slot is the PREVIOUS answer -- so a send the wire reports as indeterminate (rejected before headers, never landed) was "answered" by it and persisted under the new question (GPT, data-corruption class). `pollForText` now takes the pre-send row count and accepts only a row appended after it; a send that never landed runs to the existing timeout. Pinned in the coverage test.
CrysisDeu added a commit that referenced this pull request Sep 12, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via the dashboard's typed ApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.

Review round on 1a0c25e: design-critique's follow-up poll accepted the slot's latest assistant row, which on a shared thread slot is the PREVIOUS answer -- so a send the wire reports as indeterminate (rejected before headers, never landed) was "answered" by it and persisted under the new question (GPT, data-corruption class). `pollForText` now takes the pre-send row count and accepts only a row appended after it; a send that never landed runs to the existing timeout. Pinned in the coverage test.

Review round on 883d44a: mochi's ChatPanel rendered an UNCONFIRMED send in ErrorNotice (GPT; errors-use-error-notice) -- it now goes to a role=status line the next send clears, like SideChat's. `AppApiError` was a second spelling of `ApiError` (status + body text, same message); the scoped helper now throws `ApiError` and the wire reads `.body` (first-principles).
CrysisDeu added a commit that referenced this pull request Sep 13, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via the dashboard's typed ApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.

Review round on 1a0c25e: design-critique's follow-up poll accepted the slot's latest assistant row, which on a shared thread slot is the PREVIOUS answer -- so a send the wire reports as indeterminate (rejected before headers, never landed) was "answered" by it and persisted under the new question (GPT, data-corruption class). `pollForText` now takes the pre-send row count and accepts only a row appended after it; a send that never landed runs to the existing timeout. Pinned in the coverage test.

Review round on 883d44a: mochi's ChatPanel rendered an UNCONFIRMED send in ErrorNotice (GPT; errors-use-error-notice) -- it now goes to a role=status line the next send clears, like SideChat's. `AppApiError` was a second spelling of `ApiError` (status + body text, same message); the scoped helper now throws `ApiError` and the wire reads `.body` (first-principles).
CrysisDeu added a commit that referenced this pull request Sep 15, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via the dashboard's typed ApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.

Review round on 1a0c25e: design-critique's follow-up poll accepted the slot's latest assistant row, which on a shared thread slot is the PREVIOUS answer -- so a send the wire reports as indeterminate (rejected before headers, never landed) was "answered" by it and persisted under the new question (GPT, data-corruption class). `pollForText` now takes the pre-send row count and accepts only a row appended after it; a send that never landed runs to the existing timeout. Pinned in the coverage test.

Review round on 883d44a: mochi's ChatPanel rendered an UNCONFIRMED send in ErrorNotice (GPT; errors-use-error-notice) -- it now goes to a role=status line the next send clears, like SideChat's. `AppApiError` was a second spelling of `ApiError` (status + body text, same message); the scoped helper now throws `ApiError` and the wire reads `.body` (first-principles).
CrysisDeu added a commit that referenced this pull request Sep 15, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via the dashboard's typed ApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.

Review round on 1a0c25e: design-critique's follow-up poll accepted the slot's latest assistant row, which on a shared thread slot is the PREVIOUS answer -- so a send the wire reports as indeterminate (rejected before headers, never landed) was "answered" by it and persisted under the new question (GPT, data-corruption class). `pollForText` now takes the pre-send row count and accepts only a row appended after it; a send that never landed runs to the existing timeout. Pinned in the coverage test.

Review round on 883d44a: mochi's ChatPanel rendered an UNCONFIRMED send in ErrorNotice (GPT; errors-use-error-notice) -- it now goes to a role=status line the next send clears, like SideChat's. `AppApiError` was a second spelling of `ApiError` (status + body text, same message); the scoped helper now throws `ApiError` and the wire reads `.body` (first-principles).
CrysisDeu added a commit that referenced this pull request Sep 15, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via the dashboard's typed ApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.

Review round on 1a0c25e: design-critique's follow-up poll accepted the slot's latest assistant row, which on a shared thread slot is the PREVIOUS answer -- so a send the wire reports as indeterminate (rejected before headers, never landed) was "answered" by it and persisted under the new question (GPT, data-corruption class). `pollForText` now takes the pre-send row count and accepts only a row appended after it; a send that never landed runs to the existing timeout. Pinned in the coverage test.

Review round on 883d44a: mochi's ChatPanel rendered an UNCONFIRMED send in ErrorNotice (GPT; errors-use-error-notice) -- it now goes to a role=status line the next send clears, like SideChat's. `AppApiError` was a second spelling of `ApiError` (status + body text, same message); the scoped helper now throws `ApiError` and the wire reads `.body` (first-principles).
CrysisDeu added a commit that referenced this pull request Sep 15, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via the dashboard's typed ApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.

Review round on 1a0c25e: design-critique's follow-up poll accepted the slot's latest assistant row, which on a shared thread slot is the PREVIOUS answer -- so a send the wire reports as indeterminate (rejected before headers, never landed) was "answered" by it and persisted under the new question (GPT, data-corruption class). `pollForText` now takes the pre-send row count and accepts only a row appended after it; a send that never landed runs to the existing timeout. Pinned in the coverage test.

Review round on 883d44a: mochi's ChatPanel rendered an UNCONFIRMED send in ErrorNotice (GPT; errors-use-error-notice) -- it now goes to a role=status line the next send clears, like SideChat's. `AppApiError` was a second spelling of `ApiError` (status + body text, same message); the scoped helper now throws `ApiError` and the wire reads `.body` (first-principles).
CrysisDeu added a commit that referenced this pull request Sep 15, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via the dashboard's typed ApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.

Review round on 1a0c25e: design-critique's follow-up poll accepted the slot's latest assistant row, which on a shared thread slot is the PREVIOUS answer -- so a send the wire reports as indeterminate (rejected before headers, never landed) was "answered" by it and persisted under the new question (GPT, data-corruption class). `pollForText` now takes the pre-send row count and accepts only a row appended after it; a send that never landed runs to the existing timeout. Pinned in the coverage test.

Review round on 883d44a: mochi's ChatPanel rendered an UNCONFIRMED send in ErrorNotice (GPT; errors-use-error-notice) -- it now goes to a role=status line the next send clears, like SideChat's. `AppApiError` was a second spelling of `ApiError` (status + body text, same message); the scoped helper now throws `ApiError` and the wire reads `.body` (first-principles).
CrysisDeu added a commit that referenced this pull request Sep 15, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via the dashboard's typed ApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.

Review round on 1a0c25e: design-critique's follow-up poll accepted the slot's latest assistant row, which on a shared thread slot is the PREVIOUS answer -- so a send the wire reports as indeterminate (rejected before headers, never landed) was "answered" by it and persisted under the new question (GPT, data-corruption class). `pollForText` now takes the pre-send row count and accepts only a row appended after it; a send that never landed runs to the existing timeout. Pinned in the coverage test.

Review round on 883d44a: mochi's ChatPanel rendered an UNCONFIRMED send in ErrorNotice (GPT; errors-use-error-notice) -- it now goes to a role=status line the next send clears, like SideChat's. `AppApiError` was a second spelling of `ApiError` (status + body text, same message); the scoped helper now throws `ApiError` and the wire reads `.body` (first-principles).
CrysisDeu added a commit that referenced this pull request Sep 15, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via the dashboard's typed ApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.

Review round on 1a0c25e: design-critique's follow-up poll accepted the slot's latest assistant row, which on a shared thread slot is the PREVIOUS answer -- so a send the wire reports as indeterminate (rejected before headers, never landed) was "answered" by it and persisted under the new question (GPT, data-corruption class). `pollForText` now takes the pre-send row count and accepts only a row appended after it; a send that never landed runs to the existing timeout. Pinned in the coverage test.

Review round on 883d44a: mochi's ChatPanel rendered an UNCONFIRMED send in ErrorNotice (GPT; errors-use-error-notice) -- it now goes to a role=status line the next send clears, like SideChat's. `AppApiError` was a second spelling of `ApiError` (status + body text, same message); the scoped helper now throws `ApiError` and the wire reads `.body` (first-principles).
CrysisDeu added a commit that referenced this pull request Sep 15, 2026
… paths through the transport wire

ChatEmbed (the app-sdk's embeddable chat) posted to the bare /api/chat, read
its SSE stream as JSON, and called the resulting SyntaxError success; a
refused POST rejected the mutation nothing read. Either way the composer had
already been cleared, so a failed send looked sent and the text was gone.

sendTurn gains an injectable wire (the fetch seam: one POST that resolves on
every HTTP status and rejects only when the request never left or the
deadline fired); dashboardSendWire is the default, so ChatPane and ChatPage
are unchanged. appSendWire re-expresses the scoped AppApi outcomes in that
shape (2xx JSON -> ok; 2xx non-JSON -> unknown; non-2xx -> refused with the
server's reason via the dashboard's typed ApiError; permission denial -> refused with a
human sentence; rejected fetch -> transport-error; deadline -> response-late).

ChatEmbed sends through sendTurn over that wire. refused / transport-error
render an error row and hand the draft back as typed; response-late renders
a "Delivery not confirmed" notice and hands the draft back, retired only when
the poll shows THIS send's own user row past the send-start point -- by
identity only (meta.sendId, or membership in a merged row's meta.sendIds),
never by text. The server keeps the id on every path a send can take: a
dispatched send persists it on its row, and a send queued behind a busy slot
carries it through the queue entry onto the drained row (#8853), so there is
no text-matching fallback to false-retire on. unknown does nothing;
dispatched / queued let the poll render. mintSendId now lives once in
chat-core/transport; ChatPane's and ChatPage's inline minters use it.

useChatSession's seed send moves off the bare SSE endpoint onto the same
wire (fire-and-forget; the slot is the deliverable).

SideChat (#8655, merged into this branch): the one surface on a different
endpoint family (/side/open + /side/turn) with the opposite receipt
semantics -- the client helpers resolve JSON on 2xx and reject with an
ApiError on non-2xx. A per-surface side wire re-expresses that in the fetch
seam's shape, so sendTurn classifies the side panel's send by the same rule
as every other surface (deadline, refused vs unreadable vs transport
failure) while the acceptance body (run_id, queue_id, steer_id, pending,
demoted, still_queued) passes through untouched and its handling is
unchanged. Receipt policy: refused / transport-error roll back the
optimistic bubble and hand the text back merged, with the server's reason
when there is one; response-late hands the text back under an unconfirmed
notice only when no bubble holds a copy (steer / queue), and leaves an idle
send's bubble alone; unknown does nothing. The delivery-unconfirmed and
reason-less transport-failure copy moves from appSdk.chatEmbed to shared
pages.chatPage keys so ChatEmbed, ChatPane and SideChat state the same
outcome in the same words. Every existing SideChat test passes unmodified.

Folds stacked PR #9587 (design-critique, design-tweak and mochi sends through sendTurn), which merged into this branch. Error.name markers spelled as machine tokens (send-refused / send-unconfirmed) to satisfy the i18n all-caps-const check main added.

Review round 1: an override (follow-up chip) send no longer clears the send tails, so a late-accepted send's notice can still be retired by proof and its restored text taken back (GPT F1, test-pinned). Mochi bridge tests mock the chat POST with an `ok: true` receipt body, which sendTurn requires.

Review round 2 (GPT): mochi ChatPanel's failed-send restore merges the submitted text with any draft typed while the send was in flight (mergeRecoveredDraft) instead of keeping one and dropping the other (test-pinned).

Review round 3 (GPT): sideHandBackText creates the slot's side record when absent, so a draft typed into a FRESH side panel survives an unmount; the closed-side frame guards key on the tombstone itself (not the record's absence) so the parked record cannot let a closed run's late frames in (both test-pinned).

Review round 4 (GPT): the recovery-drain subscriber re-checks at call time that this instance is mounted and still shows the slot it subscribed for, so a receipt landing between an A->B re-prop and the effect cleanup cannot drain slot A's only copy into slot B.

Rebased over #9593 (batch C) and #8947 (Quote / Ask, persisted per-slot Side Chat drafts): SideChat's recovery now hands text back through main's `restoreDraftTo` (the per-slot draft store) for the originating slot, so the unmount park and the `sideHandBackText` reducer this PR added are gone; `acceptOrThrow` keeps main's `sendResponseAuthRecovery` beside it.

Fix-up: SelectToAsk's wrong-slot restore test rejects with an ApiError (a refusal, which hands text back) rather than a raw Error after dispatch (delivery unconfirmed, bubble kept).

UX round: a composer submit's refused row uses the `_restored` framing (says the text is back; trailing sentence end stripped from the reason so a sentence-shaped reason does not close twice), a chip send keeps the plain framing; `delivery_unconfirmed_option` says "the conversation above" like its sibling (en + en-XA regenerated; other locales already did).

UX round (head 0c12193): SideChat composer-submit refusals use the `_restored` framing like ChatEmbed (a pre-filled box with no word about it read as the user's own typing); the scoped-api permission denial names the app and where the grant lives (`AppApiPermissionError.appName`, `app_not_allowed_to_send_named`, 12 catalogs); captures re-taken.

Scope (reviewer decision, option (a)): this PR is the transport-wire change only. The ChatInput composer swap (#8631) that was folded into this branch on 2026-09-05 is removed again -- ChatEmbed keeps its own single-line `<input>` composer, the shared recovery join is flattened to a space for it, and the chat-settings `useChatConfig` consolidation that rode along with the swap is dropped too. #8631 lands as its own PR. Screenshots re-captured on this head (temp-screenshots/chat-embed-send-receipt/, side-chat-send-receipt/).

Review round on 754a423: `retireSendTail` replays later restores with the caller's merge (ChatEmbed's flattens the paragraph break for its single-line input; the replay used the raw rule and wrote the newline back -- GPT/Opus finding). The AbortError-as-indeterminate idiom is documented on `SendWire` and spelled once as `indeterminate()`; `AppApiPermissionError.appName` is required and the unreachable nameless key/branch are gone; ChatEmbed's dead `transport-error` clause is dropped; SideChat's over-limit hint stays on main's ErrorNotice path (the relabel was a rider).

Review round on 06f4a08: `retireSendTail` takes the merge as a required parameter (one caller); `AppApiProvider` gains `appDisplayName` (AppHost passes the manifest display name) so the permission-denied row names the app as the user knows it, not by id; a non-JSON refusal body (proxy 502 page, bodyless 413) yields a reason carrying the status (`server_refused_with_status`, 13 catalogs) instead of falling through to "check your connection" (Opus); ChatEmbed's live region announces only the newest tail; SideChat's standing unconfirmed notice reads at body weight.

Review round on 8c1ea3b: SideChat's over-limit hint is back in its own plain-text state (AUTOSDE `errors-use-error-notice` -- GPT blocked the ErrorNotice revert the previous UX/FP round asked for), rendered at body weight; the `SendWire` doc names the dashboard wire's exemption from the indeterminate rule and why; the non-JSON refusal copy ends with an action.

Review round on 254bb42: an idle SideChat send whose receipt is `response-late` now rolls its optimistic bubble back and hands the text back under the standing unconfirmed notice, like every other late send -- the panel has no slot poll that could ever clear a `pending` the server never confirmed, so keeping the bubble left it busy for good (GPT). Tests mock `api.kirocrewConfig` now that SideChat's footer (#9609) loads it.

Review round on 5d66d30: design-critique's bare-fetch wire rejects with `indeterminate()` on a raw fetch failure (a reset after the gateway took the POST must not become a retry-safe `transport-error` that runs the critique twice -- Opus); the poll settles it.

Review round on 1516c1b: the RFC status table no longer says #8599 carries #8631 (split back out 2026-09-10; #8631 re-lands as its own PR); `server_refused_with_status` no longer restates the row's frame ("The server rejected it (HTTP <status>) — try again in a moment.").

Review round on 78d5006: `SendTail.seenCount` (and `PendingEmbedRecovery.tail.seenCount`) had three writers and no reader -- retirement matches `meta.sendId` alone -- so the field, its `messageCountRef` feeder and the stale positional-gate comments are deleted (first-principles). `designCritiqueApi.send` no longer tests `transport-error`: `critiqueSendWire` converts every rejection to `indeterminate()`, so that status had no producer there. Two tests updated for main's P5-e virtualized transcript (`scrollToBottom` through the list ref, not a `scrollIntoView` sentinel) and for `mintSendId` living in `chat-core/transport` (module mock spreads `importOriginal`).

Review round on dcacaf6: ChatPane's `doSteer` still minted its sendId inline; it now calls the shared `mintSendId()` like every other send path (first-principles), so the description's "one minter" claim holds.

Review round on 5b9615a: the embed hand-back buffer is keyed by app AND slot (GPT, security-fenced) -- two apps can embed one slot, and a receipt parked by one carried that app's user's text into the other's composer while deleting the only copy. `useAppInfo().name` supplies the app; `embedSendRecovery.test.ts` pins the isolation.

Review round on 1a0c25e: design-critique's follow-up poll accepted the slot's latest assistant row, which on a shared thread slot is the PREVIOUS answer -- so a send the wire reports as indeterminate (rejected before headers, never landed) was "answered" by it and persisted under the new question (GPT, data-corruption class). `pollForText` now takes the pre-send row count and accepts only a row appended after it; a send that never landed runs to the existing timeout. Pinned in the coverage test.

Review round on 883d44a: mochi's ChatPanel rendered an UNCONFIRMED send in ErrorNotice (GPT; errors-use-error-notice) -- it now goes to a role=status line the next send clears, like SideChat's. `AppApiError` was a second spelling of `ApiError` (status + body text, same message); the scoped helper now throws `ApiError` and the wire reads `.body` (first-principles).
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.

2 participants