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.

Fix Proxmox tag color style propagation

rcourtman092c9ee6c738
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index c201ab1d5a..9673300935 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -1761,6 +1761,13 @@ a new API state machine, queue contract, or verification-accounting field.
host-agent row for the same machine must leave the API boundary as one
hybrid `agent` resource with merged source facets, not as duplicate rows
that disappear only after REST reconciliation.
+ Realtime `/api/state` and websocket state snapshots also own Proxmox tag
+ presentation payloads. `pveTagStyles` is keyed by Proxmox instance and
+ carries the parsed datacenter `tag-style` color overrides plus
+ `caseSensitive`; frontend consumers must treat it as the canonical
+ per-instance source when present. The older `pveTagColors` map remains a
+ compatibility aggregate only, so clients must not use it to override an
+ instance-scoped style.
8. Route unified-agent installer and binary download headers through `internal/api/unified_agent.go` and `internal/api/contract_test.go` together. Unified-agent BINARY downloads must keep the canonical `X-Checksum-Sha256` plus `X-Signature-Ed25519` contract for updater clients whether the binary is served locally or proxied from the matching GitHub release, instead of leaving callers to infer trust from source location alone. The served install-script endpoints (GET /install.sh and /install.ps1) are governed differently and have NO GitHub fallback at all: they serve the locally bundled AGENT installer or fail closed with 503. The agent installer is a per-build artifact bundled into every release tarball and Docker image, not a release asset, so the endpoint must never fetch the top-level GitHub install.sh release asset (the SERVER installer, which rejects the agent wizard's --url / --token-file, issue #1470). It attaches the base64-encoded `X-Signature-SSHSIG` header when the local detached signatures are present and omits it when they are not; a present-but-unsigned local agent installer is still served, because the agent install path (curl piped into bash) does not verify these headers, so correctness of the served script outranks signature presence.
9. Route canonical AI intelligence summary and resource-intelligence reads through `frontend-modern/src/api/ai.ts`, `frontend-modern/src/stores/aiIntelligence.ts`, `frontend-modern/src/stores/aiIntelligenceSummaryModel.ts`, `frontend-modern/src/features/patrol/usePatrolIntelligenceState.ts`, `frontend-modern/src/features/patrol/PatrolIntelligenceSurface.tsx`, the Patrol-owned section files under `frontend-modern/src/features/patrol/`, `frontend-modern/src/pages/AIIntelligence.tsx`, `internal/api/ai_handlers.go`, and `internal/api/contract_test.go` together so the store normalization owner, runtime hook, feature shell, Current work workspace, section owners, route shell, and backend payload stay aligned on one governed surface, including the canonical recent-changes slice
while keeping the learning counters backend-only coverage, so Patrol keeps health and findings primary and renders timeline, correlation, and policy-posture data as selected-item investigation context rather than as a separate headline product metric
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index f2db08f16b..143f320d5b 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2727,6 +2727,12 @@ That same owner now also holds the CSP-safe tag-dot rendering contract: tag
color and active-state emphasis must travel through SVG fill/stroke attributes
or stable classes, not inline `background-color`, `box-shadow`, or other
`style=` mutations that break the hosted demo CSP.
+TagBadges also owns Proxmox tag color fidelity. When a caller supplies a
+source instance, the primitive must read that instance's `pveTagStyles` entry
+before the legacy aggregate `pveTagColors` map, and it must honor the Proxmox
+`caseSensitive` flag for both override lookup and deterministic fallback color
+generation. Feature rows may pass instance identity into the primitive, but
+they must not rebuild Proxmox color-map lookup locally.
`frontend-modern/src/components/Settings/OperationsPanel.tsx` is now also the
canonical shared settings wrapper for operations-style panels such as
diagnostics, reporting, and system logs. Those surfaces must extend that owner
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 428519de51..c03e4268ff 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -591,6 +591,13 @@ publish those resources from the same canonical unified snapshot that
raw store-only inventory for broadcast. Otherwise cold hydrate and later
registry-backed refreshes can swap the operator-visible infrastructure set
under one running session.
+The same state-publication owner also carries Proxmox tag presentation. PVE
+polling must fetch datacenter `tag-style` through `/cluster/options`, parse the
+color map and `case-sensitive` flag per configured Proxmox instance, and merge
+that into `models.State.PVETagStyles` before websocket/API publication. Clearing
+a Proxmox color map must replace that instance's stored style with an empty
+style and rebuild the legacy aggregate `PVETagColors`; stale colors from a
+previous poll must not survive as if they still came from Proxmox.
That websocket publication boundary must also treat an absent hub as an absent
broadcast channel in both direct nil and typed-nil forms. Tenant-scoped
background monitors can start in headless test or maintenance runtimes before a
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index d56f3c2220..38e3c376a1 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -1250,6 +1250,11 @@ That shell now also routes tag-dot rendering through the shared
keeping a workload-local badge helper. Future guest-row tag presentation
changes must extend through that shared owner rather than reintroducing a
workload-only tag-badge variant.
+Guest rows may pass the already-loaded `WorkloadGuest.instance` value into that
+primitive so per-instance Proxmox tag styles render correctly, but the workload
+hot path must not add tag-color API calls, websocket lookups beyond the shared
+store read inside `TagBadges`, per-row color-map normalization, or scans across
+other workloads just to color a tag dot.
The Workloads guest drawer now follows that same ownership rule: the shell
stays in `frontend-modern/src/components/Workloads/GuestDrawer.tsx`, the
overview card surface lives in
diff --git a/frontend-modern/src/components/Workloads/GuestRow.tsx b/frontend-modern/src/components/Workloads/GuestRow.tsx
index b5f8c21ab2..7f1a4517bd 100644
--- a/frontend-modern/src/components/Workloads/GuestRow.tsx
+++ b/frontend-modern/src/components/Workloads/GuestRow.tsx
@@ -609,6 +609,7 @@ export function GuestRow(props: GuestRowProps) {
<TagBadges
tags={Array.isArray(props.guest.tags) ? props.guest.tags : []}
maxVisible={0}
+ sourceInstance={props.guest.instance}
onTagClick={props.onTagClick}
activeSearch={props.activeSearch}
/>
diff --git a/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx b/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx
index a83ee23eae..34a4a3acf9 100644
--- a/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx
+++ b/frontend-modern/src/components/Workloads/__tests__/GuestRow.test.tsx
@@ -84,8 +84,12 @@ vi.mock('../StackedMemoryBar', () => ({
}));
vi.mock('@/components/shared/TagBadges', () => ({
- TagBadges: (props: { tags: string[] }) => (
- <div data-testid="tag-badges" data-count={props.tags.length} />
+ TagBadges: (props: { tags: string[]; sourceInstance?: string }) => (
+ <div
+ data-testid="tag-badges"
+ data-count={props.tags.length}
+ data-source-instance={props.sourceInstance}
+ />
),
}));
@@ -388,11 +392,12 @@ describe('GuestRow', () => {
it('shows tags when in visibleColumnIds', () => {
renderGuestRow({
- guest: makeGuest({ tags: ['prod', 'web'] }),
+ guest: makeGuest({ instance: 'pve-a', tags: ['prod', 'web'] }),
visibleColumnIds: ['name', 'tags'],
});
const badges = screen.getByTestId('tag-badges');
expect(badges.dataset.count).toBe('2');
+ expect(badges.dataset.sourceInstance).toBe('pve-a');
});
});
diff --git a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsx b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsx
index 16e580cef0..45cd287cb4 100644
--- a/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsx
+++ b/frontend-modern/src/components/Workloads/__tests__/WorkloadsSurface.k8s.test.tsx
@@ -27,6 +27,7 @@ const mockWebSocketState: State = {
activeAlerts: [],
recentlyResolved: [],
pveTagColors: {},
+ pveTagStyles: {},
lastUpdate: 0,
resources: [],
temperatureMonitoringEnabled: false,
diff --git a/frontend-modern/src/components/shared/TagBadges.tsx b/frontend-modern/src/components/shared/TagBadges.tsx
index 60e2948845..66f7e3896f 100644
--- a/frontend-modern/src/components/shared/TagBadges.tsx
+++ b/frontend-modern/src/components/shared/TagBadges.tsx
@@ -3,11 +3,14 @@ import { getTagColorWithSpecial } from '@/utils/tagColors';
import { useDarkMode } from '@/contexts/appRuntime';
import { showTooltip, hideTooltip } from '@/components/shared/Tooltip';
import { getGlobalWebSocketStore } from '@/stores/websocket-global';
+import type { PVETagStyle } from '@/types/api';
interface TagBadgesProps {
tags?: string[];
maxVisible?: number;
isDarkMode?: boolean;
+ sourceInstance?: string;
+ pveTagStyle?: PVETagStyle;
onTagClick?: (tag: string) => void;
activeSearch?: string;
}
@@ -18,13 +21,20 @@ export const TagBadges: Component<TagBadgesProps> = (props) => {
const darkModeSignal = useDarkMode();
const isDark = () => props.isDarkMode ?? darkModeSignal();
const ws = getGlobalWebSocketStore();
- const pveTagColors = () => ws.state.pveTagColors;
+ const instanceTagStyle = () =>
+ props.sourceInstance ? ws.state.pveTagStyles?.[props.sourceInstance] : undefined;
+ const pveTagStyle = () => props.pveTagStyle ?? instanceTagStyle();
+ const pveTagColors = () => pveTagStyle()?.colors ?? ws.state.pveTagColors;
+ const pveTagCaseSensitive = () => pveTagStyle()?.caseSensitive ?? false;
const visibleTags = () => props.tags?.slice(0, maxVisible()) || [];
const hiddenTags = () => props.tags?.slice(maxVisible()) || [];
const TagDot: Component<{ tag: string }> = (dotProps) => {
- const colors = () => getTagColorWithSpecial(dotProps.tag, isDark(), pveTagColors());
+ const colors = () =>
+ getTagColorWithSpecial(dotProps.tag, isDark(), pveTagColors(), {
+ caseSensitive: pveTagCaseSensitive(),
+ });
const isActive = () => props.activeSearch?.includes(`tags:${dotProps.tag}`) || false;
const ringClass = () =>
isActive() ? (isDark() ? 'text-white/90' : 'text-black/80') : 'text-transparent';
diff --git a/frontend-modern/src/components/shared/__tests__/TagBadges.test.tsx b/frontend-modern/src/components/shared/__tests__/TagBadges.test.tsx
index b070b6b281..b3f720a35e 100644
--- a/frontend-modern/src/components/shared/__tests__/TagBadges.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/TagBadges.test.tsx
@@ -3,13 +3,21 @@ import { render, screen, cleanup, fireEvent } from '@solidjs/testing-library';
// ── Hoisted mocks ──────────────────────────────────────────────────────
-const { darkModeMock, showTooltipMock, hideTooltipMock, pveTagColors } = vi.hoisted(() => {
- const darkModeMock = vi.fn(() => false);
- const showTooltipMock = vi.fn();
- const hideTooltipMock = vi.fn();
- const pveTagColors = { web: '#112233' };
- return { darkModeMock, showTooltipMock, hideTooltipMock, pveTagColors };
-});
+const { darkModeMock, showTooltipMock, hideTooltipMock, pveTagColors, pveTagStyles } = vi.hoisted(
+ () => {
+ const darkModeMock = vi.fn(() => false);
+ const showTooltipMock = vi.fn();
+ const hideTooltipMock = vi.fn();
+ const pveTagColors = { web: '#112233' };
+ const pveTagStyles = {
+ 'pve-a': {
+ colors: { web: '#abcdef' },
+ caseSensitive: true,
+ },
+ };
+ return { darkModeMock, showTooltipMock, hideTooltipMock, pveTagColors, pveTagStyles };
+ },
+);
// ── Module mocks ───────────────────────────────────────────────────────
@@ -26,12 +34,18 @@ vi.mock('@/stores/websocket-global', () => ({
getGlobalWebSocketStore: () => ({
state: {
pveTagColors,
+ pveTagStyles,
},
}),
}));
const getTagColorWithSpecialMock = vi.fn(
- (_tag: string, isDark: boolean, _colorMap?: Record<string, string>) => ({
+ (
+ _tag: string,
+ isDark: boolean,
+ _colorMap?: Record<string, string>,
+ _options?: { caseSensitive?: boolean },
+ ) => ({
bg: isDark ? 'rgb(30, 30, 30)' : 'rgb(200, 200, 200)',
text: isDark ? 'rgb(240, 240, 240)' : 'rgb(20, 20, 20)',
border: isDark ? 'rgb(80, 80, 80)' : 'rgb(150, 150, 150)',
@@ -40,7 +54,14 @@ const getTagColorWithSpecialMock = vi.fn(
vi.mock('@/utils/tagColors', () => ({
getTagColorWithSpecial: (...args: unknown[]) =>
- getTagColorWithSpecialMock(...(args as [string, boolean, Record<string, string> | undefined])),
+ getTagColorWithSpecialMock(
+ ...(args as [
+ string,
+ boolean,
+ Record<string, string> | undefined,
+ { caseSensitive?: boolean } | undefined,
+ ]),
+ ),
}));
import { TagBadges } from '../TagBadges';
@@ -152,14 +173,18 @@ describe('TagBadges', () => {
it('calls getTagColorWithSpecial with isDark=false in light mode', () => {
darkModeMock.mockReturnValue(false);
render(() => <TagBadges tags={['web']} />);
- expect(getTagColorWithSpecialMock).toHaveBeenCalledWith('web', false, pveTagColors);
+ expect(getTagColorWithSpecialMock).toHaveBeenCalledWith('web', false, pveTagColors, {
+ caseSensitive: false,
+ });
const dot = getTagDots()[0];
expect(getTagDotFill(dot)).toBe('rgb(200, 200, 200)');
});
it('calls getTagColorWithSpecial with isDark=true when isDarkMode prop is true', () => {
render(() => <TagBadges tags={['web']} isDarkMode={true} />);
- expect(getTagColorWithSpecialMock).toHaveBeenCalledWith('web', true, pveTagColors);
+ expect(getTagColorWithSpecialMock).toHaveBeenCalledWith('web', true, pveTagColors, {
+ caseSensitive: false,
+ });
const dot = getTagDots()[0];
expect(getTagDotFill(dot)).toBe('rgb(30, 30, 30)');
});
@@ -167,7 +192,9 @@ describe('TagBadges', () => {
it('uses dark mode signal when isDarkMode prop is not set', () => {
darkModeMock.mockReturnValue(true);
render(() => <TagBadges tags={['db']} />);
- expect(getTagColorWithSpecialMock).toHaveBeenCalledWith('db', true, pveTagColors);
+ expect(getTagColorWithSpecialMock).toHaveBeenCalledWith('db', true, pveTagColors, {
+ caseSensitive: false,
+ });
const dot = getTagDots()[0];
expect(getTagDotFill(dot)).toBe('rgb(30, 30, 30)');
});
@@ -175,10 +202,24 @@ describe('TagBadges', () => {
it('isDarkMode=false overrides dark mode signal', () => {
darkModeMock.mockReturnValue(true);
render(() => <TagBadges tags={['web']} isDarkMode={false} />);
- expect(getTagColorWithSpecialMock).toHaveBeenCalledWith('web', false, pveTagColors);
+ expect(getTagColorWithSpecialMock).toHaveBeenCalledWith('web', false, pveTagColors, {
+ caseSensitive: false,
+ });
const dot = getTagDots()[0];
expect(getTagDotFill(dot)).toBe('rgb(200, 200, 200)');
});
+
+ it('uses the Proxmox tag style for the source instance when available', () => {
+ render(() => <TagBadges tags={['web']} sourceInstance="pve-a" />);
+ expect(getTagColorWithSpecialMock).toHaveBeenCalledWith(
+ 'web',
+ false,
+ pveTagStyles['pve-a'].colors,
+ {
+ caseSensitive: true,
+ },
+ );
+ });
});
describe('activeSearch highlighting', () => {
diff --git a/frontend-modern/src/features/storageBackups/__tests__/storageAdapters.test.ts b/frontend-modern/src/features/storageBackups/__tests__/storageAdapters.test.ts
index 3785848efd..3d39bf3d44 100644
--- a/frontend-modern/src/features/storageBackups/__tests__/storageAdapters.test.ts
+++ b/frontend-modern/src/features/storageBackups/__tests__/storageAdapters.test.ts
@@ -24,6 +24,7 @@ const baseState = (overrides: Partial<State> = {}): State => ({
resources: [],
...overrides,
pveTagColors: overrides.pveTagColors ?? {},
+ pveTagStyles: overrides.pveTagStyles ?? {},
});
const makeResourceStorage = (overrides: Partial<Resource> = {}): Resource =>
diff --git a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
index e3550bf5dc..4123457444 100644
--- a/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
+++ b/frontend-modern/src/hooks/__tests__/useUnifiedResources.test.ts
@@ -181,6 +181,7 @@ describe('useUnifiedResources', () => {
activeAlerts: [],
recentlyResolved: [],
pveTagColors: {},
+ pveTagStyles: {},
resources: [wsResource],
lastUpdate: 0,
});
diff --git a/frontend-modern/src/stores/websocket-global.ts b/frontend-modern/src/stores/websocket-global.ts
index c10713bd3d..2d5edd16b0 100644
--- a/frontend-modern/src/stores/websocket-global.ts
+++ b/frontend-modern/src/stores/websocket-global.ts
@@ -46,6 +46,7 @@ const createNoopWebSocketStore = (): ReturnType<typeof createWebSocketStore> =>
recentlyResolved: [],
lastUpdate: 0,
pveTagColors: {},
+ pveTagStyles: {},
resources: [],
});
diff --git a/frontend-modern/src/stores/websocket.ts b/frontend-modern/src/stores/websocket.ts
index b83a1110a6..d9883602ac 100644
--- a/frontend-modern/src/stores/websocket.ts
+++ b/frontend-modern/src/stores/websocket.ts
@@ -149,6 +149,7 @@ export function createWebSocketStore(url: string) {
recentlyResolved: [],
lastUpdate: 0,
pveTagColors: {},
+ pveTagStyles: {},
// Unified resources for cross-platform monitoring
resources: [],
});
@@ -467,6 +468,9 @@ export function createWebSocketStore(url: string) {
if (message.data.pveTagColors !== undefined) {
setState('pveTagColors', message.data.pveTagColors ?? {});
}
+ if (message.data.pveTagStyles !== undefined) {
+ setState('pveTagStyles', message.data.pveTagStyles ?? {});
+ }
// Handle unified resources
if (message.data.resources !== undefined) {
const nextResources = Array.isArray(message.data.resources)
diff --git a/frontend-modern/src/types/api.ts b/frontend-modern/src/types/api.ts
index 5c7d3e0368..399e0672c0 100644
--- a/frontend-modern/src/types/api.ts
+++ b/frontend-modern/src/types/api.ts
@@ -27,10 +27,16 @@ export interface State {
lastUpdate: number;
temperatureMonitoringEnabled?: boolean;
pveTagColors: Record<string, string>;
+ pveTagStyles?: Record<string, PVETagStyle>;
// Unified resources (canonical resource model)
resources: Resource[];
}
+export interface PVETagStyle {
+ colors: Record<string, string>;
+ caseSensitive: boolean;
+}
+
export interface ConnectedInfrastructureSurface {
id: string;
kind: 'agent' | 'availability' | 'docker' | 'kubernetes' | 'proxmox' | 'pbs' | 'pmg' | 'truenas';
diff --git a/frontend-modern/src/utils/__tests__/tagColors.test.ts b/frontend-modern/src/utils/__tests__/tagColors.test.ts
index 2626db2863..7880b980c4 100644
--- a/frontend-modern/src/utils/__tests__/tagColors.test.ts
+++ b/frontend-modern/src/utils/__tests__/tagColors.test.ts
@@ -48,6 +48,30 @@ describe('tagColors', () => {
});
});
+ it('uses exact tag keys and fallback hashing when Proxmox case-sensitive mode is enabled', () => {
+ expect(
+ getTagColorWithSpecial(
+ 'Production',
+ false,
+ {
+ Production: '#112233',
+ production: '#445566',
+ },
+ { caseSensitive: true },
+ ),
+ ).toEqual({
+ bg: 'rgb(17, 34, 51)',
+ text: '#ffffff',
+ border: 'rgb(17, 34, 51)',
+ });
+
+ expect(getTagColorWithSpecial('STAGING', false, {}, { caseSensitive: true })).toEqual({
+ bg: 'rgb(80.70000000000002, 212.3, 244.5)',
+ text: '#000000',
+ border: 'rgb(80.70000000000002, 212.3, 244.5)',
+ });
+ });
+
it('falls back to generated colors when proxmox color is invalid', () => {
expect(
getTagColorWithSpecial('backup', false, {
diff --git a/frontend-modern/src/utils/tagColors.ts b/frontend-modern/src/utils/tagColors.ts
index 9a7a48c852..a03c6db35c 100644
--- a/frontend-modern/src/utils/tagColors.ts
+++ b/frontend-modern/src/utils/tagColors.ts
@@ -4,13 +4,18 @@ interface TagColorStyle {
border: string;
}
-function stringToRGB(tag: string): [number, number, number] {
+interface TagColorOptions {
+ caseSensitive?: boolean;
+}
+
+function stringToRGB(tag: string, options: TagColorOptions = {}): [number, number, number] {
let hash = 0;
if (!tag) {
return [255, 255, 255];
}
- const value = `${tag.toLowerCase()}prox`;
+ const normalizedTag = options.caseSensitive ? tag : tag.toLowerCase();
+ const value = `${normalizedTag}prox`;
for (let i = 0; i < value.length; i++) {
hash = value.charCodeAt(i) + ((hash << 5) - hash);
hash &= hash;
@@ -79,9 +84,10 @@ export function getTagColorWithSpecial(
tag: string,
_isDarkMode: boolean,
colorMap?: Record<string, string>,
+ options: TagColorOptions = {},
): TagColorStyle {
- const lowerTag = tag.toLowerCase();
- const proxmoxHex = colorMap?.[lowerTag];
+ const colorKey = options.caseSensitive ? tag : tag.toLowerCase();
+ const proxmoxHex = colorMap?.[colorKey];
if (proxmoxHex) {
const rgb = parseHexColor(proxmoxHex);
if (rgb) {
@@ -89,5 +95,5 @@ export function getTagColorWithSpecial(
}
}
- return buildStyleFromRGB(stringToRGB(tag));
+ return buildStyleFromRGB(stringToRGB(tag, options));
}
diff --git a/internal/models/deepcopy.go b/internal/models/deepcopy.go
index 47e39d12b2..7cb5966475 100644
--- a/internal/models/deepcopy.go
+++ b/internal/models/deepcopy.go
@@ -56,6 +56,24 @@ func cloneStringMap(src map[string]string) map[string]string {
return dest
}
+func clonePVETagStyles(src map[string]PVETagStyle) map[string]PVETagStyle {
+ if len(src) == 0 {
+ return nil
+ }
+ dest := make(map[string]PVETagStyle, len(src))
+ for instance, style := range src {
+ colors := cloneStringMap(style.Colors)
+ if colors == nil {
+ colors = map[string]string{}
+ }
+ dest[instance] = PVETagStyle{
+ Colors: colors,
+ CaseSensitive: style.CaseSensitive,
+ }
+ }
+ return dest
+}
+
func cloneStringFloat64Map(src map[string]float64) map[string]float64 {
if len(src) == 0 {
return nil
diff --git a/internal/models/models.go b/internal/models/models.go
index e7b59b7845..5d4eca6f19 100644
--- a/internal/models/models.go
+++ b/internal/models/models.go
@@ -45,6 +45,13 @@ type State struct {
LastUpdate time.Time `json:"lastUpdate"`
TemperatureMonitoringEnabled bool `json:"temperatureMonitoringEnabled"`
PVETagColors map[string]string `json:"pveTagColors,omitempty"`
+ PVETagStyles map[string]PVETagStyle `json:"pveTagStyles,omitempty"`
+}
+
+// PVETagStyle is the frontend-facing Proxmox tag style for one PVE instance.
+type PVETagStyle struct {
+ Colors map[string]string `json:"colors"`
+ CaseSensitive bool `json:"caseSensitive"`
}
var (
@@ -2963,6 +2970,7 @@ func NewState() *State {
ActiveAlerts: make([]Alert, 0),
RecentlyResolved: make([]ResolvedAlert, 0),
PVETagColors: make(map[string]string),
+ PVETagStyles: make(map[string]PVETagStyle),
Performance: Performance{}.NormalizeCollections(),
LastUpdate: time.Now(),
}
@@ -2987,6 +2995,55 @@ func (s *State) MergeTagColors(colors map[string]string) {
s.LastUpdate = time.Now()
}
+// MergePVETagStyle merges the Proxmox tag style for one PVE instance into the
+// shared state while preserving the legacy aggregate color map.
+func (s *State) MergePVETagStyle(instance string, style PVETagStyle) {
+ instance = strings.TrimSpace(instance)
+ if instance == "" && len(style.Colors) == 0 && !style.CaseSensitive {
+ return
+ }
+
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ if s.PVETagColors == nil {
+ s.PVETagColors = make(map[string]string, len(style.Colors))
+ }
+ if s.PVETagStyles == nil {
+ s.PVETagStyles = make(map[string]PVETagStyle)
+ }
+
+ normalizedColors := make(map[string]string, len(style.Colors))
+ for tag, color := range style.Colors {
+ tag = strings.TrimSpace(tag)
+ if tag == "" {
+ continue
+ }
+ if !style.CaseSensitive {
+ tag = strings.ToLower(tag)
+ }
+ color = strings.TrimSpace(color)
+ normalizedColors[tag] = color
+ }
+
+ if instance != "" {
+ s.PVETagStyles[instance] = PVETagStyle{
+ Colors: normalizedColors,
+ CaseSensitive: style.CaseSensitive,
+ }
+ s.PVETagColors = make(map[string]string)
+ for _, instanceStyle := range s.PVETagStyles {
+ for tag, color := range instanceStyle.Colors {
+ s.PVETagColors[tag] = color
+ }
+ }
+ } else {
+ for tag, color := range normalizedColors {
+ s.PVETagColors[tag] = color
+ }
+ }
+ s.LastUpdate = time.Now()
+}
+
// syncBackupsLocked updates the aggregated backups structure.
func (s *State) syncBackupsLocked() {
s.Backups = Backups{
diff --git a/internal/models/models_frontend.go b/internal/models/models_frontend.go
index 4153cba9e2..4438bdccf5 100644
--- a/internal/models/models_frontend.go
+++ b/internal/models/models_frontend.go
@@ -894,15 +894,16 @@ type ReplicationJobFrontend struct {
// StateFrontend represents the state with frontend-friendly field names
type StateFrontend struct {
- ActiveAlerts []Alert `json:"activeAlerts"` // Active alerts
- RecentlyResolved []ResolvedAlert `json:"recentlyResolved"` // Recently resolved alerts
- Metrics []Metric `json:"metrics"` // Time-series metrics
- Performance Performance `json:"performance"` // Polling/runtime performance
- ConnectionHealth map[string]bool `json:"connectionHealth"` // Keep as is
- Stats Stats `json:"stats"` // Runtime statistics
- LastUpdate int64 `json:"lastUpdate"` // Unix timestamp
- TemperatureMonitoringEnabled bool `json:"temperatureMonitoringEnabled"` // Global temperature monitoring setting
- PVETagColors map[string]string `json:"pveTagColors"` // Tag name -> "#rrggbb" from Proxmox datacenter config
+ ActiveAlerts []Alert `json:"activeAlerts"` // Active alerts
+ RecentlyResolved []ResolvedAlert `json:"recentlyResolved"` // Recently resolved alerts
+ Metrics []Metric `json:"metrics"` // Time-series metrics
+ Performance Performance `json:"performance"` // Polling/runtime performance
+ ConnectionHealth map[string]bool `json:"connectionHealth"` // Keep as is
+ Stats Stats `json:"stats"` // Runtime statistics
+ LastUpdate int64 `json:"lastUpdate"` // Unix timestamp
+ TemperatureMonitoringEnabled bool `json:"temperatureMonitoringEnabled"` // Global temperature monitoring setting
+ PVETagColors map[string]string `json:"pveTagColors"` // Tag name -> "#rrggbb" from Proxmox datacenter config
+ PVETagStyles map[string]PVETagStyle `json:"pveTagStyles"` // PVE instance -> Proxmox tag style
// Unified resources - the new way to access all monitored entities
Resources []ResourceFrontend `json:"resources"`
ConnectedInfrastructure []ConnectedInfrastructureItemFrontend `json:"connectedInfrastructure"`
@@ -932,6 +933,9 @@ func (s StateFrontend) NormalizeCollections() StateFrontend {
if s.PVETagColors == nil {
s.PVETagColors = map[string]string{}
}
+ if s.PVETagStyles == nil {
+ s.PVETagStyles = map[string]PVETagStyle{}
+ }
if s.Performance.APICallDuration == nil {
s.Performance.APICallDuration = map[string]float64{}
}
diff --git a/internal/models/state_additional_test.go b/internal/models/state_additional_test.go
index f4fb84df2d..e67618acff 100644
--- a/internal/models/state_additional_test.go
+++ b/internal/models/state_additional_test.go
@@ -27,6 +27,41 @@ func TestStateClearAllDockerHosts(t *testing.T) {
}
}
+func TestStateMergePVETagStyleReplacesInstanceStyle(t *testing.T) {
+ state := NewState()
+
+ state.MergePVETagStyle("pve-a", PVETagStyle{
+ Colors: map[string]string{"Production": "#00ff00"},
+ CaseSensitive: true,
+ })
+ state.MergePVETagStyle("pve-b", PVETagStyle{
+ Colors: map[string]string{"backup": "#112233"},
+ })
+
+ snapshot := state.GetSnapshot()
+ if got := snapshot.PVETagStyles["pve-a"].Colors["Production"]; got != "#00ff00" {
+ t.Fatalf("pve-a Production color = %q, want #00ff00", got)
+ }
+ if !snapshot.PVETagStyles["pve-a"].CaseSensitive {
+ t.Fatal("expected pve-a style to preserve case-sensitive mode")
+ }
+ if got := snapshot.PVETagColors["backup"]; got != "#112233" {
+ t.Fatalf("aggregate backup color = %q, want #112233", got)
+ }
+
+ state.MergePVETagStyle("pve-a", PVETagStyle{})
+ snapshot = state.GetSnapshot()
+ if _, ok := snapshot.PVETagStyles["pve-a"].Colors["Production"]; ok {
+ t.Fatalf("expected pve-a Production color to be removed, got %#v", snapshot.PVETagStyles["pve-a"])
+ }
+ if _, ok := snapshot.PVETagColors["Production"]; ok {
+ t.Fatalf("expected aggregate Production color to be removed, got %#v", snapshot.PVETagColors)
+ }
+ if got := snapshot.PVETagColors["backup"]; got != "#112233" {
+ t.Fatalf("aggregate backup color after replacement = %q, want #112233", got)
+ }
+}
+
func TestStateKubernetesClusterLifecycle(t *testing.T) {
state := &State{}
diff --git a/internal/models/state_host_test.go b/internal/models/state_host_test.go
index cb30060b96..f4384391dc 100644
--- a/internal/models/state_host_test.go
+++ b/internal/models/state_host_test.go
@@ -198,6 +198,42 @@ func TestSetConnectionHealth(t *testing.T) {
}
}
+func TestPVETagStyleSnapshotRebuildsAggregateByInstance(t *testing.T) {
+ state := NewState()
+
+ state.MergePVETagStyle("pve-a", PVETagStyle{
+ Colors: map[string]string{
+ "Production": "#00ff00",
+ },
+ CaseSensitive: true,
+ })
+ state.MergePVETagStyle("pve-b", PVETagStyle{
+ Colors: map[string]string{
+ "Backup": "#112233",
+ },
+ })
+
+ snapshot := state.GetSnapshot()
+ if got := snapshot.PVETagStyles["pve-a"].Colors["Production"]; got != "#00ff00" {
+ t.Fatalf("expected pve-a tag style to preserve case-sensitive color, got %q", got)
+ }
+ if !snapshot.PVETagStyles["pve-a"].CaseSensitive {
+ t.Fatal("expected pve-a tag style to preserve case-sensitive flag")
+ }
+ if got := snapshot.PVETagStyles["pve-b"].Colors["backup"]; got != "#112233" {
+ t.Fatalf("expected pve-b tag style to normalize non-case-sensitive tag, got %q", got)
+ }
+
+ state.MergePVETagStyle("pve-a", PVETagStyle{})
+ snapshot = state.GetSnapshot()
+ if _, ok := snapshot.PVETagColors["Production"]; ok {
+ t.Fatalf("expected stale pve-a aggregate color to be removed, got %#v", snapshot.PVETagColors)
+ }
+ if got := snapshot.PVETagColors["backup"]; got != "#112233" {
+ t.Fatalf("expected pve-b aggregate color to remain, got %q", got)
+ }
+}
+
func TestRemoveConnectionHealth(t *testing.T) {
state := NewState()
diff --git a/internal/models/state_snapshot.go b/internal/models/state_snapshot.go
index 8b64666984..ec71aaa53b 100644
--- a/internal/models/state_snapshot.go
+++ b/internal/models/state_snapshot.go
@@ -35,6 +35,7 @@ type StateSnapshot struct {
LastUpdate time.Time `json:"lastUpdate"`
TemperatureMonitoringEnabled bool `json:"temperatureMonitoringEnabled"`
PVETagColors map[string]string `json:"pveTagColors,omitempty"`
+ PVETagStyles map[string]PVETagStyle `json:"pveTagStyles,omitempty"`
}
// EmptyStateSnapshot returns a normalized zero-value snapshot for runtime
@@ -153,6 +154,9 @@ func (s *StateSnapshot) NormalizeCollections() {
if s.PVETagColors == nil {
s.PVETagColors = map[string]string{}
}
+ if s.PVETagStyles == nil {
+ s.PVETagStyles = map[string]PVETagStyle{}
+ }
s.Performance = s.Performance.NormalizeCollections()
}
@@ -192,6 +196,7 @@ func (s StateSnapshot) Clone() StateSnapshot {
LastUpdate: s.LastUpdate,
TemperatureMonitoringEnabled: s.TemperatureMonitoringEnabled,
PVETagColors: cloneStringMap(s.PVETagColors),
+ PVETagStyles: clonePVETagStyles(s.PVETagStyles),
}
for key, healthy := range s.ConnectionHealth {
snapshot.ConnectionHealth[key] = healthy
@@ -243,6 +248,7 @@ func (s *State) GetSnapshot() StateSnapshot {
LastUpdate: s.LastUpdate,
TemperatureMonitoringEnabled: s.TemperatureMonitoringEnabled,
PVETagColors: cloneStringMap(s.PVETagColors),
+ PVETagStyles: clonePVETagStyles(s.PVETagStyles),
}
snapshot.NormalizeCollections()
@@ -591,5 +597,6 @@ func (s StateSnapshot) ToFrontend() StateFrontend {
frontend.LastUpdate = s.LastUpdate.Unix() * 1000 // JavaScript timestamp
frontend.TemperatureMonitoringEnabled = s.TemperatureMonitoringEnabled
frontend.PVETagColors = cloneStringMap(s.PVETagColors)
+ frontend.PVETagStyles = clonePVETagStyles(s.PVETagStyles)
return frontend.NormalizeCollections()
}
diff --git a/internal/models/state_snapshot_frontend_test.go b/internal/models/state_snapshot_frontend_test.go
index bb9cd07abf..3e5870c366 100644
--- a/internal/models/state_snapshot_frontend_test.go
+++ b/internal/models/state_snapshot_frontend_test.go
@@ -33,6 +33,12 @@ func TestStateSnapshotToFrontend_UsesConcreteStateContract(t *testing.T) {
LastUpdate: now,
TemperatureMonitoringEnabled: true,
PVETagColors: map[string]string{"production": "#ff0000"},
+ PVETagStyles: map[string]PVETagStyle{
+ "pve-a": {
+ Colors: map[string]string{"Production": "#00ff00"},
+ CaseSensitive: true,
+ },
+ },
}.ToFrontend()
if len(frontend.Metrics) != 1 || frontend.Metrics[0].ID != "node-1" {
@@ -47,6 +53,9 @@ func TestStateSnapshotToFrontend_UsesConcreteStateContract(t *testing.T) {
if frontend.PVETagColors["production"] != "#ff0000" {
t.Fatalf("expected PVE tag colors to survive frontend conversion, got %#v", frontend.PVETagColors)
}
+ if frontend.PVETagStyles["pve-a"].Colors["Production"] != "#00ff00" || !frontend.PVETagStyles["pve-a"].CaseSensitive {
+ t.Fatalf("expected PVE tag styles to survive frontend conversion, got %#v", frontend.PVETagStyles)
+ }
encoded, err := json.Marshal(frontend)
if err != nil {
@@ -76,6 +85,11 @@ func TestStateSnapshotToFrontend_UsesConcreteStateContract(t *testing.T) {
if tagColors, ok := payload["pveTagColors"].(map[string]any); !ok || tagColors["production"] != "#ff0000" {
t.Fatalf("expected pveTagColors to serialize as an object, got %T (%v)", payload["pveTagColors"], payload["pveTagColors"])
}
+ if tagStyles, ok := payload["pveTagStyles"].(map[string]any); !ok {
+ t.Fatalf("expected pveTagStyles to serialize as an object, got %T (%v)", payload["pveTagStyles"], payload["pveTagStyles"])
+ } else if pveA, ok := tagStyles["pve-a"].(map[string]any); !ok || pveA["caseSensitive"] != true {
+ t.Fatalf("expected pve-a tag style to serialize with caseSensitive=true, got %T (%v)", tagStyles["pve-a"], tagStyles["pve-a"])
+ }
}
func TestEmptyStateFrontend_UsesCanonicalCollectionShapes(t *testing.T) {
diff --git a/internal/monitoring/canonical_guardrails_test.go b/internal/monitoring/canonical_guardrails_test.go
index cf7b2fe6e3..64a867da47 100644
--- a/internal/monitoring/canonical_guardrails_test.go
+++ b/internal/monitoring/canonical_guardrails_test.go
@@ -74,6 +74,30 @@ func TestNoGetStateResourceArrayRegression(t *testing.T) {
}
}
+func TestPVETagStyleRefreshStaysPerInstance(t *testing.T) {
+ data, err := os.ReadFile("monitor_pve.go")
+ if err != nil {
+ t.Fatalf("failed to read monitor_pve.go: %v", err)
+ }
+ source := string(data)
+
+ for _, snippet := range []string{
+ "func (m *Monitor) refreshPVETagColors(ctx context.Context, instanceName string, client PVEClientInterface)",
+ "tagStyle := proxmox.ParseTagStyle(opts.TagStyle)",
+ "m.state.MergePVETagStyle(instanceName, models.PVETagStyle{",
+ } {
+ if !strings.Contains(source, snippet) {
+ t.Fatalf("monitor_pve.go must contain %q", snippet)
+ }
+ }
+ if strings.Contains(source, "ParseTagColorMap(opts.TagStyle)") {
+ t.Fatal("PVE tag refresh must preserve case-sensitive style metadata, not only the legacy color map")
+ }
+ if strings.Contains(source, "m.state.MergeTagColors(") {
+ t.Fatal("PVE tag refresh must merge style by instance so cleared color maps do not leave stale aggregate colors")
+ }
+}
+
func TestBroadcastResourceDiskIOUsesUnifiedResourceMetrics(t *testing.T) {
hasDiskIO, readRate, writeRate := monitorDiskIOMetricInput(&unifiedresources.ResourceMetrics{
DiskRead: &unifiedresources.MetricValue{Value: 4096.4, Unit: "bytes/s", Source: unifiedresources.SourceAgent},
diff --git a/internal/monitoring/monitor_pve.go b/internal/monitoring/monitor_pve.go
index 5d2146abe1..565b1fcc7c 100644
--- a/internal/monitoring/monitor_pve.go
+++ b/internal/monitoring/monitor_pve.go
@@ -456,7 +456,7 @@ func (m *Monitor) fetchPVENodes(ctx context.Context, instanceName string, instan
return nodes, client, nil
}
-func (m *Monitor) refreshPVETagColors(ctx context.Context, client PVEClientInterface) {
+func (m *Monitor) refreshPVETagColors(ctx context.Context, instanceName string, client PVEClientInterface) {
type clusterOptionsGetter interface {
GetClusterOptions(ctx context.Context) (*proxmox.ClusterOptions, error)
}
@@ -470,9 +470,11 @@ func (m *Monitor) refreshPVETagColors(ctx context.Context, client PVEClientInter
if err != nil || opts == nil {
return
}
- if colors := proxmox.ParseTagColorMap(opts.TagStyle); len(colors) > 0 {
- m.state.MergeTagColors(colors)
- }
+ tagStyle := proxmox.ParseTagStyle(opts.TagStyle)
+ m.state.MergePVETagStyle(instanceName, models.PVETagStyle{
+ Colors: tagStyle.Colors,
+ CaseSensitive: tagStyle.CaseSensitive,
+ })
}
func (m *Monitor) updatePVEConnectionHealth(ctx context.Context, instanceName string, client PVEClientInterface) string {
@@ -1142,7 +1144,7 @@ func (m *Monitor) pollPVEInstance(ctx context.Context, instanceName string, clie
return
}
client = updatedClient
- m.refreshPVETagColors(ctx, client)
+ m.refreshPVETagColors(ctx, instanceName, client)
// Check if client is a ClusterClient to determine health status
connectionHealthStr := m.updatePVEConnectionHealth(ctx, instanceName, client)
diff --git a/pkg/proxmox/client.go b/pkg/proxmox/client.go
index 008dcebd12..8eba518c98 100644
--- a/pkg/proxmox/client.go
+++ b/pkg/proxmox/client.go
@@ -2254,6 +2254,13 @@ type ClusterOptions struct {
TagStyle string `json:"tag-style,omitempty"`
}
+// TagStyle captures the Proxmox tag presentation settings Pulse needs to
+// reproduce Proxmox tag colors in other surfaces.
+type TagStyle struct {
+ Colors map[string]string
+ CaseSensitive bool
+}
+
// GetClusterOptions fetches datacenter-level options such as tag color config.
func (c *Client) GetClusterOptions(ctx context.Context) (*ClusterOptions, error) {
resp, err := c.get(ctx, "/cluster/options")
@@ -2271,37 +2278,63 @@ func (c *Client) GetClusterOptions(ctx context.Context) (*ClusterOptions, error)
return &result.Data, nil
}
-// ParseTagColorMap parses a Proxmox tag-style string and returns a map of
-// lowercase tag name to "#rrggbb" hex color string.
-// Example input: "color-map=production:ff0000;staging:ffaa00,ordering=config"
-func ParseTagColorMap(tagStyle string) map[string]string {
- colors := make(map[string]string)
+// ParseTagStyle parses Proxmox's tag-style property string and returns the
+// presentation settings needed for tag color rendering.
+func ParseTagStyle(tagStyle string) TagStyle {
+ style := TagStyle{
+ Colors: make(map[string]string),
+ }
+
+ properties := make(map[string]string)
for _, part := range strings.Split(tagStyle, ",") {
part = strings.TrimSpace(part)
- if !strings.HasPrefix(part, "color-map=") {
+ if part == "" {
continue
}
- for _, pair := range strings.Split(strings.TrimPrefix(part, "color-map="), ";") {
- fields := strings.Split(pair, ":")
- if len(fields) < 2 {
- continue
- }
- tag := strings.ToLower(strings.TrimSpace(fields[0]))
- hex := strings.TrimSpace(fields[1])
- hex = strings.TrimPrefix(hex, "#")
- if tag == "" || !isHexColorToken(hex) {
- continue
- }
- colors[tag] = "#" + strings.ToLower(hex)
+ key, value, ok := strings.Cut(part, "=")
+ if !ok {
+ continue
}
+ properties[strings.TrimSpace(key)] = strings.TrimSpace(value)
+ }
+
+ style.CaseSensitive = properties["case-sensitive"] == "1"
+ parseTagColorMapInto(style.Colors, properties["color-map"], style.CaseSensitive)
+ return style
+}
+
+// ParseTagColorMap parses a Proxmox tag-style string and returns a map of tag
+// name to "#rrggbb" hex color string. The keys are lowercase unless the
+// Proxmox tag-style enables case-sensitive tags.
+// Example input: "color-map=production:ff0000;staging:ffaa00,ordering=config"
+func ParseTagColorMap(tagStyle string) map[string]string {
+ return ParseTagStyle(tagStyle).Colors
+}
+
+func parseTagColorMapInto(colors map[string]string, colorMap string, caseSensitive bool) {
+ if colors == nil {
+ return
+ }
+ for _, pair := range strings.Split(colorMap, ";") {
+ fields := strings.Split(pair, ":")
+ if len(fields) < 2 {
+ continue
+ }
+ tag := strings.TrimSpace(fields[0])
+ if !caseSensitive {
+ tag = strings.ToLower(tag)
+ }
+ hex := strings.TrimSpace(fields[1])
+ hex = strings.TrimPrefix(hex, "#")
+ if tag == "" || !isHexColorToken(hex) {
+ continue
+ }
+ colors[tag] = "#" + strings.ToLower(hex)
}
- return colors
}
func isHexColorToken(value string) bool {
- switch len(value) {
- case 3, 6, 8:
- default:
+ if len(value) != 6 {
return false
}
diff --git a/pkg/proxmox/client_test.go b/pkg/proxmox/client_test.go
index 4e91daac42..31da86d857 100644
--- a/pkg/proxmox/client_test.go
+++ b/pkg/proxmox/client_test.go
@@ -183,11 +183,19 @@ func TestParseTagColorMap(t *testing.T) {
},
{
name: "ignores invalid color tokens",
- tagStyle: "color-map=good:00ff00;bad:zzzzzz;also-bad:12345",
+ tagStyle: "color-map=good:00ff00;bad:zzzzzz;also-bad:12345;too-short:abc;too-long:12345678",
expected: map[string]string{
"good": "#00ff00",
},
},
+ {
+ name: "preserves tag case when Proxmox case-sensitive mode is enabled",
+ tagStyle: "case-sensitive=1,color-map=Production:000000:FFFFFF;production:ffaa00:101010",
+ expected: map[string]string{
+ "Production": "#000000",
+ "production": "#ffaa00",
+ },
+ },
}
for _, tc := range tests {
@@ -199,6 +207,17 @@ func TestParseTagColorMap(t *testing.T) {
}
}
+func TestParseTagStyle(t *testing.T) {
+ got := ParseTagStyle("shape=full,case-sensitive=1,color-map=Production:000000:FFFFFF")
+
+ if !got.CaseSensitive {
+ t.Fatal("expected case-sensitive tag style")
+ }
+ if !reflect.DeepEqual(got.Colors, map[string]string{"Production": "#000000"}) {
+ t.Fatalf("colors = %#v, want Production override", got.Colors)
+ }
+}
+
func TestDiskUnmarshalJSON_InvalidJSON(t *testing.T) {
var disk Disk
err := json.Unmarshal([]byte(`{invalid json`), &disk)