Skip to content

fix(chat): never bounce a typed follow-up on a slow complete-history read - #4958

Merged
reachjalil merged 1 commit into
devfrom
fix/thread-restart-resume
Sep 13, 2026
Merged

reachjalil merged 1 commit into
devfrom
fix/thread-restart-resume

Conversation

@reachjalil

Copy link
Copy Markdown
Member

Summary

After restarting OpenWork, reopening a thread whose turn was still working and typing the next message could show it as pending and then hand the text back to the composer with a failure.

Since #4838 every send awaited the uncapped complete-history read so a follow-up could tell whether it must interrupt a delegated task. On a cold engine after a restart, a long thread's complete history can outlast the renderer's 10 s request timeout (four attempts), and that failed read failed the send itself — the message was pulled from the transcript and returned to the composer. A second defect hid the cause: unwrapSessionResult dereferenced result.response.status when the SDK settles a thrown fetch with response: undefined, so the banner read Cannot read properties of undefined (reading 'status') instead of Request timed out..

  • session-history.tsx: new readSendHistory() — cached complete history when the thread has it, otherwise one bounded newest read (24 messages, which always holds the current turn's running delegation). A send never waits on the uncapped read. ensureFullSnapshot() stays for branching.
  • session-surface.tsx: sendDraft uses it in place of ensureFullSnapshot().
  • opencode-session-native.ts: a transport failure keeps its own message when the SDK settles without a response.

Proof

Verdict: Passed at 9f61bd25f, local lane.

  • pnpm evals:e2e thread-continues-after-restart --local → placement: local (--local), 3 passed / 0 failed / 0 skipped. New journey evals/specs/thread-continues-after-restart.e2e.test.ts (world evals/worlds/thread-restart.ts: Den-less desktop, host-booted model witness, caller-owned profile relaunched on the same renderer origin). A running tool is interrupted by a crash (SIGKILL of the desktop process group: renderer, embedded server, engine), by an ordinary quit, and by a relaunch whose complete-history read is delayed past the request timeout. Each case requires the typed continuation to be accepted exactly once, answered, the composer left empty, earlier history intact, and the interrupted tool not replayed.
  • Negative control: with only the two app source files reverted, the slow-read case reproduced the report (draft: "continue", bounced, 0 continuations, "The rest of this conversation could not be loaded · Retry") while the crash and quit cases passed.
  • Unit: apps/app/tests/session-history.test.tsx 45/45 (new: a send reads from cached complete history or one bounded newest read, never the uncapped read; a foreign newest read is refused); apps/app/tests/opencode-session-native.test.ts 51/51 (new: a transport failure keeps its own message). pnpm --filter @openwork/app typecheck clean; eval channel/boundary ratchets and layer lint clean for the new files.
  • Not covered here: a running subagent delegation at restart, an engine unreachable at the archived pre-check, signed-in managed-model startup, Den boundary (Den-less by design).

Observed, not changed

A SIGKILL of the desktop lost the last minute of renderer localStorage (default model reverted to its first committed value, active workspace, drafts, per-session model memory) on the same renderer origin; an ordinary quit lost nothing. The crash case therefore commits preferences with one ordinary quit before the interrupted turn, so it tests thread continuity rather than storage durability.

UI/UX impact

None — existing UI/UX preserved. Only the failure path changes: the message no longer bounces back into the composer, and an engine transport failure shows its real cause instead of a TypeError.

…read

After a restart, reopening a thread whose turn was interrupted and typing the
next message could show it as pending and then hand the text back to the
composer with an error. Since #4838 the send waited on the uncapped
complete-history read so a follow-up could tell whether it must interrupt a
delegated task; on a cold engine that read can outlast the renderer's request
timeout, and the timed-out read failed the send itself.

Decide the interruption from cached complete history when the thread has it,
otherwise from one bounded newest read, and never block a send on the uncapped
read. Keep a transport failure's own message when the SDK settles without a
response instead of surfacing a TypeError in its place.

Proof: evals/specs/thread-continues-after-restart.e2e.test.ts covers a crash
(SIGKILL of the process group), an ordinary quit, and a relaunch whose
complete-history read is slower than the request timeout; each case requires
the typed continuation to be accepted exactly once, answered, and never
returned to the composer, with earlier history intact and no replay of the
interrupted tool. The slow-read case bounces the message on the previous
send path. Unit coverage in session-history.test.tsx and
opencode-session-native.test.ts.
@vercel

vercel Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 13, 2026 6:06am UTC
openwork-den Ready Ready Preview Sep 13, 2026 6:06am UTC
openwork-diagnostics Ready Ready Preview Sep 13, 2026 6:06am UTC
openwork-landing Ready Ready Preview, v0 Sep 13, 2026 6:06am UTC

@reachjalil

reachjalil commented Sep 13, 2026 •

Copy link
Copy Markdown
Member Author

Passed · 12/12 tests · 18/18 assertions · 8 images

Commit 9f61bd25fd810a0c8c3311765598b2d0bb574195 · selected evidence

Open review report

@github-actions

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native findings: 0. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run

Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (65642 ms), confidentiality-review (92221 ms), spec-provenance-review (138213 ms), desktop-den-sync-review (126950 ms).

Blockers

  • None.

Advisories

  • None.

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 1
  • Distinct heads in retained window: 1
  • Current unresolved Warden threads: 0 of 0 observed
  • Observed resolved/unresolved transitions in retained snapshots: 0 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 0
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 1/20 run attempts retained; truncated: false
  • Transition snapshot: 0/0 current attributed threads retained (limit 500); truncated: false

Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority.

@diff-warden diff-warden Bot 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.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (9f61bd25fd810a0c8c3311765598b2d0bb574195). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@reachjalil
reachjalil merged commit ed0fa31 into dev Sep 13, 2026
27 checks passed

This branch was successfully deployed

4 active deployments
Preview – openwork-landing — 9f61bd25 Deployed Sep 13, 2026 by vercel[bot]
Preview – openwork-app — 9f61bd25 Deployed Sep 13, 2026 by vercel[bot]
Preview – openwork-den — 9f61bd25 Deployed Sep 13, 2026 by vercel[bot]
Preview – openwork-diagnostics — 9f61bd25 Deployed Sep 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant