Skip to content

fix(tui): scope non-git sessions by directory, not hierarchical path#31210

Open
malventano wants to merge 1 commit into
anomalyco:devfrom
malventano:fix/session-directory-filter
Open

fix(tui): scope non-git sessions by directory, not hierarchical path#31210
malventano wants to merge 1 commit into
anomalyco:devfrom
malventano:fix/session-directory-filter

Conversation

@malventano

@malventano malventano commented Jun 7, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #8836, Closes #18890, Closes #19340, Closes #26099, Closes #28972, Closes #9881

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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 set worktree = "/" (a truthy value), so the TUI's sessionListQuery() check !worktree never triggered — it 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.

Changes:

  1. packages/tui/src/context/sync.tsx: Check worktree === "/" explicitly and return { directory } for non-git projects so the server's existing eq(directory) fallback is used.
  2. packages/opencode/src/cli/cmd/session.ts: Pass directory: process.cwd() to CLI session list so it's also scoped.

The server already has the else if (scope !== "project") fallback that performs eq(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:

Screenshots / recordings

N/A - not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicates Found

PR #29026 - fix(tui): scope session list to current worktree directory

PR #29582 - fix(tui): show home sessions in global project

PR #20361 - fix(sdk): avoid implicit directory filtering on /session list

PR #29539 - fix(tui): handle non-git project paths in autocomplete and session fi…

@malventano

malventano commented Jun 7, 2026

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment