anomalyco / anomalyco/opencode

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

Open
#40,373 3 comments 0 reactions 1 assignee View on GitHub

@Hona is already working on this.

Since Aug 4, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.