* Validate before persisting workspace metadata. * Checks if a Coder workspace with this name already exists.
(
_finalBranchName: string,
config: RuntimeConfig
)
| 522 | * Checks if a Coder workspace with this name already exists. |
| 523 | */ |
| 524 | async validateBeforePersist( |
| 525 | _finalBranchName: string, |
| 526 | config: RuntimeConfig |
| 527 | ): Promise<Result<void, string>> { |
| 528 | if (!isSSHRuntime(config) || !config.coder) { |
| 529 | return Ok(undefined); |
| 530 | } |
| 531 | |
| 532 | // Skip for "existing" mode - user explicitly selected an existing workspace |
| 533 | if (config.coder.existingWorkspace) { |
| 534 | return Ok(undefined); |
| 535 | } |
| 536 | |
| 537 | const workspaceName = config.coder.workspaceName; |
| 538 | if (!workspaceName) { |
| 539 | return Ok(undefined); |
| 540 | } |
| 541 | |
| 542 | const exists = await this.coderService.workspaceExists(workspaceName); |
| 543 | |
| 544 | if (exists) { |
| 545 | await this.coderService.disposeProvisioningSession(workspaceName); |
| 546 | return Err( |
| 547 | `A Coder workspace named "${workspaceName}" already exists. ` + |
| 548 | `Either switch to "Existing" mode to use it, delete/rename it in Coder, ` + |
| 549 | `or choose a different mux workspace name.` |
| 550 | ); |
| 551 | } |
| 552 | |
| 553 | return Ok(undefined); |
| 554 | } |
| 555 | |
| 556 | /** |
| 557 | * Create workspace (fast path only - no SSH needed). |
nothing calls this directly
no test coverage detected