GeezerVison is showing github.com — feat(tui): add directory + project session filter modes by davidlewallen · Pull Request #32855 · anomalyco/opencode
Conversation
Problem
The TUI session-list directory filter is a single boolean (session_directory_filter_enabled): either hierarchical (current directory + all descendants) or whole project. There is no way to scope the list to exactly the current directory.
For anyone working in multiple git worktrees of the same repo, this is a real pain: sibling worktrees share a project_id, so the hierarchical/project modes always fold every worktree's sessions into each other's lists. There's no exact-match mode to keep them separate. (Refs #26099, which calls out this missing exact-match mode.)
Solution
Replace the boolean with a three-state mode stored in kv as session_filter_mode:
hierarchical — current directory and its descendants (default; unchanged behavior)
directory — exactly the current directory (isolates sibling worktrees)
project — every session in the project, regardless of directory
Details:
- TUI-only change. The server already accepts all three list query shapes (
{ path }, { directory }, { scope: "project" }) — this just selects which one to send. No server, config-schema, or SDK changes.
- Back-compat. The old
session_directory_filter_enabled boolean is still honored when session_filter_mode is unset (enabled → hierarchical, disabled → project), so no existing user loses their preference.
- Default preserved. With neither key set, behavior is identical to today.
- Follows the existing
thinking.ts pattern — literal-union + isSessionFilterMode type guard + nextSessionFilterMode cycle helper.
- The command-palette entry (
app.toggle.session_directory_filter, name unchanged so existing keybinds keep working) now cycles through the three modes.
Why this shape
A few deliberate tradeoffs, in case it helps reviewers weigh this against related work:
- Smallest surface that closes the gap. One source file + tests; the server already supports the query shapes, so nothing downstream changes.
- Keeps
hierarchical as the default. Monorepo users who rely on current-dir-plus-descendants see no change unless they opt in.
- Zero migration risk. Honors the legacy flag lazily; nothing is rewritten on disk.
Relationship to other PRs / issues
Testing
- Extended
packages/tui/test/cli/cmd/tui/sync.test.tsx to assert the list-query shape for each mode (path / directory / scope=project) and the legacy-flag fallback.
- Added
packages/tui/test/cli/tui/session-filter.test.ts unit-testing isSessionFilterMode and nextSessionFilterMode.
Refs #26099
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This PR doesn't fully meet our contributing guidelines and PR template.
What needs to be fixed:
- PR description is missing required template sections. Please use the PR template.
Please edit this PR description to address the above within 2 hours, or it will be automatically closed.
If you believe this was flagged incorrectly, please let a maintainer know.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The following comment was made by an LLM, it may be inaccurate:
I found one potentially related PR:
Related PR:
This PR is related because it also addresses session scoping by directory. It may be worth reviewing to ensure the two changes work well together or to understand if there's overlapping logic that needs coordination.
However, this doesn't appear to be a direct duplicate since #31210 is specifically about "non-git sessions" while #32855 is implementing a three-state filter mode for all sessions to solve the worktree isolation problem.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The session list directory filter was a boolean (session_directory_filter_enabled):
hierarchical (current dir + descendants) or whole-project. There was no way to
scope the list to exactly the current directory, so sibling git worktrees that
share a project_id always bled into each other's lists (issue anomalyco#26099).
Replace the boolean with a three-state mode stored in kv as session_filter_mode:
- hierarchical (default, unchanged behavior)
- directory (exact current dir; isolates worktrees)
- project (everything in the project)
The server already supports all three query shapes, so this is a TUI-only change.
The old boolean is still honored for back-compat (enabled->hierarchical, disabled->
project) until the user picks a mode. The command palette entry now cycles the three
modes. Follows the existing thinking.ts mode pattern (literal-union + type guard +
next* cycle helper).
Tests: extend tui/sync integration test to assert each mode's list query shape and
the legacy-flag fallback; add unit tests for isSessionFilterMode/nextSessionFilterMode.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.
Feel free to open a new pull request that follows our guidelines.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
Hona
Awaiting requested review from Hona
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|