Add multi-repo folder workspaces (v1) (#5172)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Brennan Benson
2026-06-11 02:34:01 -07:00
committed by GitHub
co-authored by Orca
parent 7fbb3003f2
commit 91e354ccb1
99 changed files with 8285 additions and 761 deletions
+31
View File
@@ -0,0 +1,31 @@
import type { WorkspaceKey, WorkspaceScope } from './types'
export function worktreeWorkspaceKey(worktreeId: string): WorkspaceKey {
return `worktree:${worktreeId}`
}
export function folderWorkspaceKey(folderWorkspaceId: string): WorkspaceKey {
return `folder:${folderWorkspaceId}`
}
export function workspaceKeyFromScope(scope: WorkspaceScope): WorkspaceKey {
return scope.type === 'worktree'
? worktreeWorkspaceKey(scope.worktreeId)
: folderWorkspaceKey(scope.folderWorkspaceId)
}
export function parseWorkspaceKey(value: string): WorkspaceScope | null {
if (value.startsWith('worktree:')) {
const worktreeId = value.slice('worktree:'.length)
return worktreeId.length > 0 ? { type: 'worktree', worktreeId } : null
}
if (value.startsWith('folder:')) {
const folderWorkspaceId = value.slice('folder:'.length)
return folderWorkspaceId.length > 0 ? { type: 'folder', folderWorkspaceId } : null
}
return null
}
export function isWorkspaceKey(value: string): value is WorkspaceKey {
return parseWorkspaceKey(value) !== null
}