fix(sidebar): don't scroll to an unfocused worktree when pinning/unpinning it (#8930)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil
2026-07-15 19:07:49 -07:00
committed by GitHub
co-authored by Orca
parent 49e2ac6f59
commit 891a456b69
4 changed files with 102 additions and 27 deletions
+16
View File
@@ -29,3 +29,19 @@ export function parseWorkspaceKey(value: string): WorkspaceScope | null {
export function isWorkspaceKey(value: string): value is WorkspaceKey {
return parseWorkspaceKey(value) !== null
}
// Why: folder workspaces are tracked by the scoped active key, while older
// worktree-only paths still read activeWorktreeId.
export function getActiveSidebarWorkspaceId(
activeWorkspaceKey: string | null,
activeWorktreeId: string | null
): string | null {
const scope = activeWorkspaceKey ? parseWorkspaceKey(activeWorkspaceKey) : null
if (scope?.type === 'folder') {
return folderWorkspaceKey(scope.folderWorkspaceId)
}
if (scope?.type === 'worktree') {
return scope.worktreeId
}
return activeWorktreeId
}