-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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.