anomalyco / anomalyco/opencode
Session picker hides all sessions after the folder's .git directory is removed (project re-keying); CLI `session list` still shows them
@simonklee is already working on this.
Since Sep 16, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
OpenCode keys sessions to a per-project id derived from the enclosing git repo.
If that repo is removed (e.g. deleting an unused/accidental .git in a plain folder), the directory re-keys to the global project. The TUI session picker then hides every pre-existing session for that folder, with no UI path to discover them. The data is intact: opencode -s <sessionID> resumes them, and opencode session list in the same directory still lists them. Only the picker's filter excludes them.
Additional observations
- The CLI and the TUI disagree:
opencode session listin the same directory lists the hidden sessions; the picker does not. The picker applies a project/subpath filter the CLI does not. - Root cause (from reading the
devbranch): the picker query defaults to a subpath filter (sessionListQuery()inpackages/tui/src/context/sync.tsx, gated by thesession_directory_filter_enabledkv), while sessions persistproject_idplus a path subpath computed at creation time (packages/core/src/session.ts:path.relative(project.directory, directory)). After repo removal, old sessions keepproject_id = <repo project>andpath = ""(project root), new sessions getproject = globalandpath = "home/user/..."- so the filter never matches the old rows again. - Recovery that worked for me (opencode closed,
~/.local/share/opencode/opencode.db):
This restored full picker visibility.UPDATE session SET project_id='global', path='<dir without leading slash>' WHERE directory='<dir>'; DELETE FROM project_directory WHERE directory='<dir>'; -- stale mapping to the old project
Suggested fixes (any one of)
- Match sessions by directory as well as project (directory OR project match)
- Surface a UI toggle for the directory/project filter scope (
session_directory_filter_enabledkv exists but I found no UI for it) - Offer migration of old sessions when a directory's project re-keys
Plugins
opencode-scheduler
OpenCode version
1.18.31
Steps to reproduce
- mkdir /tmp/repro && cd /tmp/repro && git init # empty repo, zero commits is enough
- Start opencode, send a few messages so a session exists, then quit opencode
- rm -rf .git
- Start opencode again in the same folder and open the session picker.
Actual: the session from step 2 is not listed (picker browse and title search both miss it).
Expected: prior sessions for this directory remain visible, or there is some UI affordance to reach them.
Screenshot and/or share link
No response
Operating System
Arch Linux
Terminal
Terminator
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.