(branchPrefix: string)
| 421 | } |
| 422 | |
| 423 | async function createNonSelectedWorkspace(branchPrefix: string): Promise<{ |
| 424 | workspaceId: string; |
| 425 | displayTitle: string; |
| 426 | }> { |
| 427 | const trunkBranch = await detectDefaultTrunkBranch(app.repoPath); |
| 428 | const createResult = await app.env.orpc.workspace.create({ |
| 429 | projectPath: app.repoPath, |
| 430 | branchName: generateBranchName(branchPrefix), |
| 431 | trunkBranch, |
| 432 | }); |
| 433 | if (!createResult.success) { |
| 434 | throw new Error(`Failed to create workspace: ${createResult.error}`); |
| 435 | } |
| 436 | |
| 437 | const createdWorkspace = createResult.metadata; |
| 438 | createdWorkspaceIds.push(createdWorkspace.id); |
| 439 | const displayTitle = createdWorkspace.title ?? createdWorkspace.name; |
| 440 | |
| 441 | await waitFor( |
| 442 | () => { |
| 443 | const workspaceRow = app.view.container.querySelector( |
| 444 | `[data-workspace-id="${createdWorkspace.id}"]` |
| 445 | ) as HTMLElement | null; |
| 446 | if (!workspaceRow) { |
| 447 | throw new Error("Created workspace row not visible yet"); |
| 448 | } |
| 449 | }, |
| 450 | { timeout: 10_000 } |
| 451 | ); |
| 452 | |
| 453 | await waitFor( |
| 454 | () => { |
| 455 | const { recencyTimestamp } = workspaceStore.getWorkspaceSidebarState(createdWorkspace.id); |
| 456 | if (recencyTimestamp === null) { |
| 457 | throw new Error("Created workspace has no recency timestamp yet"); |
| 458 | } |
| 459 | }, |
| 460 | { timeout: 10_000 } |
| 461 | ); |
| 462 | |
| 463 | return { |
| 464 | workspaceId: createdWorkspace.id, |
| 465 | displayTitle, |
| 466 | }; |
| 467 | } |
| 468 | |
| 469 | function getWorkspaceTitleElement( |
| 470 | workspaceId: string, |
no test coverage detected