Skip to content

Bug: Desktop embedded terminal freezes when shell exits via Ctrl+D or exit command #6004

Closed

Description

@anntnzrb

Description

The embedded terminal in the bottom panel of OpenCode Desktop freezes/hangs when the shell session terminates, either by pressing Ctrl+D or typing exit.

I don't use the Desktop or Web version regularly, so I haven't investigated this deeply. I encountered this bug on my first time trying the Desktop app.

Additional observation: In opencode web, the terminal panel failed to open entirely (this might be related to issue #5844).

OpenCode version

v1.0.190

Steps to reproduce

  1. Open OpenCode Desktop (Tauri app) or run opencode web
  2. Open a project
  3. Open the terminal panel (bottom sidebar)
  4. Either:
    • Press Ctrl+D to send EOF, OR
    • Type exit and press Enter
  5. The application freezes/hangs

Expected behavior

The terminal should gracefully handle shell exit by either:

  • Closing the terminal panel
  • Showing a "Terminal exited" message with option to restart
  • Automatically spawning a new shell session

Actual behavior

  • Tauri Desktop: Application freezes after shell exits
  • opencode web: Terminal panel doesn't open at all

Operating System

macOS (Apple Silicon M4 - MacBook Air)

Terminal

Default shell


Preliminary investigation (with LLM assistance)

A superficial analysis of the codebase suggests the issue may be related to a disconnect between backend PTY cleanup and frontend handling:

Backend (packages/opencode/src/pty/index.ts, lines 158-163):

  • When shell exits, ptyProcess.onExit() publishes pty.exited event and deletes session from state
  • WebSocket connections to subscribers may not be properly closed

Frontend (packages/desktop/src/components/terminal.tsx, lines 124-126):

  • WebSocket close handler only logs the disconnection
  • No recovery or cleanup is triggered

Global Sync (packages/desktop/src/context/global-sync.tsx, lines 183-294):

  • Event handler does not appear to listen for pty.exited or pty.deleted events

Note: This investigation was done with LLM assistance and has not been thoroughly verified.

Activity

  1. github-actions commented on Dec 23, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    The root cause may be related to PTY cleanup and websocket connection handling when the shell exits, as you've already noted in your investigation. Feel free to ignore if none of these address your specific case.

  2. anntnzrb commented on Dec 23, 2025

    @anntnzrb
    ContributorAuthor

    Thanks for the suggestions! After reviewing, I don't believe these are duplicates:

    • Bun crash when /exiting #5896 (Bun crash when /exiting): That issue is about a Bun crash when using the /exit command in the CLI/TUI. This issue is about the embedded terminal (Ghostty) in the Desktop bottom panel freezing when the shell exits via Ctrl+D or the shell's exit command.

    • Random Artifactts In Terminal After Running #5936 (Random Artifacts In Terminal After Running): That issue is about visual artifacts in the terminal on Windows after closing OpenCode TUI. This issue is specifically about the Desktop app freezing, not visual glitches.

    • Bug: opencode run and TUI exits hang on v0.15+ #3213 (opencode run and TUI exits hang): That issue is about the CLI mode (opencode run) and TUI hanging. This issue is specific to the Desktop (Tauri) and opencode web embedded terminal panel.

    The key distinction is that this bug occurs in the Desktop/Web embedded terminal component, not in the CLI/TUI.

  3. AlexandrosLiaskos commented on Dec 23, 2025

    @AlexandrosLiaskos

    For me the terminal never opens. In wsl the deb worked, but in windows app, both the stable and beta didn't even open a terminal

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

webRelates to opencode on web / desktop

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions