fix(opencode): sanitize preview database filenames#16430
Merged
Hona merged 1 commit intoanomalyco:devfrom Mar 7, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where preview channel names containing / (common in git branch names like fix/windows-modified-files-tracking) could create nested directory paths instead of single database files on Windows. It extracts the database filename logic into a dedicated Database.file() function that sanitizes channel names by replacing non-alphanumeric characters (except ._-) with -, and adds test coverage for this behavior.
Changes:
- Extract
Database.file(channel)helper that sanitizes channel names for safe use as database filenames, keeping"opencode.db"for thelatestchannel - Refactor
Database.Pathto use the newfile()function instead of inline construction - Add unit tests for the
latestchannel and slash-containing preview channel names
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/opencode/src/storage/db.ts |
Extract Database.file() function with channel name sanitization regex, refactor Path to use it |
packages/opencode/test/storage/db.test.ts |
New test file covering Database.file() for latest and slash-containing channel names |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
manno23
pushed a commit
to manno23/opencode
that referenced
this pull request
Mar 12, 2026
demostanis
pushed a commit
to demostanis/opencode
that referenced
this pull request
Mar 19, 2026
demostanis
pushed a commit
to demostanis/opencode
that referenced
this pull request
Mar 20, 2026
balcsida
pushed a commit
to balcsida/opencode
that referenced
this pull request
Mar 24, 2026
inspirepan
added a commit
to inspirepan/opencode
that referenced
this pull request
Apr 6, 2026
- predev.ts: add --skip-install to dev build (deps already installed)
- index.ts (electron): sqliteFileExists() now checks for any opencode*.db file instead of hardcoded opencode.db
- index.ts (sidecar): use Database.Path instead of hardcoded opencode.db as migration marker
- root cause: upstream added channel-based DB naming (opencode-{channel}.db) in anomalyco#16430 but electron and sidecar marker still checked opencode.db, causing loading screen to hang and migration to re-run on every startup
balcsida
pushed a commit
to balcsida/opencode
that referenced
this pull request
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/stay single-file paths on Windowsopencode.dbfilename while preserving per-channel database names for preview buildsTesting
bun test test/storage/db.test.tsbun run --cwd packages/opencode --conditions=browser src/index.ts --print-logs --log-level DEBUG session listbun run typecheck