anomalyco / anomalyco/opencode
desktop: renderer crash loop on launch when restored tab references deleted session (TypeError: reading 'directory')
@Hona is already working on this.
Since Aug 4, 2026.
- 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
- Open a project in OpenCode Desktop and create/keep several sessions.
- Delete the sessions from a previous project via the desktop app UI (works fine).
- Delete the project itself.
- 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 inopencode.global.datare 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:75appears to fix this; the shipped 1.18.12 build lacks it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.