Repository navigation
[BUG] Closing an active terminal leaves command stuck as Running #1362
Description
Problem
When a Zoo Code command's VS Code terminal is closed or killed immediately after the command runs, the command remains marked as Running in chat indefinitely. Subsequent user messages are queued because the task continues waiting for terminal completion.
This has occurred repeatedly with different compound Git commands.
Reproduction steps
- Let Zoo Code run a command in a VS Code-backed terminal.
- Close/kill the terminal immediately after it produces output (or immediately after the command visibly returns).
- Observe that the command card in chat continues displaying Running and the task does not proceed.
Expected result
Closing the terminal should finalize the attached command as interrupted/terminated (with an unknown exit code if necessary), clear its running state, and allow the task to continue.
Actual result
The terminal disappears, but the command card remains Running indefinitely and the conversation is suspended.
Relevant logs
One occurrence showed the complete command output, including its final git log output, before the terminal disappeared. A second occurrence produced this extension-host sequence:
[Extension Host] [onDidStartTerminalShellExecution] {command: 'GIT_EDITOR=true GIT_SEQUENCE_EDITOR=true git rebas…one && cat .git/rebase-merge/done || true; exit 0', terminalId: 2}
[Extension Host] [Terminal Process] stream chunk #1 (+77ms, 318 chars)
There is no corresponding onDidEndTerminalShellExecution event after the terminal closes.
An unrelated VS Code warning appeared nearby:
WARN [mainThreadStorage] large extension state detected (extensionId: ZooCodeOrganization.zoo-code, global: true): 1036.4345703125kb.
That warning appears separate from the missing terminal completion transition.
Suspected lifecycle gap
TerminalRegistry.initialize() handles onDidCloseTerminal, but the close handler currently only calls ShellIntegrationManager.zshCleanupTmpDir(terminal.id). It does not finalize an attached terminal.process, clear busy/running, or emit the completion signal that ultimately posts an exited command status to the webview.
If terminal disposal prevents VS Code from emitting onDidEndTerminalShellExecution or delivering the OSC 633 D marker, neither of the existing completion paths can run.
Related issues
- [BUG] #800 covered the same visible stuck-running symptom when VS Code omitted its completion event/stream closure. PR fix(terminal): fix output loss on cold terminals by moving read() into onDidStartTerminalShellExecution (#800) #834 added OSC 633
D-marker self-finalization, but terminal disposal can prevent that marker from being received. - Shell Integration Warning when using MiMo: Root Cause Analysis and Fix #752 discusses dead/user-closed terminal reuse, but not finalizing the command attached at the moment of terminal disposal.
- [BUG] zoo code stuck after that run process #622 reported the broader stuck-after-command symptom.
This appears to be a residual terminal-disposal lifecycle case rather than an exact duplicate of #800.
Suggested regression coverage
- Close the terminal while a shell execution is active.
- Close it immediately after output arrives but before the end event.
- Close it while waiting for shell integration to initialize.
- Ensure normal completion followed by terminal closure does not emit completion twice.
Version
Observed on the current Zoo Code build in use on 2026-08-24; exact packaged version was not captured.
Activity