Skip to content

fix(transcript): keep a delivered prompt above the reply it triggers - #1415

Merged
pascalandr merged 8 commits into
NeuralNomadsAI:devfrom
heunghingwan:fix/inbox-delivered-stuck
Nov 9, 2026
Merged

pascalandr merged 8 commits into
NeuralNomadsAI:devfrom
heunghingwan:fix/inbox-delivered-stuck

Conversation

@heunghingwan

Copy link
Copy Markdown
Contributor

Problem

With two clients open on the same session, sending a prompt from one left the other client showing that message stuck at the very bottom of the transcript, below the streaming reply, for the rest of the run.

Root cause

OpenCode V2 has no message.updated: a prompt sent by another client reaches every client through session.inbox.enqueued (which materializes the user row and parks it in the session inbox), and session.inbox.delivered clears it. The SDK reducer's delivery handler answers by moving the prompt's row to the tail of its message list.

When the reply's assistant row was appended between the prompt's enqueue and its admission — a real window, confirmed by recording a live service's event stream (enqueued → execution.started → …engine startup… → delivered → step.started) — that tail-move sinks the prompt below its own reply, and every subsequent live projection carries the wrong order until an authoritative read replaces the reducer. The service's own message page orders the pair correctly ([user, assistant]); the demotion is purely client-side.

Fix

stores/opencode-data.ts records, at session.inbox.delivered admission, the reducer row that followed the prompt's row at that moment (per-transcript deliveredPromptAnchors). Every live projection restores each delivered prompt directly above its recorded row — matching the native page order — and consumes the record once both rows hold that order or either is gone. Anchors live on the transcript entry, so an authoritative resync (which replaces the reducer) drops them naturally.

Parked prompts and queued-delivery flows are unchanged: for the still-parked case the transcript already re-appends pending prompts for display, so the projected order change is invisible there.

Validation

  • New browser test tests/browser/inbox-delivery-order.test.ts through the real SessionView and native event dispatcher, covering both the faithful admission order and admission landing after the reply started streaming (the repro — fails on dev, passes with the fix), plus fixture helpers reproducing the daemon's real event choreography.
  • 253 focused store tests (re-verified 139 after rebase onto origin/dev), UI typecheck, and the 48-test session-rendering browser suite all green.
  • dev-docs/TRANSCRIPT.md ordering convention updated.

@pascalandr pascalandr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heunghingwan I reviewed 038e783aa. The SDK does move an admitted prompt to the tail on delivery, but the row following an enqueued prompt does not establish its native delivery order. Four P2 findings block this approach; the ordinary-order reproductions pass on the base and regress on this head.

P2: the captured follower can reverse native message order

packages/ui/src/stores/opencode-data.ts:344-348,354-364

Two prompts enqueued as steers and delivered before their reply produce native/reducer order [Q1,Q2,reply], but this projection produces [Q2,Q1,reply]. This reproduces both with synchronous projection and frame coalescing, including the real browser. A private native 2.2.6 run also confirmed the three-steer version: its authoritative page held [Q1,Q2,Q3,assistant], while replaying its actual events through this head displayed users [Q3,Q1,Q2].

Another case: enqueue Q during an existing turn, start its next assistant step A2, then deliver Q. The native/reducer order is [A1,A2,Q]; the projection changes it to [A1,Q,A2]. A shell, compaction or interrupted/idle follower can likewise be earlier work rather than Q's reply.

Please restore only relationships established by authoritative native order; otherwise reconcile the message page on delivery, coalescing requests. Raw enqueue position cannot identify the reply. Message IDs/timestamps are not a replacement ordering authority either: #1294 deliberately preserves incoming native page order.

P2: authoritative reducer replacement retains obsolete anchors

packages/ui/src/stores/opencode-data.ts:79,327-331

The map belongs to TranscriptEntry, but replaceTranscriptEntry replaces only its DataEntry. A pruning resync that returns authoritative [previous-step,Q] is immediately projected as [Q,previous-step] by an anchor left from the old reducer.

Please drop obsolete ordering state when accepting an authoritative replacement. Clearing the map at that boundary makes the independent reproduction pass.

P2: verified reconnect loses the correction but keeps the corrupted reducer order

packages/ui/src/stores/opencode-data.ts:319,436-464

  1. Establish the late-admission case covered by the PR: reducer [reply,user], display [user,reply].
  2. Admit a same-daemon server.connected.
  3. Continue streaming.

Reconnect captures raw reducer rows, destroys the anchors and seeds [reply,user] again. The next projection sinks the prompt below its reply. Continuous streaming postpones the quiet authoritative reconciliation.

Please preserve corrected order across verified continuity seeding, for example by capturing a corrected row-list clone. Authoritative replacement should still discard obsolete corrections.

P2: the new browser file fails the fixture-wiring gate

packages/ui/tests/browser/inbox-delivery-order.test.ts:18

It starts its own Vite server without borrowing the shared fixture or registering an exemption. fixture-wiring.test.ts fails locally, and the same PR-caused failure is present in browser shard 1 of run 42578736671.

Please use borrowFixture; an owned server instead needs a justified exemption and heavy-tier registration.

P3: the fixture immediately closes its EventSource response

packages/ui/tests/browser/inbox-delivery-order.test.ts:48

An empty text/event-stream response ends immediately, causing EOF/reconnect rather than a persistent fixture stream. Please use fixtureEventStream and keep console/network error collection strict.

Validation

UI typecheck and 377 focused store tests across 33 files pass twice. The new browser file passes three runs; streaming projection, tool images, compaction responsiveness, focused history/scroll cases and session rendering also pass. Independent ordering/lifetime probes expose the regressions despite those green suites.

The new browser test catches disabling restoration or capturing after delivery, but still passes when anchor consumption is removed or authoritative-replacement cleanup is added: multiple deliveries, replacement and reconnect need explicit regressions.

The Ubuntu WebKit failure is separate: AppImage bundling received HTTP 504 downloading AppRun-x86_64 from GitHub. That does not explain the fixture-wiring failure above. Merge checks against current dev and #1414 were clean.

@heunghingwan

Copy link
Copy Markdown
Contributor Author

@pascalandr Thank you for the thorough review — all four P2s and the P3 are addressed in 8af56a7.

P2 (order restored only from authoritative native order): the per-transcript anchor map is gone entirely. A session.inbox.delivered that relocates a row which is not the reducer's last now owes an authoritative read: the message key is invalidated and the read finishes exactly like a settlement read — shared with any in-flight one through the SDK's key-coalescing, published under the same newer-execution fence. The native page owns the delivered prompt's position in every shape you probed: the two- and three-steer bursts reconcile to [Q1,Q2,Q3,assistant] (parked prompts ride the SDK's own admitted-row rescue until their own delivery), and a mid-stream admission settles after the earlier reply per the page. The ordinary idle-session delivery stays at the tail and triggers no read.

P2 (obsolete anchors across replacement) and P2 (reconnect losing the correction): both dissolve with the state removal — the read heals the reducer itself, so replaceTranscriptEntry has nothing stale to retain and reconnect continuity seeding captures the corrected rows. Covered by new store regressions: the pruning-shaped replacement (invalidateOpenCodeSessionContent) and a verified same-daemon server.connected whose quiet resync reads the page again (opencode-data-reconnect.test.ts).

P2 (fixture wiring) and P3: the browser file now borrows the shared fixture, launches through borrowFixture, keeps a persistent fixtureEventStream, and passes fixture-wiring.test.ts. It drives the daemon's real event order (parked burst, mid-stream admission, idle prompt) with a stored-from-first-step reply row so mid-stream reads serve it, plus DOM-order assertions. That was indeed the shard 1 failure in run 42578736671.

Validation: 235 focused store tests, UI typecheck, the wiring gate, the three borrowed-fixture runs and the 48-test session-rendering suite.

One honest note: your probes confirm the base already renders the daemon's ordinary delivery orders correctly, so the original two-terminal report this PR started from likely has a different mechanism — my best candidate from reading the server relay is InstanceEventBridge.publishEvent silently dropping a session event whose location cannot be resolved (no resync pulse on that path), which would strand a delivered prompt in the inbox on the watching client. I have not reproduced that yet; happy to open a separate investigation if you agree it is worth one.

@pascalandr pascalandr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heunghingwan I re-reviewed 8af56a77. Moving the authority to the native page fixes the ordering findings: two/three steers (including the replay of recorded native 2.2.6 events), and prior assistant, shell, compaction and idle followers all keep native order before and after the read. Authoritative replacement passes, the fixture now borrows the shared server with a persistent event stream, and tail-only delivery issues zero reads. Three lifetime/gating issues around the asynchronous repair remain; each reproduces on this head.

P2: the repair's completion bypasses the display-window gates

packages/ui/src/stores/opencode-data.ts:349-351, publishing at :1010

  1. Keep a reducer with parked q1,q2 while the session displays a history window containing only history.
  2. Deliver q1 and hold its read; then resolve it.

The live dispatcher correctly leaves the history window alone, but the completion calls projectOpenCodeMessages directly and turns that window's membership into [history,q1,q2] while keeping its history cursors. The same happens after switching to another session.

Please publish through the existing gated projection path (active-session/latest-window gates), as live events do. A scratch change routing it through the scheduler passes both gate probes.

P2: normal settlement retires the reducer under an outstanding repair

packages/ui/src/stores/opencode-data.ts:947-960

  1. An interrupted-turn read returns [old,idle,user,reply] before the delivery SSE arrives (a genuine HTTP-ahead crossing).
  2. Delivery moves user below reply and starts the repair read.
  3. Hold that read; admit step.ended and execution.succeeded.
  4. Resolve the read.

With nothing pending in the inbox and no unsettled rows, retireDrainedTranscript destroys the reducer before the read completes, so the display stays [old,reply,user]. This fails standalone and with #1414 merged.

Please treat the owed read as a retirement barrier. Checking #1414's entry-scoped pending read in the retirement guard makes this probe pass.

P2: verified reconnect abandons a pending repair behind the quiet timer

packages/ui/src/stores/opencode-data.ts:417-450, opencode-reconnect.ts:49-76

  1. Hold a delivery repair while reducer/display order is [reply,user].
  2. Admit a verified same-daemon server.connected.
  3. Keep streaming deltas every 500 ms; complete the abandoned old read.

After five simulated seconds no replacement read has started and the order is still [reply,user]: continued activity keeps postponing the quiet reconciliation.

Please carry the outstanding repair demand across verified reconnect and resume it after seeding instead of relying only on the quiet timer.

P3: the browser fixture only collects page exceptions

packages/ui/tests/browser/inbox-delivery-order.test.ts:36

Please also fail on request failures, HTTP errors and console errors, as the neighboring fixtures do.

Scope and test coverage

The genuine bug this fixes is the HTTP-ahead crossing above: base sinks the delivered user below a reply already received over HTTP, and this head repairs it while the reducer lives. The three authored browser tests and the burst store test also pass on base and with delivery reconciliation disabled, so they do not protect that fix. Only the reconnect store test fails on base, and it forces the page/event relationship. Please add a regression for the natural crossing (an interrupted-turn or settlement read carrying the newer delivered user and reply before their SSE), plus the settlement-during-repair and reconnect-during-repair lifetimes.

I agree the original two-terminal report is not demonstrated by this PR. The unresolved-location relay drop is worth a separate investigation with a reproduction.

#1414 interaction

Merging with the approved #1414 head (08699226) gives two textual conflicts around the post-emission hooks. Resolved in scratch, both reconciliations work, and #1414's promise-following fixes this helper publishing read A while a queued read B is outstanding. It does not fix the three P2s above. Rebasing after #1414 lands, on its completeSettlementRead, is probably the simplest path.

Validation

UI typecheck passes standalone and combined with #1414. Focused units pass 378/378 twice standalone and 384/384 twice combined. The delivery browser file passes three runs; fixture wiring, streaming projection, tool images, compaction responsiveness and session rendering (48/48) pass. Two/three-steer bursts coalesce to two reads; 100 deltas during a held repair keep their text with no extra reads; full-window queued replay reconciliation passes.

The current CI run is still waiting at authorize, so it has no results for this head yet.

@heunghingwan

Copy link
Copy Markdown
Contributor Author

@pascalandr All three P2 lifetimes and the P3 are addressed in 5cd1a05.

Gated publication: the repair's completion now publishes through scheduleTranscriptProjection — the same active-session/latest-window frame gates live events pass through — instead of calling projectOpenCodeMessages directly. A context without registered gates (unit tests) keeps the direct projection, so both of your gate probes hold: a repair landing on a history window or another session no longer touches that window's membership.

Retirement barrier: an outstanding repair read now blocks retireDrainedTranscript beside parked prompts and unsettled rows, so the settlement-during-repair probe keeps the reducer alive as the publication owner and the resolved read heals the display.

Reconnect carry-over: the reconnect capture records the outstanding demand (deliveryRepairOwed), the recreated transcript carries it, and the moment the seeded page lands the repair resumes against the new entry — no waiting on the quiet timer, so continued streaming can no longer strand the unreconciled order. The abandoned old read stays fenced by owner identity.

Coverage: the natural HTTP-ahead crossing now has the regression you asked for — an interrupted round's held settlement read returns the page with the delivered prompt above its reply, the delivery's own SSE then lands late (opencode-data-settlement.test.ts); it fails on the base with the prompt sunk below the reply, and also covers settlement-during-repair. opencode-data-reconnect.test.ts gains the reconnect-during-repair lifetime (held repair, verified server.connected, continued deltas, resumed read heals). The browser fixture now fails on request failures, HTTP errors and console errors (the stricter collection immediately caught an unstubbed Yolo read, now fulfilled like the neighboring fixtures).

I'll rebase onto #1414's completeSettlementRead once it lands, as suggested — the changes here keep the helper's call shape compatible to make that a textual merge.

@pascalandr pascalandr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heunghingwan I re-reviewed 5cd1a058. The history-window and inactive-session gates hold (an inactive refusal also invalidates the loaded flag), the held repair now survives settlement, and reconnect resumes the repair during continuous streaming. The new HTTP-ahead regression fails on base with a feasible page/SSE crossing. One lifetime issue remains in the new retirement barrier.

P2: a completed repair leaves the settled reducer resident

packages/ui/src/stores/opencode-data.ts:362-363, :974-975, :1049

  1. Hold the delivery repair.
  2. Admit the round's settlement.
  3. Complete, reject or abort the repair.
  4. Deliver no further native event.

completeSettlementRead calls retireDrainedTranscript at :1049 while deliveryRepairPending is still above zero, so retirement refuses. The caller's finally at :363 then decrements the counter but never retries retirement. In all three outcomes the reducer stays resident with its rows (five in the probe) instead of retiring; with an animation frame held, the retirement flush never happens either.

Please retry retireDrainedTranscript right after decrementing, in the same finally; its current-transcript guard already protects abandoned scopes. With that one addition, the combined probe set (with #1414 merged) goes from 25/29 to 29/29.

P3: the receipts-abort exclusion hides unrelated failures

packages/ui/tests/browser/inbox-delivery-order.test.ts:38-40

Any /permission-receipts request failing with net::ERR_ABORTED is ignored without correlating it to an owned cancellation; a probe that issued and aborted an unrelated receipts request went unrecorded. Please remove the exclusion or match the exact owned cancellation, as neighboring fixtures do.

P3: no authored test protects the publication gates

Reversing gated publication fails both independent gate probes, but the authored delivery/reconnect tests all still pass. Please add history-window and inactive-session completion regressions.

Checked

Session deletion, instance removal and eviction during a repair or during reconnect seeding; different-daemon and unattributed reconnects (no carried repair); authoritative replacement with the preceding read held; tail-only delivery (zero reads); two/three-steer bursts (two coalesced reads); 100 deltas during a held repair (no extra reads, no lost text). Independently reversing the retirement barrier or the reconnect resumption fails both the independent probe and the authored test.

With #1414 (08699226) merged in scratch, conflicts resolve by keeping the gated options and the returned Promise used by the repair counter. Combined units and typecheck pass; #1414 does not fix the retirement issue above.

Validation

UI typecheck passes standalone and combined. Focused units pass 380/380 twice standalone and 386/386 twice combined. The delivery browser file passes three runs; fixture wiring, streaming projection, tool images, compaction responsiveness and session rendering (48/48) pass. Merge with current dev is clean. The CI run for this head was still waiting at authorize when inspected.

@heunghingwan

Copy link
Copy Markdown
Contributor Author

@pascalandr Both remaining items are addressed in c0412d1.

Retirement retry: the repair counter's finally now retries retireDrainedTranscript immediately after decrementing, so a settled round's reducer retires when the repair completes, rejects or aborts with no further event; abandoned scopes stay behind the current-transcript guard.

Gate regressions: two authored cases in opencode-data-settlement.test.ts — a repair completing over a history window leaves that window's membership and cursors untouched, and a repair completing for an inactive session leaves its display to the next activation read.

Receipts exclusion: removed; the strict collection passes the delivery browser file across repeated runs without it.

Validation: 253 focused store tests, UI typecheck, delivery browser file twice with strict request/HTTP/console error collection.

@pascalandr pascalandr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heunghingwan I re-reviewed c0412d1f. The retirement retry fixes the resident reducer: complete, reject and abort all retire without another event, and the active-session retirement frame flushes. The receipts exclusion is gone (an injected foreign abort is now caught), and reversing the publication gates kills both new gate tests. One interaction of the retry with the frame gates remains.

P2: the retirement retry publishes an inactive session's repair

packages/ui/src/stores/opencode-data.ts:369,986, with opencode-projection-frame.ts:112,178-181

  1. Hold a delivery repair while an animation frame is pending.
  2. Settle its execution.
  3. Switch to another session.
  4. Resolve the repair.

The repair correctly schedules a gated frame, but the retry then reaches retireDrainedTranscript, whose flushTranscriptProjections(instanceId, sessionId) drains with bypassActiveGate = true. The inactive session's display is rewritten instead of invalidated ([old,idle,reply,user,idle] becomes [old,idle,user,reply,idle]) and it stays marked loaded, so its next activation can skip the authoritative read. Reproduced standalone and with #1414 merged.

Please let the retirement flush respect the active-session gate (invalidating an inactive session as a normal frame does) while keeping the selection-change flush unchanged. A scratch version doing that passes the full 33-probe set and 388 combined units, including active-session retirement flushing.

P3: no authored test covers retirement after the repair

Removing the new retry leaves the five selected authored tests green, while independent complete/reject/abort and held-frame probes all fail. Please assert that the settled reducer retired after the repair completes, not only the displayed order.

Checked

Another outstanding or coalesced repair blocks early retirement; a newer execution keeps its reducer; repeated retirement checks are harmless; rotation and queued settlement release correctly; deleted, removed, evicted and abandoned reconnect scopes stay fenced; different-daemon and unattributed reconnects carry nothing; an ordinary inactive completion invalidates the loaded flag.

Validation

UI typecheck passes standalone and combined with #1414. Focused units pass 382/382 twice standalone and 388/388 twice combined. The delivery browser file passes three runs with the strict collector; fixture wiring, streaming projection, tool images, compaction responsiveness and session rendering (48/48) pass. Merge with current dev is clean. The CI run for this head had just started (no failures yet) when inspected.

@heunghingwan

Copy link
Copy Markdown
Contributor Author

@pascalandr Both items are addressed in 87c035a.

Scoped flush behind the gate: flushTranscriptProjections(instanceId, sessionId) now drains with the active-session gate, so a repair settling for an inactive session invalidates its loaded page for the next activation read instead of rewriting its display; the unscoped selection-change flush still bypasses, as before. Active-session retirement flushing is unchanged.

Retirement assertion: the HTTP-ahead regression now also asserts the settled reducer retired once the repair settled — the probe event lands on a fresh reducer holding only its own row.

Receipts aborts: the exclusion is now an exact owned-cancellation match: an aborted receipts read is tolerated only when a later read for the same message superseded it (the cache's own join-and-abort); any other abort still fails the test.

Validation: 253 focused store tests, UI typecheck, the delivery browser file twice with the strict collector.

@pascalandr pascalandr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heunghingwan I re-reviewed 87c035a9. The projection side is done: an inactive session's retirement now invalidates its loaded page instead of rewriting it, and removing the retirement retry now fails your HTTP-ahead regression. I also audited every flushTranscriptProjections caller for #1289's selection-flush contract: selection writes (session-state.ts:708) and the visibility listener stay unscoped, retirement is the only session-scoped caller, and nothing uses the instance-only form; the frame suite's switch-flush test and the hidden/visible probes still pass. One test-reliability issue blocks.

P2: the receipts-cancellation matcher flakes and accepts foreign aborts

packages/ui/tests/browser/inbox-delivery-order.test.ts:41-55,73-75

  • In my three runs, run 2 failed "a steer burst delivered while parked keeps the native page order" with permission-receipts?messageId=msg_b3 net::ERR_ABORTED, while the transcript order was correct. The abort is numbered when it fails (:54), not when its request was issued, so a successor sent between the original request and its failure is not counted as later.
  • An injected foreign abort was silently accepted when an unrelated later request in another workspace reused the same messageId. A messageId plus any later request does not establish ownership; the receipts cache also cancels when its last subscriber releases, without a successor.

Please correlate the exact request with its owning AbortSignal (the pattern in panel-read-fixture.ts), or stub the receipts read so the fixture never cancels it, keeping foreign and unclassified failures strict. Flaking in CI would mask real failures in this suite.

Validation

UI typecheck passes standalone and combined with #1414. Focused units pass 382/382 twice standalone and 388/388 twice combined; the projection-frame file passes 14/14. The full probe set passes 35/35 with #1414 merged (34/35 standalone, the remaining one being the A/B publication timing #1414 fixes). Independently restoring the scoped bypass fails the inactive-retirement probe; removing the retry fails the authored regression and all independent retirement probes. Fixture wiring, streaming projection, tool images, compaction responsiveness, session rendering (48/48) and history window-switch cases (8/8) pass. Merge with current dev is clean; #1414 still needs the helper/test conflict resolution. The CI run for this head was still waiting at authorize when inspected.

@heunghingwan

Copy link
Copy Markdown
Contributor Author

@pascalandr Addressed in c612d06: the receipts matcher now correlates the exact request with its own AbortSignal, following the panel-read pattern. The fixture tags each receipts read's fetch with a per-read header and records whether its own signal fired (signal.aborted + AbortError); the test tolerates precisely an abort whose tagged request the cache owned — a last-subscriber release with no successor classifies correctly — and every foreign or unclassified failure remains an error, with the checks awaited before the assertion.

Validation: the delivery browser file passes three consecutive runs with the strict collector; session rendering (48/48) and UI typecheck unchanged.

A client watching a session that another client prompted showed the
sent message hanging at the very bottom, below the streaming reply:
with two pages open, the prompt arrived through session.inbox.enqueued,
the reply's assistant row was appended while the prompt was still parked,
and session.inbox.delivered then answered by moving the prompt's row to
the reducer's tail — below its own reply. Every later live projection
carried that order, so the message stayed sunk until an authoritative
read replaced the reducer.

Record, at delivered admission, the reducer row that followed the
prompt's row; live projections restore each delivered prompt directly
above that row, which matches the native page order (verified against
the running service's message list). The record lives on the transcript
entry and is consumed once both rows hold that order or either is gone;
parked prompts and queued deliveries render exactly as before.

Validation: a new browser test through the real SessionView and native
dispatcher covers both the faithful admission order and admission after
the reply started streaming (failed on dev, passes now); 253 focused
store tests, UI typecheck and the session-rendering browser suite stay
green.
Review of 038e783 (thanks @pascalandr): the recorded follower of an
enqueued prompt does not establish its native delivery order — with two
steers the restored pair reversed the page order, an authoritative
replacement kept projecting an obsolete anchor, and a verified reconnect
re-seeded the corrupted order the correction no longer covered. The new
browser file also spun its own Vite server, failing the fixture-wiring
gate in shard 1.

The native message page owns a delivered prompt's position. A delivery
that relocates a row which is not the reducer's last (the SDK's tail
move) now owes an authoritative read: the message key is invalidated and
the read finishes exactly like a settlement read — shared with any
in-flight one, published under the same newer-execution fence. No
ordering state survives the delivery; the reducer itself is healed, so
reconnect seeding and authoritative replacement carry the corrected
order. The ordinary idle-session delivery stays at the tail and reads
nothing.

The browser test now borrows the shared fixture, keeps a persistent
fixture event stream, and drives the daemon's real event order: a parked
steer burst reconciles to [Q1,Q2,Q3,reply], a mid-stream admission
settles after the earlier reply per the page, and an idle prompt renders
above its reply. Store regressions cover the burst, the pruning-shaped
replacement and a verified reconnect.

Validation: 235 focused store tests, UI typecheck, the fixture-wiring
gate, the three borrowed-fixture runs and the 48-test session-rendering
suite all pass.
…-over of a live read

Review of 8af56a7 (thanks @pascalandr): the delivery repair's
completion published directly, ignoring the active-session and
latest-window gates live projections pass through, so a repair landing
on a history window rewrote that window's membership; a drained
settlement destroyed the reducer beneath an outstanding repair, leaving
the sunk prompt unreconciled; and a verified reconnect abandoned a
pending repair behind the quiet timer, which continued streaming kept
postponing.

The repair now publishes through the instance layer's frame gates (a
gate-free context keeps the direct projection), its outstanding read is
a retirement barrier beside parked prompts and unsettled rows, and
reconnect carries the demand: the capture records it, the seeded page
resuming it immediately after it lands. The natural HTTP-ahead crossing
— a settlement read returning the delivered prompt above its reply
before the delivery's own SSE arrives — now has a regression that fails
on the base (the late delivery sinks the prompt below the reply), plus
settlement-during-repair and reconnect-during-repair lifetime
regressions, and the browser fixture fails on request, HTTP and console
errors like its neighbors.

Validation: 211 focused store tests, UI typecheck, the fixture-wiring
gate, the three borrowed-fixture runs with strict error collection.
…ttles

Review of 5cd1a05 (thanks @pascalandr): the repair counter's decrement
ran after the read's own publication pass, whose retirement check still
saw the barrier — so a reducer whose round had settled stayed resident
with its rows after the repair completed, rejected or aborted, and no
later event existed to retry the retirement.

The counter's finally now retries retireDrainedTranscript right after
decrementing; abandoned scopes stay protected by the current-transcript
guard. The receipts-abort exclusion in the browser fixture is gone (the
strict collection passes without it), and the publication gates gain
authored regressions: a repair completing over a history window keeps
that window's membership and cursors, and a repair completing for an
inactive session leaves its display to the next activation read.

Validation: 253 focused store tests, UI typecheck, the delivery browser
file twice with strict request/HTTP/console error collection.
…gate

Review of c0412d1 (thanks @pascalandr): the retirement retry's scoped
flush drained with the active gate bypassed, so a repair settling for an
inactive session rewrote its display and left it marked loaded — the
next activation could then skip the authoritative read.

A scoped flushTranscriptProjections now keeps the gate: an inactive
session's pending page is invalidated for its next activation read
exactly as a normal frame does, while the unscoped selection-change
flush still lands pages admitted under the previous selection. The
HTTP-ahead regression now also asserts the settled reducer retired once
the repair settled (the next event lands on a fresh one), and the
browser fixture correlates receipts aborts to the cache's own
supersession — an abort with no successor read for the same message
still fails the test.

Validation: 253 focused store tests, UI typecheck, the delivery browser
file twice with strict error collection.
Review of 87c035a (thanks @pascalandr): the successor-read heuristic
both flaked (an abort is numbered when it fails, so a successor issued
between request and failure was missed) and accepted a foreign abort
whose messageId an unrelated later request reused — and the cache also
cancels on last-subscriber release, with no successor at all.

The fixture now tags each receipts read's fetch with a per-read header
and records whether its own AbortSignal fired (the panel-read pattern);
the test tolerates exactly an abort whose tagged request the cache's
signal owned, and every foreign or unclassified failure stays an error.

Validation: the delivery browser file passes three consecutive runs with
the strict collector; session rendering (48) and UI typecheck unchanged.
Rebase onto NeuralNomadsAI#1414 (9f00cff) surfaced an ordering hazard in the merged
completeSettlementRead: the SDK read promise settles one microtask hop
before the publishing chain (which passes through .catch), so a caller
holding obligations on the returned promise — the delivery repair's
counter decrement and retirement retry — ran its retirement before the
chain published, destroying the reducer and fencing out the repair's
publication.

completeSettlementRead now records and returns the publishing chain
itself; the shared in-flight path returns the recorded chain, and
replaceTranscriptEntry releases it with the other read state.

Validation: 259 focused store tests on the rebased tree, UI typecheck,
the delivery browser file and the fixture-wiring gate.
@heunghingwan
heunghingwan force-pushed the fix/inbox-delivered-stuck branch from c612d06 to b24e23b Compare November 9, 2026 15:47
@heunghingwan

Copy link
Copy Markdown
Contributor Author

@pascalandr Rebased onto #1414 (9f00cffb) and pushed as b24e23b — conflicts resolved by keeping the gated publication option and extending the helper to return the publishing chain, as you suggested.

The merge surfaced one ordering hazard worth noting: #1414's publishing chain passes through .catch, so the SDK read promise settles one microtask before the chain; the repair counter's finally on the returned promise then ran its retirement retry before the chain published, destroying the reducer and fencing out the repair. completeSettlementRead now records and returns the publishing chain itself (settlementReadChain, released by replaceTranscriptEntry with the other read state), so obligation holders settle with the publication. All authored regressions — the HTTP-ahead crossing (including its retirement assertion), both gate cases, both reconnect lifetimes — pass on the rebased tree, alongside 259 focused store tests, UI typecheck, the delivery browser file and the wiring gate.

…ad publishes

A delivery repair settles its counter when the read chain it started ends.
When a later settlement (an execution terminal event, or an observed
settlement followed by one) invalidates beneath that read, the SDK starts a
trailing read that owns the publication; the repair's chain then ends early
and its retirement retry destroyed the reducer before the trailing read
published. A tool whose terminal event was missed stayed visibly running even
though the authoritative page had it completed.

Retirement now also waits while a reconciliation read is pending for the
current reducer; that read's own completion retries retirement after it
publishes.

The browser fixture's receipts-cancellation check also handles a
verification that cannot complete (page closed or navigated) by keeping the
original failure instead of rejecting unhandled.

Test: a queued delivery repair superseded by the round's settlement read keeps
the reducer until the trailing read publishes the completed tool; removing the
retirement guard fails it.
@heunghingwan

Copy link
Copy Markdown
Contributor Author

@pascalandr Thanks for the direct fixup (32d0308) — fast-forwarded locally and verified: the settlement/reconnect/data suites (59), the delivery browser file with the hardened receipts check, and the HTTP-ahead crossing regression all pass on that head. The trailing-read retirement barrier reads right to me: the superseding read owns the publication, so the reducer owes it residency.

@pascalandr

Copy link
Copy Markdown
Contributor

thanks @heunghingwan !!

@pascalandr
pascalandr merged commit 9e2e2a6 into NeuralNomadsAI:dev Nov 9, 2026
19 checks passed
@heunghingwan
heunghingwan deleted the fix/inbox-delivered-stuck branch November 9, 2026 16:37
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