diff --git a/app/components/HelpPanel.tsx b/app/components/HelpPanel.tsx index dd83998..9c637fa 100644 --- a/app/components/HelpPanel.tsx +++ b/app/components/HelpPanel.tsx @@ -256,7 +256,17 @@ function McpHealthAccordion() { ) } -export default function HelpPanel({ sandboxes }: { sandboxes: SandboxInventoryItem[] }) { +type HelpPanelProps = { + sandboxes: SandboxInventoryItem[] + telemetryBarEnabled: boolean + onTelemetryBarEnabledChange: (enabled: boolean) => void +} + +export default function HelpPanel({ + sandboxes, + telemetryBarEnabled, + onTelemetryBarEnabledChange, +}: HelpPanelProps) { return (
@@ -329,6 +339,25 @@ export default function HelpPanel({ sandboxes }: { sandboxes: SandboxInventoryIt + +
+ +
) } diff --git a/app/page.tsx b/app/page.tsx index 3960ebf..613809b 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -17,12 +17,15 @@ import { updateDashboardSessionSelection, } from './lib/dashboardSession' +const TELEMETRY_BAR_ENABLED_KEY = 'openshell-control.telemetry-bar-enabled' + export default function Dashboard() { const [theme, setTheme] = useState<'light' | 'dark'>('dark') const [dashboardSession, setDashboardSession] = useState(() => createHydrationSafeDashboardSessionState()) const [isCreateMode, setIsCreateMode] = useState(false) const [isDestroyMode, setIsDestroyMode] = useState(false) const [activeView, setActiveView] = useState<'settings' | 'sandboxes' | 'help' | 'wizards' | 'mcp'>('sandboxes') + const [telemetryBarEnabled, setTelemetryBarEnabled] = useState(false) const [deletingSandboxId, setDeletingSandboxId] = useState(null) const [showDeleteConfirm, setShowDeleteConfirm] = useState(false) const [lifecycleMessage, setLifecycleMessage] = useState(null) @@ -34,6 +37,7 @@ export default function Dashboard() { useEffect(() => { setDashboardSession(loadDashboardSessionState()) + setTelemetryBarEnabled(window.localStorage.getItem(TELEMETRY_BAR_ENABLED_KEY) === 'true') }, []) useEffect(() => { @@ -57,6 +61,11 @@ export default function Dashboard() { setTheme(theme === 'light' ? 'dark' : 'light') } + const handleTelemetryBarEnabledChange = (enabled: boolean) => { + setTelemetryBarEnabled(enabled) + window.localStorage.setItem(TELEMETRY_BAR_ENABLED_KEY, enabled ? 'true' : 'false') + } + useEffect(() => { if (!inventoryEnabled || loading || isCreateMode || isDestroyMode) return if (sandboxes.length === 0) { @@ -238,7 +247,7 @@ export default function Dashboard() {
- + {telemetryBarEnabled && } {activeView === 'settings' ? (
@@ -263,7 +272,11 @@ export default function Dashboard() {
) : activeView === 'help' ? ( - + ) : activeView === 'mcp' ? ( ) : activeView === 'wizards' ? ( diff --git a/tests/telemetry-bar-toggle-check.mjs b/tests/telemetry-bar-toggle-check.mjs new file mode 100644 index 0000000..bea5688 --- /dev/null +++ b/tests/telemetry-bar-toggle-check.mjs @@ -0,0 +1,22 @@ +import assert from 'node:assert/strict' +import { readFile } from 'node:fs/promises' +import path from 'node:path' + +const root = process.cwd() +const pagePath = path.join(root, 'app/page.tsx') +const helpPanelPath = path.join(root, 'app/components/HelpPanel.tsx') + +const [pageSource, helpPanelSource] = await Promise.all([ + readFile(pagePath, 'utf8'), + readFile(helpPanelPath, 'utf8'), +]) + +assert.match(pageSource, /useState\(false\)/, 'telemetry bar must be disabled by default') +assert.match(pageSource, /TELEMETRY_BAR_ENABLED_KEY/, 'telemetry bar preference must have a persistent storage key') +assert.match(pageSource, /telemetryBarEnabled && /, 'live telemetry bar must only mount when enabled') +assert.match(pageSource, /localStorage\.setItem\(TELEMETRY_BAR_ENABLED_KEY/, 'telemetry bar preference must persist when toggled') +assert.match(helpPanelSource, /Enable Telemetry Bar - EXPERIMENTAL/, 'Help must expose the requested telemetry bar checkbox label') +assert.match(helpPanelSource, /The telemetry bar is setup for vLLM tokens per second and does not currently work with other endpoints\./, 'Help must include the requested experimental caveat') +assert.match(helpPanelSource, /type="checkbox"[\s\S]*checked=\{telemetryBarEnabled\}/, 'Help checkbox must reflect telemetry bar enabled state') + +console.log('telemetry bar toggle checks passed')