fix(tui): flush pending modals + cancel pauseGate on Esc and /new#552
Merged
Conversation
When a tool awaits pauseGate.ask (plan_checkpoint, plan_proposed, etc.),
the gate's promise ignores AbortSignal. Esc-during-busy fires
loop.abort(), but the awaiting tool fn never returns, so:
- busy stays true forever — PromptInput stays disabled.
- The pending modal (or its plan card) can't be dismissed.
- /new is silently dropped by handleSubmit's `if (busy) return`,
so the user can't even wipe the session to start over.
Add pauseGate.cancelAll() that resolves every outstanding request with
its kind's safe-cancel verdict (deny / cancel / stop / cancelled). Wire
it into a resetPendingModals helper that also clears every pending*
modal state, and call it from both Esc-during-busy and apply-slash-
result's clear branch. The awaiting tool fn now returns or throws
cleanly, busy clears, and the user can recover.
This was referenced May 10, 2026
Closed
Merged
ChasLui
pushed a commit
to ChasLui/DeepSeek-Reasonix
that referenced
this pull request
May 23, 2026
…engine#552) When a tool awaits pauseGate.ask (plan_checkpoint, plan_proposed, etc.), the gate's promise ignores AbortSignal. Esc-during-busy fires loop.abort(), but the awaiting tool fn never returns, so: - busy stays true forever — PromptInput stays disabled. - The pending modal (or its plan card) can't be dismissed. - /new is silently dropped by handleSubmit's `if (busy) return`, so the user can't even wipe the session to start over. Add pauseGate.cancelAll() that resolves every outstanding request with its kind's safe-cancel verdict (deny / cancel / stop / cancelled). Wire it into a resetPendingModals helper that also clears every pending* modal state, and call it from both Esc-during-busy and apply-slash- result's clear branch. The awaiting tool fn now returns or throws cleanly, busy clears, and the user can recover.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A user reported a stuck-task pattern: the plan card freezes at `0/N
done`, can't be dismissed, and `/new` doesn't clear it either.
Reproducer
The model proposes a plan, the user approves, the model calls a tool
that goes through pauseGate (e.g. `mark_step_complete` →
`plan_checkpoint`). Either the modal mounts and the user closes the
terminal modal in some way that misses the resolve, or the modal mounts
but the user wants to bail out via Esc / `/new`.
Root cause
`PauseGate.ask()` returns a Promise that ignores AbortSignal — it only
resolves when someone calls `gate.resolve(id, verdict)`. Three knock-on
problems:
AbortController. The model fetch path bails on `signal.aborted`,
but the `await pauseGate.ask(...)` inside a tool fn doesn't see
the signal — the tool fn stays awaiting forever.
`busy` stays `true`, and `` stays
disabled. The user can't type.
`if (busy) return` (App.tsx:2066) silently drops it.
The plan card the user sees frozen at `0/N done` is the visible
manifestation of the awaiting tool fn behind it.
Fix
with its kind's safe-cancel verdict (`run_command` → `deny`,
`plan_proposed` → `cancel`, `plan_checkpoint` → `stop`,
`plan_revision` → `cancelled`, `choice` → `cancel`). Awaiting tool
fns return or throw cleanly.
`setPending*` modal state and calls `pauseGate.cancelAll()`.
calls it before `log.reset()`, so the wipe is atomic.
After the fix:
await returns with `{type: "stop"}` → `mark_step_complete` throws
→ the loop's `signal.aborted` check catches the next iter → busy
clears → prompt re-enables.
now also flushes any modals/gate state that survived a partial
cleanup.
Test plan
tests in `tests/pause-gate.test.ts`)
confirm modal closes, prompt re-enables, busy spinner stops
wipe and no plan card returns