* Fork workspace: delegates to SSHRuntime, but marks both source and fork * as existingWorkspace=true so neither can delete the shared Coder workspace. * * IMPORTANT: Also updates this instance's coderConfig so that if postCreateSetup * runs on this same runtime instance (for the forked
(params: WorkspaceForkParams)
| 747 | * to create a new Coder workspace. |
| 748 | */ |
| 749 | override async forkWorkspace(params: WorkspaceForkParams): Promise<WorkspaceForkResult> { |
| 750 | const result = await super.forkWorkspace(params); |
| 751 | // Coder tasks must share the parent's VM - don't fall back to creating a new one |
| 752 | if (!result.success) return { ...result, failureIsFatal: true }; |
| 753 | |
| 754 | // Both workspaces now share the Coder workspace - mark as existing so |
| 755 | // deleting either mux workspace won't destroy the underlying Coder workspace |
| 756 | const sharedCoderConfig = { ...this.coderConfig, existingWorkspace: true }; |
| 757 | |
| 758 | // Update this instance's config so postCreateSetup() skips coder create |
| 759 | this.coderConfig = sharedCoderConfig; |
| 760 | |
| 761 | const sshConfig = this.getConfig(); |
| 762 | const sharedRuntimeConfig = { type: "ssh" as const, ...sshConfig, coder: sharedCoderConfig }; |
| 763 | |
| 764 | return { |
| 765 | ...result, |
| 766 | forkedRuntimeConfig: sharedRuntimeConfig, |
| 767 | sourceRuntimeConfig: sharedRuntimeConfig, |
| 768 | }; |
| 769 | } |
| 770 | |
| 771 | /** |
| 772 | * Post-create setup: provision Coder workspace and configure SSH. |
nothing calls this directly
no test coverage detected