Repository navigation
fix(ui): remove scope=project from session list requests - #572
Conversation
OpenCode 1.17.10 has a bug in the /session endpoint: when scope=project is passed, it ignores the directory filter and returns ALL sessions across every project. This made the same session appear in every project tab in CodeNomad — deleting a session from one tab deleted it from all of them. The scope=project parameter was added in upstream PR NeuralNomadsAI#565 (commit e29c3a0) to avoid pagination limits on the default endpoint. With the directory filter ignored, that optimization becomes a correctness bug, so drop scope=project until OpenCode fixes the backend. With directory alone, the endpoint correctly returns only the sessions for the requested folder. Verified via curl on the running process: directory=/test returns 1 session (Hola greeting), directory=/idm returns 1 session (up). Co-Authored-By: Claude <[email protected]>
|
PR builds are available as GitHub Actions artifacts: Artifacts expire in 7 days.
|
|
@CodeNomadBot |
|
Gatekeeper review for latest PR state. I understand this PR as: remove Findings:
This should be updated before merge so the test now protects the intended behavior:
scope: "project"But Implementation assessment: The production-side fix in Regression risk: The main behavioral tradeoff is returning to a directory-only request with Validation performed:
Verdict: do not merge yet. The request-construction fix is correct, but the PR needs at least the focused test updated, and preferably the stale log corrected, before it passes a ruthless quality gate. -- |
Update buildProjectSessionListOptions test expectation to match the new request shape (no scope field). Also drop the stale scope field from the session-list log so the log reflects what is actually sent. Refs PR NeuralNomadsAI#572
|
PR builds are available as GitHub Actions artifacts: Artifacts expire in 7 days.
|
|
@CodeNomadBot |
|
Repeat gatekeeper review for latest PR state. I understand Findings: No blocking findings in the latest state. What changed since the prior review:
Implementation assessment: The implementation remains the right minimal fix. Validation performed: Result: passed, 3/3 tests. Result: failed in this checkout due broad dependency/type-resolution failures, starting with missing Quality notes:
Verdict: mergeable from this gatekeeper pass, assuming CI/build artifacts are otherwise green and the runtime validation in the PR description remains accurate. -- |
|
@pascalandr |
Analysis of the
|
| Directory | Project ID | Notes |
|---|---|---|
/home/dark/Project/idm |
f6d9b8cf… |
Single folder in this project |
/home/dark/Project/codenomad |
e3625924… |
Single folder |
/home/dark/Project/test |
global |
Non-git folder |
/home/dark/Project/tiktok |
global |
Non-git folder, same as /test |
Sessions in non-git folders are merged into a "global" project, so /test and /tiktok share the same project_id = global.
What the user-visible bug was
In a fresh CodeNomad tab for /test, the sidebar showed Hola greeting, Find Jellyfin IMDB lookup endpoint, and Automatizar publicaciones TikTok — the last one is /tiktok, not /test. Both folders are "global" in OpenCode, so scope=project returned both.
When I added directory=/home/dark/Project/test as well, OpenCode 1.17.9 on this build did not narrow the response. The user behavior I confirmed earlier (sidebar mixing sessions across folder tabs) lines up with that.
Worktree concern
I cannot reproduce a session-in-worktree scenario on this machine today, so I do not want to claim that scope=project is "safe to remove globally". The two paths I can think of:
- Sibling directories under the same git repo (the
bc5afa1…project): SQLite showsmemory-systemand the now-removedhackDarkboth hadproject_id = bc5afa1…. This is the only placescope=projectwould surface additional sessions in the same project. They are not literal git worktrees though —hackDarkwas just a normal sibling that OpenCode matched onto the same project row. If the desired behavior is "show all sessions in the same git repo across sibling folders", we have lost that with this PR. - Actual git worktree sessions (
.codenomad/worktrees/foo) — I do not have a reproducible case here. The behavior the previous PR fix(ui): scope project session list requests #565 added would have supported them, but I do not know if they ever appeared correctly underscope=projecteither, given the broader backend bug.
Concrete questions before merge
@shantur, can you confirm one of:
- Which exact
directoryvalue does the missing worktree session have in OpenCode DB? (x-opencode-directoryforwarded by CodeNomad, or the main repo path?) - When the worktree session is missing, does adding
scope=projectto the current request actually return it, or does it still ignoredirectory? - If the answer to (2) is "yes it does return it today on a fresh OpenCode 1.17.x", then a follow-up OpenCode bug to support both
directoryfiltering AND worktree-session inclusion is the right path — and this PR is the right temporary fix until that lands.
Without (2) being true, keeping scope=project does not actually solve the original issue #518 either; it only papers over one form of cross-folder leakage with another.
My read
- This PR fixes the reproducer I have (the one @pascalandr and I saw with
Hola greeting/TikTokshowing in/test). - The cost is potentially losing cross-sibling-folder visibility for
project_id-grouped sessions, which may or may not include real worktree sessions depending on OpenCode version. - I think the right next step is OpenCode upstreaming support for
{directory, scope=project}together, then re-addingscope=projecthere once that lands. Until then, removing it is strictly less buggy than keeping it on 1.17.x.
Happy to revise wording, add a test for the sibling-folder scenario, or split the change into two PRs if that helps. Just want to make sure the decision is based on the actual session data and not the original PR #565 description.
Restore scope=project on session list requests so worktree sessions remain visible through the OpenCode project-scoped endpoint, then filter the returned sessions client-side to the current root and known CodeNomad worktree directories. This keeps the original worktree-session requirement while avoiding unrelated cross-directory leakage when OpenCode ignores directory alongside project scope. Add focused tests for project-scoped request construction, root/worktree filtering, and Windows path normalization. Validation: npm exec tsx -- --test packages/ui/src/stores/session-pagination.test.ts; npm run typecheck --workspace @codenomad/ui; npm run build --workspace @codenomad/ui; npm run build:tauri.
|
@JDis03 To answer your analysis more directly: I agree with the distinction you made. I pushed a comit to try to preserve both requirements:
So this avoids the blanket removal of This should be a safer temporary client-side workaround until OpenCode supports Validation passed: focused session pagination tests, UI typecheck, UI build, and Tauri release build/manual exe launch. |
|
PR builds are available as GitHub Actions artifacts: Artifacts expire in 7 days.
|
|
I want you to perform the gatekeeper checks for latest PR state check for regressions |
|
Gatekeeper review for latest PR state. I understand the latest request as: re-run the ruthless quality gate after the PR changed direction from blanket Findings: No blocking findings in the latest state. Implementation assessment: The current approach is materially better than the previous blanket removal because it preserves the #565 requirement that project/worktree sessions remain discoverable while still mitigating the OpenCode 1.17.x bug where The key path is now:
Regression checks:
Validation performed: Result: passed, 5/5 tests. Result: failed in this checkout because dependencies/types are broadly unresolved, starting with missing Result: failed in this checkout because Residual risks / quality notes:
Verdict: mergeable from this gatekeeper pass, assuming CI artifacts/builds from a dependency-complete environment are green and the manual validation described in the thread remains accurate. -- |
|
PR builds are available as GitHub Actions artifacts: Artifacts expire in 7 days.
|
Problem
PR #565 (commit e29c3a0) added
scope=projectto session list requests to avoid pagination limits. With OpenCode 1.17.x, the/sessionendpoint ignores thedirectoryfilter whenscope=projectis present and returns all sessions from the global SQLite database instead.This makes the same session appear in every project tab. Deleting a session from one tab deletes it from the shared DB, affecting all of them.
Reproduction
Related: anomalyco/opencode#33113
Fix
Drop
scope: "project"frombuildProjectSessionListOptions(). Thedirectoryparameter alone correctly filters sessions to the requested folder on OpenCode 1.17.x.scope: "project"can be reintroduced once the backend respectsdirectoryalongside it.Validation
directory=/test→ 1 session (correct)directory=/idm→ 1 session (correct)