Skip to content

fix: cancel chat runs when deleting conversations (#90)#92

Open
aiis2 wants to merge 6 commits into
masterfrom
codex/impl-chat-delete-cancellation
Open

fix: cancel chat runs when deleting conversations (#90)#92
aiis2 wants to merge 6 commits into
masterfrom
codex/impl-chat-delete-cancellation

Conversation

@aiis2

@aiis2 aiis2 commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Why

Deleting a streaming conversation removed its UI/DB row but left the agent controller and ask_user resolver alive. Deleted runs could continue tools, remain stuck awaiting input, and leave global streaming state with no visible Stop target. A second race allowed a run deleted during message persistence to start later, after its conversation was already gone.

What changed

  • Add ID-scoped cancellation that resolves the target ask_user with __ABORT__ and aborts only its controller.
  • Reuse that cancellation path for the existing Stop action.
  • Atomically remove the deleted ID from conversations and streaming state, recompute the newly active conversation's isStreaming, and clear target-owned question/turn state.
  • Preserve the controller entry until the normal finalizer observes aborted and owns cleanup.
  • Refuse to start an agent if its conversation was deleted during pre-agent persistence.
  • Add product-level regressions for two concurrent streams, deletion during ask_user, and the pre-start deletion race.

Issue

Closes #90

Mainline

Implementation branch created from authoritative origin/master@fdc1cc3 after Spec PR #91 merged. The repository has no origin/main.

TDD evidence

  • Initial RED on the unmodified base: 0 pass / 2 fail (target signal stayed live, stale streaming ID remained, ask_user did not settle).
  • Review-driven race RED: 2 pass / 1 fail (runReactAgent still started after deletion during persistence).
  • GREEN: deletion lifecycle + prior chat settlement tests 5/5 pass.

Verification

  • node --test tests/*.test.cjs (162 pass)
  • npx tsc --noEmit
  • npx tsc -p src/main/tsconfig.json --noEmit
  • npx vite build (2346 modules)
  • node scripts/smoke-report-preview-isolation.cjs --expect-isolated
  • node scripts/smoke-export-origin-isolation.cjs --expect-isolated
  • node scripts/smoke-export-runtime-compatibility.cjs --expect-isolated
  • production dependency audit: 0 vulnerabilities
  • full dependency audit: 0 vulnerabilities
  • git diff --check origin/master...HEAD

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.

[Optimization] Cancel and settle active chat runs when deleting a conversation

1 participant