diff --git a/docs-ai/050-sidebar-expand-active-and-worktree-tab-badges/000-plan.md b/docs-ai/050-sidebar-expand-active-and-worktree-tab-badges/000-plan.md index cd466c72..9773881c 100644 --- a/docs-ai/050-sidebar-expand-active-and-worktree-tab-badges/000-plan.md +++ b/docs-ai/050-sidebar-expand-active-and-worktree-tab-badges/000-plan.md @@ -145,3 +145,15 @@ _Each entry supersedes the draft above._ - Manual smoke: mixed repos (with/without tabs), workspace, plain folder; cycle through the three states; single- vs multi-worktree badge visibility. - `make check`, `make build-app`. + +## Amendments + +- 2026-07-25 (post-PR review by onevcat): **badges are exclusive per level, + not duplicated.** Showing `repo 5 / main 2 / other 3` simultaneously reads + as redundant. Revised rule supersedes Decisions #4's multi-worktree gate: + - git repo **collapsed** → header shows the aggregate count; + - git repo **expanded** → header badge hidden, every worktree row shows its + own count (single-worktree repos included — the `worktrees.count >= 2` + gate is removed, unifying the code path); + - workspaces keep the header badge even when expanded (child rows carry no + per-row count; Decisions #5 unchanged) and plain folders never expand. diff --git a/docs/components/repositories-and-worktrees.md b/docs/components/repositories-and-worktrees.md index 502e0a25..a00457d2 100644 --- a/docs/components/repositories-and-worktrees.md +++ b/docs/components/repositories-and-worktrees.md @@ -108,9 +108,10 @@ new worktree (see [custom-actions](custom-actions.md)). terminal tabs), then **Expand All**, then **Collapse All**. Expand Active is skipped when no repo (or every repo) has open tabs. Collapsed state is remembered. -- **Tab count badges:** a repo header shows its total open-tab count; in repos - with more than one worktree, each worktree row also shows its own count - (hidden at zero). +- **Tab count badges:** a collapsed repo header shows its total open-tab count; + expanding a git repo moves the count onto the individual worktree rows + (hidden at zero). Workspaces and plain folders always show the count on the + header. ## Archiving a worktree diff --git a/supacode/Features/Repositories/Views/RepositorySectionView.swift b/supacode/Features/Repositories/Views/RepositorySectionView.swift index a43265c5..0d3bb2e2 100644 --- a/supacode/Features/Repositories/Views/RepositorySectionView.swift +++ b/supacode/Features/Repositories/Views/RepositorySectionView.swift @@ -61,10 +61,16 @@ struct RepositorySectionView: View { ? (isExpanded ? "Collapse" : "Expand") : (repository.isWorkspace ? "Open terminal in workspace" : "Open terminal in folder") ) - RepoHeaderTabCountBadge( - repository: repository, - terminalManager: terminalManager - ) + // Expanded git repos move the count into the worktree rows, so the + // header stays quiet. Workspaces keep the header badge even when + // expanded (child rows carry no per-row count — tab attribution is + // by directory, not by child); plain folders never expand. + if !(isExpanded && repository.capabilities.supportsWorktrees) { + RepoHeaderTabCountBadge( + repository: repository, + terminalManager: terminalManager + ) + } } .frame(maxWidth: .infinity, alignment: .leading) .background { diff --git a/supacode/Features/Repositories/Views/WorktreeRow.swift b/supacode/Features/Repositories/Views/WorktreeRow.swift index a27a6828..bfdf6608 100644 --- a/supacode/Features/Repositories/Views/WorktreeRow.swift +++ b/supacode/Features/Repositories/Views/WorktreeRow.swift @@ -6,7 +6,7 @@ struct WorktreeRow: View { let worktreeName: String let info: WorktreeInfoEntry? /// Per-worktree open-tab count badge; `nil` hides the badge entirely - /// (single-worktree repos and workspace child rows pass nil). + /// (workspace child rows — tab attribution is per directory, not per child). let tabCountBadge: WorktreeTabCountBadge? let iconSystemName: String? let showsPullRequestInfo: Bool diff --git a/supacode/Features/Repositories/Views/WorktreeRowsView.swift b/supacode/Features/Repositories/Views/WorktreeRowsView.swift index 8f88d708..dc015e96 100644 --- a/supacode/Features/Repositories/Views/WorktreeRowsView.swift +++ b/supacode/Features/Repositories/Views/WorktreeRowsView.swift @@ -364,9 +364,7 @@ struct WorktreeRowsView: View { name: config.displayName, worktreeName: config.worktreeName, info: row.info, - tabCountBadge: repository.worktrees.count >= 2 - ? WorktreeTabCountBadge(worktreeID: row.id, terminalManager: terminalManager) - : nil, + tabCountBadge: WorktreeTabCountBadge(worktreeID: row.id, terminalManager: terminalManager), showsPullRequestInfo: !isWorktreeDragActive, isHovered: config.isHovered, isPinned: row.isPinned,