Skip to content

feat: add worktree grouping setting for sidebar#256

Merged
mattleaverton merged 6 commits intodanshapiro:mainfrom
mattleaverton:worktree-worktree-grouping-setting
Mar 30, 2026
Merged

feat: add worktree grouping setting for sidebar#256
mattleaverton merged 6 commits intodanshapiro:mainfrom
mattleaverton:worktree-worktree-grouping-setting

Conversation

@mattleaverton
Copy link
Copy Markdown
Collaborator

Summary

  • Switch Claude provider back to resolveGitRepoRoot (matching Codex and the original intent from revert: restore v0.7.0 stable state #208) so worktree sessions group under the parent repo by default
  • Add checkoutPath field to CodingCliSession — populated when the session's checkout root differs from the repo root
  • Add sidebar.worktreeGrouping setting ('repo' | 'worktree', default 'repo') as a per-browser local setting
  • Client-side buildSessionItems uses checkoutPath for subtitle and grouping when the setting is 'worktree'

Context

Sessions from git worktrees were always grouped as separate projects (each showing the worktree directory name). This was changed in Feb to fix a labeling issue where multiple worktrees all showed the same name. But it broke the original intent of grouping worktree sessions under the parent repo.

This PR provides both modes as a setting — "Repository" groups all worktrees under the repo name (cattle workflow), "Worktree" gives each worktree its own group (pets workflow).

Test plan

  • 3 new unit tests for worktree grouping modes (repo default, worktree mode, fallback)
  • All 25 sidebar selector tests pass
  • All 49 sessionsSlice tests pass
  • TypeScript compiles cleanly
  • Built and verified in Chrome — "Repository" mode shows repo name, switching to "Worktree" shows distinct worktree names per session

🤖 Generated with Claude Code

mattleaverton and others added 4 commits March 30, 2026 15:28
Switch Claude provider back to resolveGitRepoRoot (matching Codex and
Dan's original intent) so worktree sessions group under the parent repo.
Compute checkoutPath separately via resolveGitCheckoutRoot and include
it on sessions when it differs from projectPath.

This provides both paths: projectPath for repo-level grouping, and
checkoutPath for worktree-level grouping. A follow-up commit will add
the client-side setting to choose between them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add 'repo' | 'worktree' setting (default 'repo') to LocalSettings.sidebar.
Include normalizer, default value, merge/resolve support, and a dropdown
in WorkspaceSettings UI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…worktree'

buildSessionItems now accepts worktreeGrouping parameter and uses
session.checkoutPath as the effective project path for subtitle and
grouping when the setting is 'worktree'. Default 'repo' mode uses
projectPath as before.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three tests covering:
- Default 'repo' mode uses projectPath for subtitle
- 'worktree' mode uses checkoutPath when available
- Falls back to projectPath when no checkoutPath in worktree mode

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 661528d1bd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

provider: item.provider,
sessionId: item.sessionId,
projectPath: item.projectPath,
...(item.checkoutPath ? { checkoutPath: item.checkoutPath } : {}),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve checkoutPath in sidebar search results

The new worktree grouping depends on checkoutPath, but this change only threads that field through the snapshot grouping path; searchSessions() still maps directory items into SearchResult without checkoutPath, so when a sidebar query is active sessions revert to repo-level subtitles/grouping even if sidebar.worktreeGrouping is set to 'worktree'. Please carry checkoutPath through the search response and searchResultsToProjects so filtered and unfiltered sidebar views behave consistently.

Useful? React with 👍 / 👎.

mattleaverton and others added 2 commits March 30, 2026 15:41
…olve

# Conflicts:
#	test/unit/client/store/selectors/sidebarSelectors.test.ts
Add checkoutPath to SearchResult type and searchResultsToProjects
mapping so worktree grouping works consistently when a sidebar search
is active.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mattleaverton mattleaverton merged commit 8bfdcb4 into danshapiro:main Mar 30, 2026
1 check passed
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