Skip to content

[FEATURE]: Filter TUI session list by current directory/worktree #9881

@allisoneer

Description

@allisoneer

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem: Sessions are shared across all git worktrees of the same repository because they use projectID (first root commit hash) as the storage key. Users working with multiple worktrees see sessions from all worktrees mixed together, making it difficult to find relevant sessions.

Proposed Solution: Wire up the existing directory API filter so the TUI only shows sessions from the current working directory.

The infrastructure already exists:

  • API supports GET /session?directory=<path> (exact match filter)
  • tui() accepts a directory prop but it's never passed
  • SDK supports directory parameter in session.list()

Changes needed (TUI-only, no server changes):

  1. Pass directory: cwd to tui() call in thread.ts
  2. Add directory param to bootstrap session.list call in sync.tsx
  3. Filter session.updated realtime events by directory (prevent cross-worktree sessions appearing)
  4. Add directory param to session search in dialog-session-list.tsx

Alternatives considered:

  • Server-side auto-filter: Rejected because it changes behavior for all clients (web UI, API consumers may want cross-worktree visibility). TUI-only approach is purely additive.
  • Plugin approach: Not feasible - no plugin hook exists for session listing.
  • Hidden session field: Out of scope - separate feature that requires schema changes.

Known limitations:

  • Uses exact directory match (API behavior). Sessions created from a subdirectory won't appear when TUI is launched from repo root.
  • No config toggle - filtering is always-on (this is the expected UX for worktree users).

Happy to submit a PR if this approach sounds reasonable.

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions