Skip to content

Comments

fix(session): scope session list and TUI to current directory#14489

Open
Aegis-commits wants to merge 1 commit intoanomalyco:devfrom
Aegis-commits:fix/session-directory-scoping
Open

fix(session): scope session list and TUI to current directory#14489
Aegis-commits wants to merge 1 commit intoanomalyco:devfrom
Aegis-commits:fix/session-directory-scoping

Conversation

@Aegis-commits
Copy link

@Aegis-commits Aegis-commits commented Feb 20, 2026

Issue for this PR

Closes #8836

Type of change

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

What does this PR do?

The TUI and CLI session list show sessions from ALL directories instead of scoping to the current working directory.

The root cause is in thread.ts — the normal TUI startup path never passes directory to tui(), so sdk.directory is undefined throughout the entire TUI lifecycle. All downstream directory filtering silently becomes a no-op. Only attach.ts (remote attach) correctly passed directory.

The fix:

  1. thread.ts — Pass directory: cwd to tui(). This is the root fix that makes everything else work.
  2. sdk.tsx — Expose directory on the SDK context return so downstream consumers can read it.
  3. sync.tsx — Pass sdk.directory to the bootstrap session.list() call so the initial load is filtered. Also guard SSE session inserts — if the incoming session's directory doesn't match sdk.directory, don't insert it (existing sessions can still update).
  4. dialog-session-list.tsx — Pass sdk.directory to search queries, with sync.data.path.directory as fallback.
  5. session.ts — CLI session list passes Instance.directory to Session.list().

The server already supports directory filtering in Session.list() (line 518-520 of session/index.ts) — it just was never being passed from the TUI path.

Supersedes #14443 (closed — missed the thread.ts root cause).

How did you verify your code works?

  • Built a patched binary and installed it locally
  • CLI verification: patched binary shows 13 sessions for a specific directory vs 25 sessions (all directories leaked) with the stock binary, from the same working directory
  • TUI verification: opened opencode from two different project directories, /sessions dialog shows only sessions belonging to each respective directory
  • bun turbo typecheck passes 12/12 packages
  • No new dependencies added

Screenshots / recordings

N/A — this is a data filtering fix, not a UI change. The session list looks identical, it just shows the correct subset of sessions.

Checklist

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

Pass the existing `directory` parameter to all session list call sites
that were missing it, so sessions are filtered to the current working
directory instead of showing all sessions globally.

Fixes four entry points:
- CLI `session list` command
- TUI bootstrap session fetch
- TUI /sessions dialog search
- TUI SSE session.updated event handler (new session inserts)

Uses the existing Session.list() directory filter and GET /session?directory=
API parameter — no server or API contract changes required.

Fixes anomalyco#8836
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Feb 20, 2026
@github-actions
Copy link
Contributor

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

Based on my search, I found several related PRs that address similar issues:

Potentially Related PRs:

  1. fix(tui): scope session list to current directory (#8836) #8886 — "fix(tui): scope session list to current directory (session list is showing all sessions not only the ones scopes to the curent dir #8836)"

  2. fix: pass directory to tui() in thread.ts #13630 — "fix: pass directory to tui() in thread.ts"

  3. fix(tui): pass directory to tui() to fix session loading #13602 — "fix(tui): pass directory to tui() to fix session loading"

    • Similar fix targeting the TUI directory parameter issue.
  4. feat(opencode): add session workspace directories and searchable add-directory UX. #14244 — "feat(opencode): add project navigation to /session dialog in TUI"

    • Related feature work on session workspace directories and directory-aware session management.
  5. feat(session): filter sessions by current directory #6724 — "feat(session): filter sessions by current directory"

    • Earlier feature that attempted to address session filtering by directory.

Note: PR #14489 explicitly states it "Supersedes #14443" — you may want to verify that #14443 has been closed to avoid confusion.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Feb 20, 2026
@github-actions
Copy link
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session list is showing all sessions not only the ones scopes to the curent dir

1 participant