Skip to content

TUI /sessions picker only shows recent sessions #13877

Closed as not planned
Closed as not planned

Description

@itzxSage

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.

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Feb 16, 2026
  2. dinhphieu commented on Mar 6, 2026

    @dinhphieu

    @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?

  3. ahmzaa commented on Mar 7, 2026

    @ahmzaa

    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.

  4. albertobissacco commented on Mar 7, 2026

    @albertobissacco

    I noticed some inconsistencies with session visibility:

    • Running opencode db "select count(*) as total_sessions from session;" gives 128 sessions, and opencode db "select count(*) as root_sessions from session where parent_id is null;" gives 104.
    • However, hitting /sessions shows only a few.
    • Using opencode session list shows all sessions.
    • When in a git repo, I only see sessions for that folder, not others.

    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.

  5. ahmzaa commented on Mar 7, 2026

    @ahmzaa

    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 ?

  6. CasualDeveloper commented on Apr 2, 2026

    @CasualDeveloper
    Contributor

    ahhh, so I wasn't going crazy! Was wondering where my sessions went lol

    Update: Dug into this on my local opencode fork (updated to dev tip 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 /sessions backend (and the Sessions dialog) was still hiding most of them because it was filtering by exact session.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_id matched.

    This looks like an interaction between b020758 (show all project sessions from any working directory), 68bb8ce (database-level session filtering), and c7760b4 (SDK rewrite that sends directory on /session requests).

  7. jiwangyihao commented on Apr 18, 2026

    @jiwangyihao

    There is now a related PR for one confirmed branch of the /sessions visibility problem: #23276 #23276

    That 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.

  8. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on May 3, 2026
  9. codeg-old commented on May 9, 2026

    @codeg-old

    I opened #26432 for this.

    It avoids the earlier broad-bootstrap side effect by leaving the shared sync.data.session list 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 dev base with:

    • bun test test/cli/tui/dialog-session-list.test.ts test/server/session-list.test.ts test/server/httpapi-sdk.test.ts --timeout 30000
    • bun run typecheck
    • bun run build

    Authorship disclosure: prepared with AI assistance.

  10. EdgarSedov commented on May 30, 2026

    @EdgarSedov

    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.

  11. CasualDeveloper commented on Jun 27, 2026

    @CasualDeveloper
    Contributor

    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.

  12. wsaaaqqq commented on Jul 27, 2026

    @wsaaaqqq

    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.

    • Type a keyword → real-time filter across every project
    • ↑/↓ to pick, Enter to resume the conversation
    • Multi-keyword AND + ! exclusion
    • Zero config, single binary

    https://github.com/wsaaaqqq/oos

    MIT, one-liner install. Happy to take feedback.

  13. github-actions commented on Sep 26, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions