Scale sidebar workspace group header with sidebar font size (#5398)

Merged
AU
6mo ago
+172-12

Summary

Fixes #5398. cmux's sidebar font size is configurable via sidebar-font-size, and the workspace rows already scale with it — but the workspace group/folder header (the collapsible row with the chevron, folder icon, group name, unread badge, and + button) hardcoded every font size and frame, so enlarging the sidebar font left the header small and mismatched against the rows beneath it.

Root cause

SidebarWorkspaceGroupHeaderView (Sources/SidebarWorkspaceGroupHeaderView.swift) hardcoded every font (.system(size: 9/10/11)) and frame (14x14, 18x18) and never received the sidebar font scale. The workspace-row path threads settings.sidebarFontScale (= SidebarTabItemFontScale.scale(for:), 1.0 at the default size) into TabItemView and multiplies every size by it. The header is built at VerticalTabsSidebar+WorkspaceGroups.swift:77, where settings is already in scope, but the scale was never passed in.

Fix

  • Extracted the header's sizes/frames/badge padding into a pure, testable SidebarWorkspaceGroupHeaderMetrics value type that multiplies each base size by fontScale.
  • Added let fontScale: CGFloat to SidebarWorkspaceGroupHeaderView and included it in the Equatable == so a font-size change invalidates the header under the LazyVStack.
  • Threaded the existing settings.sidebarFontScale in at the call site — reusing the single scaling path that already feeds TabItemView, not adding a second one.
  • The header and the workspace rows now grow at the same rate.

The outer/inner HStack spacings stay fixed, matching TabItemView (which also keeps fixed spacing), so the row layout stays stable while glyphs/frames scale.

Tests

Two-commit red/green structure (SidebarWorkspaceGroupHeaderMetricsTests, Swift Testing):

  • Commit 1 extracts the metrics helper reflecting the current unscaled behavior plus a behavior-level test asserting the metrics scale at default (1.0) and enlarged (2.0) scales, and that the header reuses SidebarTabItemFontScale — CI goes red.
  • Commit 2 makes the metrics multiply by fontScale and wires the scale into the view + call site — CI goes green.

Test file is wired into the cmux unit test target in project.pbxproj (lint-pbxproj-test-wiring passes, 152 files).

Localization

No new user-facing strings.

🤖 Generated with Claude Code


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


[!NOTE]
Low Risk
Localized SwiftUI sizing and equatable snapshot changes for the group header, with unit tests and no auth or data-path changes.

Overview
Fixes workspace group/folder headers staying at fixed sizes when sidebar-font-size is increased, so they no longer look smaller than the workspace rows below them.

Introduces SidebarWorkspaceGroupHeaderMetrics with base design sizes multiplied by fontScale, and wires SidebarWorkspaceGroupHeaderView to use those metrics for chevron, icon, title, unread badge, and plus control instead of hardcoded .system(size:) and frames. The sidebar passes settings.sidebarFontScale (same path as TabItemView via SidebarTabItemFontScale) and includes fontScale in Equatable so font-size changes refresh the equatable header in the LazyVStack. Unit tests cover default, enlarged, and shrunk scaling plus shared scaling with row font scale.

Reviewed by Cursor Bugbot for commit 933425b23448345e45ff6de631c9ac2ec2bef7a4. Bugbot is set up for automated code reviews on this repo. Configure here.


Summary by cubic

Make the sidebar workspace group header scale with the configurable sidebar font size so it matches the workspace rows. Removes hardcoded sizes and uses the same scaling path as rows for consistent sizing.

  • Bug Fixes
    • Pass settings.sidebarFontScale into SidebarWorkspaceGroupHeaderView and include fontScale in Equatable to re-render on font-size change.
    • Centralize sizes in SidebarWorkspaceGroupHeaderMetrics, multiplying base values by the scale for icons, text, badge, and plus button.
    • Update the call site in VerticalTabsSidebar+WorkspaceGroups.swift; keep existing HStack spacings unchanged for stable layout.
    • Add SidebarWorkspaceGroupHeaderMetricsTests to verify scaling at default, enlarged, and shrunk sizes, and reuse of SidebarTabItemFontScale.

Summary by CodeRabbit

  • New Features

    • Sidebar workspace group headers accept a font scale and adjust chevrons, icons, names, unread badges, and action buttons so sizing and padding scale consistently with user font preferences.
  • Tests

    • Added tests verifying header metric defaults and proportional scaling behavior across different font scales.