mirror of
https://github.com/stablyai/orca.git
synced 2026-11-03 02:27:43 +00:00
fix(persistence): clear canonical active workspace key on worktree owner removal (#6255)
Worktree session owners are removed by their raw id, but activeWorkspaceKey stores the canonical worktree:<id> form, so deleting a worktree left the persisted active key pointing at the removed workspace in every partition. Match both forms in deleteOwnerKeyedSessionFields so every owner-removal path (worktree delete, repo pruning, invalid-layout purge) clears it. Co-authored-by: Neil <neil@stably.ai>
This commit is contained in:
@@ -475,6 +475,7 @@ describe('Store host-partitioned workspace sessions', () => {
|
||||
const makeSession = (): ReturnType<typeof makeHostSession> => ({
|
||||
...makeHostSession('repo-ssh'),
|
||||
activeWorktreeId: worktreeId,
|
||||
activeWorkspaceKey: worktreeWorkspaceKey(worktreeId),
|
||||
lastVisitedAtByWorktreeId: { [worktreeId]: 123 },
|
||||
tabsByWorktree: {
|
||||
[worktreeId]: [makeTerminalTab({ id: 'stale-tab', worktreeId })]
|
||||
@@ -493,6 +494,7 @@ describe('Store host-partitioned workspace sessions', () => {
|
||||
expect(store.getWorkspaceSession(hostId)).toMatchObject({
|
||||
tabsByWorktree: {},
|
||||
activeWorktreeId: null,
|
||||
activeWorkspaceKey: null,
|
||||
lastVisitedAtByWorktreeId: {},
|
||||
terminalTopologyRevisionByRepoId: { 'repo-ssh': 1 }
|
||||
})
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
getWorktreeIdFromHostIdentity,
|
||||
isWorktreeHostIdentity
|
||||
} from '../../../shared/worktree/host-qualified-identity'
|
||||
import { worktreeWorkspaceKey } from '../../../shared/workspace-scope'
|
||||
import { SESSION_FIELDS_PRUNED_BY_OWNER_KEY } from '../../orca-profiles/profile-project-session-field-disposition'
|
||||
|
||||
// Repo-keyed topology revisions advance rather than delete; host-qualified recency keys need a scan.
|
||||
@@ -91,7 +92,11 @@ export function deleteOwnerKeyedSessionFields(
|
||||
}
|
||||
}
|
||||
}
|
||||
if (next.activeWorkspaceKey === ownerKey) {
|
||||
// Worktree owners are raw ids, but the active key stores their canonical worktree: form.
|
||||
if (
|
||||
next.activeWorkspaceKey === ownerKey ||
|
||||
next.activeWorkspaceKey === worktreeWorkspaceKey(ownerKey)
|
||||
) {
|
||||
next.activeWorkspaceKey = null
|
||||
}
|
||||
if (next.activeWorktreeId === ownerKey) {
|
||||
|
||||
Reference in New Issue
Block a user