Repository navigation
TUI /sessions picker only shows recent sessions #13877
Description
Draft: OpenCode /sessions Picker Shows Only Recent Sessions
Summary
In the OpenCode TUI, the built-in /sessions command opens an interactive picker, but it only shows a small set of recent sessions (for this user: sessions updated around Feb 11, 2026 and later). Older sessions still exist in the database and can be discovered via direct DB queries, but they do not appear in the picker by default.
This blocks the core workflow of quickly switching to an older session by selecting it from the picker.
Environment
- OpenCode:
opencode1.2.5 (opencode-ainpm package) - OS: macOS (darwin-x64)
- Installed binary path:
~/.npm-global/lib/node_modules/opencode-ai/node_modules/opencode-darwin-x64/bin/opencode - Sessions DB path:
~/.local/share/opencode/opencode.db
Expected Behavior
/sessionsshows all sessions (or at least provides pagination/scrolling to reach older sessions), so the user can select any session to switch.
Actual Behavior
/sessionspicker only shows recent sessions (observed cutoff: ~Feb 11, 2026 for this user).- Older sessions remain accessible via DB queries (example below), but cannot be selected from
/sessions.
Evidence
DB Contains Older Sessions
Run:
opencode db "select id, title, strftime('%Y-%m-%d %H:%M', time_updated/1000, 'unixepoch') as updated from session where parent_id is null order by time_updated desc limit 20;"Example output includes sessions older than Feb 11:
ses_3c647855fffeCu2IIkDKR0whqW(2026-02-08)ses_455c4ac03ffeDgygUTJn673heI(2026-02-01)ses_3f9105c55ffeJ53lBI332PPuPS(2026-01-28)ses_418bd7846ffeqR9Ub0yCQadYBG(2026-01-22)
DB Counts
opencode db "select count(*) as total_sessions from session;"
opencode db "select count(*) as root_sessions from session where parent_id is null;"Observed:
- total_sessions: 320
- root_sessions: 35
Suspected Root Cause
/sessions appears to use the same underlying session listing logic that supports parameters like start and limit.
Two likely failure modes:
- Implicit
start: The picker request injects astarttimestamp (e.g., now minus N days), cutting off older sessions. - Default
limit+ root filtering: The server-side session list uses a hardcoded defaultlimit(commonly 100) and sorts bytime_updated desc. If combined with additional filtering, this could look like a date cutoff.
Either way, the picker needs a way to retrieve older sessions (pagination) or default to a sufficiently high limit with no implicit time window.
Suggested Fix
- Ensure
/sessionspicker request does not apply an implicitstartfilter. - Add pagination/virtualized scrolling for sessions in the picker.
- OR (minimal): increase default session list limit for the picker and expose a way to load older sessions.
Why Not a Custom Command
OpenCode custom commands configured via opencode.json are prompt-to-LLM commands (see https://opencode.ai/docs/commands/) and cannot replicate an interactive picker UI.
Activity
dinhphieu commentedon Mar 6, 2026
@itzxSage I've opened a PR #16273 that might fix this. Could you confirm if you spawn a lot of a subagents like I do?
ahmzaa commentedon Mar 7, 2026
Just to add to this, I had the same issue happen to me. I only have ever spawned 2 sessions. Today they were not in the list however when querying the database they show up.
albertobissacco commentedon Mar 7, 2026
I noticed some inconsistencies with session visibility:
opencode db "select count(*) as total_sessions from session;"gives 128 sessions, andopencode db "select count(*) as root_sessions from session where parent_id is null;"gives 104./sessionsshows only a few.opencode session listshows all sessions.Would it be possible to always show all sessions, but maybe pin sessions for the current project/folder at the top? That would make it easier to find what I’m actively working on.
ahmzaa commentedon Mar 7, 2026
Maybe my lack of experience, and I havent read through the code but do these sessions have token limits ? i.e when you reach the token limit opencode hides the session ?
CasualDeveloper commentedon Apr 2, 2026
ahhh, so I wasn't going crazy! Was wondering where my sessions went lolUpdate: Dug into this on my local opencode fork (updated to
devtip at post time) and my issue seems to have a different root cause from the ones discussed above.In my case, sessions all shared the same git-derived
project_id, but/sessionsbackend (and the Sessions dialog) was still hiding most of them because it was filtering by exactsession.directory. I had 77 session rows split across four paths (opencode,opencode-cli,opencode/packages/opencode,opencode-cli.bak) due to local repo/folder renames.After normalising them all to the correct directory, every missing session came back. So at least for me, this wasn't the 100-session limit or the 30-day filter. Exact directory scoping was independently dropping sessions even when the
project_idmatched.This looks like an interaction between
b020758(show all project sessions from any working directory),68bb8ce(database-level session filtering), andc7760b4(SDK rewrite that sendsdirectoryon/sessionrequests).jiwangyihao commentedon Apr 18, 2026
There is now a related PR for one confirmed branch of the
/sessionsvisibility problem: #23276 #23276That PR addresses the child-session dilution root cause described in #16270: the TUI dialog was requesting a mixed root+child session list, hitting the default limit, and only filtering root sessions client-side, so recent child sessions could crowd recent root sessions out of the picker.
I would not assume it resolves every report in this issue, though. Some comments here point at a different directory / project-scoping path after repo renames or path changes, so this PR is intended to cover the confirmed mixed-list / limit / root-filtering case rather than the whole issue family.
codeg-old commentedon May 9, 2026
I opened #26432 for this.
It avoids the earlier broad-bootstrap side effect by leaving the shared
sync.data.sessionlist unchanged and querying root sessions only inside the session switch dialog. It also avoids the 30-day bootstrap window for the default dialog list, preserves the existing scope/path filter, and includes a focused unit test for the query shape.Verified locally on the current
devbase with:bun test test/cli/tui/dialog-session-list.test.ts test/server/session-list.test.ts test/server/httpapi-sdk.test.ts --timeout 30000bun run typecheckbun run buildAuthorship disclosure: prepared with AI assistance.
EdgarSedov commentedon May 30, 2026
I’m affected by this too. #26432 looks like the best current rally point for the session picker visibility problem because it scopes the fix to the session switch dialog instead of changing broader session bootstrap behavior.
CasualDeveloper commentedon Jun 27, 2026
FYI: #33931 landed on dev and fixed the confirmed child-session dilution problem discussed here (closes #16270 and #32725).
That fix makes the TUI session switcher request root sessions directly. Before that, the switcher loaded a mixed root and child session page, hit the server limit, then filtered out child sessions on the client. In projects with many recent child sessions, most root sessions never reached the picker.
wsaaaqqq commentedon Jul 27, 2026
Feel your pain — session picker only showing a handful of recent ones despite hundreds in the db.
Built a workaround: oos
It reads the OpenCode SQLite db directly, so it searches ALL sessions from
ALL projects at once — no directory scoping, no pagination limits, no
subagent dilution.
https://github.com/wsaaaqqq/oos
MIT, one-liner install. Happy to take feedback.
github-actions commentedon Sep 26, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.