Skip to content

[BUG] Closing an active terminal leaves command stuck as Running #1362

Description

@edelauna

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

  1. Let Zoo Code run a command in a VS Code-backed terminal.
  2. Close/kill the terminal immediately after it produces output (or immediately after the command visibly returns).
  3. 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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions