Skip to content

fix(desktop): pin the dev sidecar build channel so sessions persist - #344

Merged
quickbeard merged 1 commit into
mainfrom
fix/dev-db-channel
Aug 28, 2026
Merged

quickbeard merged 1 commit into
mainfrom
fix/dev-db-channel

Conversation

@quickbeard

Copy link
Copy Markdown
Owner

Summary

Every bun dev:desktop run on a different git branch appeared to lose all previous sessions. Nothing was deleted — the sessions were stranded in per-branch database files:

  1. predev.ts/prebuild.ts run packages/opencode/script/build-node.ts, which bakes Script.channel into the server bundle.
  2. With CODEV_CHANNEL unset, packages/script/src/index.ts falls back to git branch --show-current (upstream's preview-release logic leaking into local builds).
  3. Core's Database.path() suffixes the session database with the channel: opencode-<branch>.db.

~/.local/share/codev/ accordingly holds opencode-main.db (6 sessions), opencode-feat-sidebar-account.db (1), opencode-feat-account-probe.db (1), opencode-local.db (206), etc. — one per branch dev-run. The desktop's own electron-vite define already defaulted its channel to dev; the sidecar build was the inconsistent one.

Fix

Default CODEV_CHANNEL to dev (??=) in packages/desktop/scripts/predev.ts and prebuild.ts before the sidecar build. An explicitly set value (CI) passes through untouched, so release packaging is unaffected. Local dev runs now always use opencode-dev.db. DIVERGENCES rows for both scripts amended.

Existing per-branch DBs are left in place; recovering those sessions (merging them into opencode-dev.db) is a separate task if wanted.

Testing

  • Rebuilt the sidecar via bun ./scripts/predev.ts with CODEV_CHANNEL unset on branch fix/dev-db-channel: the bundle now contains InstallationChannel = "dev" and version 0.0.0-dev-…, with zero occurrences of the branch name (previously the branch was baked in).
  • Database.path()'s template (opencode-${InstallationChannel}.db) therefore resolves to opencode-dev.db on every branch.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BcADw33oD8qs5jvn5NWMJx

The node-sidecar build bakes Script.channel into the server bundle, and
with CODEV_CHANNEL unset packages/script falls back to
`git branch --show-current`. Core's Database.path() suffixes the
session database with that channel (opencode-<channel>.db), so every
branch's dev runs landed in a fresh database and the previous branch's
sessions seemed to vanish. Default CODEV_CHANNEL to "dev" in predev and
prebuild (`??=`, so CI's explicit value passes through) so local builds
always use opencode-dev.db.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BcADw33oD8qs5jvn5NWMJx
@quickbeard
quickbeard merged commit 65e4535 into main Aug 28, 2026
0 of 5 checks passed
@quickbeard
quickbeard deleted the fix/dev-db-channel branch August 28, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant