fix(opencode): web UI sidebar not showing session history#17752
fix(opencode): web UI sidebar not showing session history#17752762278834 wants to merge 1 commit intoanomalyco:devfrom
Conversation
The /session API route used Session.list() which filters by Instance.project.id, causing empty results when sessions belong to a different project (e.g. "global"). Switch to Session.listGlobal() which queries across all projects. Also fix loadSessions to use sdkFor(directory) instead of globalSDK.client so the correct x-opencode-directory header is sent, and add case-insensitive path comparison in isRootVisibleSession for Windows compatibility. Fixes anomalyco#11331
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, I found two potentially related PRs:
These PRs appear to be addressing related session listing and compatibility issues. However, PR #17752 (the current PR) appears to be the most specific fix for the sidebar session history issue (#11331). |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #15108
Closes #14572
Related #11331
Type of change
What does this PR do?
Root cause: The
/sessionroute usesSession.list()which always filters byInstance.project.id(session/index.ts line 549). The project ID is derived from the directory whereopencode serveis started.Trigger condition: When the directory used to start
opencode serve(directory A, a git repo) differs from the directory where sessions were created (directory B, not a git repo or a different git repo), the project IDs do not match. Sessions from directory B getproject_id = "global", but the API filters by directory A's project ID (e.g.4b0ea68...), so the query returns zero results.This is easy to reproduce:
project_id = "global")opencode servefrom a git repo directory (project ID = git root commit hash)/sessionAPI returns[]becauseWHERE project_id = '4b0ea68...'does not match"global"Fix: Switch the
/sessionroute fromSession.list()toSession.listGlobal(), which queries across all projects without filtering byInstance.project.id. This matches the behavior of the experimental session endpoint.Also includes two frontend fixes:
global-sync.tsx: UsesdkFor(directory)instead ofglobalSDK.clientso the correctx-opencode-directoryheader is sent with session list requestshelpers.ts: Case-insensitive path comparison inisRootVisibleSessionfor Windows path compatibilityHow did you verify your code works?
opencode serve --hostname 127.0.0.1 --port 4096curl http://127.0.0.1:4096/sessionreturned[]project_id = "global"via sqlite3Screenshots / recordings
N/A - backend API fix, verified via curl and browser
Checklist