TUI /sessions picker only shows recent sessions #9484

Open
opened 2026-02-16 18:12:33 -05:00 by yindo · 0 comments
Owner

Originally created by @itzxSage on GitHub (Feb 16, 2026).

Originally assigned to: @rekram1-node on GitHub.

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: opencode 1.2.5 (opencode-ai npm 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

  • /sessions shows all sessions (or at least provides pagination/scrolling to reach older sessions), so the user can select any session to switch.

Actual Behavior

  • /sessions picker 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:

  1. Implicit start: The picker request injects a start timestamp (e.g., now minus N days), cutting off older sessions.
  2. Default limit + root filtering: The server-side session list uses a hardcoded default limit (commonly 100) and sorts by time_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 /sessions picker request does not apply an implicit start filter.
  • 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.

Originally created by @itzxSage on GitHub (Feb 16, 2026). Originally assigned to: @rekram1-node on GitHub. # 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: `opencode` 1.2.5 (`opencode-ai` npm 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 - `/sessions` shows *all* sessions (or at least provides pagination/scrolling to reach older sessions), so the user can select any session to switch. ## Actual Behavior - `/sessions` picker 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: ```bash 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 ```bash 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: 1. **Implicit `start`**: The picker request injects a `start` timestamp (e.g., now minus N days), cutting off older sessions. 2. **Default `limit` + root filtering**: The server-side session list uses a hardcoded default `limit` (commonly 100) and sorts by `time_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 `/sessions` picker request does not apply an implicit `start` filter. - 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.
yindo added the opentui label 2026-02-16 18:12:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9484