MCPcopy
hub / github.com/coder/mux / createWorkspaceViaOrpc

Function createWorkspaceViaOrpc

scripts/reproWorkspaceSwitchTearWeb.ts:110–131  ·  view source on GitHub ↗
(args: {
  page: Page;
  projectPath: string;
  branchName: string;
  trunkBranch: string;
})

Source from the content-addressed store, hash-verified

108}
109
110async function createWorkspaceViaOrpc(args: {
111 page: Page;
112 projectPath: string;
113 branchName: string;
114 trunkBranch: string;
115}): Promise<{ workspaceId: string }> {
116 return await args.page.evaluate(
117 async ({ projectPath, branchName, trunkBranch }) => {
118 const client = window.__ORPC_CLIENT__;
119 if (!client) throw new Error("ORPC client not initialized");
120 await client.projects.setTrust({ projectPath, trusted: true });
121 const createResult = await client.workspace.create({ projectPath, branchName, trunkBranch });
122 if (!createResult.success) throw new Error(createResult.error);
123 return { workspaceId: createResult.metadata.id };
124 },
125 {
126 projectPath: args.projectPath,
127 branchName: args.branchName,
128 trunkBranch: args.trunkBranch,
129 }
130 );
131}
132
133async function waitForProjectPage(page: Page): Promise<void> {
134 await page.waitForFunction(() => Boolean(window.__ORPC_CLIENT__), { timeout: 60_000 });

Callers 1

mainFunction · 0.85

Calls 1

createMethod · 0.65

Tested by

no test coverage detected