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

Function openClineInNewTab

src/activate/registerCommands.ts:224–298  ·  view source on GitHub ↗
({ context, outputChannel }: Omit<RegisterCommandOptions, "provider">)

Source from the content-addressed store, hash-verified

222})
223
224export const openClineInNewTab = async ({ context, outputChannel }: Omit<RegisterCommandOptions, "provider">) => {
225 // (This example uses webviewProvider activation event which is necessary to
226 // deserialize cached webview, but since we use retainContextWhenHidden, we
227 // don't need to use that event).
228 // https://github.com/microsoft/vscode-extension-samples/blob/main/webview-sample/src/extension.ts
229 const contextProxy = await ContextProxy.getInstance(context)
230 const codeIndexManager = CodeIndexManager.getInstance(context)
231
232 // Get the existing MDM service instance to ensure consistent policy enforcement
233 let mdmService: MdmService | undefined
234 try {
235 mdmService = MdmService.getInstance()
236 } catch (error) {
237 // MDM service not initialized, which is fine - extension can work without it
238 mdmService = undefined
239 }
240
241 const tabProvider = new ClineProvider(context, outputChannel, "editor", contextProxy, mdmService)
242 const lastCol = Math.max(...vscode.window.visibleTextEditors.map((editor) => editor.viewColumn || 0))
243
244 // Check if there are any visible text editors, otherwise open a new group
245 // to the right.
246 const hasVisibleEditors = vscode.window.visibleTextEditors.length > 0
247
248 if (!hasVisibleEditors) {
249 await vscode.commands.executeCommand("workbench.action.newGroupRight")
250 }
251
252 const targetCol = hasVisibleEditors ? Math.max(lastCol + 1, 1) : vscode.ViewColumn.Two
253
254 const newPanel = vscode.window.createWebviewPanel(ClineProvider.tabPanelId, "Roo Code", targetCol, {
255 enableScripts: true,
256 retainContextWhenHidden: true,
257 localResourceRoots: [context.extensionUri],
258 })
259
260 // Save as tab type panel.
261 setPanel(newPanel, "tab")
262
263 // TODO: Use better svg icon with light and dark variants (see
264 // https://stackoverflow.com/questions/58365687/vscode-extension-iconpath).
265 newPanel.iconPath = {
266 light: vscode.Uri.joinPath(context.extensionUri, "assets", "icons", "panel_light.png"),
267 dark: vscode.Uri.joinPath(context.extensionUri, "assets", "icons", "panel_dark.png"),
268 }
269
270 await tabProvider.resolveWebviewView(newPanel)
271
272 // Add listener for visibility changes to notify webview
273 newPanel.onDidChangeViewState(
274 (e) => {
275 const panel = e.webviewPanel
276 if (panel.visible) {
277 panel.webview.postMessage({ type: "action", action: "didBecomeVisible" }) // Use the same message type as in SettingsView.tsx
278 }
279 },
280 null, // First null is for `thisArgs`
281 context.subscriptions, // Register listener for disposal

Callers 2

startNewTaskMethod · 0.90
getCommandsMapFunction · 0.85

Calls 6

resolveWebviewViewMethod · 0.95
setPanelFunction · 0.85
executeCommandMethod · 0.80
joinPathMethod · 0.80
postMessageMethod · 0.65
getInstanceMethod · 0.45

Tested by

no test coverage detected