fix: restore --resume for Gemini and --continue for OpenCode#162
Merged
bfly123 merged 1 commit intobfly123:mainfrom Apr 5, 2026
Merged
Conversation
Gemini CLI stores sessions under ~/.gemini/tmp/<project_name>/chats/ but CCB was looking for ~/.gemini/tmp/<sha256(cwd)>/chats/. The hash directory never exists, so has_history was always False and --resume latest was never passed. Fix: try both sha256 and Path(cwd).name to support all versions. OpenCode migrated from JSON session files to an SQLite database (opencode.db). _opencode_resume_allowed() returned False early when storage/session/ didn't exist, before reaching any fallback. Fix: check the SQLite database first (querying sessions by directory), then fall back to the legacy JSON file scan for older installations. Both fixes confirmed working locally against Gemini CLI and OpenCode.
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
Two independent bugs that both cause
ccb -rto silently start a fresh session instead of resuming.Gemini: project name directory vs sha256 hash
CCB computes
sha256(cwd)to locate Gemini's session directory, but Gemini CLI stores sessions under~/.gemini/tmp/<project_name>/chats/(using the directory basename, not a hash). The hash path never exists, sohas_historyis alwaysFalseand--resume latestis never appended.Fix: try both
sha256(cwd)andPath(cwd).nameas candidate directory names, returning on first match. Preserves compatibility with any older Gemini version that may have used the hash.OpenCode: SQLite database vs JSON files
_opencode_resume_allowed()checked forstorage/session/(JSON files), but OpenCode migrated session storage toopencode.db(SQLite). The directory doesn't exist, so the function returnedFalseimmediately — before any fallback could run.Fix: query the SQLite database first (
SELECT id FROM session WHERE directory = ? AND time_archived IS NULL), then fall back to the legacy JSON scan for older installations.Test plan
ccb -rwith Gemini: resumes last session with--resume latest(tested on Gemini CLI with~/.gemini/tmp/<project_name>/chats/layout)ccb -rwith OpenCode: resumes last session with--continue(tested againstopencode.dbSQLite backend)ccb -rwith no prior history: still starts fresh (no regression)