MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / handleSwitchWorktree

Function handleSwitchWorktree

src/core/webview/worktree/handlers.ts:183–216  ·  view source on GitHub ↗
(
	provider: ClineProvider,
	worktreePath: string,
	newWindow: boolean,
)

Source from the content-addressed store, hash-verified

181}
182
183export 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
218export async function handleGetAvailableBranches(provider: ClineProvider): Promise<BranchInfo> {
219 const cwd = provider.cwd

Callers 2

webviewMessageHandlerFunction · 0.90
WorktreesViewFunction · 0.85

Calls 4

fileMethod · 0.80
executeCommandMethod · 0.80
setValueMethod · 0.65
StringInterface · 0.50

Tested by

no test coverage detected