MCPcopy Index your code
hub / github.com/coder/mux / createWorkspace

Method createWorkspace

src/node/runtime/SSHRuntime.ts:2470–2499  ·  view source on GitHub ↗
(params: WorkspaceCreationParams)

Source from the content-addressed store, hash-verified

2468 */
2469 // eslint-disable-next-line @typescript-eslint/require-await
2470 async createWorkspace(params: WorkspaceCreationParams): Promise<WorkspaceCreationResult> {
2471 try {
2472 const { projectPath, directoryName } = params;
2473 const layout = this.getProjectLayout(projectPath);
2474 // Workspace directories follow the persisted workspace name; branch checkout happens later.
2475 const workspacePath = getRemoteWorkspacePath(layout, directoryName);
2476
2477 // STARTUP-PERF: The previous implementation issued an SSH `mkdir -p` here
2478 // to ensure the workspace's parent directory exists before `initWorkspace`.
2479 // That round-trip is unnecessary because both materialization paths in
2480 // `prepareWorkspaceCheckout()` (warm fast-path + slow path) create their
2481 // own parents:
2482 // - The slow path's `ensureBaseRepo()` runs `mkdir -p <baseRepoPath>`,
2483 // which creates the shared project root dir as a side effect.
2484 // - The warm fast-path's single fused command runs `mkdir -p` for the
2485 // workspace parent inline before `git worktree add`.
2486 // Folding the mkdir into materialization shaves one full SSH RTT off
2487 // every workspace startup, which is the dominant constant cost on the
2488 // warm path.
2489 return {
2490 success: true,
2491 workspacePath,
2492 };
2493 } catch (error) {
2494 return {
2495 success: false,
2496 error: getErrorMessage(error),
2497 };
2498 }
2499 }
2500
2501 async initWorkspace(params: WorkspaceInitParams): Promise<WorkspaceInitResult> {
2502 // Disable git hooks for untrusted projects (prevents post-checkout execution)

Callers

nothing calls this directly

Calls 3

getProjectLayoutMethod · 0.95
getRemoteWorkspacePathFunction · 0.90
getErrorMessageFunction · 0.90

Tested by

no test coverage detected