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.

Split dashboard guest drawer runtime owners

rcourtman488e6c3336f7
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 61efd75c00..1f395f6173 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -30,14 +30,18 @@ regression protection.
8. `frontend-modern/src/components/Dashboard/GuestRow.tsx`
9. `frontend-modern/src/components/Dashboard/guestRowModel.tsx`
10. `frontend-modern/src/components/Dashboard/useGuestRowState.ts`
-11. `frontend-modern/src/components/Dashboard/workloadSelectors.ts`
-12. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
-13. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
-14. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
-15. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
-16. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
-17. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
-18. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
+11. `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
+12. `frontend-modern/src/components/Dashboard/guestDrawerModel.ts`
+13. `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`
+14. `frontend-modern/src/components/Dashboard/workloadSelectors.ts`
+15. `frontend-modern/src/components/Infrastructure/UnifiedResourceTable.tsx`
+16. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
+17. `frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts`
+18. `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
+19. `frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx`
+20. `frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx`
+21. `frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx`
+22. `frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx`
## Shared Boundaries
@@ -58,6 +62,7 @@ regression protection.
7. Render dashboard row identity directly from the shared canonical workload helper so row selection, hover, and fallback metadata lookup stay aligned with the same workload contract
8. Format infrastructure sensor labels through the shared `frontend-modern/src/utils/textPresentation.ts` presentation helper instead of maintaining a local title-casing implementation in `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`
9. Extend dashboard row contract and per-row hot-path derivations through `frontend-modern/src/components/Dashboard/guestRowModel.tsx` and `frontend-modern/src/components/Dashboard/useGuestRowState.ts` rather than rebuilding column metadata, row identity, or anomaly correlation inside `frontend-modern/src/components/Dashboard/GuestRow.tsx`
+10. Extend dashboard drawer derivations and runtime wiring through `frontend-modern/src/components/Dashboard/guestDrawerModel.ts` and `frontend-modern/src/components/Dashboard/useGuestDrawerState.ts` rather than rebuilding canonical guest identity, discovery routing, or drawer-local normalization inside `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`
## Forbidden Paths
@@ -97,6 +102,14 @@ canonical row contract and per-row hot-path derivations live in
`frontend-modern/src/components/Dashboard/useGuestRowState.ts`. Future row
identity, column, anomaly-correlation, and link-state changes must extend
through those owners instead of rebuilding row-local state inside the shell.
+The dashboard guest drawer now follows that same ownership rule: the shell
+stays in `frontend-modern/src/components/Dashboard/GuestDrawer.tsx`, while
+drawer-local normalization, backup/tag formatting, discovery identity wiring,
+and workload-derived navigation state live in
+`frontend-modern/src/components/Dashboard/guestDrawerModel.ts` and
+`frontend-modern/src/components/Dashboard/useGuestDrawerState.ts`. Future
+drawer runtime changes must extend through those owners instead of adding
+more mixed state and helper drift back into the shell.
The unified resource table hot path is now also governed as explicit
performance-owned runtime, with shared ownership against the unified-resource
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index b9bc379a50..298b4581ec 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -2518,9 +2518,12 @@
],
"owned_files": [
"frontend-modern/src/components/Dashboard/Dashboard.tsx",
+ "frontend-modern/src/components/Dashboard/GuestDrawer.tsx",
+ "frontend-modern/src/components/Dashboard/guestDrawerModel.ts",
"frontend-modern/src/components/Dashboard/GuestRow.tsx",
"frontend-modern/src/components/Dashboard/guestRowModel.tsx",
"frontend-modern/src/components/Dashboard/useDashboardState.ts",
+ "frontend-modern/src/components/Dashboard/useGuestDrawerState.ts",
"frontend-modern/src/components/Dashboard/useGuestRowState.ts",
"frontend-modern/src/components/Dashboard/workloadSelectors.ts",
"frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts",
@@ -2566,9 +2569,12 @@
"match_prefixes": [],
"match_files": [
"frontend-modern/src/components/Dashboard/Dashboard.tsx",
+ "frontend-modern/src/components/Dashboard/GuestDrawer.tsx",
+ "frontend-modern/src/components/Dashboard/guestDrawerModel.ts",
"frontend-modern/src/components/Dashboard/GuestRow.tsx",
"frontend-modern/src/components/Dashboard/guestRowModel.tsx",
"frontend-modern/src/components/Dashboard/useDashboardState.ts",
+ "frontend-modern/src/components/Dashboard/useGuestDrawerState.ts",
"frontend-modern/src/components/Dashboard/useGuestRowState.ts",
"frontend-modern/src/components/Dashboard/workloadSelectors.ts",
"frontend-modern/src/components/Infrastructure/infrastructureSelectors.ts",
@@ -2582,6 +2588,7 @@
"frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/GuestRow.test.tsx",
"frontend-modern/src/components/Dashboard/__tests__/workloadSelectors.test.ts",
+ "frontend-modern/src/components/Dashboard/GuestDrawer.test.tsx",
"frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx"
]
},
diff --git a/frontend-modern/src/components/Dashboard/GuestDrawer.tsx b/frontend-modern/src/components/Dashboard/GuestDrawer.tsx
index 1ed5f7e804..224c99e16a 100644
--- a/frontend-modern/src/components/Dashboard/GuestDrawer.tsx
+++ b/frontend-modern/src/components/Dashboard/GuestDrawer.tsx
@@ -1,113 +1,39 @@
-import { Component, Show, For, Suspense, createSignal } from 'solid-js';
+import { Component, Show, For, Suspense } from 'solid-js';
import { useNavigate } from '@solidjs/router';
-import type { WorkloadGuest } from '@/types/workloads';
import { formatBytes, formatUptime } from '@/utils/format';
import { DiskList } from './DiskList';
import { DiscoveryTab } from '../Discovery/DiscoveryTab';
-import {
- getDiscoveryResourceTypeForWorkload,
- getCanonicalWorkloadId,
- getWebInterfaceTargetLabelForWorkload,
- resolveWorkloadType,
-} from '@/utils/workloads';
-import { buildInfrastructureHrefForWorkload } from './infrastructureLink';
import { WebInterfaceUrlField } from '@/components/shared/WebInterfaceUrlField';
-import { getDiscoveryLoadingState } from '@/utils/discoveryPresentation';
-import {
- getDiscoveryHostIdForWorkload,
- getDiscoveryResourceIdForWorkload,
-} from './workloadSelectors';
-
-type Guest = WorkloadGuest;
-
-interface GuestDrawerProps {
- guest: Guest;
- onClose: () => void;
- customUrl?: string;
- onCustomUrlChange?: (guestId: string, url: string) => void;
-}
+import { isGuestDrawerVM, type GuestDrawerProps } from './guestDrawerModel';
+import { useGuestDrawerState } from './useGuestDrawerState';
export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
const navigate = useNavigate();
- const guestId = () => getCanonicalWorkloadId(props.guest);
- const infrastructureHref = () => buildInfrastructureHrefForWorkload(props.guest);
-
- const isVM = (guest: Guest): boolean => {
- return resolveWorkloadType(guest) === 'vm';
- };
-
- const hasOsInfo = () => {
- // Both VMs and containers can have OS info
- return (props.guest.osName?.length ?? 0) > 0 || (props.guest.osVersion?.length ?? 0) > 0;
- };
-
- const osName = () => {
- return props.guest.osName || '';
- };
-
- const osVersion = () => {
- return props.guest.osVersion || '';
- };
-
- const hasAgentInfo = () => {
- return !!props.guest.agentVersion;
- };
-
- const agentVersion = () => {
- return props.guest.agentVersion || '';
- };
-
- const ipAddresses = () => {
- return props.guest.ipAddresses || [];
- };
-
- const memoryExtraLines = () => {
- if (!props.guest.memory) return undefined;
- const lines: string[] = [];
- const total = props.guest.memory.total ?? 0;
- if (
- props.guest.memory.balloon &&
- props.guest.memory.balloon > 0 &&
- props.guest.memory.balloon !== total
- ) {
- lines.push(`Balloon: ${formatBytes(props.guest.memory.balloon)}`);
- }
- if (props.guest.memory.swapTotal && props.guest.memory.swapTotal > 0) {
- const swapUsed = props.guest.memory.swapUsed ?? 0;
- lines.push(`Swap: ${formatBytes(swapUsed)} / ${formatBytes(props.guest.memory.swapTotal)}`);
- }
- return lines.length > 0 ? lines : undefined;
- };
+ const {
+ activeTab,
+ agentLabel,
+ agentTitle,
+ backupPresentation,
+ discoveryAgentId,
+ discoveryLoadingState,
+ discoveryResourceId,
+ discoveryResourceType,
+ guestId,
+ hasAgentInfo,
+ hasFilesystemDetails,
+ hasNetworkInterfaces,
+ hasOsInfo,
+ infrastructureHref,
+ ipAddresses,
+ memoryExtraLines,
+ networkInterfaces,
+ normalizedTags,
+ osName,
+ osVersion,
+ switchTab,
+ webInterfaceTargetLabel,
+ } = useGuestDrawerState(props);
- const hasFilesystemDetails = () => {
- if (!props.guest.disks) return false;
- return props.guest.disks.length > 0;
- };
-
- const networkInterfaces = () => {
- // Both VMs and containers can have network interfaces
- return props.guest.networkInterfaces || [];
- };
-
- const hasNetworkInterfaces = () => {
- return networkInterfaces().length > 0;
- };
-
- const [activeTab, setActiveTab] = createSignal<'overview' | 'discovery'>('overview');
-
- // All tabs are always rendered (hidden via CSS) to avoid any DOM
- // mount/unmount during tab switches. Mounting new components inside
- // a <For>-rendered table row causes SolidJS to recreate the row,
- // which detaches the element and resets the scroll container.
- const switchTab = (tab: 'overview' | 'discovery') => {
- setActiveTab(tab);
- };
- const discoveryAgentId = () => {
- return getDiscoveryHostIdForWorkload(props.guest);
- };
- const discoveryResourceId = () => {
- return getDiscoveryResourceIdForWorkload(props.guest);
- };
return (
<div class="space-y-3">
{/* Tabs */}
@@ -179,13 +105,8 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
<Show when={hasAgentInfo()}>
<div class="flex items-center justify-between">
<span class="text-muted">Agent</span>
- <span
- class="font-medium text-base-content truncate ml-2"
- title={
- isVM(props.guest) ? `QEMU guest agent ${agentVersion()}` : agentVersion()
- }
- >
- {isVM(props.guest) ? `QEMU ${agentVersion()}` : agentVersion()}
+ <span class="font-medium text-base-content truncate ml-2" title={agentTitle()}>
+ {agentLabel()}
</span>
</div>
</Show>
@@ -252,60 +173,34 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
Backup
</div>
<div class="space-y-1 text-[11px]">
- {(() => {
- const backupDate = new Date(props.guest.lastBackup);
- const now = new Date();
- const daysSince = Math.floor(
- (now.getTime() - backupDate.getTime()) / (1000 * 60 * 60 * 24),
- );
- const isOld = daysSince > 7;
- const isCritical = daysSince > 30;
- return (
+ <Show when={backupPresentation()}>
+ {(presentation) => (
<>
<div class="flex items-center justify-between">
<span class="text-muted">Last Backup</span>
- <span
- class={`font-medium ${isCritical ? 'text-red-600 dark:text-red-400' : isOld ? 'text-amber-600 dark:text-amber-400' : 'text-green-600 dark:text-green-400'}`}
- >
- {daysSince === 0
- ? 'Today'
- : daysSince === 1
- ? 'Yesterday'
- : `${daysSince}d ago`}
+ <span class={`font-medium ${presentation().ageClass}`}>
+ {presentation().ageLabel}
</span>
</div>
- <div class="text-[10px] text-muted">{backupDate.toLocaleDateString()}</div>
+ <div class="text-[10px] text-muted">{presentation().dateLabel}</div>
</>
- );
- })()}
+ )}
+ </Show>
</div>
</div>
</Show>
{/* Tags */}
- <Show
- when={
- props.guest.tags &&
- (Array.isArray(props.guest.tags)
- ? props.guest.tags.length > 0
- : props.guest.tags.length > 0)
- }
- >
+ <Show when={normalizedTags().length > 0}>
<div class="rounded border border-border bg-surface p-3 shadow-sm">
<div class="text-[11px] font-medium uppercase tracking-wide text-base-content mb-2">
Tags
</div>
<div class="flex flex-wrap gap-1">
- <For
- each={
- Array.isArray(props.guest.tags)
- ? props.guest.tags
- : props.guest.tags?.split(',') || []
- }
- >
+ <For each={normalizedTags()}>
{(tag) => (
<span class="inline-block rounded bg-surface-alt px-1.5 py-0.5 text-[10px]">
- {tag.trim()}
+ {tag}
</span>
)}
</For>
@@ -323,7 +218,7 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
<DiskList
disks={props.guest.disks || []}
diskStatusReason={
- isVM(props.guest) ? (props.guest as any).diskStatusReason : undefined
+ isGuestDrawerVM(props.guest) ? (props.guest as any).diskStatusReason : undefined
}
/>
</div>
@@ -384,10 +279,10 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
</div>
<div class="mt-3">
- <WebInterfaceUrlField
+ <WebInterfaceUrlField
metadataKind="guest"
metadataId={guestId()}
- targetLabel={getWebInterfaceTargetLabelForWorkload(props.guest)}
+ targetLabel={webInterfaceTargetLabel()}
customUrl={props.customUrl}
onCustomUrlChange={(url) => props.onCustomUrlChange?.(guestId(), url)}
/>
@@ -405,12 +300,12 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
fallback={
<div class="flex items-center justify-center py-8">
<div class="animate-spin h-6 w-6 border-2 border-blue-500 border-t-transparent rounded-full" />
- <span class="ml-2 text-sm text-muted">{getDiscoveryLoadingState().text}</span>
+ <span class="ml-2 text-sm text-muted">{discoveryLoadingState.text}</span>
</div>
}
>
<DiscoveryTab
- resourceType={getDiscoveryResourceTypeForWorkload(props.guest)}
+ resourceType={discoveryResourceType()}
agentId={discoveryAgentId()}
resourceId={discoveryResourceId()}
hostname={props.guest.name}
diff --git a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
index 12309af1bd..9481ec1d40 100644
--- a/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Dashboard/__tests__/Dashboard.performance.contract.test.tsx
@@ -5,7 +5,10 @@ import type { Resource } from '@/types/resource';
import { Dashboard } from '../Dashboard';
import dashboardSource from '../Dashboard.tsx?raw';
import dashboardStateSource from '../useDashboardState.ts?raw';
+import guestDrawerSource from '../GuestDrawer.tsx?raw';
+import guestDrawerModelSource from '../guestDrawerModel.ts?raw';
import guestRowSource from '../GuestRow.tsx?raw';
+import guestDrawerStateSource from '../useGuestDrawerState.ts?raw';
import guestRowModelSource from '../guestRowModel.tsx?raw';
import guestRowStateSource from '../useGuestRowState.ts?raw';
import {
@@ -481,6 +484,18 @@ describe('Dashboard performance contract', () => {
expect(guestRowStateSource).toContain('getWorkloadTypeBadge');
});
+ it('keeps guest drawer runtime and derivations in canonical drawer owners', () => {
+ expect(guestDrawerSource).toContain('useGuestDrawerState');
+ expect(guestDrawerSource).not.toContain('const guestId = () =>');
+ expect(guestDrawerSource).not.toContain('const infrastructureHref = () =>');
+ expect(guestDrawerStateSource).toContain('getCanonicalWorkloadId');
+ expect(guestDrawerStateSource).toContain('buildInfrastructureHrefForWorkload');
+ expect(guestDrawerStateSource).toContain('getDiscoveryResourceTypeForWorkload');
+ expect(guestDrawerStateSource).toContain('getWebInterfaceTargetLabelForWorkload');
+ expect(guestDrawerModelSource).toContain('export const getGuestDrawerBackupPresentation');
+ expect(guestDrawerModelSource).toContain('export const normalizeGuestDrawerTags');
+ });
+
it('filterWorkloads returns all guests when no filters active', () => {
const guests = makeGuests(PROFILES.S);
const result = filterWorkloads({
diff --git a/frontend-modern/src/components/Dashboard/guestDrawerModel.ts b/frontend-modern/src/components/Dashboard/guestDrawerModel.ts
new file mode 100644
index 0000000000..e66cf7a056
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/guestDrawerModel.ts
@@ -0,0 +1,92 @@
+import type { WorkloadGuest } from '@/types/workloads';
+
+import { formatBytes } from '@/utils/format';
+import { resolveWorkloadType } from '@/utils/workloads';
+
+type Guest = WorkloadGuest;
+
+export interface GuestDrawerProps {
+ guest: Guest;
+ onClose: () => void;
+ customUrl?: string;
+ onCustomUrlChange?: (guestId: string, url: string) => void;
+}
+
+export type GuestDrawerTab = 'overview' | 'discovery';
+
+export interface GuestDrawerBackupPresentation {
+ ageClass: string;
+ ageLabel: string;
+ dateLabel: string;
+}
+
+export const isGuestDrawerVM = (guest: Guest): boolean => resolveWorkloadType(guest) === 'vm';
+
+export const hasGuestDrawerOsInfo = (guest: Guest): boolean =>
+ (guest.osName?.length ?? 0) > 0 || (guest.osVersion?.length ?? 0) > 0;
+
+export const getGuestDrawerAgentLabel = (guest: Guest): string => {
+ const version = (guest.agentVersion || '').trim();
+ if (!version) return '';
+ return isGuestDrawerVM(guest) ? `QEMU ${version}` : version;
+};
+
+export const getGuestDrawerAgentTitle = (guest: Guest): string => {
+ const version = (guest.agentVersion || '').trim();
+ if (!version) return '';
+ return isGuestDrawerVM(guest) ? `QEMU guest agent ${version}` : version;
+};
+
+export const getGuestDrawerMemoryExtraLines = (guest: Guest): string[] | undefined => {
+ if (!guest.memory) return undefined;
+
+ const lines: string[] = [];
+ const total = guest.memory.total ?? 0;
+ if (guest.memory.balloon && guest.memory.balloon > 0 && guest.memory.balloon !== total) {
+ lines.push(`Balloon: ${formatBytes(guest.memory.balloon)}`);
+ }
+ if (guest.memory.swapTotal && guest.memory.swapTotal > 0) {
+ const swapUsed = guest.memory.swapUsed ?? 0;
+ lines.push(`Swap: ${formatBytes(swapUsed)} / ${formatBytes(guest.memory.swapTotal)}`);
+ }
+ return lines.length > 0 ? lines : undefined;
+};
+
+export const hasGuestDrawerFilesystemDetails = (guest: Guest): boolean =>
+ Array.isArray(guest.disks) && guest.disks.length > 0;
+
+export const getGuestDrawerNetworkInterfaces = (guest: Guest) => guest.networkInterfaces || [];
+
+export const normalizeGuestDrawerTags = (tags: Guest['tags']): string[] => {
+ if (Array.isArray(tags)) {
+ return tags.map((tag) => tag.trim()).filter((tag) => tag.length > 0);
+ }
+ if (typeof tags === 'string') {
+ return tags
+ .split(',')
+ .map((tag) => tag.trim())
+ .filter((tag) => tag.length > 0);
+ }
+ return [];
+};
+
+export const getGuestDrawerBackupPresentation = (
+ lastBackup: string | number | Date,
+ now: Date = new Date(),
+): GuestDrawerBackupPresentation => {
+ const backupDate = new Date(lastBackup);
+ const daysSince = Math.floor((now.getTime() - backupDate.getTime()) / (1000 * 60 * 60 * 24));
+ const isOld = daysSince > 7;
+ const isCritical = daysSince > 30;
+
+ return {
+ ageClass: isCritical
+ ? 'text-red-600 dark:text-red-400'
+ : isOld
+ ? 'text-amber-600 dark:text-amber-400'
+ : 'text-green-600 dark:text-green-400',
+ ageLabel:
+ daysSince === 0 ? 'Today' : daysSince === 1 ? 'Yesterday' : `${daysSince}d ago`,
+ dateLabel: backupDate.toLocaleDateString(),
+ };
+};
diff --git a/frontend-modern/src/components/Dashboard/useGuestDrawerState.ts b/frontend-modern/src/components/Dashboard/useGuestDrawerState.ts
new file mode 100644
index 0000000000..40f67a3b38
--- /dev/null
+++ b/frontend-modern/src/components/Dashboard/useGuestDrawerState.ts
@@ -0,0 +1,85 @@
+import { createMemo, createSignal } from 'solid-js';
+
+import { getDiscoveryLoadingState } from '@/utils/discoveryPresentation';
+import {
+ getCanonicalWorkloadId,
+ getDiscoveryResourceTypeForWorkload,
+ getWebInterfaceTargetLabelForWorkload,
+} from '@/utils/workloads';
+
+import { buildInfrastructureHrefForWorkload } from './infrastructureLink';
+import {
+ getDiscoveryHostIdForWorkload,
+ getDiscoveryResourceIdForWorkload,
+} from './workloadSelectors';
+import {
+ getGuestDrawerAgentLabel,
+ getGuestDrawerAgentTitle,
+ getGuestDrawerBackupPresentation,
+ getGuestDrawerMemoryExtraLines,
+ getGuestDrawerNetworkInterfaces,
+ hasGuestDrawerFilesystemDetails,
+ hasGuestDrawerOsInfo,
+ normalizeGuestDrawerTags,
+ type GuestDrawerProps,
+ type GuestDrawerTab,
+} from './guestDrawerModel';
+
+export function useGuestDrawerState(props: GuestDrawerProps) {
+ const [activeTab, setActiveTab] = createSignal<GuestDrawerTab>('overview');
+
+ const guestId = createMemo(() => getCanonicalWorkloadId(props.guest));
+ const infrastructureHref = createMemo(() => buildInfrastructureHrefForWorkload(props.guest));
+ const osName = createMemo(() => props.guest.osName || '');
+ const osVersion = createMemo(() => props.guest.osVersion || '');
+ const hasOsInfo = createMemo(() => hasGuestDrawerOsInfo(props.guest));
+ const agentLabel = createMemo(() => getGuestDrawerAgentLabel(props.guest));
+ const agentTitle = createMemo(() => getGuestDrawerAgentTitle(props.guest));
+ const hasAgentInfo = createMemo(() => agentLabel().length > 0);
+ const ipAddresses = createMemo(() => props.guest.ipAddresses || []);
+ const memoryExtraLines = createMemo(() => getGuestDrawerMemoryExtraLines(props.guest));
+ const hasFilesystemDetails = createMemo(() => hasGuestDrawerFilesystemDetails(props.guest));
+ const networkInterfaces = createMemo(() => getGuestDrawerNetworkInterfaces(props.guest));
+ const hasNetworkInterfaces = createMemo(() => networkInterfaces().length > 0);
+ const normalizedTags = createMemo(() => normalizeGuestDrawerTags(props.guest.tags));
+ const backupPresentation = createMemo(() =>
+ props.guest.lastBackup ? getGuestDrawerBackupPresentation(props.guest.lastBackup) : null,
+ );
+ const discoveryAgentId = createMemo(() => getDiscoveryHostIdForWorkload(props.guest));
+ const discoveryResourceId = createMemo(() => getDiscoveryResourceIdForWorkload(props.guest));
+ const discoveryResourceType = createMemo(() =>
+ getDiscoveryResourceTypeForWorkload(props.guest),
+ );
+ const webInterfaceTargetLabel = createMemo(() =>
+ getWebInterfaceTargetLabelForWorkload(props.guest),
+ );
+
+ const switchTab = (tab: GuestDrawerTab) => {
+ setActiveTab(tab);
+ };
+
+ return {
+ activeTab,
+ agentLabel,
+ agentTitle,
+ backupPresentation,
+ discoveryAgentId,
+ discoveryLoadingState: getDiscoveryLoadingState(),
+ discoveryResourceId,
+ discoveryResourceType,
+ guestId,
+ hasAgentInfo,
+ hasFilesystemDetails,
+ hasNetworkInterfaces,
+ hasOsInfo,
+ infrastructureHref,
+ ipAddresses,
+ memoryExtraLines,
+ networkInterfaces,
+ normalizedTags,
+ osName,
+ osVersion,
+ switchTab,
+ webInterfaceTargetLabel,
+ };
+}
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index b993cb418b..655aa0dfc8 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -100,6 +100,8 @@ import guestRowModelSource from '@/components/Dashboard/guestRowModel.tsx?raw';
import guestRowStateSource from '@/components/Dashboard/useGuestRowState.ts?raw';
import dashboardDiskListSource from '@/components/Dashboard/DiskList.tsx?raw';
import guestDrawerSource from '@/components/Dashboard/GuestDrawer.tsx?raw';
+import guestDrawerModelSource from '@/components/Dashboard/guestDrawerModel.ts?raw';
+import guestDrawerStateSource from '@/components/Dashboard/useGuestDrawerState.ts?raw';
import dashboardGuestPresentationSource from '@/utils/dashboardGuestPresentation.ts?raw';
import orgScopeSource from '@/utils/orgScope.ts?raw';
import workloadsSource from '@/utils/workloads.ts?raw';
@@ -510,7 +512,8 @@ describe('frontend resource type boundaries', () => {
expect(guestRowStateSource).toContain('getCanonicalWorkloadId');
expect(guestRowModelSource).toContain('export const GUEST_COLUMNS');
expect(guestRowSource).not.toContain('buildGuestId');
- expect(guestDrawerSource).toContain('getCanonicalWorkloadId');
+ expect(guestDrawerSource).toContain('useGuestDrawerState');
+ expect(guestDrawerStateSource).toContain('getCanonicalWorkloadId');
expect(guestDrawerSource).not.toContain('const guestId = () => {');
expect(emptyStateSource).toContain('getEmptyStatePresentation');
expect(emptyStateSource).not.toContain('const iconBgClass: Record<EmptyStateTone, string> =');
@@ -2219,11 +2222,13 @@ describe('frontend resource type boundaries', () => {
expect(discoveryTabSource).toContain('getDiscoveryLoadingState');
expect(discoveryTabSource).toContain('getDiscoverySuggestedURLFallback');
expect(discoveryTabSource).toContain('getDiscoveryNotesEmptyState');
- expect(guestDrawerSource).toContain('getDiscoveryResourceTypeForWorkload');
- expect(guestDrawerSource).toContain('getWebInterfaceTargetLabelForWorkload');
- expect(guestDrawerSource).toContain('getDiscoveryLoadingState');
+ expect(guestDrawerSource).toContain('useGuestDrawerState');
+ expect(guestDrawerStateSource).toContain('getDiscoveryResourceTypeForWorkload');
+ expect(guestDrawerStateSource).toContain('getWebInterfaceTargetLabelForWorkload');
+ expect(guestDrawerStateSource).toContain('getDiscoveryLoadingState');
expect(guestDrawerSource).not.toContain('const discoveryResourceType = () =>');
expect(guestDrawerSource).not.toContain('const urlTargetLabel = () =>');
+ expect(guestDrawerModelSource).toContain('export const getGuestDrawerBackupPresentation');
expect(workloadsSource).toContain('export const getDiscoveryResourceTypeForWorkload');
expect(workloadsSource).toContain('export const getWebInterfaceTargetLabelForWorkload');
expect(infrastructureDetailsDrawerSource).toContain('getDiscoveryLoadingState');
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index 1ac0bcb737..c78681c925 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -1801,6 +1801,36 @@ class SubsystemLookupTest(unittest.TestCase):
"dashboard-workload-hot-path",
)
+ def test_lookup_paths_assigns_dashboard_guest_drawer_runtime_to_performance_and_scalability(self) -> None:
+ result = lookup_paths(
+ [
+ "frontend-modern/src/components/Dashboard/GuestDrawer.tsx",
+ "frontend-modern/src/components/Dashboard/guestDrawerModel.ts",
+ "frontend-modern/src/components/Dashboard/useGuestDrawerState.ts",
+ ]
+ )
+ self.assertEqual(result["unowned_runtime_files"], [])
+ self.assertEqual(
+ {item["subsystem"] for item in result["impacted_subsystems"]},
+ {"performance-and-scalability"},
+ )
+ for file_entry in result["files"]:
+ self.assertEqual(file_entry["classification"], "runtime")
+ self.assertEqual(
+ {match["subsystem"] for match in file_entry["matches"]},
+ {"performance-and-scalability"},
+ )
+ match = file_entry["matches"][0]
+ self.assertEqual(
+ match["contract"],
+ "docs/release-control/v6/internal/subsystems/performance-and-scalability.md",
+ )
+ self.assertEqual(match["lane_context"]["lane_id"], "L10")
+ self.assertEqual(
+ match["verification_requirement"]["id"],
+ "dashboard-workload-hot-path",
+ )
+
def test_lookup_paths_assigns_settings_page_shell_to_frontend_primitives(self) -> None:
result = lookup_paths(["frontend-modern/src/components/Settings/SettingsPageShell.tsx"])
self.assertEqual(result["unowned_runtime_files"], [])