MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / workspaceIdForSession

Function workspaceIdForSession

apps/kimi-web/src/lib/mergeWorkspaces.ts:13–18  ·  view source on GitHub ↗

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 },
)

Source from the content-addressed store, hash-verified

11 * root matches the session cwd; otherwise the daemon-provided workspaceId;
12 * otherwise the cwd itself (derived/fallback mode). */
13function 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
20export interface MergeWorkspacesInput {
21 /** Registered workspaces from the daemon (listWorkspaces). */

Callers 1

mergeWorkspacesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected