Skip to content

feat: project-scoped session filtering#261

Open
emersonthis wants to merge 1 commit intosmtg-ai:mainfrom
emersonthis:filter-by-directory
Open

feat: project-scoped session filtering#261
emersonthis wants to merge 1 commit intosmtg-ai:mainfrom
emersonthis:filter-by-directory

Conversation

@emersonthis
Copy link

@emersonthis emersonthis commented Mar 6, 2026

When working across multiple projects, it is easy to mix up which agent instances belong to which project. This PR addresses this issue by scoping the list of instances to the current project. The original behavior is still available with an --all flag.

Summary

  • Filter sessions by the current git repo so only relevant sessions are shown when running cs from a project directory
  • Add --all / -a flag to bypass filtering and see all sessions
  • Display the project name in the list header when filtering is active
  • Non-matching sessions are preserved in storage and merged back on save — nothing is lost

Implementation

  • Export FindGitRepoRoot from session/git and resolve repo root in main.go
  • Add LoadInstanceData() and SaveInstancesWithExtra() to storage for data-level partitioning
  • Filter sessions in app.go by matching Worktree.RepoPath against the current repo root, with a fallback to Path prefix matching for older sessions
  • Only hydrate (connect to tmux) sessions that match the current project

Test plan

  • go build ./... compiles successfully
  • go test ./... passes
  • Run cs in repo A, create a session, quit. Run cs in repo B — repo A's session should not appear
  • Run cs --all — all sessions from all projects should be visible
  • Return to repo A — session is still there
  • Kill a session while filtering is active — other project sessions remain in storage

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@emersonthis
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

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.

1 participant