7.3 KiB
Experimental Compact Worktree Cards
Problem
PR #2843 made compact one-line worktree cards the default in
src/renderer/src/components/sidebar/WorktreeCard.tsx:183 and
src/renderer/src/components/sidebar/WorktreeCard.tsx:557. The behavior is useful for dense
sidebars, but it is visually different enough that it should be trialed behind Experimental first.
Users also cannot infer why some cards remain two-line: the hidden row only disappears when it
would carry no distinct visible metadata.
Goal
Add an Experimental setting, off by default, that controls the compact-card behavior. When disabled,
workspace cards use the pre-compact layout: branch line stays visible, unread remains in the left
status column, PR/issue/comment/port badges stay in the metadata row, and the primary worktree uses
the pre-compact primary badge instead of the compact star. When enabled, keep the current compact
behavior from PR #2843.
Non-goals
- Do not redesign worktree card metadata.
- Do not remove card property settings such as PR, ports, issue, comment, unread, or status.
- Do not change SSH, GitLab/GitHub provider lookup, prompt-cache timer, or workspace port logic.
- Do not add per-repo or per-worktree compact preferences.
Design
- Add
experimentalCompactWorktreeCards: booleantoGlobalSettings, defaulting tofalse. - Add an Experimental pane toggle titled
Compact worktree cards. Copy must explain the rule: cards collapse only when the second line would be redundant or empty; real metadata such as a different branch, repo badge, conflict/cache state, or folder badge keeps the card taller. - In
WorktreeCard, deriveconst compactCards = settings?.experimentalCompactWorktreeCards === truefrom the existing settings read and branch layout:- Disabled: show branch row for non-folder worktrees, keep unread in the left column, keep
PR/issue/comment/port details in the metadata row, and show the pre-compact
primarybadge. - Enabled: use PR #2843 compact behavior, including title-row unread, details/ports cluster, and primary star.
- Disabled: show branch row for non-folder worktrees, keep unread in the left column, keep
PR/issue/comment/port details in the metadata row, and show the pre-compact
- Preserve the accessible title tooltip in
WorktreeTitleInlineRename; it is useful in both modes and replaces the nativetitleattribute. - Keep
CacheTimerpresentational. The card can still derive cache state, but the metadata-row gate must only use compact gating when the experimental flag is enabled. In disabled mode, render the metadata row even when the cache timer is inactive.
Data Flow
- Main process persistence loads settings via
getDefaultSettings(). - Renderer settings pane toggles
experimentalCompactWorktreeCardsthroughupdateSettings. WorktreeCardreadssettings?.experimentalCompactWorktreeCards === true; missing/null settings must behave as disabled so existing server-render tests and old profiles do not compact.- Card layout branches locally; no IPC, SSH, or provider data path changes.
Edge Cases
- Missing legacy setting hydrates to
false, so existing users get the less-surprising two-line default after upgrade. - Folder repos keep their folder badge in the metadata row in both modes.
- Custom display names keep branch metadata in compact mode because the branch differs.
- Repo-grouped cards with
hideRepoBadgecan become one-line only when compact mode is enabled and no other metadata is visible. - Active prompt-cache timer and conflict state keep the metadata row visible in compact mode.
- SSH cards keep the SSH icon on the title row in both modes.
- Sparse checkout badges, remote-branch conflict warnings, inline agents, and lineage child chips are independent rows/badges and must not be hidden by the compact toggle.
Test Plan
- Unit/render tests:
- default settings value is
false; - Experimental pane renders the toggle and explanatory copy;
- compact disabled renders a metadata row and branch when title equals branch;
- compact disabled keeps unread in the left status column, details/ports in the metadata row, and
the
primarybadge for the main worktree; - compact enabled hides the redundant metadata row;
- compact enabled moves unread/details/ports to the title row and uses the primary star;
- compact enabled preserves branch row when title differs from branch;
- title tooltip remains focusable and does not use native
title.
- default settings value is
- Validation:
- Electron screenshot with compact disabled: repeated branch cards are two-line.
- Electron screenshot with compact enabled: repeated branch cards collapse to one-line.
- Electron screenshot of Experimental setting showing explanatory copy.
UI Quality Bar
- Toggle follows existing Experimental pane layout, spacing, typography, and switch style.
- Copy is concise and explains what counts as metadata without teaching implementation details.
- Sidebar cards do not overlap, clip icons, or jump unexpectedly when the setting changes.
- Compact-disabled mode should look understandable rather than like an accidental regression.
Review Screenshots
- Experimental pane with
Compact worktree cardstoggle off. - Sidebar card list with compact disabled: repeated branch cards show the second line.
- Sidebar card list with compact enabled: repeated branch cards collapse to one line.
Rollout
- Add setting type/default/search entry/persistence tests.
- Add Experimental pane UI.
- Branch
WorktreeCardlayout behind the setting. - Update focused render tests.
- Validate with Electron screenshots.
Lightweight Eng Review
- Scope: Keep the PR to one persisted Experimental flag, one settings row, and local card layout branching. No new metadata model or card explanation surface.
- Architecture/data flow: Settings persistence already merges defaults with parsed settings; adding a default-off boolean is enough for old profiles and SSH/web clients because renderer state is hydrated from the same settings object.
- Failure modes covered:
- Old profiles unexpectedly compacting: default false.
- Toggle copy failing to explain mixed one-line/two-line cards: explicit description.
- Tests only checking branch text instead of row presence: use
data-worktree-card-meta-row. - Shipping a half-compact default: assert unread placement, details/ports placement, and primary badge/star per mode.
- Prompt-cache/conflict metadata disappearing: metadata-row gate keeps these rows in compact mode.
- Test coverage required:
src/shared/constants.test.tsfor default value.src/renderer/src/components/settings/ExperimentalPane.test.tsxor adjacent render test for settings copy/toggle behavior.src/renderer/src/components/sidebar/WorktreeCard.quick-actions.test.tsxfor enabled/disabled layout behavior.- Existing
WorktreeTitleInlineRename.test.tsxremains relevant for tooltip behavior.
- Performance/blast radius: Reuse the existing settings read in
WorktreeCard; no new polling, IPC, file watching, or provider calls. - UI quality bar: Settings row should match existing Experimental rows; sidebar must remain dense but mixed-height behavior should be explainable from the toggle copy.
- Required review screenshots:
- Experimental setting off.
- Sidebar compact disabled.
- Sidebar compact enabled.
- Residual risks: The mixed card heights are still inherently subtle; this PR explains the rule in settings but does not add per-card visible reasons.