Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Move static inline styles to classes the production CSP allows

rcourtman579ff5ca0f1a
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index d58b392ed1..07510556f3 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -5339,6 +5339,18 @@ That tooltip owner now also holds the CSP-safe hover contract: chart tooltips
must render inside the chart surface with model-owned layout and SVG/attribute
positioning, not through fixed portals or inline `left`/`top` style attributes
that violate the public demo CSP.
+The same CSP rule binds every runtime component, not only these owners. Solid
+compiles a static `style` value (a `style="..."` string, or any literal entry
+of a `style={{ ... }}` object) into the element's template HTML, and the
+production `style-src 'self' 'nonce-...'` policy reports each one as a
+`style-src-attr` violation when that template is parsed. Static styling must be
+a class: a Tailwind utility, or an arbitrary property such as the
+`[overflow-anchor:none]` on drawer tab panels. Only dynamic values may use
+`style`, because Solid applies those through CSSOM.
+`frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts`
+compiles every runtime `.tsx` that mentions `style` with the client-build Solid
+preset and fails on any `style` attribute or `<style>` element in the
+resulting templates, including nested `<template>` content.
Tooltip shell chrome must follow semantic surface, text, and border tokens
rather than hardcoded dark palette utilities so light and dark themes share one
primitive-owned contrast contract.
diff --git a/frontend-modern/browser-verification/a3125d7841e88aa9.json b/frontend-modern/browser-verification/a3125d7841e88aa9.json
new file mode 100644
index 0000000000..73bbb599e8
--- /dev/null
+++ b/frontend-modern/browser-verification/a3125d7841e88aa9.json
@@ -0,0 +1,78 @@
+{
+ "version": 1,
+ "base_sha": "bea0cec8b9c5bcc009b1d7a06c8a02d7458a459d",
+ "verified_at": "2026-10-07T08:00:14Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/components/AI/Chat/MessageItem.tsx",
+ "frontend-modern/src/components/AI/Chat/index.tsx",
+ "frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx",
+ "frontend-modern/src/components/Storage/DiskDetail.tsx",
+ "frontend-modern/src/components/Storage/StoragePoolDetail.tsx",
+ "frontend-modern/src/components/Workloads/GuestDrawer.tsx",
+ "frontend-modern/src/components/Workloads/NodeDrawer.tsx",
+ "frontend-modern/src/components/Workloads/ThresholdSlider.tsx",
+ "frontend-modern/src/components/shared/HelpIcon.tsx",
+ "frontend-modern/src/features/docker/DockerHostDrawer.tsx",
+ "frontend-modern/src/index.tsx"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/components/AI/Chat/MessageItem.tsx": "65cd98df1d0403de7e11c5a12eaeb919d0dd0af63c2889890bedd7d91a52831a",
+ "frontend-modern/src/components/AI/Chat/index.tsx": "bda296d1b6618237c1d358cf02974101b37325642fa85f13b8ecf9f8a4158b0c",
+ "frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx": "9e7ee3e3cbb5f8da38cf43e0aaecd105f43333d16df7338e849d3ccaf6804d8f",
+ "frontend-modern/src/components/Storage/DiskDetail.tsx": "0e0c2c3e924f81edb50afc07f35d8c15206d317a2cda73472444b958483fd5ca",
+ "frontend-modern/src/components/Storage/StoragePoolDetail.tsx": "891929182a286d0082aafe604eb5357e394dca1f33aefc684ffa03fd14eb98f2",
+ "frontend-modern/src/components/Workloads/GuestDrawer.tsx": "604deee9674aa3d97e45ccf7bc5b8c5dda27017dee2f235c107750911d2981b7",
+ "frontend-modern/src/components/Workloads/NodeDrawer.tsx": "060b6f94c7a1750219171188dcc016b17cc74b5459192d667c7995a4a9302380",
+ "frontend-modern/src/components/Workloads/ThresholdSlider.tsx": "1fcc6a5ad0c265a121c3b884744fc2b2925952aba81f99b56c144f91d9f8b046",
+ "frontend-modern/src/components/shared/HelpIcon.tsx": "dd8a0440ebac1c897fe9f14c3377ba3f0b7a261defc9f11ee4c74812532d4021",
+ "frontend-modern/src/features/docker/DockerHostDrawer.tsx": "e51a8a54858a5be8f31ed5aecaab1fe651925d29df0c411b76d95241611dee7d",
+ "frontend-modern/src/index.tsx": "2e05e71fa386dd56cc5d7ae74429e147a29fa79b71fb83e3464f5aab309cd72c"
+ },
+ "routes": [
+ "/standalone/machines",
+ "/docker/images",
+ "/docker",
+ "/proxmox",
+ "/proxmox/storage",
+ "/proxmox/storage?tab=disks",
+ "/alerts/thresholds",
+ "/settings/system-updates"
+ ],
+ "viewports": [
+ {
+ "width": 1440,
+ "height": 900
+ },
+ {
+ "width": 1920,
+ "height": 1080
+ },
+ {
+ "width": 390,
+ "height": 844
+ }
+ ],
+ "states": [
+ "Production build of this tree (vite build embedded into go build ./cmd/pulse) on origin/main bea0cec8b9, served by a private PULSE_MOCK_MODE backend without FRONTEND_DEV_SERVER, so every page carried the production CSP style-src 'self' 'nonce-...'; a second backend served the origin/main build as the before case",
+ "Before (origin/main build): opening a row's inline detail logged 8 style-src-attr CSP violations on /standalone/machines and /docker/images, 3 on a Docker host and 3 on a Proxmox guest, all from the vendor-solid template code; the HelpIcon popover logged 1 and the Assistant typing dots 5",
+ "After: 0 CSP console errors and 0 securitypolicyviolation events on every one of those opens at 1440x900 and 390x844, on the HelpIcon popover and on both sets of Assistant typing dots",
+ "Drawer tab panels have no style attribute and still compute overflow-anchor: none from the [overflow-anchor:none] class (8 panels on machines and images, 3 on a Docker host, 2 on a Proxmox guest); the origin/main build already computed none in Chromium despite the violations",
+ "Proxmox node drawer (opened from the host row chevron, 3 panels), storage pool detail on /proxmox/storage (2 panels) and physical disk detail History tab (1 panel): no style attribute, overflow-anchor none, 0 CSP events at 1440x900 and 390x844",
+ "Below the fold: rows opened at 785px and 778px of 900 (1440 wide) and 729px of 844 (390 wide) put the drawer 215 to 351px past the fold, and the clicked row did not move (0px drift over 2.5s) in either build",
+ "Alert threshold slider (desktop thresholds table at 1920 and 2560 wide, after clicking a CPU metric cell): the range inputs carry touch-none and no style attribute, compute touch-action none, and log 0 CSP events; the origin/main build put touch-action:none in a style attribute and logged 1 violation",
+ "HelpIcon popover on /settings/system-updates computes min-width 200px from the min-w-[200px] class while its dynamic top, left and max-width still apply through CSSOM",
+ "Assistant typing dots keep their stagger from classes: 0s, 0.12s and 0.24s on the first-token indicator, and 0s, 0.15s and 0.3s with 1s duration on the active-turn status bar",
+ "Pre-existing and identical in both builds, not changed here: a Docker host drawer opened near the page bottom moves its tab bar 73 to 93px when switching to the shorter History tab, and a Proxmox guest row scrolls 489px on open",
+ "No other console errors in any run"
+ ],
+ "interactions": [
+ "Playwright Chromium 1440x900 and 390x844 (mobile emulation) against both backends: on each route, picked the lowest fully visible row in the lower half of the viewport, clicked it, sampled the row's top every 25ms for 2.5s, counted CSP console errors and securitypolicyviolation events, and read computed overflow-anchor on every drawer tab panel",
+ "Scrolled the drawer tab bar to 140px from the top, clicked History then Overview, and sampled the tab bar position after each click",
+ "Opened the Proxmox node drawer by its chevron, a storage pool row on /proxmox/storage, and the first physical disk on the Physical Disks tab followed by its History tab, reading each tab panel's style attribute, computed overflow-anchor and CSP events",
+ "On /alerts/thresholds expanded all sections and clicked a row's CPU metric cell to open the slider editor, then read the range inputs' style attribute, class and computed touch-action",
+ "Opened the update channel HelpIcon on /settings/system-updates and read the popover's style attribute and computed min-width",
+ "Opened the Assistant on /proxmox, sent a question, and read the computed animation delay, duration and style attribute of each typing dot while waiting for the first token",
+ "WebKit probe of the origin/main build: no CSP events, and overflow-anchor is unsupported there"
+ ]
+}
diff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
index 0e17f19ab4..e5ca1eb767 100644
--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx
+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
@@ -691,14 +691,8 @@ export const MessageItem: Component<MessageItemProps> = (props) => {
<div class="flex items-center gap-2 py-1 text-sm text-muted">
<span class="flex gap-1" aria-hidden="true">
<span class="h-1.5 w-1.5 rounded-full bg-blue-500 animate-bounce" />
- <span
- class="h-1.5 w-1.5 rounded-full bg-blue-500 animate-bounce"
- style="animation-delay: 120ms"
- />
- <span
- class="h-1.5 w-1.5 rounded-full bg-blue-500 animate-bounce"
- style="animation-delay: 240ms"
- />
+ <span class="h-1.5 w-1.5 rounded-full bg-blue-500 animate-bounce [animation-delay:120ms]" />
+ <span class="h-1.5 w-1.5 rounded-full bg-blue-500 animate-bounce [animation-delay:240ms]" />
</span>
<Show when={workflowStatusText()} fallback={<span>Thinking...</span>}>
<span>{workflowStatusText()}</span>
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
index 90b73867f9..b3ea9b3f5b 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
@@ -679,6 +679,27 @@ describe('MessageItem', () => {
expect(container.querySelector('.animate-pulse')).not.toBeInTheDocument();
});
+ it('staggers the first-token dots with classes the production CSP allows', () => {
+ const { container } = render(() => (
+ <MessageItem
+ message={makeMessage({
+ role: 'assistant',
+ content: '',
+ isStreaming: true,
+ pendingTools: [],
+ streamEvents: [],
+ })}
+ {...makeHandlers()}
+ />
+ ));
+
+ const dots = Array.from(container.querySelectorAll('.animate-bounce'));
+ expect(dots).toHaveLength(3);
+ expect(dots.map((dot) => dot.getAttribute('style'))).toEqual([null, null, null]);
+ expect(dots[1]).toHaveClass('[animation-delay:120ms]');
+ expect(dots[2]).toHaveClass('[animation-delay:240ms]');
+ });
+
it('shows workflow progress inline before content arrives', () => {
render(() => (
<MessageItem
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index 51158f0824..168b7ba41f 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -5069,16 +5069,13 @@ export const AIChat: Component<AIChatProps> = (props) => {
<span class="min-w-0 flex-1 truncate font-medium">{currentStatusText()}</span>
<span class="flex shrink-0 gap-0.5" aria-hidden="true">
<span
- class={`h-1 w-1 rounded-full animate-bounce ${currentStatusDotClass()}`}
- style="animation-delay: 0ms; animation-duration: 1s"
+ class={`h-1 w-1 rounded-full animate-bounce [animation-delay:0ms] ${currentStatusDotClass()}`}
/>
<span
- class={`h-1 w-1 rounded-full animate-bounce ${currentStatusDotClass()}`}
- style="animation-delay: 150ms; animation-duration: 1s"
+ class={`h-1 w-1 rounded-full animate-bounce [animation-delay:150ms] ${currentStatusDotClass()}`}
/>
<span
- class={`h-1 w-1 rounded-full animate-bounce ${currentStatusDotClass()}`}
- style="animation-delay: 300ms; animation-duration: 1s"
+ class={`h-1 w-1 rounded-full animate-bounce [animation-delay:300ms] ${currentStatusDotClass()}`}
/>
</span>
</div>
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
index 243092e9dd..8a37e9c94b 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
@@ -187,10 +187,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
tabs={drawer.tabs().map((tab) => ({ value: tab.id, label: tab.label }))}
/>
- <div
- class={drawer.activeTab() === 'overview' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${drawer.activeTab() === 'overview' ? '' : 'hidden'}`}>
<ResourceDetailDrawerOverviewTab
resource={props.resource}
drawer={drawer}
@@ -199,10 +196,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
</div>
{/* Agent Machine Metrics History Tab */}
- <div
- class={drawer.activeTab() === 'history' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${drawer.activeTab() === 'history' ? '' : 'hidden'}`}>
<Show when={drawer.activeTab() === 'history'}>
<Show
when={drawer.metricsHistoryTarget()}
@@ -229,10 +223,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
</Show>
</div>
- <div
- class={drawer.activeTab() === 'manage' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${drawer.activeTab() === 'manage' ? '' : 'hidden'}`}>
<Show when={drawer.activeTab() === 'manage'}>
<div class="space-y-3" data-testid="resource-manage-tab">
<ResourceOperatorStateSection
@@ -261,10 +252,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
</div>
{/* Discovery Tab */}
- <div
- class={drawer.activeTab() === 'discovery' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${drawer.activeTab() === 'discovery' ? '' : 'hidden'}`}>
<Show when={drawer.activeTab() === 'discovery'}>
<Show
when={drawer.discoveryConfig()}
@@ -289,10 +277,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
</div>
{/* PMG Mail Tab */}
- <div
- class={drawer.activeTab() === 'mail' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${drawer.activeTab() === 'mail' ? '' : 'hidden'}`}>
{/* Mount on-demand to avoid background fetching when the tab isn't open. */}
<Show when={drawer.activeTab() === 'mail'}>
<Show
@@ -307,10 +292,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
</div>
{/* Kubernetes Namespaces Tab */}
- <div
- class={drawer.activeTab() === 'namespaces' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${drawer.activeTab() === 'namespaces' ? '' : 'hidden'}`}>
{/* Mount on-demand to avoid background fetching when the tab isn't open. */}
<Show when={drawer.activeTab() === 'namespaces'}>
<Show
@@ -331,10 +313,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
</div>
{/* Kubernetes Deployments Tab */}
- <div
- class={drawer.activeTab() === 'deployments' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${drawer.activeTab() === 'deployments' ? '' : 'hidden'}`}>
{/* Mount on-demand to avoid background fetching when the tab isn't open. */}
<Show when={drawer.activeTab() === 'deployments'}>
<Show
@@ -354,10 +333,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
</div>
{/* Docker Swarm Tab */}
- <div
- class={drawer.activeTab() === 'swarm' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${drawer.activeTab() === 'swarm' ? '' : 'hidden'}`}>
{/* Mount on-demand to avoid background fetching when the tab isn't open. */}
<Show when={drawer.activeTab() === 'swarm'}>
<Show
@@ -376,10 +352,7 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
{/* Debug Tab */}
<Show when={drawer.debugEnabled()}>
- <div
- class={drawer.activeTab() === 'debug' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${drawer.activeTab() === 'debug' ? '' : 'hidden'}`}>
<ResourceDetailDrawerDebugTab resource={props.resource} drawer={drawer} />
</div>
</Show>
diff --git a/frontend-modern/src/components/Storage/DiskDetail.tsx b/frontend-modern/src/components/Storage/DiskDetail.tsx
index b90f772797..3343c8cfd5 100644
--- a/frontend-modern/src/components/Storage/DiskDetail.tsx
+++ b/frontend-modern/src/components/Storage/DiskDetail.tsx
@@ -180,10 +180,7 @@ export const DiskDetail: Component<DiskDetailProps> = (props) => {
</Show>
</div>
- <div
- class={activeTab() === 'history' ? 'space-y-3' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${activeTab() === 'history' ? 'space-y-3' : 'hidden'}`}>
<Show when={activeTab() === 'history'}>
<Show when={metricResourceId() && liveIOAvailable()}>
<div class={STORAGE_DISK_DETAIL_SECTION_CLASS}>
diff --git a/frontend-modern/src/components/Storage/StoragePoolDetail.tsx b/frontend-modern/src/components/Storage/StoragePoolDetail.tsx
index c1b9521523..ddecaebb0e 100644
--- a/frontend-modern/src/components/Storage/StoragePoolDetail.tsx
+++ b/frontend-modern/src/components/Storage/StoragePoolDetail.tsx
@@ -115,8 +115,7 @@ export const StoragePoolDetail: Component<StoragePoolDetailProps> = (props) => {
/>
<div
- class={activeTab() === 'overview' ? STORAGE_DETAIL_ROOT_GRID_CLASS : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
+ class={`[overflow-anchor:none] ${activeTab() === 'overview' ? STORAGE_DETAIL_ROOT_GRID_CLASS : 'hidden'}`}
>
<Show when={topologyRows().length > 0}>
<div class={STORAGE_DETAIL_CARD_CLASS}>
@@ -305,10 +304,7 @@ export const StoragePoolDetail: Component<StoragePoolDetailProps> = (props) => {
</Show>
</div>
- <div
- class={activeTab() === 'history' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${activeTab() === 'history' ? '' : 'hidden'}`}>
<Show when={activeTab() === 'history'}>
<div class={STORAGE_DETAIL_CARD_CLASS}>
<div class={STORAGE_DETAIL_HEADER_ROW_CLASS}>
diff --git a/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx b/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx
index 0438d3f0a8..5f094a8215 100644
--- a/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx
+++ b/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx
@@ -171,7 +171,7 @@ function makeGuestWithDiscoveryTarget(overrides: Partial<WorkloadGuest> = {}): W
}
function getDiscoveryPanel(): HTMLElement {
- const panel = screen.getByTestId('discovery-tab').closest('[style*="overflow-anchor"]');
+ const panel = screen.getByTestId('discovery-tab').closest('[class*="overflow-anchor"]');
if (!(panel instanceof HTMLElement)) {
throw new Error('Discovery tab panel not found');
}
@@ -649,7 +649,7 @@ describe('GuestDrawer', () => {
const { container } = solidRender(() => (
<GuestDrawer guest={makeGuestWithDiscoveryTarget()} onClose={vi.fn()} />
));
- const panels = container.querySelectorAll('[style*="overflow-anchor"]');
+ const panels = container.querySelectorAll('[class*="overflow-anchor"]');
expect(panels[0]).not.toHaveClass('hidden');
expect(panels[1]).toHaveClass('hidden');
});
@@ -950,7 +950,7 @@ describe('GuestDrawer', () => {
<GuestDrawer guest={makeGuestWithDiscoveryTarget()} onClose={vi.fn()} />
));
await fireEvent.click(screen.getByRole('tab', { name: 'Discovery' }));
- const panels = container.querySelectorAll('[style*="overflow-anchor"]');
+ const panels = container.querySelectorAll('[class*="overflow-anchor"]');
expect(panels[0]).toHaveClass('hidden');
expect(getDiscoveryPanel()).not.toHaveClass('hidden');
});
@@ -1084,7 +1084,7 @@ describe('GuestDrawer', () => {
));
await fireEvent.click(screen.getByRole('tab', { name: 'Discovery' }));
await fireEvent.click(screen.getByRole('tab', { name: 'Overview' }));
- const panels = container.querySelectorAll('[style*="overflow-anchor"]');
+ const panels = container.querySelectorAll('[class*="overflow-anchor"]');
expect(panels[0]).not.toHaveClass('hidden');
expect(getDiscoveryPanel()).toHaveClass('hidden');
});
diff --git a/frontend-modern/src/components/Workloads/GuestDrawer.tsx b/frontend-modern/src/components/Workloads/GuestDrawer.tsx
index 74901bb1d3..4b0b7f12c8 100644
--- a/frontend-modern/src/components/Workloads/GuestDrawer.tsx
+++ b/frontend-modern/src/components/Workloads/GuestDrawer.tsx
@@ -160,7 +160,7 @@ const GuestDrawerContent: Component<GuestDrawerProps> = (props) => {
{/* Use CSS hidden instead of Show to avoid mount/unmount which causes scroll jumps.
overflow-anchor: none prevents browser scroll anchoring from jumping when display toggles. */}
- <div class={activeTab() === 'overview' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
+ <div class={`[overflow-anchor:none] ${activeTab() === 'overview' ? '' : 'hidden'}`}>
<GuestDrawerOverview
guest={props.guest}
guestOsSummary={guestOsSummary()}
@@ -188,7 +188,7 @@ const GuestDrawerContent: Component<GuestDrawerProps> = (props) => {
</div>
{hasHistorySupport() && activeTab() === 'history' && (
- <div style={{ 'overflow-anchor': 'none' }}>
+ <div class="[overflow-anchor:none]">
<GuestDrawerHistory
target={historyTarget()}
range={historyRange()}
@@ -203,10 +203,7 @@ const GuestDrawerContent: Component<GuestDrawerProps> = (props) => {
up to the app-level Suspense and replace the entire page. */}
<Show when={discoveryPanelKey()} keyed>
{(_targetKey) => (
- <div
- class={activeTab() === 'discovery' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${activeTab() === 'discovery' ? '' : 'hidden'}`}>
<Suspense fallback={<DiscoveryLoadingFallback text={discoveryLoadingState.text} />}>
<DiscoveryTab
resourceType={discoveryResourceType()!}
@@ -226,7 +223,7 @@ const GuestDrawerContent: Component<GuestDrawerProps> = (props) => {
)}
</Show>
- <div class={activeTab() === 'manage' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
+ <div class={`[overflow-anchor:none] ${activeTab() === 'manage' ? '' : 'hidden'}`}>
<Show when={activeTab() === 'manage'}>
<GuestDrawerManage
guest={props.guest}
diff --git a/frontend-modern/src/components/Workloads/NodeDrawer.tsx b/frontend-modern/src/components/Workloads/NodeDrawer.tsx
index 38006379af..20ee64ad42 100644
--- a/frontend-modern/src/components/Workloads/NodeDrawer.tsx
+++ b/frontend-modern/src/components/Workloads/NodeDrawer.tsx
@@ -124,7 +124,7 @@ export const NodeDrawer: Component<NodeDrawerProps> = (props) => {
{/* Use CSS hidden instead of Show to avoid mount/unmount which causes scroll jumps.
overflow-anchor: none prevents browser scroll anchoring from jumping when display toggles. */}
- <div class={activeTab() === 'overview' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
+ <div class={`[overflow-anchor:none] ${activeTab() === 'overview' ? '' : 'hidden'}`}>
<NodeDrawerOverview
node={props.node}
disks={props.disks}
@@ -133,7 +133,7 @@ export const NodeDrawer: Component<NodeDrawerProps> = (props) => {
/>
</div>
- <div class={activeTab() === 'history' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
+ <div class={`[overflow-anchor:none] ${activeTab() === 'history' ? '' : 'hidden'}`}>
<GuestDrawerHistory
currentMetrics={currentMetrics()}
groups={historyGroups()}
@@ -142,7 +142,7 @@ export const NodeDrawer: Component<NodeDrawerProps> = (props) => {
/>
</div>
- <div class={activeTab() === 'manage' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
+ <div class={`[overflow-anchor:none] ${activeTab() === 'manage' ? '' : 'hidden'}`}>
<Show when={activeTab() === 'manage'}>
<div data-testid="node-manage-tab">
<ResourceOperatorStateSection
@@ -156,10 +156,7 @@ export const NodeDrawer: Component<NodeDrawerProps> = (props) => {
<Show when={enabledDiscoveryTarget()}>
{(target) => (
- <div
- class={activeTab() === 'discovery' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${activeTab() === 'discovery' ? '' : 'hidden'}`}>
<Suspense fallback={<DiscoveryLoadingFallback />}>
<DiscoveryTab
resourceType="agent"
diff --git a/frontend-modern/src/components/Workloads/ThresholdSlider.tsx b/frontend-modern/src/components/Workloads/ThresholdSlider.tsx
index 520895ff1e..dae5b17ed8 100644
--- a/frontend-modern/src/components/Workloads/ThresholdSlider.tsx
+++ b/frontend-modern/src/components/Workloads/ThresholdSlider.tsx
@@ -33,9 +33,8 @@ export function ThresholdSlider(props: ThresholdSliderProps) {
onInput={state.handleInput}
onMouseDown={state.handleMouseDown}
onWheel={state.handleInputWheel}
- class={`absolute inset-0 w-full h-3.5 opacity-0 ${props.disabled ? 'cursor-not-allowed' : 'cursor-pointer'} z-20`}
+ class={`absolute inset-0 w-full h-3.5 opacity-0 ${props.disabled ? 'cursor-not-allowed' : 'cursor-pointer'} z-20 touch-none`}
disabled={props.disabled}
- style={{ 'touch-action': 'none' }}
title={state.sliderTitle()}
/>
diff --git a/frontend-modern/src/components/shared/HelpIcon.tsx b/frontend-modern/src/components/shared/HelpIcon.tsx
index ab98ec2f05..97588da1c2 100644
--- a/frontend-modern/src/components/shared/HelpIcon.tsx
+++ b/frontend-modern/src/components/shared/HelpIcon.tsx
@@ -41,12 +41,11 @@ export const HelpIcon: Component<HelpIconProps> = (props) => {
id={popoverId}
role="dialog"
aria-labelledby={titleId}
- class="fixed z-9999 bg-surface rounded-md shadow-xs border border-border overflow-hidden animate-in fade-in-0 zoom-in-95 duration-150"
+ class="fixed z-9999 bg-surface rounded-md shadow-xs border border-border overflow-hidden animate-in fade-in-0 zoom-in-95 duration-150 min-w-[200px]"
style={{
top: `${state.popoverPosition().top}px`,
left: `${state.popoverPosition().left}px`,
'max-width': `${state.maxWidth()}px`,
- 'min-width': '200px',
}}
>
{/* Header */}
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 7697db0332..43b31bfe80 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -1,3 +1,6 @@
+import { traverse, transformSync, types as t } from '@babel/core';
+// @ts-expect-error babel-preset-solid ships no type declarations.
+import solidPreset from 'babel-preset-solid';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { describe, expect, it } from 'vitest';
@@ -8859,3 +8862,135 @@ describe('shared primitive guardrails', () => {
}
});
});
+
+// The production server sends `style-src 'self' 'nonce-...'` without
+// 'unsafe-inline' (internal/api/security.go), so the browser reports every
+// style attribute that arrives as markup. Solid compiles static style values
+// (`style="..."`, or any literal entry of a `style={{ ... }}` object) into the
+// element's template HTML, which is such markup: each render logs a CSP
+// violation, and whether the style still applies is up to the browser. The Vite
+// dev server allows inline styles, so this only shows in a production build.
+// Dynamic style values are applied through CSSOM at runtime and are fine.
+const componentRuntimeSources = import.meta.glob(
+ ['../../**/*.tsx', '!../../**/__tests__/**', '!../../**/*.test.tsx'],
+ { query: '?raw', eager: true, import: 'default' },
+) as Record<string, string>;
+
+const compileSolidTemplates = (source: string, filename: string): string[] => {
+ // Same Solid preset options vite-plugin-solid uses for the client build.
+ const result = transformSync(source, {
+ filename,
+ babelrc: false,
+ configFile: false,
+ ast: true,
+ code: false,
+ parserOpts: { plugins: ['jsx', 'typescript'] },
+ presets: [[solidPreset, { generate: 'dom', hydratable: false }]],
+ });
+ const templates: string[] = [];
+ if (!result?.ast) return templates;
+
+ const templateHelpers = new Set<string>();
+ traverse(result.ast, {
+ ImportSpecifier(path) {
+ const imported = path.node.imported;
+ const importedName = t.isIdentifier(imported) ? imported.name : imported.value;
+ const parent = path.parentPath.node;
+ if (
+ importedName === 'template' &&
+ t.isImportDeclaration(parent) &&
+ parent.source.value === 'solid-js/web'
+ ) {
+ templateHelpers.add(path.node.local.name);
+ }
+ },
+ });
+ if (templateHelpers.size === 0) return templates;
+
+ traverse(result.ast, {
+ CallExpression(path) {
+ const { callee, arguments: args } = path.node;
+ if (!t.isIdentifier(callee) || !templateHelpers.has(callee.name)) return;
+ const [html] = args;
+ if (t.isTemplateLiteral(html)) {
+ templates.push(html.quasis.map((quasi) => quasi.value.cooked ?? '').join(''));
+ } else if (t.isStringLiteral(html)) {
+ templates.push(html.value);
+ }
+ },
+ });
+ return templates;
+};
+
+// Style attributes and <style> elements, including those inside nested
+// <template> content, which querySelectorAll does not enter.
+const collectInlineStyleMarkup = (root: ParentNode): string[] =>
+ Array.from(root.querySelectorAll('[style], style, template')).flatMap((element) => {
+ const found: string[] = [];
+ if (element.hasAttribute('style')) {
+ found.push(`<${element.localName} style="${element.getAttribute('style')}">`);
+ }
+ if (element.localName === 'style') found.push('<style>');
+ if (element instanceof HTMLTemplateElement) {
+ found.push(...collectInlineStyleMarkup(element.content));
+ }
+ return found;
+ });
+
+const findTemplateStyleAttributes = (source: string, filename: string): string[] =>
+ compileSolidTemplates(source, filename).flatMap((html) => {
+ const template = document.createElement('template');
+ template.innerHTML = html;
+ return collectInlineStyleMarkup(template.content);
+ });
+
+describe('production CSP inline style guardrails', () => {
+ it('detects the static style forms Solid compiles into template markup', () => {
+ const fixture = `
+ export const Fixture = (props: { width: number; shown: boolean }) => (
+ <section>
+ <div style={{ 'overflow-anchor': 'none' }} />
+ <span style="animation-delay: 120ms" />
+ <p style={{ 'min-width': '0', width: \`\${props.width}px\` }} />
+ <b style={{ width: \`\${props.width}px\` }} />
+ <i style={props.shown ? 'opacity: 1' : undefined} />
+ <em class="[overflow-anchor:none]" />
+ <u STYLE="color: blue" />
+ <template>
+ <s style="color: red" />
+ </template>
+ <style>{'.fixture { color: green; }'}</style>
+ </section>
+ );
+ `;
+
+ expect(findTemplateStyleAttributes(fixture, 'Fixture.tsx')).toEqual([
+ '<div style="overflow-anchor:none">',
+ '<span style="animation-delay:120ms">',
+ '<p style="min-width:0">',
+ '<u style="color:blue">',
+ '<s style="color:red">',
+ '<style>',
+ ]);
+ });
+
+ // Use a class for static styling instead: a Tailwind utility, or an
+ // arbitrary property such as `[overflow-anchor:none]`. Only files that
+ // mention style can emit one, and compiling those takes a few seconds, or
+ // tens of seconds on a loaded machine.
+ it('keeps static style attributes out of every runtime component template', () => {
+ const paths = Object.keys(componentRuntimeSources);
+ expect(paths.length).toBeGreaterThan(100);
+
+ const offenders = paths
+ .filter((path) => /\bstyle\b/i.test(componentRuntimeSources[path]))
+ .flatMap((path) =>
+ findTemplateStyleAttributes(componentRuntimeSources[path], path).map(
+ (attribute) => `${path}: ${attribute}`,
+ ),
+ )
+ .sort();
+
+ expect(offenders).toEqual([]);
+ }, 120_000);
+});
diff --git a/frontend-modern/src/features/docker/DockerHostDrawer.tsx b/frontend-modern/src/features/docker/DockerHostDrawer.tsx
index 241b953949..4a58c4c2dd 100644
--- a/frontend-modern/src/features/docker/DockerHostDrawer.tsx
+++ b/frontend-modern/src/features/docker/DockerHostDrawer.tsx
@@ -111,11 +111,11 @@ export const DockerHostDrawer: Component<DockerHostDrawerProps> = (props) => {
{/* Use CSS hidden instead of Show to avoid mount/unmount which causes scroll jumps.
overflow-anchor: none prevents browser scroll anchoring from jumping when display toggles. */}
- <div class={activeTab() === 'overview' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
+ <div class={`[overflow-anchor:none] ${activeTab() === 'overview' ? '' : 'hidden'}`}>
<DockerHostDrawerOverview host={props.host} />
</div>
- <div class={activeTab() === 'manage' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
+ <div class={`[overflow-anchor:none] ${activeTab() === 'manage' ? '' : 'hidden'}`}>
<Show when={activeTab() === 'manage'}>
<div class="space-y-3" data-testid="docker-host-manage-tab">
<DockerHostDrawerManagement host={props.host} />
@@ -137,7 +137,7 @@ export const DockerHostDrawer: Component<DockerHostDrawerProps> = (props) => {
</Show>
</div>
- <div class={activeTab() === 'history' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
+ <div class={`[overflow-anchor:none] ${activeTab() === 'history' ? '' : 'hidden'}`}>
<GuestDrawerHistory
currentMetrics={currentMetrics()}
groups={DOCKER_HOST_DRAWER_HISTORY_GROUPS}
@@ -148,10 +148,7 @@ export const DockerHostDrawer: Component<DockerHostDrawerProps> = (props) => {
<Show when={hasDiscoverySupport() ? discoveryConfig() : null}>
{(config) => (
- <div
- class={activeTab() === 'discovery' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
+ <div class={`[overflow-anchor:none] ${activeTab() === 'discovery' ? '' : 'hidden'}`}>
<Suspense fallback={<DiscoveryLoadingFallback />}>
<DiscoveryTab
resourceType={config().resourceType}
diff --git a/frontend-modern/src/index.tsx b/frontend-modern/src/index.tsx
index b8ac0b322c..cc472e2a50 100644
--- a/frontend-modern/src/index.tsx
+++ b/frontend-modern/src/index.tsx
@@ -21,11 +21,16 @@ if (root) {
logger.debug('[Index] Render call completed');
} catch (error) {
logger.error('[Index] Render error', error);
- // Show error on page
- root.innerHTML = `<div style="color: red; padding: 20px;">
- <h1>Error Loading App</h1>
- <pre>${error}</pre>
- </div>`;
+ // Show error on page. Built with DOM nodes and classes: the production CSP
+ // refuses inline style attributes, and the error text is not markup.
+ const fallback = document.createElement('div');
+ fallback.className = 'p-5 text-red-600';
+ const heading = document.createElement('h1');
+ heading.textContent = 'Error Loading App';
+ const detail = document.createElement('pre');
+ detail.textContent = String(error);
+ fallback.append(heading, detail);
+ root.replaceChildren(fallback);
}
} else {
logger.error('[Index] Root element not found', new Error('root element missing'));