The workspace id a session belongs to: prefer the registered workspace whose * root matches the session cwd; otherwise the daemon-provided workspaceId; * otherwise the cwd itself (derived/fallback mode).
(
workspaces: AppWorkspace[],
s: { workspaceId?: string; cwd: string },
)
| 11 | * root matches the session cwd; otherwise the daemon-provided workspaceId; |
| 12 | * otherwise the cwd itself (derived/fallback mode). */ |
| 13 | function workspaceIdForSession( |
| 14 | workspaces: AppWorkspace[], |
| 15 | s: { workspaceId?: string; cwd: string }, |
| 16 | ): string { |
| 17 | return workspaces.find((w) => w.root === s.cwd)?.id ?? s.workspaceId ?? s.cwd; |
| 18 | } |
| 19 | |
| 20 | export interface MergeWorkspacesInput { |
| 21 | /** Registered workspaces from the daemon (listWorkspaces). */ |