Skip to content

Commit 064adab

Browse files
authored
Add ability to show or hide other panels (#77)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Introduced a "Panel Visibility" toggle in Advanced Settings, enabling users to display only the AI Chat panel * User preference persists across sessions and applies immediately upon activation <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 97a0c49 commit 064adab

File tree

5 files changed

+60
-5
lines changed

5 files changed

+60
-5
lines changed

front_end/panels/ai_chat/ui/SettingsDialog.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import * as Host from '../../../core/host/host.js';
56
import * as UI from '../../../ui/legacy/legacy.js';
67
import { createLogger } from '../core/Logger.js';
78
import { LLMClient } from '../LLM/LLMClient.js';
@@ -10,7 +11,7 @@ import { CustomProviderManager } from '../core/CustomProviderManager.js';
1011

1112
// Import settings utilities
1213
import { i18nString, UIStrings } from './settings/i18n-strings.js';
13-
import { PROVIDER_SELECTION_KEY, MINI_MODEL_STORAGE_KEY, NANO_MODEL_STORAGE_KEY, ADVANCED_SETTINGS_ENABLED_KEY } from './settings/constants.js';
14+
import { PROVIDER_SELECTION_KEY, MINI_MODEL_STORAGE_KEY, NANO_MODEL_STORAGE_KEY, ADVANCED_SETTINGS_ENABLED_KEY, PANEL_FILTER_ENABLED_KEY } from './settings/constants.js';
1415
import { applySettingsStyles } from './settings/utils/styles.js';
1516
import { isVectorDBEnabled } from './settings/utils/storage.js';
1617
import type { ModelOption, ProviderType, FetchLiteLLMModelsFunction, UpdateModelOptionsFunction, GetModelOptionsFunction, AddCustomModelOptionFunction, RemoveCustomModelOptionFunction } from './settings/types.js';
@@ -490,6 +491,43 @@ export class SettingsDialog {
490491
evaluationSection.className = 'settings-section evaluation-section';
491492
contentDiv.appendChild(evaluationSection);
492493

494+
// Create panel filter section (inside advanced settings)
495+
const panelFilterSection = document.createElement('div');
496+
panelFilterSection.className = 'settings-section panel-filter-section';
497+
contentDiv.appendChild(panelFilterSection);
498+
499+
const panelFilterTitle = document.createElement('h3');
500+
panelFilterTitle.className = 'settings-subtitle';
501+
panelFilterTitle.textContent = 'Panel Visibility';
502+
panelFilterSection.appendChild(panelFilterTitle);
503+
504+
const panelFilterContainer = document.createElement('div');
505+
panelFilterContainer.className = 'settings-checkbox-container';
506+
panelFilterContainer.style.cssText = 'display: flex; align-items: center; gap: 8px; margin-bottom: 8px;';
507+
panelFilterSection.appendChild(panelFilterContainer);
508+
509+
const panelFilterCheckbox = document.createElement('input');
510+
panelFilterCheckbox.type = 'checkbox';
511+
panelFilterCheckbox.id = 'panel-filter-toggle';
512+
panelFilterCheckbox.checked = localStorage.getItem(PANEL_FILTER_ENABLED_KEY) !== 'false';
513+
panelFilterContainer.appendChild(panelFilterCheckbox);
514+
515+
const panelFilterLabel = document.createElement('label');
516+
panelFilterLabel.htmlFor = 'panel-filter-toggle';
517+
panelFilterLabel.textContent = 'Show only AI Chat panel';
518+
panelFilterContainer.appendChild(panelFilterLabel);
519+
520+
const panelFilterHint = document.createElement('div');
521+
panelFilterHint.className = 'settings-hint';
522+
panelFilterHint.textContent = 'When disabled, shows all standard DevTools panels (Elements, Console, etc.). Requires DevTools reload.';
523+
panelFilterSection.appendChild(panelFilterHint);
524+
525+
panelFilterCheckbox.addEventListener('change', () => {
526+
localStorage.setItem(PANEL_FILTER_ENABLED_KEY, panelFilterCheckbox.checked.toString());
527+
// Reload DevTools to apply the panel filter change
528+
Host.InspectorFrontendHost.InspectorFrontendHostInstance.reattach(() => window.location.reload());
529+
});
530+
493531
// Instantiate advanced feature settings classes
494532
const browsingHistorySettings = new BrowsingHistorySettings(historySection);
495533
const vectorDBSettings = new VectorDBSettings(vectorDBSection);
@@ -523,6 +561,7 @@ export class SettingsDialog {
523561
vectorDBSection.style.display = display;
524562
tracingSection.style.display = display;
525563
evaluationSection.style.display = display;
564+
panelFilterSection.style.display = display;
526565

527566
// Save state to localStorage
528567
localStorage.setItem(ADVANCED_SETTINGS_ENABLED_KEY, show.toString());

front_end/panels/ai_chat/ui/settings/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ export const ADVANCED_SETTINGS_ENABLED_KEY = 'ai_chat_advanced_settings_enabled'
5050
* Memory system toggle key
5151
*/
5252
export const MEMORY_ENABLED_KEY = 'ai_chat_memory_enabled';
53+
54+
/**
55+
* Panel filter toggle key - controls whether only AI Chat panel is shown
56+
*/
57+
export const PANEL_FILTER_ENABLED_KEY = 'ai_chat_panel_filter_enabled';

front_end/panels/ai_chat/ui/settings/utils/styles.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ export function getSettingsStyles(): string {
373373
border-bottom: 1px solid var(--color-details-hairline);
374374
}
375375
376+
.panel-filter-section {
377+
margin-top: 16px;
378+
padding: 16px 20px;
379+
border-bottom: 1px solid var(--color-details-hairline);
380+
}
381+
376382
.settings-section-title {
377383
font-size: 16px;
378384
font-weight: 500;

front_end/ui/legacy/InspectorView.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,11 @@ export class InspectorView extends VBox implements ViewLocationResolver {
257257
drag: true,
258258
keydown: 'ArrowUp|ArrowLeft|ArrowDown|ArrowRight|Enter|Space',
259259
})}`);
260-
(mainHeaderElement as HTMLElement).style.display = 'none';
260+
// Only hide the tab bar when panel filter is enabled (ai-chat only mode)
261+
const panelFilterEnabled = localStorage.getItem('ai_chat_panel_filter_enabled') !== 'false';
262+
if (panelFilterEnabled) {
263+
(mainHeaderElement as HTMLElement).style.display = 'none';
264+
}
261265

262266
// Store the initial selected panel for use in launch histograms
263267
Host.userMetrics.setLaunchPanel(this.tabbedPane.selectedTabId);

front_end/ui/legacy/ViewRegistration.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,12 @@ export interface ViewRegistration {
162162

163163
const viewIdSet = new Set<string>();
164164
export function registerViewExtension(registration: ViewRegistration): void {
165-
// START ADDED CODE: Filter out panels other than ai-chat
166-
if (registration.location === ViewLocationValues.PANEL && registration.id !== 'ai-chat') {
165+
// Check if panel filtering is enabled (default: true for ai-chat only mode)
166+
const panelFilterEnabled = localStorage.getItem('ai_chat_panel_filter_enabled') !== 'false';
167+
168+
if (panelFilterEnabled && registration.location === ViewLocationValues.PANEL && registration.id !== 'ai-chat') {
167169
return; // Don't register this panel
168170
}
169-
// END ADDED CODE
170171

171172
const viewId = registration.id;
172173
if (viewIdSet.has(viewId)) {

0 commit comments

Comments
 (0)