fix(persistence): backfill the jira-issue workspace-card property for upgraded profiles (#11618)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-07-30 17:56:58 -07:00
committed by GitHub
co-authored by Orca
parent 8e9dc4ecf2
commit 6442a9f649
4 changed files with 123 additions and 5 deletions
+108 -2
View File
@@ -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,
+12 -3
View File
@@ -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.
@@ -11,6 +11,7 @@ type MainOwnedUIState =
| 'trayMinimizeNoticeShown'
| 'dashboardPopoutBounds'
| '_expandedWorktreeCardPropertiesDefaulted'
| '_jiraIssueWorktreeCardPropertyDefaulted'
| 'starNagBaselineAgents'
| 'starNagAppVersion'
| 'starNagNextThreshold'
+2
View File
@@ -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. */