fix(tui): scope non-git sessions by directory, not hierarchical path#31210
fix(tui): scope non-git sessions by directory, not hierarchical path#31210malventano wants to merge 1 commit into
Conversation
PR anomalyco#24849 introduced hierarchical path filtering for git repos. But non-git projects set worktree = "/" (truthy), so sessionListQuery() never triggered the !worktree fallback and fell through to the path branch instead. path.relative("/", "/root/oc") -> "root/oc" then matched ALL sessions under /root/oc/ hierarchically, including sessions from unrelated subdirectories. Fix: - sync.tsx: check worktree === "/" explicitly, return { directory } for non-git projects so server-side eq(directory) matching is used - session.ts: pass directory: process.cwd() to CLI session list Closes anomalyco#8836, Closes anomalyco#18890, Closes anomalyco#19340, Closes anomalyco#26099, Closes anomalyco#28972, Closes anomalyco#9881
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicates FoundPR #29026 -
PR #29582 -
PR #20361 -
PR #29539 -
|
|
This PR focuses on non-git directory filtering, restoring the behavior to what it was pre-#24849 (while not impacting that PR's intent for git repos). The 4 potential duplicates address different problems:
All 4 remain open. None supersede this fix. |
Issue for this PR
Closes #8836, Closes #18890, Closes #19340, Closes #26099, Closes #28972, Closes #9881
Type of change
What does this PR do?
PR #24849 introduced hierarchical path filtering (
eq(path, X) OR like(path, X + "/%")) for git repos to support worktrees. But non-git projects setworktree = "/"(a truthy value), so the TUI'ssessionListQuery()check!worktreenever triggered — it fell through to thepathbranch instead.path.relative("/", "/root/oc")→"root/oc"then matched ALL sessions under/root/oc/hierarchically, including sessions from unrelated subdirectories.Changes:
packages/tui/src/context/sync.tsx: Checkworktree === "/"explicitly and return{ directory }for non-git projects so the server's existingeq(directory)fallback is used.packages/opencode/src/cli/cmd/session.ts: Passdirectory: process.cwd()to CLIsession listso it's also scoped.The server already has the
else if (scope !== "project")fallback that performseq(directory, ...)matching - no server changes needed. Git repo hierarchical filtering is untouched.How did you verify your code works?
Tested locally with a local build:
session listfrom a non-git directory shows only sessions from that directoryScreenshots / recordings
N/A - not a UI change.
Checklist