fix(client): prune removed workspace view state

This commit is contained in:
_Kerman
2026-08-11 18:59:06 +08:00
parent 230f3b8295
commit 909725f2e9
10 changed files with 71 additions and 12 deletions

View File

@@ -395,6 +395,22 @@ describe('createWorkspaceViewStore', () => {
recentSessionUpdatedAt: { alpha: { one: 1, two: 2 } },
})
})
it('removes view state outside the retained Workspace key set', () => {
const store = createWorkspaceViewStore().create()
store.actions.setWorkspaceExpanded('', true)
store.actions.setWorkspaceExpanded('alpha', true)
store.actions.setWorkspaceExpanded('deleted', true)
store.actions.syncRecentSessions('alpha', ['alpha-session'], { 'alpha-session': 2 })
store.actions.syncRecentSessions('deleted', ['deleted-session'], { 'deleted-session': 1 })
store.actions.retainWorkspaceKeys(['', 'alpha'])
const snapshot = store.getSnapshot()
expect(snapshot.workspaceExpansion).toEqual({ '': true, alpha: true })
expect(snapshot.recentSessionOrder).toEqual({ alpha: ['alpha-session'] })
expect(snapshot.recentSessionUpdatedAt).toEqual({ alpha: { 'alpha-session': 2 } })
})
})
describe('projectLabel', () => {