( provider: ClineProvider, worktreePath: string, newWindow: boolean, )
| 181 | } |
| 182 | |
| 183 | export async function handleSwitchWorktree( |
| 184 | provider: ClineProvider, |
| 185 | worktreePath: string, |
| 186 | newWindow: boolean, |
| 187 | ): Promise<WorktreeResult> { |
| 188 | try { |
| 189 | const worktreeUri = vscode.Uri.file(worktreePath) |
| 190 | |
| 191 | if (newWindow) { |
| 192 | // Set the auto-open path so the new window opens Roo Code sidebar. |
| 193 | await provider.contextProxy.setValue("worktreeAutoOpenPath", worktreePath) |
| 194 | |
| 195 | // Open in new window. |
| 196 | await vscode.commands.executeCommand("vscode.openFolder", worktreeUri, { forceNewWindow: true }) |
| 197 | } else { |
| 198 | // For current window, we need to flush pending state first since window will reload. |
| 199 | await provider.contextProxy.setValue("worktreeAutoOpenPath", worktreePath) |
| 200 | |
| 201 | // Open in current window (this will reload the window). |
| 202 | await vscode.commands.executeCommand("vscode.openFolder", worktreeUri, { forceNewWindow: false }) |
| 203 | } |
| 204 | |
| 205 | return { |
| 206 | success: true, |
| 207 | message: `Opened worktree at ${worktreePath}`, |
| 208 | } |
| 209 | } catch (error) { |
| 210 | const errorMessage = error instanceof Error ? error.message : String(error) |
| 211 | return { |
| 212 | success: false, |
| 213 | message: `Failed to switch worktree: ${errorMessage}`, |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | export async function handleGetAvailableBranches(provider: ClineProvider): Promise<BranchInfo> { |
| 219 | const cwd = provider.cwd |
no test coverage detected