Skip to content

fix(chat): keep the optimistic user bubble across a slot refetch - #6825

Closed
rnoack1 wants to merge 1 commit into
kirodotdev:mainfrom
rnoack1:fix/preserve-optimistic-user-bubble-on-slot-refetch
Closed

rnoack1 wants to merge 1 commit into
kirodotdev:mainfrom
rnoack1:fix/preserve-optimistic-user-bubble-on-slot-refetch

Conversation

@rnoack1

@rnoack1 rnoack1 commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

A slot-detail refetch rebuilds messages from the fetched page and drops the user's just-sent message.

The composer appends the user's row client-side at send time (appendMessage, flagged meta.optimistic because it carries a sendId), so it is on screen before the server has persisted anything. Both refetch reducers then rebuild the list, and both preserve some local rows the page may predate:

  • switchSlot.fulfilled re-attaches a trailing local reply only when it is an assistant/streaming row, otherwise falls through to next = preserved
  • refreshSlot.fulfilled re-injects only permission cards over the fetched page
  • both additionally carry pastes, thinking blocks and the queue

Neither preserves a trailing user row. So a refetch resolving in the window between the optimistic append and the server's own append silently discards the bubble.

Why it matters

isWelcomeState requires !slotLoading, so once messages is emptied the pane renders blank with a spinner rather than the welcome hero. The composer has already cleared. The message reappears only when the turn's first reply lands, which on a first turn can be 10+ seconds later.

The net effect is that a slow turn is indistinguishable from a lost message — the user has no evidence their send was accepted.

What changed

One shared guard, applied at both call sites, re-attaching sent user rows the fetched page cannot legitimately contain.

Retention is set where the composer renders a bubble ahead of the server (meta.pendingServerRow) and is released by exactly two things: the row's own identity appearing in a fetched page, or an explicit outcome dispatched through clearPendingServerRow. Nothing else retires it — not a wall clock, not a row count, and not dispatch order. That last exclusion is deliberate and was the subject of two earlier iterations here: neither a timestamp nor the client's dispatch sequence says when the SERVER took its snapshot, so a refetch issued after the send can still have read the transcript before the POST committed, and treating its page as proof of absence deletes a delivered prompt. The explicit outcomes are exactly two, and both come from the SERVER: a refusal, and a queued acceptance (whose queued twin owns the message). A transport failure never retires the row, in either direction — no browser signal proves the POST did not leave, navigator.onLine least of all, since it is read when the exception surfaces and so reads false on a connection that dropped after the bytes went out. The cost is stated rather than hidden: a send that genuinely never left leaves a bubble that no refetch clears, which is the deliberate trade against deleting a delivered prompt. A superseded same-slot response is discarded outright by the shared dispatch clock, so an older refetch cannot rebuild the transcript without a row a newer one already persisted.

Four further changes ride here and are called out rather than left implicit:

  • state.slotLoading = false moved above the supersede guard in switchSlot.fulfilled — a real timing change. It is placed deliberately between the guards: BELOW activeSlot !== key (where a newer switch owns the flag and must clear it itself, so clearing here would lie about that switch) and ABOVE the superseded return (where nothing else ever clears it — refreshSlot.fulfilled never touches the flag — so a discarded response would leave a permanent spinner). The remaining early return, isUnsafeKey(key), did not clear the flag before this change either, so its behaviour is unchanged.
  • Failure rows are addressed to the SENDING slot, at three ChatPage sites (refusal, abort, transport) plus the session-create failure. This is a SECOND defect fixed here, beyond the stated bug, and it changes WHERE a failure row lands: previously the row was appended to whichever slot was active when the exception surfaced, so switching slots mid-send filed the error in the wrong transcript. The sending slot is captured before the first await and used for every failure arm.
  • A receipt or echo makes the caption DEFINITE; it does not clear the composer. The failure arms stage the payload back so a reload cannot lose it, but confirmation retires the "resending may send it twice" caption, which previously left the identical payload staged with the warning gone — one reflexive Enter duplicated an answered turn. Both clear sites now set a positive meta.deliveryConfirmed marker (absence cannot carry this: a DROPPED row is absent too, and clearing on absence would destroy the text the restore just rescued) plus meta.confirmedSendId, naming WHICH send the row confirms, and both composers READ that identity to swap the caption from "resending may send it twice" to "Message delivered - sending it again will send it twice". Confirmation deliberately clears NOTHING: the composer's own onChange is only one mutation entry point, and a dropped session ref, a pasted block or a picked file change no text at all, so neither a touched flag nor a text comparison can see them and an automatic clear would delete work it cannot prove is a duplicate. The caption is released only when the user edits or clears the payload, and the marker is PERSISTED alongside the draft so a reload cannot bring the payload back unmarked. Content is deliberately NOT compared: two sends of the same short prompt ("continue") are indistinguishable by text, so a content match let an EARLIER confirmed row retire a LATER still-unconfirmed resend and delete the only copy of it. reconcileOptimisticEcho strips the one-shot sendId (fix(chat): pipelined sends cause duplicate bubbles and orphaned optimistic rows #3898 item 2), which is why the durable key is needed rather than reusing it; the receipt path stamps the same key so neither reader has to know which path confirmed. A composer the user has since edited is left alone.
  • Warm and slot-detail ordering share one dispatch clock (nextSeq). Needed by the supersede guard, which requires a monotonic token; a second counter beside the existing warm one would let two orderings interleave incomparably. It is minted in thunks only — no reducer reads the counter.

ChatPane's abort arm now restores unconditionally, matching its own transport arm and ChatPage: abort is the WEAKEST delivery state and the bubble is store-only, so a reload keeps neither it nor the composer cleared before the POST.

Three review items are declared here rather than folded in, because each changes a contract wider than the identity defect this commit fixes. (a) Refining the retire to strip only a recovered suffix when the restore MERGED, instead of clearing, alters the merge/clear contract. (b) The four-flag delivery lifecycle (optimistic, pendingServerRow, deliveryUnknown, deliveryConfirmed) is choreographed by hand in two surfaces; extracting the shared receipt/echo->caption handshake into one owner is a follow-up, not a bug fix. (c) The retention trade below — a send that genuinely never left leaves a bubble no refetch clears — is a declared product-behaviour trade a human should ratify; it is stated, not changed.

Re-attachment keys on meta.sendId, which the server preserves on the row it appends, so a page that already carries the row reconciles instead of gaining a duplicate.

Re-attachment composes over the existing tailNotInPage / rowIdentities identity pair rather than hand-rolling a second sendId set, and each row is reinserted at its prior relative position rather than concatenated: a thinking row can arrive after the optimistic append and the refetch re-seats it, so a tail append would render reasoning above the prompt that caused it. Anchoring on the nearest preceding identifiable neighbour also keeps pipelined sends in order.

Retention is a POSITIVE meta.pendingServerRow marker, set only where the composer renders a bubble ahead of the server. clearPendingServerRow retires it on every outcome meaning the transcript must not get the row back from this client: a refused or errored send, and a QUEUED acceptance — keyed on sendId, because the slot-detail queue redacts its content for display, so no content join can pair a queued twin. It deliberately does NOT clear meta.optimistic: that flag is delivery state, and ChatPageSendConfirm.test.tsx pins that a refusal is not a receipt.

Retention otherwise holds until a fetched page actually CONTAINS the row, so two concurrent pre-append refetches cannot delete an unacknowledged bubble between them. There is no other release: a row count cannot distinguish a rewind from a stale page for a send the server has not acknowledged, so no total comparison is made — the earlier shrink wiring was unreachable once retention required optimistic, and has been deleted rather than left as dead code. ChatPane's three failure arms get the same treatment through their shared reportFailedSend, and the send-timeout arm is left preserved rather than collected, so a timed-out send cannot lose the user's text silently.

Tests

chatSlice.optimisticBubblePreserved.test.ts drives the real thunks against a real store with a mocked slot-detail response. Both drop-tests fail without the fix:

AssertionError: expected [] to have a length of 1 but got +0   (switchSlot)
AssertionError: expected [] to have a length of 1 but got +0   (refreshSlot)

messages emptying to length 0 is precisely the blank-pane state, so the test pins the symptom and not just the merge.

Also pinned:

  • duplicate-safety per path — a page already containing the row must not gain a second copy, so a fix that blindly re-appends cannot pass
  • a superseded switch discards its paging cursor along with the rebuild — setPagingCursor early-returns while a switch claim is open, so a refresh resolving first installs no cursor, and then supersedes the switch that would have. The slot was left with slotCursorKey === null, which loadOlder's own condition reads as "paging mid-switch" forever. The superseded branch installs NOTHING and returns: applying an older response's own hasMore/nextBefore would set the paging anchor from a page a newer response has already superseded, which skips rows. The residual is stated rather than hidden -- switchSlot.pending has already de-keyed slotCursorKey, and loadOlder's condition (slotCursorKey === activeSlot) therefore refuses paging until the next successful switchSlot/refreshSlot installs a cursor. The test installs NO cursor from a superseded switch, even with none landed pins exactly that. The refresh itself is deliberately NOT suppressed: skipping it would let a switch that snapshotted running: true outlive the chat_done that ended the turn, leaving the slot stuck streaming.
  • the warm reconcile retains a pending send too — it is the third rebuild site: with no identity overlap its base is the warm page alone, which dropped a pane send before the user switched in.
  • a superseded switch cannot overwrite a newer paging cursor — setPagingCursor writes unconditionally, so after two same-slot bounded switches resolved newest-first the stale response's older next_before replaced the newer one and the rows between them became unreachable. There is no slotCursorKey comparison at the call site. The protection is setPagingCursor's own early return while a switch claim is open for the active slot, together with switchSlot.pending de-keying the cursor, so a stale response landing second writes nothing over the newer one. The test keeps the newer cursor when the stale response lands second pins it.
  • an unconfirmed bubble no longer reads as delivered — a transport error keeps retention (no signal proves non-delivery), so the row survives every refetch while the adjacent error row says the send failed. markDeliveryUnknown marks that row and the bubble renders at reduced opacity with a dashed outline, so the transcript stops vouching for a delivery the code calls unknown.
  • an unanchored send is positioned structurally, not by clock — with an empty cache the send is the only prior row, so no preceding identity can anchor it, and a client clock running BEHIND the server made every fetched row look later, seating the prompt ABOVE the fetched history. An unanchored send now walks past every SERVER-IDENTIFIED row instead of consulting a timestamp, so it lands after the history while later local rows stay after it.
  • the unconfirmed state is stated in words, not only in styling — one shared catalog string (pages.chatPage.delivery_unconfirmed, "Delivery unconfirmed — resending may send it twice.") is used by BOTH unknown-delivery arms, so the pane and the page describe one state identically instead of borrowing the refusal copy that asserts a non-delivery the code does not hold. The bubble carries a visible caption and an accessible label, not just reduced opacity and a dashed outline.
  • proven delivery retires the marking — confirmOptimisticSend and reconcileOptimisticEcho both clear deliveryUnknown, so a row whose receipt or WS echo already proved delivery stops rendering as unconfirmed instead of waiting for the next refetch to replace it.
  • a failed send is recoverable after a RELOAD, not just on screen — the composer restore runs on every page arm that ends without a receipt: an explicit refusal, a dropped queued send, a transport error, and the 10s abort. The abort is the weakest state of the four -- delivery is unknown -- so it is the arm that most needs the payload handed back, and it now restores unconditionally like its siblings. It still reports nothing in the transcript, because the request was probably received and only the reply is late; the duplicate-resend risk is carried by the caption rather than by withholding the text. An earlier iteration here restored only where no bubble had taken the text, reasoning that a retained bubble already held it and that re-staging invited a duplicate resend. That was wrong about durability: the bubble lives only in the store, and the draft was cleared and PERSISTED as cleared before the POST, so a reload lost the text and its attachments with no copy anywhere. restoreComposerAfterFailedSend merges rather than overwrites and calls saveDrafts(), so the recovery is the durable one. The duplicate-resend risk is carried by the caption instead ("resending may send it twice"), which is a warning the user can act on, where silent data loss is not. The unconfirmed bubble also drops its title tooltip, which merely restated the caption rendered directly beneath it.
  • a BUSY send keeps its text — a busy send appends no optimistic bubble at all (ChatPage if (!_busy || forceNew), ChatPane if (!busy && (text || files.length))), so markDeliveryUnknown marks nothing and the composer, already cleared before the POST, was the only copy. Both arms capture that gate's own result and restore when no bubble took the text; the transport arm restores regardless, since no bubble outlives a reload.
  • a failure row is addressed to the SENDING slot — appendMessage writes to whichever slot is on screen, so switching away while the POST was in flight filed the failure in the wrong transcript. Both the refused and the transport arm now use appendSlotMessage with the captured slot.
  • a timed-out send stops reading as delivered — both AbortError arms dispatch markDeliveryUnknown, so a POST that stalled before any receipt no longer leaves a normal-looking phantom prompt that later refetches preserve indefinitely.
  • retention is now OPT-IN, closing a set/release asymmetry — the reducers used to stamp pendingServerRow onto ANY user row carrying a sendId, while release stayed hand-wired per outcome in two surfaces. A third send surface would have inherited retention for free and the release choreography not at all, turning its failed sends into tab-lifetime phantoms captioned "delivery unconfirmed". The reducers now set only optimistic; retention comes from an explicit retainedSend(meta) whose contract names the releases it obliges. A surface that does not ask gets no retention, so the trap cannot be inherited by construction. The helper returns a new object because the caller's meta also goes over the wire and must not gain a client-only flag.
  • an aborted send keeps its text — both AbortError arms marked delivery unknown but restored nothing. On the page the restore is now unconditional: the bubble is store-only, so when one WAS appended a reload still lost the text, the draft having been cleared and persisted as cleared before the POST. The pane arm keeps its no-bubble guard, because restoreIntoComposer writes React state only and the pane persists no draft, so restoring there cannot make a payload outlive a reload.
  • the warning is no longer printed twice — the bubble caption owns the delivery state, so the error row carries a distinct string (pages.chatPage.send_no_response, "The server did not respond to this send."). That is a transport fact rather than a delivery claim, so it stays true and cannot contradict the row once a receipt or echo makes the caption definite.
  • negative controls — removing the retainedSend opt-in at the pane's append site fails four component tests, proving the opt-in sites are covered rather than only the fixtures; reverting each of the earlier three fixes fails its own test (four in total, incl. expected 'chat/appendMessage' to be 'chat/appendSlotMessage'); suppressing the composer restore fails five tests, one of which asserts the PERSISTED draft after a transport rejection and fails with expected undefined to be 'survives a reload' -- the reload-loss the restore exists to prevent; reverting the unanchored walk fails both clock-skew tests, and removing either proven-delivery clear fails its own test; removing the cursor guard fails the stale-overwrite test (cursor 100 instead of 300) and over-reaching it to skip the install entirely fails two others; removing the unconfirmed-marker dispatch fails the marker test; suppressing the refresh on a superseded switch fails the stuck-running test; reverting the warm retention fails the warm test; disabling the page-identity release makes 7 tests fail (an implementation that retains unconditionally is rejected); reinstating any transport-error clear fails the offline-retain test; and reverting the timestamp advance, the retention hold or the ordering guard each fails exactly its own test, so none passes vacuously

Ordering and the failure path are pinned too, and both were negative-controlled: reverting the reinsertion to a tail append fails stays ABOVE a thinking row that arrived after it, and forcing the front-insertion fallback fails lands after the history it followed, not at the very front.

Ordering, the page-identity release and the two-concurrent-refetch case are each negative-controlled: reverting the timestamp advance, the identity filter, or the retention hold makes the corresponding tests fail.

Verification

  • new file: 5 passed
  • src/store/: 6 files, 109 passed
  • src/pages/: 14 files, 215 passed
  • all 52 files referencing switchSlot/refreshSlot: 1268 tests passed, 0 test failures
  • tsc --noEmit clean, eslint clean on both changed files

11 of those 52 files fail at collection in my sandbox. I ran the identical set on an unmodified baseline: also exactly 11 failures, 1263 tests passed (the 5-test delta is precisely this PR's new tests). Pre-existing and environmental to my local node_modules symlink, not introduced here — but worth a second look in CI.

Screenshots

The unknown-delivery bubble: dimmed, dashed, and captioned, with a confirmed row above and a still-pending row below as controls that must look identical. Captured from the real component via website/capture/user-message-delivery-unknown.html; the capture script fails unless exactly one role="status" caption renders, so a checkout that lost the caption cannot produce these images.

Unknown-delivery bubble, dark theme

Unknown-delivery bubble, light theme

Pattern harvest

Rule candidate: semgrep
Pattern: a reducer rebuilding a locally-accumulated list wholesale from a fetched server page,
without routing the result through a preservation step for the rows that page cannot yet contain.

Evidence the class recurs rather than being a one-off: the same omission was present at THREE
independent rebuild sites in this one file -- both slot-refetch reducers and the warm reconcile.
Each site reads as locally correct, because the fetched page genuinely IS the authoritative
history; what it silently drops is the one row the server could not have known about yet.

Limit of the mechanical rule: the shape is syntactically detectable, so semgrep can flag the site
and require the author to say how in-flight local rows survive. It cannot judge whether a given
row is still unacknowledged -- that residue belongs in a review-prompt line, not in a gate.

Note on the shared localStorage budget: the two existing draft stores KEEP their 2 MiB cap -- an earlier revision derived it by dividing the shared budget, which lowered it to about 1.07 MiB and would have LRU-evicted unsent drafts a user had already typed, purely because the constant moved. The recovery store is budgeted separately at 512 KiB on top, so 2 + 2 + 0.5 = 4.5 MiB against the ~5 MB an origin gives. That cap bounds marker records only: a record still carrying a prompt is never evicted for budget, because this store is that prompt's only copy.

@rnoack1
rnoack1 requested review from a team and krishdhasmana August 29, 2026 18:28
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Aug 29, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated.

Missing sections:

  • ## Problem / Motivation
  • ## Why it matters
  • ## What changed

Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle.

1 similar comment
@dwu96

dwu96 commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated.

Missing sections:

  • ## Problem / Motivation
  • ## Why it matters
  • ## What changed

Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle.

@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 Aug 29, 2026
@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5, fork) — 🟡 CONCERNS

UX-level review of bf49dee2d19e7c534170f755de6653e7370dc4a2 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

I have enough to assess. The screenshots the PR embeds are committed files on the fork branch (not user-attachment assets), so the workflow's attachment lists are empty and network fetch is blocked in this lane — I could not materialize them. I verified every UI change from the diff itself.

Reconciliation of user-visible controls this PR adds/changes: the DeliveryWarningStrip above the composer (four states: Discard / Clear / Remove / Dismiss + a consequence note), the unknown-delivery bubble treatment (opacity-70, dashed outline, "Delivery unconfirmed" caption, row "Remove message, keep the text" button), the queue-edit ErrorNotice banner ("Couldn't save the edit"), and the reworded delivery/transport strings. No blind read ran (fork, single pass), so comprehension of each is unverified.

No BLOCK exit fires: the bubble transforms in place (same node, className + appended caption — not an A-unmounts/B-mounts hard swap, so no lens-13 recording is owed), the "Delivery unconfirmed" copy reflects genuine client-side uncertainty the code does not hold, and the notices both assert a fact and offer an adjacent action.

UX-Verdict: CONCERNS

Novel "delivery unconfirmed" recovery UI with multiple similar exits ships with no blind read and its primary controls in no PR-embedded screenshot.

Watch

  • Undelivered+discardable strip stacks two near-synonymous exits — delivery_discard "Discard message and clear the composer" (warn) and delivery_remove "Remove message, keep the text" (muted) — plus the resend caption plus the consequence note, above the composer at the moment a message may have been lost. The only real difference is composer-keep-vs-clear. Frequency: every failed/timed-out send; impact: wrong pick costs typed text; persistence: every occurrence. Labels do name outcomes, but the distinction is unverified against a real reader — confirm comprehension before merge.

Evidence gaps

  • No blind read ran (fork lane): comprehension of the DeliveryWarningStrip exits and the bubble's "Remove message, keep the text" button is unverified — a maintainer can push the branch to this repo to get the cold read.
  • DeliveryWarningStrip (the primary interactive control) appears in no screenshot the PR description embeds — only delivery-unknown-dark/light.png (the bubble states) are linked; the delivery-strip-*.png captures exist in scripts/capture-user-message-delivery-unknown.mjs but were not attached. Embed the strip captures in the PR body.
  • The embedded bubble screenshots (delivery-unknown-dark/light.png) are committed to the fork branch, not the PR attachment store, so they were not materialized in this lane and I could not verify the rendered dimmed/dashed state.

[UX-REVIEWED] bf49dee

@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed bf49dee2d19e7c534170f755de6653e7370dc4a2 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] bf49dee

@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — 🟡 CONCERNS

Premise-level review of bf49dee2d19e7c534170f755de6653e7370dc4a2 via the fork AI-review pipeline — 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.

I have enough evidence to complete the review. Verifying my counts: the four rebuild sites (switchSlot, refreshSlot, warmSlotCache, resume) all appear in the chatSlice hunk; the five per-class preservation passes (pastes, thinking, permissions, queued bubbles, now optimistic sends) are all visible in the refetch reducers; the base pin at test_queue_drain_preserve_send_id.py:236-240 reads "no id leaks onto the broadcast" and the PR inverts it citing commit 16ec93b's own message, which I cannot verify without a shell.

First-Principles-Verdict: CONCERNS

A one-bubble fix carries three feature subsystems — persisted recovery store, delivery-warning strip, queue-edit failure protocol — plus a reversed pin I cannot verify.

Not justified as shipped

  1. Failure rows land in the sending slot — rides along: declared second defect, harm named.
  2. Delivery-warning strip + reload-surviving recovery store — rides along: ~578-line persisted subsystem (tab claims, heartbeats, bfcache) far exceeds the declared "marker is persisted" sentence.
  3. sendId on queue_push/slot-detail — rides along: reverses the base pin "no id leaks onto the broadcast" on quoted-but-unverified commit wording.
  4. Queue-edit edited/editId/editRev protocol — rides along: resolves Queue actions: shared optimistic-update rollback, pending latch, and three-host duplication (useQueuedMessageActions) #5891 item 1, not this bug; permanent wire surface guarding races inside machinery this same PR adds.
  5. Busy steer that starts a turn now gets a bubble — undeclared: absent from the readable 8KB of the description.
  6. "(GPT round N)" comment scrubs — undeclared.

What this change ships

Inventory (10 items) — 4 justified

Intent: keep a just-sent user message visible when a slot refetch rebuilds the transcript — a FIX.

  1. A sent message survives refetch at all four rebuild sites — justified
  2. An older refetch response can no longer overwrite a newer one (slotDetailSeq, one dispatch clock) — justified
  3. Spinner clears even when a refetch response is discarded — justified
  4. Send-failure rows land in the conversation they were typed into — rides along
  5. Unconfirmed sends get a warning strip, dimmed bubble, and reload-surviving recovery (13-locale copy) — rides along
  6. Cancel of a queued send restores text+attachments in tabs that missed the push — rides along
  7. Failed queue edits now report, reopen seeded, and roll back, via a new edit-identity wire protocol — rides along
  8. A busy steer that starts a new turn now shows its bubble — undeclared
  9. history.md documents the send-identity and delivery markers — justified
  10. "(GPT round N)" comment references removed — undeclared

Watch

  • Pin reversal (item 6): the new test text quotes 16ec93b's message ("Additive: … The queue_push broadcast is untouched") as license; I have no shell to check it. Clears when: a human confirms the quoted wording in that commit.
  • Item 7's edit_rev exists for races between channels this PR itself wires together (HTTP detail adoption vs WS echo); its defect provenance is Queue actions: shared optimistic-update rollback, pending latch, and three-host duplication (useQueuedMessageActions) #5891 item 1, which covers silent failure, not cross-client revision ordering. Clears when: a race is named that survives the detailSeq-gated adoption plus the ordered socket, or the ordering half is deferred.
  • The declared trade — a send that never left leaves a bubble no refetch clears — is one the description itself asks a human to ratify. Clears when: a maintainer ratifies it.
  • Root cause left standing: refetch reducers replace messages wholesale, so this is the fifth per-class rescue pass (pastes, thinking, permissions, queued, now sends) — counted in chatSlice.ts. Accepted-and-deferred. Clears when: noted as the known level of this fix.

Subtractions

  • Defer item 7 to its own PR: edited/edit_id/edit_rev on queue entries, the queue_edit echo fields, applyQueueEdit/rollbackQueueEdit/queueEditSettled, and the QueueStack banner — the bubble fix and the stash adoption stand without it if adoption simply refuses an edited entry.

[FIRST-PRINCIPLES-REVIEWED] bf49dee

@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — 🟡 CONCERNS

Design-level review of bf49dee2d19e7c534170f755de6653e7370dc4a2 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

I have a full picture of this change now: the core retention fix in chatSlice.ts, the backend sendId/edit-identity carry, the queue-edit revision protocol, the persisted recovery store (chatPaneRecovery.ts, queuedSendStash.ts), the delivery-unknown UI, and the rewritten queue_push pin from commit 16ec93beff. The retention design itself is sound and well-falsified by its tests; the design risks are scope and two explicitly-declared contract reversals.

Design-Verdict: CONCERNS

Sound retention design, but a core-path reducer rewrite bundled with three separable subsystems and two contract reversals that need explicit human ratification.

Watch

  • One PR rewrites all four transcript-rebuild sites AND lands a queue-edit revision protocol (server edit_rev + client rollback), a persisted composer-recovery store (~860 new util lines, its own localStorage budget), and the delivery-unknown UI. Any regression in one drags a revert of the transcript core with it, and the repo's own one-logical-change rule is exceeded by a wide margin — the bubble-retention fix plus the backend sendId carry would stand alone.
    Clears when: a maintainer explicitly accepts landing as one unit, or the queue-edit protocol, recovery store, and delivery UI split into follow-up PRs.
  • Two declared decisions ride on maintainer sign-off the PR itself requests: (a) a send that never left leaves a tab-lifetime captioned bubble no refetch clears (mitigated by dropUnconfirmedRow, but it is a product-behaviour trade); (b) queue_push now carries sendId, inverting the "sendId" not in payload assertion from 16ec93beff — the reinterpretation of that pin as shape-stability is argued well, but it is still the author overruling a pinned decision.
    Clears when: a human ratifies the never-left-bubble trade and the queue_push pin reversal in review.

Suggestions

  • Extract the four-flag delivery lifecycle owner (utils/sendDelivery.ts expansion) before the ~50 new tests fossilize the hand-choreography across ChatPage/ChatPane — the PR already names this follow-up; doing it after doubles the migration.

[DESIGN-REVIEWED] bf49dee

@github-actions

github-actions Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review (fork) — ✅ no blocking findings

Reviewed bf49dee2d19e7c534170f755de6653e7370dc4a2 via the fork AI-review pipeline; updated in place on each push.

Review details

The candidate's core premise is false. It claims delivery_unconfirmed was deleted from every catalog. The diff shows the opposite: every catalog entry for delivery_unconfirmed is a modification (-/+ pair that retains the key with a reworded value), e.g. en.manual.json line 2733→2734 keeps "delivery_unconfirmed": "Delivery unconfirmed — …". The PR adds sibling keys (_short, _resend, _dismiss_note) but never removes delivery_unconfirmed. So the untouched consumer at useSceneInteraction.tsx:386 still resolves its key normally — no raw-key fallback occurs. (a)/(c) fail. Candidate dropped.

No further grounded defect surfaced within the opened i18n hunks.

No findings.

[OPUS-REVIEWED] bf49dee

@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 Aug 29, 2026
@rnoack1
rnoack1 force-pushed the fix/preserve-optimistic-user-bubble-on-slot-refetch branch from 787e318 to 5bd4536 Compare August 29, 2026 19:35
@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 Aug 29, 2026
@rnoack1
rnoack1 force-pushed the fix/preserve-optimistic-user-bubble-on-slot-refetch branch from 5bd4536 to b75621c Compare August 29, 2026 20:11
@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 Aug 29, 2026
@rnoack1
rnoack1 force-pushed the fix/preserve-optimistic-user-bubble-on-slot-refetch branch from b75621c to 7970b0c Compare August 29, 2026 20:33
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Aug 29, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Open PR relationship audit

This is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion.

Relationship findings

  • PR #5909 is OVERLAPPING relative to this PR. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #5909: MERGE_DISCUSSION. A sequencing decision is needed, not a closure. 5909's own description names PR #6825 as the follow-up that must rebase its markSendFailed/delivery-unknown behavior onto this transport caller; the conflict is real and the two encode opposite abort-path policies. Files: website/src/components/ChatPane.tsx, website/src/test/ChatPane.dirSend.test.tsx.
  • This PR is OVERLAPPING with PR #4180. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #6825: MERGE_DISCUSSION. Reinstating a surface a merged PR deliberately removed needs an explicit human ratification, specifically for the 10s-abort trigger; the transport-failure trigger is defensible on its own terms. Files: website/src/pages/chat/UserMessage.tsx.
  • This PR is OVERLAPPING with PR #7255. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #6825: MERGE_DISCUSSION. A behaviour change and a wholesale relocation of the same ~200 lines. Sequencing this (fix first, refactor rebases) is far cheaper than the reverse, and should be agreed rather than discovered at merge time. Files: website/src/pages/ChatPage.tsx.
  • This PR is OVERLAPPING with PR #7911. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #6825: MERGE_DISCUSSION. Independent features on one line; no behavioural contradiction and no goal overlap. Files: website/src/pages/chat/UserMessage.tsx.
  • This PR is OVERLAPPING with PR #7916. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #6825: MERGE_DISCUSSION. Two open PRs rewrite the same switchSlot thunk for unrelated reasons and already conflict. Land order needs to be decided explicitly, and whoever rebases second must carry detailSeq onto BOTH of 7916's return paths. Files: website/src/store/chatSlice.ts, website/src/store/chatSlice.olderHistoryCursor.test.ts.
  • This PR is OVERLAPPING with PR #7997. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #6825: MERGE_DISCUSSION. Complementary halves of the same honesty principle on different flags; no code collision. Files: website/src/pages/chat/UserMessage.tsx.

No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit.

@bolichen97

Copy link
Copy Markdown
Contributor

@rnoack1 Thanks for this. The 2026-09-08 audit read this PR at c7feee4; the head has since moved to 6cc147b, but the files below are still in the diff, so the overlaps stand. Three open PRs touch the same code.

#8613 (@CrysisDeu) is the one to settle first, and it is a duplicate mechanism, not just a text conflict. Both PRs add a sendId-keyed pre-receipt send stash so a queue card cancelled before the HTTP receipt still restores its text. #8613 inserts inFlightSendStash / takeInFlightSend into the top of website/src/hooks/useQueuedMessageActions.ts, which is exactly the block this PR deletes and re-exports from the new website/src/utils/queuedSendStash.ts. Both also add sendId to the same queue_push payload in src/kiro_crew/dashboard/chat_delivery.py, the same hold branch in src/kiro_crew/dashboard/chat_handlers.py, and the same drain block in src/kiro_crew/dashboard/chat_runner.py. Yours is the more complete mechanism (adoption from queue_push and from slot-detail, refusal on an edited entry, typed sends carry their real payload) while #8613 matches by wire text and stores empty records for option sends only. #8613 sits on main; this PR is 35 behind. Please agree with @CrysisDeu that one stash survives, then rebase onto it.

#8599 (@CrysisDeu) shares website/src/components/ChatPane.tsx, website/src/pages/ChatPage.tsx and website/src/store/chatSlice.ts, and duplicates your sendDelivered/confirmsSend predicate as a local isOwnUserRow. Landing that shared predicate as its own small PR would let both rebase on it.

#9130 (@buluoray) reads the field this PR can leave null: a superseded switchSlot leaves slotCursorKey unset, and #9130's trigger-side gate refuses older-history paging on that condition. No textual conflict expected; whichever lands second should re-verify paging recovers.

Separately, please narrow this to the stated bug. Retaining the optimistic row across a refetch is a handful of rebuild sites in chatSlice.ts, not 75 files.

Posted from the 2026-09-08 open-PR relationship audit (read-only, one auditor per PR); reply here if any of this is wrong.

@iamwhatever

Copy link
Copy Markdown
Contributor

Not approving for now: the body itself declares an unresolved item — the retention trade (a send that never left leaves a bubble no refetch clears) is stated as "a declared product-behaviour trade a human should ratify" — so a maintainer ruling is still outstanding. Scope is also well beyond the stated root cause: 12k+ added lines over 94 files bundling a second defect (failure rows addressed to the sending slot), the slotLoading move, caption/confirmedSendId work, paging-cursor guards and a new shared dispatch clock. Please split it.

Position an unanchored send past the server-identified rows rather than by timestamp, so a client clock behind the server cannot seat a new prompt above the history it followed.
Hand the payload back on every page arm that ends without a receipt, the 10s abort included, since the bubble is store-only and a reload keeps neither it nor the draft cleared before the POST; name the unconfirmed state in one shared string, and retire it on edit history rather than value equality, re-checked whenever a restoration stages, so an echo that confirms before the abort cannot strand a delivered prompt where a resend duplicates the turn.
@bolichen97

Copy link
Copy Markdown
Contributor

Rebased onto main cff7de5416 by a maintainer to resolve merge conflicts. Old head bf49dee2d1, new head 0ab3923c37.

Conflicts resolved (only these files were hand-merged):

  • src/kiro_crew/dashboard/chat_delivery.py — kept main’s queue ledger and durable persistence; added the PR’s sendId to queue_push.
  • src/kiro_crew/dashboard/chat_handlers.py — kept durable hold-queue writes and receipts while carrying sendId in the hold broadcast.
  • src/kiro_crew/dashboard/chat_runner.py — retained both main’s stop-generation helper and the PR’s merged-send-ID helper.
  • src/kiro_crew/dashboard/chat_utils.py — retained main’s structured-content redaction/serialization helpers and the PR’s queue-detail identity helper.
  • website/src/components/ChatPane.tsx — integrated retained-send/recovery bookkeeping through main’s shared applySteerReceipt adapter; retained native question-card handling and main’s removal of PendingDecisionCard.
  • website/src/pages/ChatPage.tsx — retained the shared receipt adapter, isolated-app composer guards, remote-bound dependency and prefill-edit tracking together with the PR’s recovery/ref updates and captions.
  • website/src/pages/chat/UserMessage.tsx — combined delivery-doubt styling/caption with main’s server-timestamp-first content rendering.
  • website/src/store/chatSlice.ts — kept send-ID lookup while retaining main’s reconciliation of plain optimistic question-answer rows (not only steer-tagged rows).
  • website/src/test/ChatPane.dirSend.test.tsx — retained both sides’ imports, helpers and tests, including main’s native-question-card regression coverage.
  • website/src/i18n/locales/bn.json — kept both terminal-error and delivery/recovery keys; preserved the PR’s input-box terminology for the overlapping side-command string.
  • website/src/i18n/locales/de.json — kept both main’s terminal-error keys and the PR’s delivery/recovery keys.
  • website/src/i18n/locales/en-XA.json — kept both main’s terminal-error keys and the PR’s delivery/recovery keys.
  • website/src/i18n/locales/en.manual.json — kept both main’s terminal-error keys and the PR’s delivery/recovery keys.
  • website/src/i18n/locales/es.json — kept both main’s terminal-error keys and the PR’s delivery/recovery keys.
  • website/src/i18n/locales/fr.json — kept both main’s terminal-error keys and the PR’s delivery/recovery keys.
  • website/src/i18n/locales/hi.json — kept both terminal-error and delivery/recovery keys; preserved the PR’s input-box terminology for the overlapping side-command string.
  • website/src/i18n/locales/it.json — kept both main’s terminal-error keys and the PR’s delivery/recovery keys.
  • website/src/i18n/locales/ja.json — kept both main’s terminal-error keys and the PR’s delivery/recovery keys.
  • website/src/i18n/locales/ko.json — kept both main’s terminal-error keys and the PR’s delivery/recovery keys.
  • website/src/i18n/locales/pt.json — kept both main’s terminal-error keys and the PR’s delivery/recovery keys.
  • website/src/i18n/locales/ru.json — kept both main’s terminal-error keys and the PR’s delivery/recovery keys.
  • website/src/i18n/locales/zh-CN.json — kept both main’s terminal-error keys and the PR’s delivery/recovery keys.

Same single commit, same author, same message. File set remains exactly the original 94 files; no additions or omissions. Manual edits were confined to conflict regions; everything outside those regions is Git’s automatic rebase result, including upstream main changes.

Validation: frontend build passed; 279 frontend tests across the four directly relevant test files passed; 73 queue/steer backend tests passed. All changed Python files compiled, all changed JSON parsed, all 13 conflicted locale JSON files passed duplicate-key validation, and diff whitespace/conflict-marker checks passed. No full test suite was run.

Any prior approval dismissed by the push needs to be re-given after CI re-runs.

Copy link
Copy Markdown
Contributor

PR triage (2026-10-05): OVERLAPPING with merged #14699, needs a REBASE onto #14665

This audit read the full diff at head 0ab3923c37 (merge base cff7de5416) and compared it with origin/main af1eb612da. Main is now 2284 commits ahead, and git merge-tree shows conflicts in 29 files.

Still not fixed on main. The bug itself is still there. website/src/store/chat/slotSwitch.ts:554 on main still falls through to next = preserved. Neither it nor slotRefresh.ts keeps a trailing optimistic user row. This PR is not superseded and should stay open.

What changed on main since the last rebase:

  • refactor(website): split chatSlice into composed store/chat owners #14665 (merged) split chatSlice.ts into website/src/store/chat/*. Every switchSlot/refreshSlot/warm-reconcile hunk in this PR targets code that now lives in slotSwitch.ts / slotRefresh.ts. This is a re-port, not a textual rebase.
  • fix(chat): keep an unconfirmed send pending instead of offering Resume #14699 (merged) added meta.deliveryUnconfirmed, markSendUnconfirmed (store/chat/messages.ts:197-215) and a "Delivery pending..." line in UserMessage. Both are cleared on receipt or echo. This PR adds a parallel meta.deliveryUnknown / markDeliveryUnknown and its own caption for the same state. Main covers only that sub-part, and only for the response-late arm. Please converge on a single marker instead of shipping two.
  • queuedSendStash is still a Map in hooks/useQueuedMessageActions.ts:43 on main. The move to utils/queuedSendStash.ts has to be redone against the current callers in ChatPane.tsx:1206,1313 and ChatPage.tsx:2412.

Related open PR: #10786 (recall a prompt whose send never landed) targets the same symptom through prompt recall. It complements this PR and does not duplicate it.

No breaking change or P0 found. The backend additions are additive: sendId on queue_push, queue_entry_for_detail, and editId/editRev on queue_edit. They are omitted when absent, and only sendId is projected out of the queue meta.

Recommendation: REBASE onto current main and port the reducer changes into store/chat/slotSwitch.ts and slotRefresh.ts. Fold the delivery marker into #14699's deliveryUnconfirmed. Also, as the 2026-09-13 review asked, split the persisted recovery store, the delivery-warning strip and the queue-edit revision protocol into their own PRs.

@iamwhatever

Copy link
Copy Markdown
Contributor

Thanks a lot for this work, @rnoack1. The bug this PR fixes, a slot refetch dropping the just-sent user bubble, is now fixed on main: #18658 and #25630 keep live user sends (by sendId) across both switchSlot and refreshSlot in website/src/store/chat/slotSwitch.ts and slotRefresh.ts, and #14699 added the unconfirmed-delivery marker. Since the branch also targets the old chatSlice.ts that #14665 split up, I'm closing this as superseded. If any part (for example the backend queue sendId handling) is still missing on main, please open a small focused PR for it. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants