Skip to content

Commit d46cdca

Browse files
committed
feat: open settings in new full tab similar to VSCode
- Added new openSettingsInNewTab function to create dedicated webview panel for settings - Updated settings button click handler to open settings in new tab instead of within extension - Added localized 'Roo Code Settings' title for the new settings tab - Settings now open in a full VSCode tab with proper state management - All localization files updated with new tabTitle key
1 parent 12f94fc commit d46cdca

File tree

19 files changed

+101
-9
lines changed

19 files changed

+101
-9
lines changed

src/activate/registerCommands.ts

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,10 @@ const getCommandsMap = ({ context, outputChannel, provider }: RegisterCommandOpt
130130
},
131131
openInNewTab: () => openClineInNewTab({ context, outputChannel }),
132132
settingsButtonClicked: () => {
133-
const visibleProvider = getVisibleProviderOrLog(outputChannel)
134-
135-
if (!visibleProvider) {
136-
return
137-
}
138-
139133
TelemetryService.instance.captureTitleButtonClicked("settings")
140134

141-
visibleProvider.postMessageToWebview({ type: "action", action: "settingsButtonClicked" })
142-
// Also explicitly post the visibility message to trigger scroll reliably
143-
visibleProvider.postMessageToWebview({ type: "action", action: "didBecomeVisible" })
135+
// Open settings in a new tab instead of within the extension
136+
return openSettingsInNewTab({ context, outputChannel })
144137
},
145138
historyButtonClicked: () => {
146139
const visibleProvider = getVisibleProviderOrLog(outputChannel)
@@ -310,3 +303,84 @@ export const openClineInNewTab = async ({ context, outputChannel }: Omit<Registe
310303

311304
return tabProvider
312305
}
306+
307+
export const openSettingsInNewTab = async ({ context, outputChannel }: Omit<RegisterCommandOptions, "provider">) => {
308+
const contextProxy = await ContextProxy.getInstance(context)
309+
310+
// Get the existing MDM service instance to ensure consistent policy enforcement
311+
let mdmService: MdmService | undefined
312+
try {
313+
mdmService = MdmService.getInstance()
314+
} catch (error) {
315+
// MDM service not initialized, which is fine - extension can work without it
316+
mdmService = undefined
317+
}
318+
319+
const tabProvider = new ClineProvider(context, outputChannel, "editor", contextProxy, mdmService)
320+
const lastCol = Math.max(...vscode.window.visibleTextEditors.map((editor) => editor.viewColumn || 0))
321+
322+
// Check if there are any visible text editors, otherwise open a new group
323+
// to the right.
324+
const hasVisibleEditors = vscode.window.visibleTextEditors.length > 0
325+
326+
if (!hasVisibleEditors) {
327+
await vscode.commands.executeCommand("workbench.action.newGroupRight")
328+
}
329+
330+
const targetCol = hasVisibleEditors ? Math.max(lastCol + 1, 1) : vscode.ViewColumn.Two
331+
332+
// Get the localized title for the settings tab
333+
const settingsTitle = t("settings:tabTitle") || "Roo Code Settings"
334+
335+
const newPanel = vscode.window.createWebviewPanel(
336+
"rooCodeSettings", // Unique ID for settings panel
337+
settingsTitle,
338+
targetCol,
339+
{
340+
enableScripts: true,
341+
retainContextWhenHidden: true,
342+
localResourceRoots: [context.extensionUri],
343+
},
344+
)
345+
346+
// Save as tab type panel.
347+
setPanel(newPanel, "tab")
348+
349+
// Use the same icon as the main panel
350+
newPanel.iconPath = {
351+
light: vscode.Uri.joinPath(context.extensionUri, "assets", "icons", "panel_light.png"),
352+
dark: vscode.Uri.joinPath(context.extensionUri, "assets", "icons", "panel_dark.png"),
353+
}
354+
355+
await tabProvider.resolveWebviewView(newPanel)
356+
357+
// Immediately send a message to open the settings view
358+
newPanel.webview.postMessage({ type: "action", action: "settingsButtonClicked" })
359+
360+
// Add listener for visibility changes to notify webview
361+
newPanel.onDidChangeViewState(
362+
(e) => {
363+
const panel = e.webviewPanel
364+
if (panel.visible) {
365+
panel.webview.postMessage({ type: "action", action: "didBecomeVisible" })
366+
}
367+
},
368+
null,
369+
context.subscriptions,
370+
)
371+
372+
// Handle panel closing events.
373+
newPanel.onDidDispose(
374+
() => {
375+
setPanel(undefined, "tab")
376+
},
377+
null,
378+
context.subscriptions,
379+
)
380+
381+
// Lock the editor group so clicking on files doesn't open them over the panel.
382+
await delay(100)
383+
await vscode.commands.executeCommand("workbench.action.lockEditorGroup")
384+
385+
return tabProvider
386+
}

webview-ui/src/i18n/locales/ca/settings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/de/settings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/en/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"add": "Add Header",
99
"remove": "Remove"
1010
},
11+
"tabTitle": "Roo Code Settings",
1112
"header": {
1213
"title": "Settings",
1314
"saveButtonTooltip": "Save changes",

webview-ui/src/i18n/locales/es/settings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/fr/settings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/hi/settings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/id/settings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/it/settings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/ja/settings.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)