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

Closed
opened 2026-02-16 18:06:12 -05:00 by yindo · 2 comments
Owner

Originally created by @allisoneer on GitHub (Jan 21, 2026).

Originally assigned to: @thdxr on GitHub.

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.

Originally created by @allisoneer on GitHub (Jan 21, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] 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.
yindo added the opentui label 2026-02-16 18:06:12 -05:00
yindo closed this issue 2026-02-16 18:06:12 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 21, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #8836: Session list is showing all sessions instead of scoped to current directory (exact same symptom)
  • #6696: Project ID collision when repos cloned from same source share sessions (related root cause)
  • #6697: Session switching doesn't change working directory context (related issue with directory context)
  • #5638: Multiple git worktrees from same repo replace existing project (same root cause for worktrees)
  • #9553: Plugin hook for filtering session list in /sessions dialog (alternative approach for filtering)
  • #3758: General session filters feature request

Feel free to ignore if these don't address your specific case. Issue #8836 in particular seems to describe the exact same symptom you're addressing with this feature request.

@github-actions[bot] commented on GitHub (Jan 21, 2026): This issue might be a duplicate of existing issues. Please check: - #8836: Session list is showing all sessions instead of scoped to current directory (exact same symptom) - #6696: Project ID collision when repos cloned from same source share sessions (related root cause) - #6697: Session switching doesn't change working directory context (related issue with directory context) - #5638: Multiple git worktrees from same repo replace existing project (same root cause for worktrees) - #9553: Plugin hook for filtering session list in /sessions dialog (alternative approach for filtering) - #3758: General session filters feature request Feel free to ignore if these don't address your specific case. Issue #8836 in particular seems to describe the exact same symptom you're addressing with this feature request.
Author
Owner

@allisoneer commented on GitHub (Jan 21, 2026):

Closing as duplicate of #8836.

The existing issue #8836 tracks this same problem, and there are already two open PRs attempting to fix it:

  • PR #8886 - client-side filtering in the session list dialog
  • PR #6724 - server-side filtering with --all opt-out

I've added a comment to #8836 with analysis of these approaches and a proposed more complete solution.

@allisoneer commented on GitHub (Jan 21, 2026): Closing as duplicate of #8836. The existing issue #8836 tracks this same problem, and there are already two open PRs attempting to fix it: - PR #8886 - client-side filtering in the session list dialog - PR #6724 - server-side filtering with `--all` opt-out I've added a comment to #8836 with analysis of these approaches and a proposed more complete solution.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7105