GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(tui): add directory + project session filter modes by davidlewallen · Pull Request #32855 · anomalyco/opencode

Conversation

@davidlewallen

@davidlewallen davidlewallen commented Jun 18, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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

  • fix(tui): scope non-git sessions by directory, not hierarchical path #31210 (fixes the non-git worktree = "/" path case) is complementary — it's a targeted bug fix and doesn't add a user-facing exact-directory mode for normal git repos.
  • fix(tui): scope session list to current worktree directory #29026 targets the pre-refactor TUI layout (packages/opencode/src/cli/cmd/tui/…) from before the move to packages/tui/, and has a larger surface (server + tests); it likely needs a rebase onto the current tree.
  • feat: add global session list scope toggle (local → project → global) #32750 adds a local → project → global cycle (new ctrl+g keybind in the /sessions dialog). It overlaps in spirit but on a different axis: it drops hierarchical and adds cross-project global. This PR instead keeps hierarchical (today's default) and stays in the existing command-palette entry. The two are composable — global could be added here as a fourth mode if desired. Happy to converge on whichever direction maintainers prefer.

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.

All reactions
@davidlewallen
davidlewallen requested review from Brendonovich and Hona as code owners June 18, 2026 15:54
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 18, 2026
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@davidlewallen
davidlewallen force-pushed the feat/session-filter-modes branch from 6955c71 to f6c3296 Compare June 18, 2026 15:55
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

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

I found one potentially related PR:

Related PR:

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

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@davidlewallen
davidlewallen force-pushed the feat/session-filter-modes branch from f6c3296 to ad3fede Compare June 18, 2026 16:04
@davidlewallen @claude
feat(tui): add directory + project session filter modes
8932620
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]>
@davidlewallen
davidlewallen force-pushed the feat/session-filter-modes branch from ad3fede to 8932620 Compare June 18, 2026 16:22
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 18, 2026
@github-actions github-actions Bot closed this Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Hona Hona Awaiting requested review from Hona
@Brendonovich Brendonovich Awaiting requested review from Brendonovich

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

1 participant

@davidlewallen
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.