You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
api: session list by ?directory= returns nothing when the path has a trailing separator #53735
GET /api/session?directory=... returns zero sessions when the directory query parameter carries a trailing path separator (/ or \), while the same path without the trailing separator returns the sessions. The filter is otherwise tolerant (case- and separator-insensitive), so the trailing separator is an un-normalized special case.
Observed consequence: the TUI session list (ctrl+x l) can be empty in a directory that has sessions — the same sessions are visible via opencode session list and via ?directory= without the trailing separator.
Environment
opencode version: 2.0.24 (npm @opencode/cli)
OS: Microsoft Windows 10 Pro, win32 x64
Shells: Cygwin bash and pwsh; one project directory is a git repository
Reproduction
A project with sessions whose directory is D:/Users/strelok/.opencode-notes:
GET /api/session?directory=D:/Users/strelok/.opencode-notes&subpath -> 1
GET /api/session?directory=D:/Users/strelok/.opencode-notes/&subpath -> 0 (trailing /)
GET /api/session?directory=D:\Users\strelok\.opencode-notes&subpath -> 1
GET /api/session?directory=D:\Users\strelok\.opencode-notes\&subpath -> 0 (trailing \)
Same behaviour on a large project (50 = page limit, not the real count):
GET /api/session?directory=D:/MyDocs/My%20Devices/_lan/_OS/node3.home&subpath -> 50
GET /api/session?directory=D:/MyDocs/My%20Devices/_lan/_OS/node3.home/&subpath -> 0
Adding an explicit project parameter does not help: ?directory=.../&project=<id>&subpath also returns 0.
Expected Behavior
The directory filter should normalize the incoming path the same way it already handles case and separators — i.e. strip a trailing path separator before matching. A directory with a trailing separator should return the same sessions as without.
Actual Behavior
A single trailing separator turns the match into "no sessions".
Impact
The TUI session list for the current directory can be empty even though the sessions exist and are reachable. On the affected machine the TUI showed an empty list for D:\Users\strelok\.opencode-notes, while opening the same directory through a junction path (D:\home\strelok\.opencode-notes) showed the session. This is the same family of "sessions invisible in the list" issues as #53450 and #53454.
Suggested fix
Normalize the directory query parameter (and any path compared against it) by trimming trailing separators before matching, in both the API layer and the project/session listing path.
Thanks for the clear report! I could reproduce this on 2.0.24 (on Linux, with /):
Create a session in a directory, e.g. POST /api/session with {"location":{"directory":"<dir>"}}.
GET /api/session?directory=<dir>&subpath returns the session.
GET /api/session?directory=<dir>/&subpath returns {"data":[]}. Leaving out &subpath or encoding the slash as %2F gives the same result.
It looks like the directory filter compares the stored session directory with the query value exactly, so a trailing separator never matches. Oddly, opencode2 api GET /api/session --param directory=<dir>/ does return the session, so the CLI seems to normalize the value before sending it. I haven't checked the Windows-specific parts (trailing \, junction paths) or the TUI list myself.
Activity
github-actions commentedon Oct 7, 2026
This issue might be a duplicate of existing issues. Please check:
GET /api/sessiondirectory-filter mismatch that makes sessions disappear; it concerns path casing rather than a trailing separator.opencode-agent commentedon Oct 7, 2026
Thanks for the clear report! I could reproduce this on 2.0.24 (on Linux, with
/):POST /api/sessionwith{"location":{"directory":"<dir>"}}.GET /api/session?directory=<dir>&subpathreturns the session.GET /api/session?directory=<dir>/&subpathreturns{"data":[]}. Leaving out&subpathor encoding the slash as%2Fgives the same result.It looks like the
directoryfilter compares the stored session directory with the query value exactly, so a trailing separator never matches. Oddly,opencode2 api GET /api/session --param directory=<dir>/does return the session, so the CLI seems to normalize the value before sending it. I haven't checked the Windows-specific parts (trailing\, junction paths) or the TUI list myself.