Skip to content

desktop: renderer crash loop on launch when restored tab references deleted session (TypeError: reading 'directory') #40373

Closed as not planned

Description

@kahlos

Summary

OpenCode Desktop crashes on every launch with TypeError: Cannot read properties of undefined (reading 'directory') in rememberSessionInfo when persisted tab state references a session whose location is gone (after deleting sessions and a project). The renderer becomes completely unusable — no settings, no UI actions.

Environment

  • opencode (desktop app): 1.18.12 (prod channel)
  • opencode2 (CLI): v0.0.0-next-16741 (next channel)
  • OS: macOS Darwin 25.5.0 (arm64)
  • Terminal: ghostty (CLI only; crash is in the desktop app renderer)
  • Shell: /bin/zsh
  • Install/channel: desktop app via Homebrew cask (opencode-desktop)
  • Active plugins: None found in config

Reproduction

  1. Open a project in OpenCode Desktop and create/keep several sessions.
  2. Delete the sessions from a previous project via the desktop app UI (works fine).
  3. Delete the project itself.
  4. Quit and relaunch the desktop app.

Expected Behavior

The app should start normally and drop tabs that reference sessions which no longer exist. The dev branch already guards the call site (if (!value) return in packages/app/src/components/titlebar-tab-strip.tsx:75).

Actual Behavior

The renderer throws on startup and the app is stuck in a crash loop:

TypeError: Cannot read properties of undefined (reading 'directory')
    at Object.rememberSessionInfo (oc://renderer/assets/main-BPGTMwQV.js:83293:57)
    at Object.fn (oc://renderer/assets/main-BPGTMwQV.js:113465:10)
    at runComputation (oc://renderer/assets/main-BPGTMwQV.js:487:22)
    at updateComputation (oc://renderer/assets/main-BPGTMwQV.js:470:3)
    at runTop (oc://renderer/assets/main-BPGTMwQV.js:566:7)
    at runUserEffects (oc://renderer/assets/main-BPGTMwQV.js:660:39)
    at oc://renderer/assets/main-BPGTMwQV.js:634:35
    at runUpdates (oc://renderer/assets/main-BPGTMwQV.js:583:17)
    at completeUpdates (oc://renderer/assets/main-BPGTMwQV.js:634:18)
    at runUpdates (oc://renderer/assets/main-BPGTMwQV.js:584:5)
    at batch (oc://renderer/assets/main-BPGTMwQV.js:265:10)
    at setStore (oc://renderer/assets/main-BPGTMwQV.js:50499:5)
    at remember (oc://renderer/assets/main-BPGTMwQV.js:79664:5)
    at oc://renderer/assets/main-BPGTMwQV.js:79712:14

The crash occurs during tab restoration: rememberSessionInfo (packages/app/src/context/tabs.tsx) reads session.location.directory, but the restored tab points at a session whose location is undefined after the project was deleted.

Additional Context

  • Consistently reproducible (every launch after the session/project deletions).
  • Workaround (confirmed working): quit the app and delete the persisted window state:
    rm -f ~/Library/Application\ Support/ai.opencode.desktop/opencode.window*.dat
    This clears restored tabs (saved server connections in opencode.global.dat are unaffected).
  • Server-side cleanup of the stale session via opencode2 api delete /api/session/<id> alone does not fix the app, since the tab is still restored and the missing session still hits the unguarded read.
  • The dev branch's guard at titlebar-tab-strip.tsx:75 appears to fix this; the shipped 1.18.12 build lacks it.

Activity

  1. github-actions commented on Aug 4, 2026

    @github-actions
    Contributor

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

    If your issue is distinct (e.g. specific to the tab-strip restoration path rather than the lastProjectSession pointer), feel free to keep this open and note the difference.

  2. Hona commented on Aug 4, 2026

    @Hona
    Member

    @kahlos is this using a v1 or v2 server?
    i get ur using prod desktop but what server used to own the session?

  3. kahlos commented on Aug 5, 2026

    @kahlos
    Author

    It's using the v2 server, with opencode desktop connecting to that.

  4. github-actions commented on Oct 6, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions