Skip to content

fix: restore --resume for Gemini and --continue for OpenCode#162

Merged
bfly123 merged 1 commit intobfly123:mainfrom
M-Marbouh:fix/resume-gemini-project-name-and-opencode-sqlite
Apr 5, 2026
Merged

fix: restore --resume for Gemini and --continue for OpenCode#162
bfly123 merged 1 commit intobfly123:mainfrom
M-Marbouh:fix/resume-gemini-project-name-and-opencode-sqlite

Conversation

@M-Marbouh
Copy link
Copy Markdown
Contributor

Summary

Two independent bugs that both cause ccb -r to 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, so has_history is always False and --resume latest is never appended.

Fix: try both sha256(cwd) and Path(cwd).name as 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 for storage/session/ (JSON files), but OpenCode migrated session storage to opencode.db (SQLite). The directory doesn't exist, so the function returned False immediately — 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 -r with Gemini: resumes last session with --resume latest (tested on Gemini CLI with ~/.gemini/tmp/<project_name>/chats/ layout)
  • ccb -r with OpenCode: resumes last session with --continue (tested against opencode.db SQLite backend)
  • ccb -r with no prior history: still starts fresh (no regression)

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.
@bfly123 bfly123 merged commit cbbe952 into bfly123:main Apr 5, 2026
3 of 13 checks passed
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