anomalyco / anomalyco/opencode
tui: session picker only shows sessions from the 50 most recently updated across all projects
@simonklee is already working on this.
Since Sep 14, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
The TUI session picker requests the 50 most recently updated sessions across all projects (GET /api/session with no parameters) and then filters them client-side by the current directory. In an active multi-project setup, any session older than the newest ~50 sessions globally becomes unreachable from the picker — the session exists, the server can return it, but the TUI never asks for it and offers no server-side search. This makes old sessions look "lost" (a frequent report in this repo), especially after upgrading or migrating sessions.
Environment
- opencode version: 2.0.1
- OS: macOS (Darwin 27.0.0, arm64)
- Terminal: WezTerm (xterm-256color, truecolor)
- Shell: /bin/zsh
- Install/channel: local, v2 line
- Active plugins: none (
plugins: [])
Reproduction
- Have a project with a session last updated 2+ days ago (project A), and work in other projects so that 50+ sessions across all projects get updated more recently.
- Open the TUI in project A and open the session list.
- The old session of project A does not appear.
Instrumentation (all verified on my machine):
- Server log shows the TUI issues
GET /api/sessionwith no query parameters. - The bare endpoint returns the 50 most recently updated sessions globally (time range of the response was "today only", while the DB contains 1000+ sessions).
- The TUI then filters that response client-side by directory: only the single session created today in the current project remains visible.
- The server API itself is correct —
GET /api/session?directory=<cwd>returns all sessions of the project including old ones, andGET /api/session?directory=<cwd>&search=<term>finds old sessions by title. - The picker's filter is client-side only: the server log contains no
?search=or?cursor=requests from the TUI, so typing in the picker cannot reach sessions outside the loaded 50.
Concretely: a session updated 2 days ago was the 51st+ newest globally (96 sessions updated after it), so it was invisible in the TUI of its own project, while opencode session list (per-project, default 100) and the directory-scoped API both returned it immediately.
Expected Behavior
The session picker should list sessions scoped to the current project/directory (matching opencode session list behavior), and/or perform server-side search across all sessions of the project instead of filtering only the already-loaded 50.
Actual Behavior
The picker shows only the intersection of (globally 50 most recently updated sessions) × (current directory). In active multi-project usage this quickly becomes just "today's sessions", and older sessions are unreachable through the TUI.
Additional Context
- Workaround:
opencode -s <session-id>andopencode session listwork correctly per project; alsoopencode api get "/api/session?directory=$PWD&search=..."can locate old session IDs. - Discovered while investigating a V1→V2 migration report of "disappearing sessions": the data was intact in
opencode.dband correctly migrated; the picker was simply never requesting it. - Related reports (same user-visible symptom, different angles): #39064 (after update,
/sessionsonly shows today's sessions), #46832 (Desktop search only covers the loaded subset), #46123 (feature request: configurable list limit / show all).
Happy to provide additional log excerpts if useful.
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.