From 6442a9f6496bdecc67716b4aaa1f860ac99cf7d5 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Thu, 30 Jul 2026 17:56:58 -0700 Subject: [PATCH] fix(persistence): backfill the jira-issue workspace-card property for upgraded profiles (#11618) Co-authored-by: Orca --- src/main/persistence.test.ts | 110 +++++++++++++++++- src/main/persistence.ts | 15 ++- .../methods/ui-state-schema-parity-checks.ts | 1 + src/shared/types.ts | 2 + 4 files changed, 123 insertions(+), 5 deletions(-) diff --git a/src/main/persistence.test.ts b/src/main/persistence.test.ts index 5725cc031..ba69a92c5 100644 --- a/src/main/persistence.test.ts +++ b/src/main/persistence.test.ts @@ -7251,6 +7251,7 @@ describe('Store', () => { 'ci', 'issue', 'linear-issue', + 'jira-issue', 'pr', 'comment', 'ports', @@ -7287,6 +7288,7 @@ describe('Store', () => { 'ci', 'issue', 'linear-issue', + 'jira-issue', 'pr', 'comment', 'ports', @@ -7347,6 +7349,7 @@ describe('Store', () => { 'ci', 'issue', 'linear-issue', + 'jira-issue', 'pr', 'ports', 'inline-agents' @@ -7363,7 +7366,8 @@ describe('Store', () => { ui: { worktreeCardProperties: ['status', 'pr'], _inlineAgentsDefaultedForAllUsers: true, - _expandedWorktreeCardPropertiesDefaulted: true + _expandedWorktreeCardPropertiesDefaulted: true, + _jiraIssueWorktreeCardPropertyDefaulted: true }, githubCache: { pr: {}, issue: {} }, workspaceSession: {} @@ -7422,7 +7426,8 @@ describe('Store', () => { 'ports' ], _inlineAgentsDefaultedForAllUsers: true, - _expandedWorktreeCardPropertiesDefaulted: true + _expandedWorktreeCardPropertiesDefaulted: true, + _jiraIssueWorktreeCardPropertyDefaulted: true }, githubCache: { pr: {}, issue: {} }, workspaceSession: {} @@ -7443,6 +7448,107 @@ describe('Store', () => { expect(store.getUI().worktreeCardProperties).not.toContain('inline-agents') }) + it('backfills jira-issue once for profiles stamped before it joined the defaults', async () => { + writeDataFile({ + schemaVersion: 1, + repos: [], + worktreeMeta: {}, + settings: { compactWorktreeCards: false }, + ui: { + worktreeCardProperties: [ + 'status', + 'unread', + 'issue', + 'linear-issue', + 'pr', + 'ports', + 'inline-agents' + ], + _inlineAgentsDefaultedForAllUsers: true, + _expandedWorktreeCardPropertiesDefaulted: true + }, + githubCache: { pr: {}, issue: {} }, + workspaceSession: {} + }) + const store = await createStore() + + expect(store.getUI().worktreeCardProperties).toEqual([ + 'status', + 'unread', + 'issue', + 'linear-issue', + 'jira-issue', + 'pr', + 'ports', + 'inline-agents' + ]) + expect( + store.getUI().worktreeCardProperties?.filter((property) => property === 'jira-issue') + ).toHaveLength(1) + expect(store.getUI()._jiraIssueWorktreeCardPropertyDefaulted).toBe(true) + }) + + it('preserves a deliberate jira-issue removal after the backfill has run', async () => { + writeDataFile({ + schemaVersion: 1, + repos: [], + worktreeMeta: {}, + settings: { compactWorktreeCards: false }, + ui: { + worktreeCardProperties: ['status', 'unread', 'issue', 'linear-issue', 'pr'], + _inlineAgentsDefaultedForAllUsers: true, + _expandedWorktreeCardPropertiesDefaulted: true, + _jiraIssueWorktreeCardPropertyDefaulted: true + }, + githubCache: { pr: {}, issue: {} }, + workspaceSession: {} + }) + const store = await createStore() + + expect(store.getUI().worktreeCardProperties).toEqual([ + 'status', + 'unread', + 'issue', + 'linear-issue', + 'pr' + ]) + expect(store.getUI().worktreeCardProperties).not.toContain('jira-issue') + }) + + it('leaves fresh default profiles with a single jira-issue entry', async () => { + writeDataFile({ + schemaVersion: 1, + repos: [], + worktreeMeta: {}, + settings: {}, + ui: {}, + githubCache: { pr: {}, issue: {} }, + workspaceSession: {} + }) + const store = await createStore() + + expect( + store.getUI().worktreeCardProperties?.filter((property) => property === 'jira-issue') + ).toHaveLength(1) + expect(store.getUI()._jiraIssueWorktreeCardPropertyDefaulted).toBe(true) + }) + + it('skips the jira-issue backfill when card properties are malformed', async () => { + writeDataFile({ + schemaVersion: 1, + repos: [], + worktreeMeta: {}, + settings: { compactWorktreeCards: false }, + ui: { worktreeCardProperties: 'not-an-array' }, + githubCache: { pr: {}, issue: {} }, + workspaceSession: {} + }) + const store = await createStore() + + expect(store.getUI().worktreeCardProperties).not.toContain('jira-issue') + expect(store.getUI()._jiraIssueWorktreeCardPropertyDefaulted).toBe(true) + }) + it('uses the compact preset when card properties are missing in compact mode', async () => { writeDataFile({ schemaVersion: 1, diff --git a/src/main/persistence.ts b/src/main/persistence.ts index 310916115..e3c0fa329 100644 --- a/src/main/persistence.ts +++ b/src/main/persistence.ts @@ -3304,6 +3304,8 @@ export class Store { const inlineAgentsMigrated = parsed.ui?._inlineAgentsDefaultedForAllUsers === true const expandedCardPropsMigrated = parsed.ui?._expandedWorktreeCardPropertiesDefaulted === true + const jiraIssueCardPropDefaulted = + parsed.ui?._jiraIssueWorktreeCardPropertyDefaulted === true const hadExperimentOn = readDeprecatedExperimentFlag(parsed) const deliberateUncheck = hadExperimentOn && @@ -3342,7 +3344,12 @@ export class Store { } return next })() - const normalized = normalizeWorktreeCardProperties(expandedCandidate) + // Why: 'jira-issue' joined the defaults after the expansion migration already stamped upgraded profiles, so it needs its own one-shot backfill. + const jiraCandidate = + jiraIssueCardPropDefaulted || expandedCandidate.includes('jira-issue') + ? expandedCandidate + : [...expandedCandidate, 'jira-issue' as const] + const normalized = normalizeWorktreeCardProperties(jiraCandidate) const changed = normalized.length !== rawCardProps.length || normalized.some((property, index) => property !== rawCardProps[index]) @@ -3351,7 +3358,8 @@ export class Store { if ( migratedCardProps !== undefined || !inlineAgentsMigrated || - !expandedCardPropsMigrated + !expandedCardPropsMigrated || + !jiraIssueCardPropDefaulted ) { this.loadNeedsSave = true } @@ -3419,7 +3427,8 @@ export class Store { // Why: keep stamping the legacy flag for rollback forward-compat; the new flag actually gates the migration. _inlineAgentsDefaultedForExperiment: true, _inlineAgentsDefaultedForAllUsers: true, - _expandedWorktreeCardPropertiesDefaulted: true + _expandedWorktreeCardPropertiesDefaulted: true, + _jiraIssueWorktreeCardPropertyDefaulted: true } })(), // Why: volatile schema; zod-validate workspaceSession at read so a bad payload falls to defaults, not a renderer crash. diff --git a/src/main/runtime/rpc/methods/ui-state-schema-parity-checks.ts b/src/main/runtime/rpc/methods/ui-state-schema-parity-checks.ts index bbdece031..a1ccf86c2 100644 --- a/src/main/runtime/rpc/methods/ui-state-schema-parity-checks.ts +++ b/src/main/runtime/rpc/methods/ui-state-schema-parity-checks.ts @@ -11,6 +11,7 @@ type MainOwnedUIState = | 'trayMinimizeNoticeShown' | 'dashboardPopoutBounds' | '_expandedWorktreeCardPropertiesDefaulted' + | '_jiraIssueWorktreeCardPropertyDefaulted' | 'starNagBaselineAgents' | 'starNagAppVersion' | 'starNagNextThreshold' diff --git a/src/shared/types.ts b/src/shared/types.ts index a4018f8ab..5e6192177 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -3423,6 +3423,8 @@ export type PersistedUIState = { _inlineAgentsDefaultedForAllUsers?: boolean /** One-shot migration flag for split-out card properties, set once so later deliberate unchecks of Linear issue/Ports stick across restarts. */ _expandedWorktreeCardPropertiesDefaulted?: boolean + /** One-shot backfill flag for 'jira-issue', which joined the defaults after the expansion migration had already stamped upgraded profiles. */ + _jiraIssueWorktreeCardPropertyDefaulted?: boolean /** totalAgentsSpawned snapshot at first sighting of the current app version, so the nag counts agents since last update (not from zero). */ starNagBaselineAgents?: number | null /** App version that set the current baseline; a version change re-captures the baseline on next spawn, restarting the nag countdown. */