Repository navigation
fix(app): clear stale waiting indicators when an aborted question never reports rejection - #4840
Conversation
…er reports rejection OpenCode 1.18 marks the tool call of a stopped or superseded turn as errored but never publishes question.rejected / permission.replied, and an abandoned (not interrupted) ask stays listed by GET /question. The app kept re-seeding that zombie into the waiting set, so the sidebar showed "needs you" for hours and Archive refused the idle session. Treat the transcript as the authority: a pending question or permission whose tool call part is already completed/errored is settled from live part updates, transcript snapshots, and list seeds, and Archive no longer counts such a request as open work.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Passed · 12/12 tests · 18/18 assertions · 8 images Commit |
Warden review summary — ClearNative 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 (70221 ms), confidentiality-review (78383 ms), spec-provenance-review (87263 ms), desktop-den-sync-review (105908 ms). Blockers
Advisories
Needs recheck
Observed review-thread metrics
Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority. |
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (5e7b16f491e7a25e26dd578bfa1dac424f76f95b). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
|
Coordinated with #4843: session attention reads and both question-proposal load/confirmation now cross-check a fresh owner transcript with the same isOrphanedInteraction/terminalToolCallIds helper. The helper is included at the same sync/orphaned-interactions.ts path and is byte-identical to 5e7b16f (blob 60a55c648a697ca6155a9fc8f6e14fcb2ba3aa90). No changes to session-sync.ts, session-activity-store.ts, or use-session-archive.tsx, and no changes to this PR's branch. Running/unlinked requests stay eligible; transcript failures fail closed. 32 focused cases pass; a new real v1 abort/supersede zombie E2E is being verified on the pushed #4843 head. #4843 remains draft for its separate native-v2 host-tool exposure blocker. |
|
Follow-up proof on #4843 head 3fe27d1: the real v1 zombie E2E passed on Daytona. It requires the unchanged request to remain in GET /question after abort/supersede, verifies fresh session.attention filters it, then confirms an already-staged answer and observes rejected/sent=false. Normal v1 reply E2E also passed. Shared helper remains byte-identical to your 5e7b16f; no seed/store guard changes from this feature. Current-head CI passed and Warden approved; #4843 stays draft for the separate native-v2 host-tool integration gap. |
Symptom
A session that finished hours ago still shows the orange "needs you" dot in the sidebar, and
session.archiveis refused ("could not be confirmed" → Stop-and-archive confirmation → "A task, approval, or message acceptance is still unresolved"). Found by the workspace audit on an "E2E fix" session: 12:02 the assistant callsquestion; 12:05 a superseding prompt (another agent's STOP) arrives while the question is pending; the question tool part ends withstate.status = "error"; the follow-up turn finishes withfinish=stop; engine idle for hours; app still sayswaiting.RCA (confirmed, with one correction)
Engine (confirmed, not patchable here). The engine is the upstream OpenCode binary (
constants.json→v1.18.18, downloaded byapps/desktop/scripts/prepare-sidecar.mjs). Inpackages/opencode/src/question/index.ts(and identicallypermission/index.ts),ask()wrapsDeferred.awaitinEffect.ensuring(pending.delete(id)); only an explicitreply()/reject()publishesquestion.replied/question.rejected.SessionProcessor.cleanup()waits 250 ms for open tool calls and then marks themerror: "Tool execution aborted"without interrupting the tool fiber, so the question's deferred is never failed either. Read-only probe of the live engine while the affected session was idle:GET /session/status→ the session is absent (idle)GET /question→ still lists the session's requestque_…withtool: { messageID, callID }callID's tool part isstate.status = "error"So the RCA hypothesis 1 is confirmed and stronger than stated: not only is
question.rejectednever published, the abandoned request stays in the engine's pending list as a zombie. That rules out option (a) ("drop ids missing from the engine list") as a fix — the list is the source of the ghost.App (corrected). Hypothesis 2 (a missed SSE idle plus the snapshot guards) is not what keeps the record waiting.
setRunStatus(idle)does clear the ids, andconnect-reconcile(seedSessionRunwithsnapshotStartedAt) heals a missed idle. Therecord.status !== "idle"guards inseedWorkspaceSessions/seedSessionRunare intentional:waiting+runActive=falseis a legitimate state ("retains a pending question at the idle release deadline" test, v2 permissions), so they stay. What actually re-poisons the store is the zombie itself:useSessionInteractionsreadsGET /questionwhenever the session (or its parent) is open andseedQuestionStatere-adds the zombie →waitingagain withrunActive=false; nothing ever settles it.useSessionArchive.readWorkingreads the same list and counts the zombie as open work → archive refused forever.Fix (option (c): the transcript is authoritative)
A question/permission can only be answered while the tool call that asked it is still running. When that call's part is
completed/error, nobody can consume an answer, so the request is settled:sync/orphaned-interactions.ts(new):isTerminalToolPart,terminalToolCallIds(raw parts),terminalTranscriptToolCallIds(UI transcript),isOrphanedInteraction(tool, terminal).session-sync.ts:settleOrphanedInteractions()runs on livemessage.part.updated(before the tracked-session gate, so background sidebar rows heal too) and after each transcript snapshot;seedQuestionState/seedPermissionStatetreat orphaned requests as settled so a zombie list read cannot resurrect them. Settling goes through the existingsettle*Statepath (settled set + waiting id removal), so the existing snapshot/live ordering guards are untouched.use-session-archive.tsx:readWorkingignores a pending request whose tool call already ended in the fetched messages.Requests without a
toollink and requests whose tool part is stillrunningare never touched (covered by tests).Proof
apps/app:bun test --isolate tests/session-sync-orphaned-interactions.test.ts tests/session-sync-permissions.test.ts tests/session-sync-run-status.test.ts tests/session-sync-tool-parts.test.ts tests/session-sync-lifecycle.test.ts→ 107 pass / 0 fail (the 6 new tests were red before the fix: 5 fail / 1 pass; the existing "does not let an older idle snapshot stop a live run" guard stays green).apps/app:pnpm typecheck→ clean.evals/specs/abandoned-question-waiting-indicator.e2e.test.ts(new worldabandonedQuestioninevals/worlds/chat.ts): real question via mock model →POST /session/:id/abort+prompt_asyncfollow-up (what another agent's STOP does) → asserts the engine tool part ended and the session is idle, the question panel closes, the sidebar dot stops saying "Waiting" within 15 s, and Archive succeeds with no Stop-and-archive confirmation. Lane and result: see the evidence comment below.Upstream engine item (not patchable in this repo)
Proposed issue for anomalyco/opencode:
Coordination
Sibling branch
fix/session-blocker-introspectionexposes pending question/permission state to agents. This PR does not touchsession-activity-store.ts; it adds one helper module and small hooks insession-sync.ts(settleOrphanedInteractions, seed filters,message.part.updated,seedSessionState) anduse-session-archive.tsx. If that branch reads the engine's pending lists, it should apply the sameisOrphanedInteractionfilter so agents do not see the zombie either.