Skip to content

fix(opencode): sanitize preview database filenames#16430

Merged
Hona merged 1 commit intoanomalyco:devfrom
Hona:fix/windows-preview-db-filename
Mar 7, 2026
Merged

fix(opencode): sanitize preview database filenames#16430
Hona merged 1 commit intoanomalyco:devfrom
Hona:fix/windows-preview-db-filename

Conversation

@Hona
Copy link
Copy Markdown
Member

@Hona Hona commented Mar 7, 2026

Summary

  • sanitize preview channel names before turning them into database filenames so branch names with / stay single-file paths on Windows
  • keep latest builds on the shared opencode.db filename while preserving per-channel database names for preview builds
  • add focused coverage for latest and slash-containing preview channel filenames

Testing

  • bun test test/storage/db.test.ts
  • bun run --cwd packages/opencode --conditions=browser src/index.ts --print-logs --log-level DEBUG session list
  • bun run typecheck

Copilot AI review requested due to automatic review settings March 7, 2026 04:28
@Hona Hona enabled auto-merge (squash) March 7, 2026 04:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the latest channel
  • Refactor Database.Path to use the new file() function instead of inline construction
  • Add unit tests for the latest channel 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.

@Hona Hona merged commit 4c7fe60 into anomalyco:dev Mar 7, 2026
16 checks passed
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
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.

2 participants