fix: skip JSON to SQLite migration on opencode serve#13612
Closed
remorses wants to merge 10 commits into
Closed
Conversation
The migration can take several minutes for large databases. Commands like `serve` are designed for programmatic usage where the caller expects opencode to start quickly. The migration should only run for interactive commands where the user can see the terminal progress. Uses yargs' `opts._[0]` to check the command name in middleware.
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts CLI startup behavior to avoid the potentially long JSON→SQLite session migration when running opencode serve, since serve is intended to start quickly for programmatic usage.
Changes:
- Skip the one-time JSON→SQLite migration in the yargs middleware when the invoked command is
serve.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses review feedback: using opencode.db as marker was unsafe since programmatic commands could create the db via Database.Client(), preventing migration from ever running on interactive commands. Now uses migration.json as a dedicated marker, written only after migration completes successfully.
Simpler and more robust - if stdout is not a TTY, the user can't see the migration progress anyway.
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.
Closes #13611
Problem: The JSON to SQLite migration can take several minutes for large databases. Commands like
serveare designed for programmatic usage where the caller expects opencode to start quickly.Fix: Only run migration when
process.stdout.isTTYis true - if there's no TTY, the user can't see the progress anyway.Marker change: Uses a dedicated
migration.jsonmarker file instead of checking foropencode.dbexistence. This prevents the issue where a non-TTY invocation creates the db viaDatabase.Client(), which would permanently block migration from running on future interactive commands.