From a34801934d931b9d30ec08d26becc37bf1f566fe Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Thu, 18 Jun 2026 16:28:37 -0700 Subject: [PATCH] Keep automation off by default in compact workspace cards (#5740) --- src/main/persistence.test.ts | 42 +++-- src/main/persistence.ts | 23 ++- src/main/runtime/orca-runtime.test.ts | 32 +++- src/main/runtime/orca-runtime.ts | 7 +- .../runtime/rpc/methods/client-ui.test.ts | 10 +- src/main/runtime/rpc/methods/client-ui.ts | 2 + .../sidebar/WorktreeCard.pr-display.test.tsx | 39 ++++- .../WorktreeCardDisplayMenuSection.test.tsx | 156 ++++++++++++++++++ .../WorktreeCardDisplayMenuSection.tsx | 8 +- src/renderer/src/i18n/locales/en.json | 1 + src/renderer/src/i18n/locales/es.json | 3 +- src/renderer/src/web/web-preload-api.test.ts | 16 +- src/renderer/src/web/web-preload-api.ts | 6 + src/shared/constants.ts | 1 + src/shared/worktree-card-properties.test.ts | 20 ++- src/shared/worktree-card-properties.ts | 40 ++++- 16 files changed, 359 insertions(+), 47 deletions(-) create mode 100644 src/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.test.tsx diff --git a/src/main/persistence.test.ts b/src/main/persistence.test.ts index 7decc4fa3..9618b1343 100644 --- a/src/main/persistence.test.ts +++ b/src/main/persistence.test.ts @@ -5210,7 +5210,7 @@ describe('Store', () => { expect(store.getUI().worktreeCardProperties).not.toContain('inline-agents') }) - it('uses the default preset when card properties are missing', async () => { + it('uses the compact preset when card properties are missing in compact mode', async () => { writeDataFile({ schemaVersion: 1, repos: [], @@ -5223,19 +5223,37 @@ describe('Store', () => { const store = await createStore() expect(store.getSettings().compactWorktreeCards).toBe(true) - expect(store.getUI().worktreeCardProperties).toEqual([ - 'status', - 'unread', - 'issue', - 'linear-issue', - 'pr', - 'automation', - 'comment', - 'ports', - 'inline-agents' - ]) + expect(store.getUI().worktreeCardProperties).toEqual(['status', 'unread']) + expect(store.getUI().worktreeCardProperties).not.toContain('automation') }) + it.each([ + ['raw', ['status', 'automation']], + ['normalized', ['status', 'unread', 'automation']] + ] as const)( + 'migrates the old %s defaulted compact preset without automation', + async (_, props) => { + writeDataFile({ + schemaVersion: 1, + repos: [], + worktreeMeta: {}, + settings: { compactWorktreeCards: true }, + ui: { + worktreeCardProperties: [...props], + _worktreeCardModeDefaulted: true + }, + githubCache: { pr: {}, issue: {} }, + workspaceSession: {} + }) + const store = await createStore() + + expect(store.getSettings().compactWorktreeCards).toBe(true) + expect(store.getUI().worktreeCardProperties).toEqual(['status', 'unread']) + expect(store.getUI().worktreeCardProperties).not.toContain('automation') + expect(store.getUI()._worktreeCardModeDefaulted).toBe(true) + } + ) + // ── GitHub Cache ─────────────────────────────────────────────────── it('get/set GitHub cache round-trips', async () => { diff --git a/src/main/persistence.ts b/src/main/persistence.ts index 3a374ba7c..8a140d4cd 100644 --- a/src/main/persistence.ts +++ b/src/main/persistence.ts @@ -89,6 +89,8 @@ import { getDefaultUIState, getDefaultRepoHookSettings, getDefaultWorkspaceSession, + getWorktreeCardModeProperties, + isLegacyDefaultedCompactWorktreeCardProperties, normalizeAgentActivityDisplayMode, normalizeWorktreeCardProperties, ONBOARDING_FLOW_VERSION, @@ -2651,6 +2653,10 @@ export class Store { this.loadNeedsSave = true } const normalizedProjectGroups = normalizeProjectGroups(parsed.projectGroups) + const loadedCompactWorktreeCards = + parsed.settings?.compactWorktreeCards ?? + parsed.settings?.experimentalCompactWorktreeCards ?? + defaults.settings.compactWorktreeCards result = { ...defaults, ...parsed, @@ -2691,10 +2697,7 @@ export class Store { experimentalActivityDefaultedOffForAllUsers: true, // Why: compact worktree cards graduated from Experimental; preserve // the old opt-in for profiles written during the rollout. - compactWorktreeCards: - parsed.settings?.compactWorktreeCards ?? - parsed.settings?.experimentalCompactWorktreeCards ?? - defaults.settings.compactWorktreeCards, + compactWorktreeCards: loadedCompactWorktreeCards, experimentalCompactWorktreeCards: undefined, terminalMacOptionAsAlt: migratedOptionAsAlt, terminalMacOptionAsAltMigrated: true, @@ -2797,10 +2800,17 @@ export class Store { !deliberateUncheck && Array.isArray(rawCardProps) && !rawCardProps.includes('inline-agents') + const needsLegacyDefaultedCompactMigration = + loadedCompactWorktreeCards && + parsed.ui?._worktreeCardModeDefaulted === true && + isLegacyDefaultedCompactWorktreeCardProperties(rawCardProps) const migratedCardProps = (() => { if (!Array.isArray(rawCardProps)) { return undefined } + if (needsLegacyDefaultedCompactMigration) { + return getWorktreeCardModeProperties('Compact') + } const candidate = needsInlineAgentsMigration ? [...rawCardProps, 'inline-agents' as const] : rawCardProps @@ -2845,6 +2855,11 @@ export class Store { } return { ...defaults.ui, + // Why: missing card properties should follow the persisted card + // layout mode; explicit property choices are preserved below. + worktreeCardProperties: getWorktreeCardModeProperties( + loadedCompactWorktreeCards ? 'Compact' : 'Default' + ), ...stripMainOwnedTelemetryMarkerFromUI(parsed.ui), // Why: migrate once from the retired Appearance setting only // when no explicit persisted chrome preference exists yet. diff --git a/src/main/runtime/orca-runtime.test.ts b/src/main/runtime/orca-runtime.test.ts index 756f72449..995045068 100644 --- a/src/main/runtime/orca-runtime.test.ts +++ b/src/main/runtime/orca-runtime.test.ts @@ -1113,22 +1113,27 @@ computeWorktreePathMock.mockImplementation( ensurePathWithinWorkspaceMock.mockImplementation((targetPath: string) => targetPath) describe('OrcaRuntimeService', () => { - it('projects experimentalNewWorktreeCardStyle to paired client settings', () => { + it('projects worktree card display settings to paired clients', () => { const runtime = new OrcaRuntimeService({ ...store, getSettings: () => ({ ...store.getSettings(), - experimentalNewWorktreeCardStyle: true + experimentalNewWorktreeCardStyle: true, + compactWorktreeCards: true }) } as never) - expect(runtime.getClientSettings()).toMatchObject({ experimentalNewWorktreeCardStyle: true }) + expect(runtime.getClientSettings()).toMatchObject({ + experimentalNewWorktreeCardStyle: true, + compactWorktreeCards: true + }) }) - it('accepts experimentalNewWorktreeCardStyle updates from paired clients', () => { + it('accepts worktree card display setting updates from paired clients', () => { let settings = { ...store.getSettings(), - experimentalNewWorktreeCardStyle: false + experimentalNewWorktreeCardStyle: false, + compactWorktreeCards: false } const updateSettings = vi.fn((updates: Partial) => { settings = { ...settings, ...updates } @@ -1140,14 +1145,23 @@ describe('OrcaRuntimeService', () => { updateSettings } as never) - expect(runtime.updateClientSettings({ experimentalNewWorktreeCardStyle: true })).toMatchObject({ - experimentalNewWorktreeCardStyle: true + expect( + runtime.updateClientSettings({ + experimentalNewWorktreeCardStyle: true, + compactWorktreeCards: true + }) + ).toMatchObject({ + experimentalNewWorktreeCardStyle: true, + compactWorktreeCards: true }) expect(updateSettings).toHaveBeenCalledWith( - { experimentalNewWorktreeCardStyle: true }, + { experimentalNewWorktreeCardStyle: true, compactWorktreeCards: true }, { notifyListeners: true } ) - expect(runtime.getClientSettings()).toMatchObject({ experimentalNewWorktreeCardStyle: true }) + expect(runtime.getClientSettings()).toMatchObject({ + experimentalNewWorktreeCardStyle: true, + compactWorktreeCards: true + }) }) it('rejects relative paths for runtime nested repo scan/import', async () => { diff --git a/src/main/runtime/orca-runtime.ts b/src/main/runtime/orca-runtime.ts index d20b86a7c..9a8bc2d0a 100644 --- a/src/main/runtime/orca-runtime.ts +++ b/src/main/runtime/orca-runtime.ts @@ -714,6 +714,7 @@ type RuntimeStore = { defaultLinearTeamSelection?: GlobalSettings['defaultLinearTeamSelection'] githubProjects?: GlobalSettings['githubProjects'] experimentalNewWorktreeCardStyle?: GlobalSettings['experimentalNewWorktreeCardStyle'] + compactWorktreeCards?: GlobalSettings['compactWorktreeCards'] gitlabProjects?: GlobalSettings['gitlabProjects'] experimentalWorktreeSymlinks?: boolean mobileAutoRestoreFitMs?: number | null @@ -2081,6 +2082,7 @@ export class OrcaRuntimeService { | 'defaultLinearTeamSelection' | 'githubProjects' | 'experimentalNewWorktreeCardStyle' + | 'compactWorktreeCards' > { if (!this.store?.getSettings) { throw new Error('runtime_unavailable') @@ -2099,7 +2101,8 @@ export class OrcaRuntimeService { defaultRepoSelection: settings.defaultRepoSelection ?? null, defaultLinearTeamSelection: settings.defaultLinearTeamSelection ?? null, githubProjects: settings.githubProjects, - experimentalNewWorktreeCardStyle: settings.experimentalNewWorktreeCardStyle === true + experimentalNewWorktreeCardStyle: settings.experimentalNewWorktreeCardStyle === true, + compactWorktreeCards: settings.compactWorktreeCards === true } } @@ -2118,6 +2121,7 @@ export class OrcaRuntimeService { | 'defaultLinearTeamSelection' | 'githubProjects' | 'experimentalNewWorktreeCardStyle' + | 'compactWorktreeCards' > ): Pick< GlobalSettings, @@ -2134,6 +2138,7 @@ export class OrcaRuntimeService { | 'defaultLinearTeamSelection' | 'githubProjects' | 'experimentalNewWorktreeCardStyle' + | 'compactWorktreeCards' > { if (!this.store?.getSettings || !this.store.updateSettings) { throw new Error('runtime_unavailable') diff --git a/src/main/runtime/rpc/methods/client-ui.test.ts b/src/main/runtime/rpc/methods/client-ui.test.ts index bdb35cd2c..4baba6aef 100644 --- a/src/main/runtime/rpc/methods/client-ui.test.ts +++ b/src/main/runtime/rpc/methods/client-ui.test.ts @@ -21,6 +21,7 @@ describe('client UI RPC methods', () => { visibleTaskProviders: ['github', 'gitlab'], defaultRepoSelection: ['repo-1'], defaultLinearTeamSelection: ['team-1'], + compactWorktreeCards: true, githubProjects: { pinned: [], recent: [], @@ -51,6 +52,7 @@ describe('client UI RPC methods', () => { defaultRepoSelection: ['repo-1', 'repo-2'], defaultLinearTeamSelection: ['team-1', 'team-2'], experimentalNewWorktreeCardStyle: true, + compactWorktreeCards: true, githubProjects: { pinned: [], recent: [], @@ -74,6 +76,7 @@ describe('client UI RPC methods', () => { visibleTaskProviders: ['github', 'linear'], defaultTaskViewPreset: 'my-prs', experimentalNewWorktreeCardStyle: true, + compactWorktreeCards: true, defaultRepoSelection: settings.defaultRepoSelection, defaultLinearTeamSelection: ['team-1', 'team-2'], githubProjects: settings.githubProjects @@ -87,6 +90,7 @@ describe('client UI RPC methods', () => { visibleTaskProviders: ['github', 'linear'], defaultTaskViewPreset: 'my-prs', experimentalNewWorktreeCardStyle: true, + compactWorktreeCards: true, defaultRepoSelection: settings.defaultRepoSelection, defaultLinearTeamSelection: ['team-1', 'team-2'], githubProjects: settings.githubProjects @@ -170,7 +174,7 @@ describe('client UI RPC methods', () => { it('accepts persisted literal UI arrays and nested UI state', async () => { const updated: PersistedUIState = { ...getDefaultUIState(), - worktreeCardProperties: ['status', 'branch', 'inline-agents'], + worktreeCardProperties: ['status', 'branch', 'automation', 'inline-agents'], _worktreeCardModeDefaulted: true, statusBarItems: ['codex'], taskResumeState: { @@ -206,7 +210,7 @@ describe('client UI RPC methods', () => { const dispatcher = new RpcDispatcher({ runtime, methods: CLIENT_UI_METHODS }) const payload = { - worktreeCardProperties: ['status', 'branch', 'inline-agents'], + worktreeCardProperties: ['status', 'branch', 'automation', 'inline-agents'], _worktreeCardModeDefaulted: true, statusBarItems: ['codex'], taskResumeState: { @@ -239,7 +243,7 @@ describe('client UI RPC methods', () => { expect(runtime.updateUIState).toHaveBeenCalledWith({ ...payload, - worktreeCardProperties: ['status', 'unread', 'branch', 'inline-agents'] + worktreeCardProperties: ['status', 'unread', 'branch', 'automation', 'inline-agents'] }) expect(response).toMatchObject({ ok: true, result: { ui: updated } }) }) diff --git a/src/main/runtime/rpc/methods/client-ui.ts b/src/main/runtime/rpc/methods/client-ui.ts index d7018abb0..78e244081 100644 --- a/src/main/runtime/rpc/methods/client-ui.ts +++ b/src/main/runtime/rpc/methods/client-ui.ts @@ -31,6 +31,7 @@ const LegacyWorktreeCardProperty = z.enum([ 'issue', 'linear-issue', 'pr', + 'automation', 'comment', 'ports', 'inline-agents' @@ -140,6 +141,7 @@ const SettingsUpdate = z agentStatusHooksEnabled: z.boolean().optional(), defaultRepoSelection: z.array(z.string()).nullable().optional(), defaultLinearTeamSelection: z.array(z.string()).nullable().optional(), + compactWorktreeCards: z.boolean().optional(), githubProjects: GitHubProjectSettings.optional() }) .strict() diff --git a/src/renderer/src/components/sidebar/WorktreeCard.pr-display.test.tsx b/src/renderer/src/components/sidebar/WorktreeCard.pr-display.test.tsx index f3866e257..2555d4c35 100644 --- a/src/renderer/src/components/sidebar/WorktreeCard.pr-display.test.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCard.pr-display.test.tsx @@ -3,6 +3,7 @@ import type { ReactNode } from 'react' import { beforeEach, describe, expect, it, vi } from 'vitest' import type { HostedReviewInfo } from '../../../../shared/hosted-review' import type { GlobalSettings, Repo, Worktree, WorktreeCardProperty } from '../../../../shared/types' +import { COMPACT_WORKTREE_CARD_PROPERTIES } from '../../../../shared/worktree-card-properties' import type { WorkspacePortScanResult } from '../../../../shared/workspace-ports' const fetchHostedReviewForBranch = vi.fn() @@ -363,9 +364,41 @@ describe('WorktreeCard linked PR display', () => { expect(markup).toContain('Created by automation') expect(markup).not.toContain('>Automation') - }) + }, 20_000) - it('shows the automation metadata icon in compact card mode', async () => { + it('hides the automation metadata icon in compact card mode by preset default', async () => { + settings = { compactWorktreeCards: true } + worktreeCardProperties = [...COMPACT_WORKTREE_CARD_PROPERTIES] + const { default: WorktreeCard } = await import('./WorktreeCard') + + const markup = renderWorktreeCardMarkup( + + ) + + expect(markup).not.toContain('Created by automation') + expect(markup).not.toContain('>Automation') + expect(markup).not.toContain('Nightly triage automation') + }, 20_000) + + it('shows the automation metadata icon in compact card mode when manually enabled', async () => { settings = { compactWorktreeCards: true } worktreeCardProperties = ['status', 'automation'] const { default: WorktreeCard } = await import('./WorktreeCard') @@ -394,7 +427,7 @@ describe('WorktreeCard linked PR display', () => { expect(markup).toContain('Created by automation') expect(markup).not.toContain('>Automation') - }) + }, 20_000) it('hides automation-created card surfaces when the Automation property is disabled', async () => { worktreeCardProperties = ['status'] diff --git a/src/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.test.tsx b/src/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.test.tsx new file mode 100644 index 000000000..ac698c6c8 --- /dev/null +++ b/src/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.test.tsx @@ -0,0 +1,156 @@ +// @vitest-environment happy-dom +import { act, type ReactNode } from 'react' +import { createRoot, type Root } from 'react-dom/client' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { WorktreeCardDisplayMenuSection } from './WorktreeCardDisplayMenuSection' + +;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true + +const setWorktreeCardMode = vi.fn() +const setWorktreeCardProperties = vi.fn() +const setAgentActivityDisplayMode = vi.fn() + +let settings = { compactWorktreeCards: false, experimentalNewWorktreeCardStyle: false } +let worktreeCardProperties = [ + 'status', + 'unread', + 'issue', + 'linear-issue', + 'pr', + 'automation', + 'comment', + 'ports', + 'inline-agents' +] + +vi.mock('@/store', () => ({ + useAppStore: (selector: (state: unknown) => unknown) => + selector({ + agentActivityDisplayMode: 'compact', + setAgentActivityDisplayMode, + setWorktreeCardMode, + setWorktreeCardProperties, + settings, + worktreeCardProperties + }) +})) + +vi.mock('@/components/ui/dropdown-menu', async () => { + const ReactModule = await import('react') + type RadioItemProps = { + children: ReactNode + onSelect?: (event: { preventDefault: () => void }) => void + onValueChange?: (value: string) => void + value: string + } + return { + DropdownMenuCheckboxItem: ({ + children, + checked, + onCheckedChange + }: { + children: ReactNode + checked?: boolean + onCheckedChange?: (checked: boolean) => void + }) => ( + + ), + DropdownMenuLabel: ({ children }: { children: ReactNode }) =>
{children}
, + DropdownMenuRadioGroup: ({ + children, + onValueChange, + value + }: { + children: ReactNode + onValueChange?: (value: string) => void + value?: string + }) => ( +
+ {ReactModule.Children.map(children, (child) => + ReactModule.isValidElement(child) + ? ReactModule.cloneElement(child, { onValueChange }) + : child + )} +
+ ), + DropdownMenuRadioItem: ({ children, onSelect, onValueChange, value }: RadioItemProps) => ( + + ), + DropdownMenuSeparator: () =>
, + DropdownMenuSub: ({ children }: { children: ReactNode }) => <>{children}, + DropdownMenuSubContent: ({ children }: { children: ReactNode }) =>
{children}
, + DropdownMenuSubTrigger: ({ children }: { children: ReactNode }) =>
{children}
+ } +}) + +let root: Root | null = null +let container: HTMLDivElement | null = null + +function renderMenu(): void { + container = document.createElement('div') + document.body.appendChild(container) + root = createRoot(container) + act(() => { + root?.render() + }) +} + +beforeEach(() => { + settings = { compactWorktreeCards: false, experimentalNewWorktreeCardStyle: false } + worktreeCardProperties = [ + 'status', + 'unread', + 'issue', + 'linear-issue', + 'pr', + 'automation', + 'comment', + 'ports', + 'inline-agents' + ] + setAgentActivityDisplayMode.mockReset() + setWorktreeCardMode.mockReset() + setWorktreeCardProperties.mockReset() +}) + +afterEach(() => { + act(() => { + root?.unmount() + }) + root = null + container?.remove() + container = null + document.body.innerHTML = '' +}) + +describe('WorktreeCardDisplayMenuSection', () => { + it('applies the compact card mode preset from the visible card layout menu', () => { + renderMenu() + + const compactLayoutButton = document.querySelector( + '[data-radio-group-value="detailed"] [data-radio-item-value="compact"]' + ) + expect(compactLayoutButton).not.toBeNull() + + act(() => { + compactLayoutButton?.click() + }) + + expect(setWorktreeCardMode).toHaveBeenCalledWith('Compact') + }) +}) diff --git a/src/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.tsx b/src/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.tsx index 87a265d31..f2447813c 100644 --- a/src/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCardDisplayMenuSection.tsx @@ -29,7 +29,7 @@ export function WorktreeCardDisplayMenuSection({ const worktreeCardProperties = useAppStore((s) => s.worktreeCardProperties) const setWorktreeCardProperties = useAppStore((s) => s.setWorktreeCardProperties) const settings = useAppStore((s) => s.settings) - const updateSettings = useAppStore((s) => s.updateSettings) + const setWorktreeCardMode = useAppStore((s) => s.setWorktreeCardMode) const agentActivityDisplayMode = useAppStore((s) => s.agentActivityDisplayMode) const setAgentActivityDisplayMode = useAppStore((s) => s.setAgentActivityDisplayMode) const newCardStyle = settings?.experimentalNewWorktreeCardStyle === true @@ -108,9 +108,9 @@ export function WorktreeCardDisplayMenuSection({ { - void updateSettings({ - compactWorktreeCards: value === 'compact' - }) + // Why: layout changes are presets, not just density toggles; keep + // the visible menu path aligned with card property defaults. + setWorktreeCardMode(value === 'compact' ? 'Compact' : 'Default') }} > {CARD_LAYOUT_OPTIONS.map((opt) => ( diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 91bfb54ea..0127265d9 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -3650,6 +3650,7 @@ "2a81e07366": "Full list", "25105b28cb": "Compact", "d7084e8bc8": "Agent activity", + "automation": "Automation", "b64d8bcca0": "Ports", "26c71e536c": "Notes", "b8dcc6f321": "PR/MR link", diff --git a/src/renderer/src/i18n/locales/es.json b/src/renderer/src/i18n/locales/es.json index 9d3545af0..8da4fbcb5 100644 --- a/src/renderer/src/i18n/locales/es.json +++ b/src/renderer/src/i18n/locales/es.json @@ -3656,7 +3656,8 @@ "automation": "Automation", "2d74665a56": "Puertos", "65a9820bd1": "Estados del agente", - "219ebf1961": "Nombre de rama" + "219ebf1961": "Nombre de rama", + "automation": "Automation" }, "SshDisconnectedDialog": { "ca4a7892af": "Conectando...", diff --git a/src/renderer/src/web/web-preload-api.test.ts b/src/renderer/src/web/web-preload-api.test.ts index a3c12fb22..ec236c402 100644 --- a/src/renderer/src/web/web-preload-api.test.ts +++ b/src/renderer/src/web/web-preload-api.test.ts @@ -309,7 +309,7 @@ describe('web settings preload API', () => { expect(stored.autoRenameBranchFromWorkDefaultedOn).toBe(true) }) - it('keeps compact worktree cards local when hydrating paired runtime settings', async () => { + it('hydrates compact worktree cards from paired runtime settings', async () => { const runtimeCalls: { method: string; params: unknown }[] = [] vi.doMock('./web-runtime-client', () => ({ WebRuntimeClient: class { @@ -337,10 +337,10 @@ describe('web settings preload API', () => { compactWorktreeCards?: boolean } - expect(settings.compactWorktreeCards).toBe(false) - expect(stored.compactWorktreeCards).toBe(false) + expect(settings.compactWorktreeCards).toBe(true) + expect(stored.compactWorktreeCards).toBe(true) expect(runtimeCalls).toEqual([{ method: 'settings.get', params: undefined }]) - }) + }, 15_000) it('hydrates new worktree card style from a paired runtime', async () => { const runtimeCalls: { method: string; params: unknown }[] = [] @@ -375,7 +375,7 @@ describe('web settings preload API', () => { expect(runtimeCalls).toEqual([{ method: 'settings.get', params: undefined }]) }) - it('keeps compact worktree card updates local for paired web clients', async () => { + it('forwards compact worktree card updates to a paired runtime', async () => { const runtimeCalls: { method: string; params: unknown }[] = [] vi.doMock('./web-runtime-client', () => ({ WebRuntimeClient: class { @@ -406,8 +406,10 @@ describe('web settings preload API', () => { expect(settings.compactWorktreeCards).toBe(true) expect(stored.compactWorktreeCards).toBe(true) - expect(runtimeCalls).toEqual([]) - }) + expect(runtimeCalls).toEqual([ + { method: 'settings.update', params: { compactWorktreeCards: true } } + ]) + }, 15_000) it('forwards new worktree card style updates to a paired runtime', async () => { const runtimeCalls: { method: string; params: unknown }[] = [] diff --git a/src/renderer/src/web/web-preload-api.ts b/src/renderer/src/web/web-preload-api.ts index bdf334a94..6d4ec2f45 100644 --- a/src/renderer/src/web/web-preload-api.ts +++ b/src/renderer/src/web/web-preload-api.ts @@ -2647,6 +2647,9 @@ async function getRuntimeBackedStoredSettings(): Promise { runtimeSettings.experimentalNewWorktreeCardStyle = result.settings.experimentalNewWorktreeCardStyle } + if (typeof result.settings.compactWorktreeCards === 'boolean') { + runtimeSettings.compactWorktreeCards = result.settings.compactWorktreeCards + } const next = mergeSettings(local, runtimeSettings) writeJson(SETTINGS_STORAGE_KEY, next) return next @@ -2667,6 +2670,9 @@ async function syncRuntimeBackedSettings( if (typeof updates.experimentalNewWorktreeCardStyle === 'boolean') { runtimeUpdates.experimentalNewWorktreeCardStyle = updates.experimentalNewWorktreeCardStyle } + if (typeof updates.compactWorktreeCards === 'boolean') { + runtimeUpdates.compactWorktreeCards = updates.compactWorktreeCards + } if (Object.keys(runtimeUpdates).length === 0) { return localNext } diff --git a/src/shared/constants.ts b/src/shared/constants.ts index 7ffefd7ea..e1711b29b 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -36,6 +36,7 @@ export { TASK_WORKTREE_CARD_PROPERTIES, getWorktreeCardModeProperties, getWorktreeCardModeUpdates, + isLegacyDefaultedCompactWorktreeCardProperties, normalizeWorktreeCardProperties } from './worktree-card-properties' diff --git a/src/shared/worktree-card-properties.test.ts b/src/shared/worktree-card-properties.test.ts index 20791b47d..00a738380 100644 --- a/src/shared/worktree-card-properties.test.ts +++ b/src/shared/worktree-card-properties.test.ts @@ -1,9 +1,11 @@ import { describe, expect, it } from 'vitest' import { + COMPACT_WORKTREE_CARD_PROPERTIES, DEFAULT_WORKTREE_CARD_PROPERTIES, TASK_WORKTREE_CARD_PROPERTIES, getWorktreeCardModeProperties, getWorktreeCardModeUpdates, + isLegacyDefaultedCompactWorktreeCardProperties, normalizeWorktreeCardProperties } from './worktree-card-properties' @@ -18,9 +20,11 @@ describe('worktree card properties', () => { expect(props).toEqual(DEFAULT_WORKTREE_CARD_PROPERTIES) }) - it('defines Compact with status and automation but without extra rows or branch metadata', () => { + it('defines Compact as the status-only quiet preset', () => { const props = getWorktreeCardModeProperties('Compact') + expect(props).toEqual(['status']) + expect(props).toEqual(COMPACT_WORKTREE_CARD_PROPERTIES) expect(props).not.toContain('inline-agents') expect(props).not.toContain('issue') expect(props).not.toContain('linear-issue') @@ -28,7 +32,7 @@ describe('worktree card properties', () => { expect(props).not.toContain('ports') expect(props).not.toContain('branch') expect(props).not.toContain('pr') - expect(props).toContain('automation') + expect(props).not.toContain('automation') }) it('keeps status enabled in both presets', () => { @@ -57,4 +61,16 @@ describe('worktree card properties', () => { } }) }) + + it('recognizes only the exact old defaulted Compact preset', () => { + expect(isLegacyDefaultedCompactWorktreeCardProperties(['status', 'automation'])).toBe(true) + expect(isLegacyDefaultedCompactWorktreeCardProperties(['status', 'unread', 'automation'])).toBe( + true + ) + expect(isLegacyDefaultedCompactWorktreeCardProperties(['automation', 'status'])).toBe(false) + expect(isLegacyDefaultedCompactWorktreeCardProperties(['status'])).toBe(false) + expect(isLegacyDefaultedCompactWorktreeCardProperties(['status', 'automation', 'pr'])).toBe( + false + ) + }) }) diff --git a/src/shared/worktree-card-properties.ts b/src/shared/worktree-card-properties.ts index cddbfe73b..ee1cee312 100644 --- a/src/shared/worktree-card-properties.ts +++ b/src/shared/worktree-card-properties.ts @@ -22,7 +22,20 @@ export const DEFAULT_WORKTREE_CARD_PROPERTIES: WorktreeCardProperty[] = [ 'inline-agents' ] -export const COMPACT_WORKTREE_CARD_PROPERTIES: WorktreeCardProperty[] = ['status', 'automation'] +// Why: compact cards default to the quiet preset; metadata icons remain opt-in +// through Show properties instead of appearing automatically. +export const COMPACT_WORKTREE_CARD_PROPERTIES: WorktreeCardProperty[] = ['status'] + +const LEGACY_COMPACT_WORKTREE_CARD_PROPERTIES_WITH_AUTOMATION: WorktreeCardProperty[] = [ + 'status', + 'automation' +] + +const LEGACY_NORMALIZED_COMPACT_WORKTREE_CARD_PROPERTIES_WITH_AUTOMATION: WorktreeCardProperty[] = [ + 'status', + 'unread', + 'automation' +] const WORKTREE_CARD_PROPERTY_ORDER: WorktreeCardProperty[] = [ 'status', @@ -69,3 +82,28 @@ export function getWorktreeCardModeUpdates(mode: WorktreeCardMode): { } } } + +export function isLegacyDefaultedCompactWorktreeCardProperties( + properties: readonly unknown[] | null | undefined +): boolean { + return ( + matchesWorktreeCardProperties( + properties, + LEGACY_COMPACT_WORKTREE_CARD_PROPERTIES_WITH_AUTOMATION + ) || + matchesWorktreeCardProperties( + properties, + LEGACY_NORMALIZED_COMPACT_WORKTREE_CARD_PROPERTIES_WITH_AUTOMATION + ) + ) +} + +function matchesWorktreeCardProperties( + properties: readonly unknown[] | null | undefined, + expected: readonly WorktreeCardProperty[] +): boolean { + if (properties?.length !== expected.length) { + return false + } + return expected.every((property, index) => properties[index] === property) +}