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.

Keep guest discovery bound to its current target

pulse-triage[bot]9230aca96dd8
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 7ab08be514..84d54e0b95 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -20,6 +20,22 @@
## Purpose
+### Discovery detail reads preserve final access status
+
+`getDiscovery` retains final HTTP401/403 in a typed client error before any
+response-body read. The fixed message exposes no denied body. This applies to
+the typed resource detail, agent collection and resolved agent detail paths.
+A body or transport message claiming an access status is not that status, and
+ordinary transient failures retain their existing error behaviour. Successful
+absent-record semantics (detail HTTP404 or an empty agent list) are unchanged.
+Retained query consumers can therefore withdraw a denied service/endpoint
+rather than treating it as a transient read or a successful empty discovery.
+No endpoint, server permission, wire schema or mutation policy changes.
+`src/api/__tests__/discovery.test.ts` exercises all three paths with actual
+Response status/body objects, denied-body non-read and a misleading 503 body.
+The production guest browser fixture verifies the connected final HTTP403
+withdrawal, pending retry, transient retention and successful HTTP404 recovery.
+
### TrueNAS saved probes do not rewrite runtime evidence — issue #2382
The saved connection test uses stored server-owned secrets, or merges an edited
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 1b95e57542..97fbaf51bd 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -15,6 +15,37 @@
## Purpose
+### Guest discovery evidence and UI state have exact owners
+
+The guest drawer's passive discovery lookup changes only when its explicit
+resource-type/agent/resource target changes, not on same-target metric or name
+snapshot refreshes. Retained/remount evidence is keyed by canonical guest and
+that target. A replacement target cannot display the predecessor's service,
+endpoint, URL suggestion or assurance suggestion while its own read is pending
+or failed. A successful absent-record read is empty; errors are not absence.
+The discovery detail reader preserves final HTTP401/403 on typed failures
+without reading the denied body, including agent-list/detail paths. Those
+failures withdraw cached evidence and show the fixed access message.
+A same-target transient failure may retain its own last successful details,
+but must visibly qualify them and provide an in-place retry without raw error
+text. This preserves the shared query's denial/cache-generation policy.
+
+A different canonical guest disposes its local tabs, range, forms, disclosures
+and outstanding read consumers. Same-ID updates stay mounted. Within that
+identity, a changed discovery target remounts only the existing Discovery tab,
+so late scan/notes completions cannot populate the successor's UI. Already
+sent server-side operations are not cancelled or retried by this boundary;
+saved operator URLs remain separate from derived suggestions.
+
+Verification: `discovery.test.ts` covers final status preservation on all
+three read paths and non-authoritative body claims. `GuestDrawer.test.tsx`
+covers replacement, source stability,
+late reads, HTTP401/403/cache withdrawal, transient retention/retry and
+canonical identity reset. `browser-tests/guest-discovery-identity.cjs` uses
+production drawer/DiscoveryTab/Manage/History, clients and CSS on desktop
+Chromium and touch WebKit. Its synthetic delayed scan is not a native command,
+QGA/thaw, fleet-performance, appliance identity or delivery proof.
+
### Workload projection preserves native guest-read evidence
`useWorkloads` forwards the existing Proxmox disk-status reason, guest-agent
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 73db5c65df..01bb486de0 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -23,6 +23,37 @@ and sort the complete canonical change table while startup and ingestion wait.
## Purpose
+### Guest discovery evidence and UI state have exact owners
+
+The guest drawer's passive discovery lookup changes only when its explicit
+resource-type/agent/resource target changes, not on same-target metric or name
+snapshot refreshes. Retained/remount evidence is keyed by canonical guest and
+that target. A replacement target cannot display the predecessor's service,
+endpoint, URL suggestion or assurance suggestion while its own read is pending
+or failed. A successful absent-record read is empty; errors are not absence.
+The discovery detail reader preserves final HTTP401/403 on typed failures
+without reading the denied body, including agent-list/detail paths. Those
+failures withdraw cached evidence and show the fixed access message.
+A same-target transient failure may retain its own last successful details,
+but must visibly qualify them and provide an in-place retry without raw error
+text. This preserves the shared query's denial/cache-generation policy.
+
+A different canonical guest disposes its local tabs, range, forms, disclosures
+and outstanding read consumers. Same-ID updates stay mounted. Within that
+identity, a changed discovery target remounts only the existing Discovery tab,
+so late scan/notes completions cannot populate the successor's UI. Already
+sent server-side operations are not cancelled or retried by this boundary;
+saved operator URLs remain separate from derived suggestions.
+
+Verification: `discovery.test.ts` covers final status preservation on all
+three read paths and non-authoritative body claims. `GuestDrawer.test.tsx`
+covers replacement, source stability,
+late reads, HTTP401/403/cache withdrawal, transient retention/retry and
+canonical identity reset. `browser-tests/guest-discovery-identity.cjs` uses
+production drawer/DiscoveryTab/Manage/History, clients and CSS on desktop
+Chromium and touch WebKit. Its synthetic delayed scan is not a native command,
+QGA/thaw, fleet-performance, appliance identity or delivery proof.
+
### Native VM read outcomes survive browser projection and recovery
The existing Proxmox guest read-state facet remains intact at the WorkloadGuest
diff --git a/frontend-modern/browser-tests/guest-discovery-identity.cjs b/frontend-modern/browser-tests/guest-discovery-identity.cjs
new file mode 100644
index 0000000000..ee1ca03b1a
--- /dev/null
+++ b/frontend-modern/browser-tests/guest-discovery-identity.cjs
@@ -0,0 +1,371 @@
+const assert = require('node:assert/strict');
+const fs = require('node:fs');
+const path = require('node:path');
+const crypto = require('node:crypto');
+const { chromium, webkit } = require('playwright');
+const root = '/workspace/frontend-modern';
+const output = '/workspace/tmp/guest-discovery-browser';
+const origin = 'http://127.0.0.1:5326';
+const runtime = [
+ 'frontend-modern/src/components/Workloads/GuestDrawer.tsx',
+ 'frontend-modern/src/components/Workloads/useGuestDrawerState.ts',
+ 'frontend-modern/src/api/discovery.ts',
+];
+const hash = (p) => crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex');
+const record = (agent) => ({
+ id: `vm:${agent}:100`,
+ resource_type: 'vm',
+ resource_id: '100',
+ agent_id: agent,
+ target_id: agent,
+ hostname: agent,
+ service_name: `Service ${agent}`,
+ service_type: 'dashboard',
+ service_version: '1.0',
+ category: 'web_server',
+ confidence: 0.95,
+ ports: [],
+ facts: [],
+ config_paths: [],
+ data_paths: [],
+ log_paths: [],
+ user_notes: `Notes ${agent}`,
+ user_secrets: {},
+ discovered_at: '2026-10-04T06:00:00Z',
+ updated_at: '2026-10-04T06:00:00Z',
+ scan_duration: 1,
+ suggested_url: `https://${agent}.example.test/`,
+ discovery_engine_version: 1,
+});
+(async () => {
+ fs.mkdirSync(output, { recursive: true });
+ const result = {
+ result: 'incomplete',
+ playwright: require('playwright/package.json').version,
+ runtime_hashes: Object.fromEntries(runtime.map((p) => [p, hash('/workspace/' + p)])),
+ cases: [],
+ screenshots: [],
+ limits:
+ 'Synthetic local HTTP responses, real production GuestDrawer/DiscoveryTab/Manage/History, clients and CSS. No native target, agent command, guest freeze/thaw, appliance identity, installed recovery, physical phone, source publication or release acceptance.',
+ };
+ assert.equal(
+ result.playwright,
+ JSON.parse(fs.readFileSync('/workspace/tests/integration/package-lock.json')).packages[
+ 'node_modules/@playwright/test'
+ ].version,
+ );
+ process.chdir(root);
+ const { createServer } = await import(path.join(root, 'node_modules/vite/dist/node/index.js'));
+ const server = await createServer({
+ root,
+ configFile: path.join(root, 'vite.config.ts'),
+ cacheDir: output + '/cache',
+ server: { host: '127.0.0.1', port: 5326, strictPort: true },
+ });
+ let browser;
+ try {
+ await server.listen();
+ for (const [name, engine, width, dark] of [
+ ['chromium-desktop', chromium, 1365, false],
+ ['webkit-phone', webkit, 390, true],
+ ]) {
+ browser = await engine.launch(
+ engine === chromium
+ ? { headless: true, channel: 'chromium', args: ['--no-sandbox'] }
+ : { headless: true },
+ );
+ const page = await browser.newPage({
+ viewport: { width, height: width < 768 ? 844 : 900 },
+ hasTouch: width < 768,
+ isMobile: width < 768,
+ colorScheme: dark ? 'dark' : 'light',
+ });
+ const item = { name, browser: browser.version(), requests: [], errors: [], checks: [] };
+ result.cases.push(item);
+ page.on('pageerror', (e) => item.errors.push(e.message));
+ const modes = new Map();
+ let pendingReads = [];
+ let pendingScan;
+ await page.route('**/*', async (route) => {
+ const request = route.request();
+ const url = new URL(request.url());
+ if (url.origin !== origin) {
+ item.requests.push({ path: url.pathname, blocked: true });
+ return route.abort();
+ }
+ if (!url.pathname.startsWith('/api/')) return route.continue();
+ item.requests.push({ path: url.pathname, method: request.method() });
+ const respond = (body, status = 200) =>
+ route.fulfill({ status, contentType: 'application/json', body: JSON.stringify(body) });
+ const discovery = url.pathname.match(/^\/api\/discovery\/vm\/([^/]+)\/100$/);
+ if (discovery) {
+ const agent = decodeURIComponent(discovery[1]);
+ if (request.method() === 'POST') {
+ pendingScan = { route, agent };
+ return;
+ }
+ const mode = modes.get(agent);
+ if (mode === 'pending') {
+ pendingReads.push({ route, agent });
+ return;
+ }
+ if (typeof mode === 'number')
+ return respond({ error: 'private diagnostic must not render' }, mode);
+ if (mode === 'missing') return respond({}, 404);
+ return respond(record(agent));
+ }
+ if (url.pathname.startsWith('/api/discovery/info/'))
+ return respond({
+ ai_provider: { provider: 'fixture', label: 'Local fixture', is_local: true },
+ commands: [],
+ command_categories: [],
+ });
+ if (url.pathname === '/api/ai/agents')
+ return respond({ count: 1, agents: [{ agent_id: 'agent-a', hostname: 'agent-a' }] });
+ if (url.pathname.includes('/metrics-history/'))
+ return respond({
+ resourceType: 'vm',
+ resourceId: 'fixture:pve1:100',
+ range: '24h',
+ start: Date.UTC(2026, 9, 3, 6),
+ end: Date.UTC(2026, 9, 4, 6),
+ metrics: {},
+ source: 'store',
+ });
+ if (url.pathname.includes('/runtime-capabilities'))
+ return respond({
+ capabilities: [],
+ limits: [],
+ max_history_days: 90,
+ hosted_mode: false,
+ runtime: { build: 'community' },
+ blocked_capabilities: [],
+ });
+ if (url.pathname.includes('/license/'))
+ return respond({ tier: 'pro', valid: true, features: {}, maxHistoryDays: 90 });
+ if (url.pathname.endsWith('/operator-state')) return respond({});
+ if (url.pathname.includes('/metadata')) return respond({});
+ return respond({});
+ });
+ const activate = async (locator) => (width < 768 ? locator.tap() : locator.click());
+ const until = async (fn) => {
+ for (let n = 0; n < 100; n++) {
+ if (await fn()) return;
+ await page.waitForTimeout(50);
+ }
+ throw new Error('Condition not observed');
+ };
+ const text = () => page.locator('main').innerText();
+ const update = (agent, id) =>
+ page.evaluate(([agent, id]) => window.__guestIdentity.update(agent, id), [agent, id]);
+ const shot = async (state) => {
+ const file = `${name}-${state}.png`;
+ await page.screenshot({ path: output + '/' + file, fullPage: true });
+ result.screenshots.push({ file, state, sha256: hash(output + '/' + file) });
+ };
+ const settle = async (agent) => {
+ const matches = pendingReads.filter((r) => r.agent === agent);
+ pendingReads = pendingReads.filter((r) => r.agent !== agent);
+ for (const r of matches)
+ await r.route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify(record(agent)),
+ });
+ };
+ await page.goto(
+ origin + '/browser-tests/guest-discovery-identity.html' + (dark ? '?dark=1' : ''),
+ );
+ await until(async () => (await text()).includes('Service agent-a'));
+ await until(
+ () => item.requests.filter((r) => r.path === '/api/discovery/vm/agent-a/100').length === 2,
+ );
+ await page.evaluate(() => window.__guestIdentity.ticks(100));
+ await page.waitForTimeout(200);
+ assert.equal(
+ item.requests.filter((r) => r.path === '/api/discovery/vm/agent-a/100').length,
+ 2,
+ '100 same-target snapshots must not issue discovery reads',
+ );
+ await activate(page.getByRole('tab', { name: 'Manage', exact: true }));
+ assert.equal(
+ await page
+ .getByRole('link', { name: 'Open suggested URL', exact: true })
+ .getAttribute('href'),
+ 'https://agent-a.example.test/',
+ );
+ assert.equal(
+ await page.locator('main input[type=url]').inputValue(),
+ 'https://operator.example.test/',
+ );
+ modes.set('agent-b', 'pending');
+ await update('agent-b');
+ await until(() => pendingReads.filter((r) => r.agent === 'agent-b').length === 2);
+ assert.equal(
+ await page.getByRole('link', { name: 'Open suggested URL', exact: true }).count(),
+ 0,
+ );
+ assert.equal((await text()).includes('Service agent-a'), false);
+ assert.equal(
+ await page.locator('main input[type=url]').inputValue(),
+ 'https://operator.example.test/',
+ );
+ await shot('replacement-pending');
+ modes.delete('agent-b');
+ await settle('agent-b');
+ await until(() =>
+ page
+ .getByRole('link', { name: 'Open suggested URL', exact: true })
+ .count()
+ .then((n) => n === 1),
+ );
+ assert.equal(
+ await page
+ .getByRole('link', { name: 'Open suggested URL', exact: true })
+ .getAttribute('href'),
+ 'https://agent-b.example.test/',
+ );
+ // A command already sent for the old target is not repeated, nor may its
+ // late HTTP completion replace the successor's discovery/notes UI.
+ await activate(page.getByRole('tab', { name: 'Discovery', exact: true }));
+ await until(async () => (await text()).includes('Service agent-b'));
+ const run = page.getByRole('button', { name: 'Run Discovery', exact: true }).first();
+ await activate(run);
+ await until(() => Boolean(pendingScan));
+ await update('agent-c');
+ await until(async () => (await text()).includes('Service agent-c'));
+ await pendingScan.route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ ...record('agent-b'),
+ service_name: 'Late old result',
+ user_notes: 'Late old notes',
+ }),
+ });
+ pendingScan = undefined;
+ await page.waitForTimeout(100);
+ assert.equal((await text()).includes('Late old'), false);
+ assert.equal((await text()).includes('Notes agent-b'), false);
+ assert.equal(item.requests.filter((r) => r.method === 'POST').length, 1);
+ await shot('late-scan-isolated');
+ // A source change cannot borrow the current source's cache while its
+ // own two reads are pending; late completions are ignored as well.
+ modes.set('agent-d', 'pending');
+ await update('agent-d');
+ await until(() => pendingReads.filter((r) => r.agent === 'agent-d').length === 2);
+ await update('agent-e');
+ await until(async () => (await text()).includes('Service agent-e'));
+ await settle('agent-d');
+ await page.waitForTimeout(100);
+ assert.equal((await text()).includes('Service agent-d'), false);
+ // Final denial withdraws retained suggestions; neither a same-target
+ // transient cache nor another source's successful data stands in for it.
+ modes.set('agent-e', 403);
+ await page.evaluate(() => window.__guestIdentity.mount(false));
+ await page.evaluate(() => window.__guestIdentity.mount(true));
+ await until(async () => (await text()).includes('Access denied.'));
+ await activate(page.getByRole('tab', { name: 'Manage', exact: true }));
+ assert.equal(
+ await page.getByRole('link', { name: 'Open suggested URL', exact: true }).count(),
+ 0,
+ );
+ assert.equal((await text()).includes('private diagnostic'), false);
+ modes.set('agent-e', 'pending');
+ const retry = page.getByRole('button', { name: 'Retry service details', exact: true });
+ await retry.focus();
+ await page.keyboard.press('Enter');
+ await until(() => pendingReads.some((r) => r.agent === 'agent-e'));
+ assert.equal(
+ await page.getByRole('link', { name: 'Open suggested URL', exact: true }).count(),
+ 0,
+ );
+ await shot('denied-retry');
+ modes.delete('agent-e');
+ await settle('agent-e');
+ await until(() =>
+ page
+ .getByRole('link', { name: 'Open suggested URL', exact: true })
+ .count()
+ .then((n) => n === 1),
+ );
+ assert.equal(
+ await page
+ .getByRole('link', { name: 'Open suggested URL', exact: true })
+ .getAttribute('href'),
+ 'https://agent-e.example.test/',
+ );
+ // Same-target transient failure retains only its own data, with a fixed
+ // visible qualification; a successful no-record read is genuinely empty.
+ modes.set('agent-e', 503);
+ await page.evaluate(() => window.__guestIdentity.mount(false));
+ await page.evaluate(() => window.__guestIdentity.mount(true));
+ await until(async () =>
+ (await text()).includes('Showing previously loaded service details.'),
+ );
+ await activate(page.getByRole('tab', { name: 'Manage', exact: true }));
+ assert.equal(
+ await page
+ .getByRole('link', { name: 'Open suggested URL', exact: true })
+ .getAttribute('href'),
+ 'https://agent-e.example.test/',
+ );
+ await shot('transient-retained');
+ modes.set('agent-e', 'missing');
+ await activate(page.getByRole('button', { name: 'Retry service details', exact: true }));
+ await until(async () => !(await text()).includes('Showing previously loaded'));
+ assert.equal(
+ await page.getByRole('link', { name: 'Open suggested URL', exact: true }).count(),
+ 0,
+ );
+ await activate(page.getByRole('tab', { name: 'History', exact: true }));
+ await page.getByLabel('History range').selectOption('7d');
+ await page.evaluate(() => window.__guestIdentity.ticks(1));
+ assert.equal(await page.getByLabel('History range').inputValue(), '7d');
+ await update('agent-f', 'fixture-pve1-200');
+ assert.equal(
+ await page
+ .getByRole('tab', { name: 'Overview', exact: true })
+ .getAttribute('aria-selected'),
+ 'true',
+ );
+ await activate(page.getByRole('tab', { name: 'History', exact: true }));
+ assert.equal(await page.getByLabel('History range').inputValue(), '24h');
+ assert.equal(
+ await page.locator('main').evaluate((main) => main.scrollWidth <= main.clientWidth + 1),
+ true,
+ );
+ assert.deepEqual(item.errors, []);
+ assert.equal(
+ item.requests.some((r) => r.blocked),
+ false,
+ );
+ assert.equal(
+ item.requests.filter((r) => r.method !== 'GET').length,
+ 1,
+ 'Only the explicit synthetic old-target scan is sent',
+ );
+ item.checks = [
+ '100 same-target updates issue zero extra discovery reads and keep selection.',
+ 'Replacement target withdraws old service/URL; saved operator URL is separate.',
+ 'Late old lookup and scan completion cannot populate successor service/notes.',
+ 'Final 403 clears retained value; keyboard retry stays empty until current success.',
+ 'Same-target 503 is visibly retained, raw error withheld, successful 404 is empty.',
+ 'New canonical guest resets tabs/range, same-ID update preserves them.',
+ 'Phone touch and desktop keyboard/links, no overflow/page error/off-origin access.',
+ ];
+ await page.close();
+ await browser.close();
+ browser = undefined;
+ }
+ result.result = 'passed';
+ result.verified_at = new Date().toISOString();
+ } finally {
+ fs.writeFileSync(output + '/result.json', JSON.stringify(result, null, 2) + '\n');
+ if (browser) await browser.close();
+ await server.close();
+ }
+})().catch((error) => {
+ process.stderr.write(error.stack + '\n');
+ process.exitCode = 1;
+});
diff --git a/frontend-modern/browser-tests/guest-discovery-identity.html b/frontend-modern/browser-tests/guest-discovery-identity.html
new file mode 100644
index 0000000000..b5312a56ff
--- /dev/null
+++ b/frontend-modern/browser-tests/guest-discovery-identity.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Guest discovery identity fixture</title>
+ </head>
+ <body>
+ <div id="root"></div>
+ <script type="module" src="/browser-tests/guest-discovery-identity.tsx"></script>
+ </body>
+</html>
diff --git a/frontend-modern/browser-tests/guest-discovery-identity.tsx b/frontend-modern/browser-tests/guest-discovery-identity.tsx
new file mode 100644
index 0000000000..cf53d7e5e2
--- /dev/null
+++ b/frontend-modern/browser-tests/guest-discovery-identity.tsx
@@ -0,0 +1,76 @@
+// Production drawer, clients and CSS; synthetic targets and local HTTP only.
+import { createSignal, Show } from 'solid-js';
+import { render } from 'solid-js/web';
+import { Router, Route } from '@solidjs/router';
+import { GuestDrawer } from '../src/components/Workloads/GuestDrawer';
+import { DarkModeContext } from '../src/contexts/appRuntime';
+import { syncAIRuntimeSettings } from '../src/stores/aiRuntimeState';
+import type { WorkloadGuest } from '../src/types/workloads';
+import '../src/index.css';
+
+syncAIRuntimeSettings({ discovery_enabled: true });
+const makeGuest = (agentId: string, id = 'fixture-pve1-100'): WorkloadGuest =>
+ ({
+ id,
+ vmid: 100,
+ name: `Guest on ${agentId}`,
+ node: 'pve1',
+ instance: id === 'fixture-pve1-100' ? 'fixture' : 'fixture2',
+ status: 'running',
+ type: 'qemu',
+ cpu: 0.1,
+ cpus: 2,
+ memory: { total: 1024 ** 3, used: 256 * 1024 ** 2, usage: 25 },
+ disk: { total: 10 * 1024 ** 3, used: 2 * 1024 ** 3, usage: 20 },
+ networkIn: 0,
+ networkOut: 0,
+ diskRead: 0,
+ diskWrite: 0,
+ uptime: 600,
+ template: false,
+ lastBackup: 0,
+ tags: [],
+ lock: '',
+ lastSeen: '2026-10-04T06:00:00Z',
+ discoveryTarget: { resourceType: 'vm', agentId, resourceId: '100' },
+ }) as WorkloadGuest;
+
+function Fixture() {
+ const [guest, setGuest] = createSignal(makeGuest('agent-a'));
+ const [mounted, setMounted] = createSignal(true);
+ (window as any).__guestIdentity = {
+ update: (agentId: string, id?: string) => setGuest(makeGuest(agentId, id)),
+ ticks: (count: number) => {
+ for (let tick = 0; tick < count; tick++) {
+ setGuest({ ...guest(), name: `Updated guest ${tick}`, cpu: tick / 1000 });
+ }
+ },
+ mount: (value: boolean) => setMounted(value),
+ };
+ return (
+ <main class="mx-auto max-w-4xl p-3 bg-surface text-base-content">
+ <Show when={mounted()}>
+ <GuestDrawer
+ guest={guest()}
+ onClose={() => setMounted(false)}
+ customUrl="https://operator.example.test/"
+ />
+ </Show>
+ </main>
+ );
+}
+
+const dark = new URLSearchParams(location.search).has('dark');
+document.documentElement.classList.toggle('dark', dark);
+render(
+ () => (
+ <DarkModeContext.Provider
+ value={{ darkMode: () => dark, toggleDarkMode: () => {}, setDarkMode: () => {} }}
+ >
+ <Router>
+ <Route path="*" component={Fixture} />
+ </Router>
+ </DarkModeContext.Provider>
+ ),
+ document.getElementById('root')!,
+);
diff --git a/frontend-modern/browser-verification/0cee529c74521c8f.json b/frontend-modern/browser-verification/0cee529c74521c8f.json
new file mode 100644
index 0000000000..ec2534e6a8
--- /dev/null
+++ b/frontend-modern/browser-verification/0cee529c74521c8f.json
@@ -0,0 +1,43 @@
+{
+ "version": 1,
+ "base_sha": "903dc08d23d4278103950e0df6ed5f7b8fb97760",
+ "verified_at": "2026-10-04T06:41:09.676Z",
+ "result": "passed",
+ "changed_paths": [
+ "frontend-modern/src/api/discovery.ts",
+ "frontend-modern/src/components/Workloads/GuestDrawer.tsx",
+ "frontend-modern/src/components/Workloads/useGuestDrawerState.ts"
+ ],
+ "content_sha256": {
+ "frontend-modern/src/components/Workloads/GuestDrawer.tsx": "6c8776232e1cf6e82311c978848ca0c935e653f6a504c49c0ecb0b551a1bdc90",
+ "frontend-modern/src/components/Workloads/useGuestDrawerState.ts": "6366d199a56adfb826b9102fc47ae4143bdd32ceaabdbdc206c68376ee42a109",
+ "frontend-modern/src/api/discovery.ts": "0d06629b71afd213599b9548b85c37b351ddafb1902f60d51b20f2e15d5b47e3"
+ },
+ "routes": [
+ "/browser-tests/guest-discovery-identity.html",
+ "/browser-tests/guest-discovery-identity.html?dark=1"
+ ],
+ "viewports": [
+ {
+ "width": 1365,
+ "height": 900
+ },
+ {
+ "width": 390,
+ "height": 844
+ }
+ ],
+ "states": [
+ "Production GuestDrawer, DiscoveryTab, Manage URL field and History with real clients/CSS; desktop Chromium and dark touch WebKit, Playwright 1.56.1 matches integration lock. Eight final screenshots inspected.",
+ "100 same-target metric/name snapshot changes preserve existing query reuse (zero extra reads; parent also passes). Changed targets withdraw predecessor service/URL, retain independent operator URL and ignore old-target lookup/scan completions.",
+ "Final HTTP403 withdraws cached suggestions; retry remains empty until active-target success. Same-target HTTP503 retains only its own qualified evidence; successful HTTP404 clears it. API source tests separately cover HTTP401 and every agent-list/detail read path.",
+ "A new canonical guest disposes tabs/range/disclosures; same-ID updates retain selected History range. No current values become stored History points.",
+ "This is synthetic source/render proof, not a native agent command, QGA/thaw, workload liveness, appliance identity, fleet CPU relief, installed recovery, physical phone, source publication or release acceptance."
+ ],
+ "interactions": [
+ "Real mouse/touch tab activation, keyboard-focused retry and URL href checks; old scan is one explicit local synthetic POST, never repeated or sent to a native target.",
+ "Inspected pending-replacement, late-scan successor, denied retry and transient-retention views on both engines. Safe fixed error text, no page errors/off-origin requests or horizontal main overflow.",
+ "Initial fixture selector failure is retained. Browser then exposed real API status loss; typed final-access propagation corrects it without generic parser relaxation. Canonical identity fixture correction is retained separately.",
+ "The initial unnecessary memo rewrite failed TypeScript and was removed. This fresh browser pass binds the final original memo semantics plus the identity/access repair; no polling or fleet CPU improvement is claimed."
+ ]
+}
diff --git a/frontend-modern/src/api/__tests__/discovery.test.ts b/frontend-modern/src/api/__tests__/discovery.test.ts
index 16655d78b4..2b619cb152 100644
--- a/frontend-modern/src/api/__tests__/discovery.test.ts
+++ b/frontend-modern/src/api/__tests__/discovery.test.ts
@@ -21,6 +21,57 @@ describe('discovery api', () => {
apiFetchMock.mockReset();
});
+ describe('retained discovery access status', () => {
+ it.each([401, 403])(
+ 'preserves final HTTP %s without reading or exposing the denied body',
+ async (status) => {
+ const response = new Response('private response body', { status });
+ const read = vi.spyOn(response, 'text');
+ apiFetchMock.mockResolvedValueOnce(response);
+ await expect(getDiscovery('vm', 'host-1', '100')).rejects.toMatchObject({
+ status,
+ message: 'Discovery details unavailable.',
+ });
+ expect(read).not.toHaveBeenCalled();
+ },
+ );
+
+ it.each([401, 403])('preserves HTTP %s from the agent collection', async (status) => {
+ apiFetchMock.mockResolvedValueOnce(new Response('private response body', { status }));
+ await expect(getDiscovery('agent', 'host-1', 'host-1')).rejects.toMatchObject({
+ status,
+ message: 'Discovery details unavailable.',
+ });
+ expect(apiFetchMock).toHaveBeenCalledTimes(1);
+ });
+
+ it.each([401, 403])('preserves HTTP %s from resolved agent details', async (status) => {
+ apiFetchMock.mockResolvedValueOnce(
+ new Response(
+ JSON.stringify({
+ discoveries: [{ resource_type: 'agent', resource_id: 'host-1', agent_id: 'host-1' }],
+ }),
+ { status: 200 },
+ ),
+ );
+ apiFetchMock.mockResolvedValueOnce(new Response('private response body', { status }));
+ await expect(getDiscovery('agent', 'host-1', 'host-1')).rejects.toMatchObject({
+ status,
+ message: 'Discovery details unavailable.',
+ });
+ expect(apiFetchMock).toHaveBeenCalledTimes(2);
+ });
+
+ it('does not classify body claims in a transient failure as final access status', async () => {
+ apiFetchMock.mockResolvedValueOnce(
+ new Response('HTTP 403 claimed in a gateway error', { status: 503 }),
+ );
+ const error = await getDiscovery('vm', 'host-1', '100').catch((error: unknown) => error);
+ expect(error).toBeInstanceOf(Error);
+ expect(error).not.toHaveProperty('status');
+ });
+ });
+
it('records a proposal disposition against the exact evidence fingerprint', async () => {
apiFetchMock.mockResolvedValueOnce(
new Response(
diff --git a/frontend-modern/src/api/discovery.ts b/frontend-modern/src/api/discovery.ts
index b137513c9a..6ba9d2d08e 100644
--- a/frontend-modern/src/api/discovery.ts
+++ b/frontend-modern/src/api/discovery.ts
@@ -48,6 +48,15 @@ const buildAgentDiscoveryCollectionPath = (agentId: string): string =>
const buildAgentDiscoveryDetailPath = (agentId: string, resourceId: string): string =>
`${buildAgentDiscoveryCollectionPath(agentId)}/${encodeURIComponent(resourceId)}`;
+// Discovery reads feed retained drawer evidence. Only a final access status
+// may revoke it; do not discard that status in the generic body parser or
+// expose a denied response's body as the reason shown to the user.
+function assertDiscoveryReadAccess(response: Response): void {
+ if (response.status === 401 || response.status === 403) {
+ throw Object.assign(new Error('Discovery details unavailable.'), { status: response.status });
+ }
+}
+
/**
* List all discoveries
*/
@@ -98,6 +107,7 @@ export async function getDiscovery(
// Agent discovery is frequently absent before first scan. Resolve via list endpoint
// first to avoid noisy 404s for expected "not discovered yet" states.
const agentListResponse = await apiFetch(buildAgentDiscoveryCollectionPath(targetId));
+ assertDiscoveryReadAccess(agentListResponse);
const agentList = await parseRequiredAPIResponse<DiscoveryListResponse>(
agentListResponse,
'Failed to list agent discoveries',
@@ -128,6 +138,7 @@ export async function getDiscovery(
const response = await apiFetch(
buildAgentDiscoveryDetailPath(resolvedAgentId, resolvedAgentDiscovery.resource_id),
);
+ assertDiscoveryReadAccess(response);
return parseRequiredAPIResponseOrNull(
response,
404,
@@ -137,6 +148,7 @@ export async function getDiscovery(
}
const response = await apiFetch(buildTypedDiscoveryPath(resourceType, targetId, resourceId));
+ assertDiscoveryReadAccess(response);
return parseRequiredAPIResponseOrNull(
response,
404,
diff --git a/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx b/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx
index a357439143..b54ded0491 100644
--- a/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx
+++ b/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx
@@ -190,7 +190,7 @@ beforeEach(() => {
resetAIRuntimeState();
syncAIRuntimeSettings({ discovery_enabled: true } as Parameters<typeof syncAIRuntimeSettings>[0]);
resetCreateNonSuspendingQueryCacheForTest();
- discoveryApiMocks.getDiscovery.mockResolvedValue(null);
+ discoveryApiMocks.getDiscovery.mockReset().mockResolvedValue(null);
chartsApiMocks.getMetricsHistory.mockResolvedValue({
resourceType: 'vm',
resourceId: 'inst1:node1:100',
@@ -483,6 +483,188 @@ describe('GuestDrawer', () => {
expect(screen.getByTestId('url-suggested-reason')).toHaveTextContent('Detected 3000/tcp');
});
+ describe('discovery identity ownership', () => {
+ const service = (name: string) =>
+ ({
+ id: `vm:node1:${name}`,
+ resource_type: 'vm',
+ resource_id: '100',
+ target_id: 'node1',
+ service_name: name,
+ service_type: 'dashboard',
+ confidence: 0.95,
+ suggested_url: `http://${name}.example.test`,
+ ports: [],
+ facts: [],
+ }) as unknown as import('@/types/discovery').ResourceDiscovery;
+
+ it('reuses the lookup and mounted panel across 100 same-target snapshots', async () => {
+ discoveryApiMocks.getDiscovery.mockResolvedValueOnce(service('original'));
+ const [guest, setGuest] = createSignal(makeGuestWithDiscoveryTarget());
+ render(() => <GuestDrawer guest={guest()} onClose={vi.fn()} />);
+ await waitFor(() =>
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent('original'),
+ );
+ const panel = screen.getByTestId('discovery-tab');
+ for (let tick = 0; tick < 100; tick++)
+ setGuest({ ...guest(), name: `renamed-${tick}`, cpu: tick / 1000 });
+ expect(discoveryApiMocks.getDiscovery).toHaveBeenCalledTimes(1);
+ expect(screen.getByTestId('discovery-tab')).toBe(panel);
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent('original');
+ });
+
+ it('withdraws the prior service and URL while a replacement target loads or fails', async () => {
+ discoveryApiMocks.getDiscovery.mockResolvedValueOnce(service('original'));
+ const [guest, setGuest] = createSignal(makeGuestWithDiscoveryTarget());
+ render(() => <GuestDrawer guest={guest()} onClose={vi.fn()} />);
+ await waitFor(() =>
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent('original'),
+ );
+ const originalPanel = screen.getByTestId('discovery-tab');
+ let rejectRead!: (error: Error) => void;
+ discoveryApiMocks.getDiscovery.mockImplementationOnce(
+ () =>
+ new Promise((_resolve, reject) => {
+ rejectRead = reject;
+ }),
+ );
+ setGuest({
+ ...guest(),
+ discoveryTarget: { resourceType: 'vm', agentId: 'replacement-agent', resourceId: '100' },
+ });
+ await waitFor(() => expect(discoveryApiMocks.getDiscovery).toHaveBeenCalledTimes(2));
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent(/^$/);
+ expect(screen.queryByText('original')).toBeNull();
+ expect(screen.getByTestId('discovery-tab')).not.toBe(originalPanel);
+ rejectRead(new Error('temporary outage'));
+ await waitFor(() =>
+ expect(screen.getByText(/Service details could not be loaded/)).toBeInTheDocument(),
+ );
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent(/^$/);
+ });
+
+ it('ignores a late lookup from the old target and restores only the active target', async () => {
+ let finishOld!: (value: import('@/types/discovery').ResourceDiscovery) => void;
+ discoveryApiMocks.getDiscovery.mockImplementationOnce(
+ () =>
+ new Promise((resolve) => {
+ finishOld = resolve;
+ }),
+ );
+ const [guest, setGuest] = createSignal(makeGuestWithDiscoveryTarget());
+ render(() => <GuestDrawer guest={guest()} onClose={vi.fn()} />);
+ discoveryApiMocks.getDiscovery.mockResolvedValueOnce(service('replacement'));
+ setGuest({
+ ...guest(),
+ discoveryTarget: { resourceType: 'vm', agentId: 'replacement-agent', resourceId: '100' },
+ });
+ await waitFor(() =>
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent('replacement'),
+ );
+ finishOld(service('original'));
+ await Promise.resolve();
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent('replacement');
+ expect(screen.queryByText('original')).toBeNull();
+ });
+
+ it.each([401, 403])(
+ 'withdraws a denied service on HTTP %s and does not resurrect it during retry or remount',
+ async (status) => {
+ discoveryApiMocks.getDiscovery.mockRejectedValueOnce(
+ Object.assign(new Error('do not display raw response'), { status }),
+ );
+ const guest = makeGuestWithDiscoveryTarget();
+ const view = render(() => <GuestDrawer guest={guest} onClose={vi.fn()} />);
+ await waitFor(() =>
+ expect(
+ screen.getByRole('button', { name: 'Retry service details' }),
+ ).toBeInTheDocument(),
+ );
+ discoveryApiMocks.getDiscovery.mockResolvedValueOnce(service('original'));
+ fireEvent.click(screen.getByRole('button', { name: 'Retry service details' }));
+ await waitFor(() =>
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent('original'),
+ );
+ // A remount uses this target's cached result, then observes a final denial.
+ view.unmount();
+ discoveryApiMocks.getDiscovery.mockRejectedValueOnce(
+ Object.assign(new Error('do not display raw response'), { status }),
+ );
+ const denied = render(() => <GuestDrawer guest={guest} onClose={vi.fn()} />);
+ await waitFor(() =>
+ expect(
+ screen.getByRole('button', { name: 'Retry service details' }),
+ ).toBeInTheDocument(),
+ );
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent(/^$/);
+ expect(screen.queryByText(/do not display raw response/)).toBeNull();
+ denied.unmount();
+ let finish!: (value: import('@/types/discovery').ResourceDiscovery) => void;
+ discoveryApiMocks.getDiscovery.mockImplementationOnce(
+ () =>
+ new Promise((resolve) => {
+ finish = resolve;
+ }),
+ );
+ render(() => <GuestDrawer guest={guest} onClose={vi.fn()} />);
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent(/^$/);
+ finish(service('recovered'));
+ await waitFor(() =>
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent('recovered'),
+ );
+ },
+ );
+
+ it('labels same-target transient retention and permits a fresh retry without raw error text', async () => {
+ discoveryApiMocks.getDiscovery.mockResolvedValueOnce(service('original'));
+ const guest = makeGuestWithDiscoveryTarget();
+ const view = render(() => <GuestDrawer guest={guest} onClose={vi.fn()} />);
+ await waitFor(() =>
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent('original'),
+ );
+ view.unmount();
+ discoveryApiMocks.getDiscovery.mockRejectedValueOnce(new Error('private diagnostic'));
+ render(() => <GuestDrawer guest={guest} onClose={vi.fn()} />);
+ await waitFor(() =>
+ expect(screen.getByText(/Showing previously loaded service details/)).toBeInTheDocument(),
+ );
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent('original');
+ expect(screen.queryByText(/private diagnostic/)).toBeNull();
+ discoveryApiMocks.getDiscovery.mockResolvedValueOnce(service('recovered'));
+ fireEvent.click(screen.getByRole('button', { name: 'Retry service details' }));
+ await waitFor(() =>
+ expect(screen.getByTestId('url-suggested')).toHaveTextContent('recovered'),
+ );
+ expect(screen.queryByText(/Showing previously loaded/)).toBeNull();
+ });
+
+ it('resets tabs, range and disclosures only when canonical guest identity changes', async () => {
+ const [guest, setGuest] = createSignal(makeGuestWithDiscoveryTarget());
+ render(() => <GuestDrawer guest={guest()} onClose={vi.fn()} />);
+ fireEvent.click(screen.getByRole('tab', { name: 'History' }));
+ const range = screen.getByLabelText('History range');
+ fireEvent.change(range, { target: { value: '7d' } });
+ setGuest({ ...guest(), name: 'renamed', cpu: 0.5 });
+ expect(screen.getByRole('tab', { name: 'History' })).toHaveAttribute(
+ 'aria-selected',
+ 'true',
+ );
+ expect(screen.getByLabelText('History range')).toBe(range);
+ expect(range).toHaveValue('7d');
+ setGuest(
+ makeGuestWithDiscoveryTarget({ id: 'inst1-node1-200', vmid: 200, name: 'new-guest' }),
+ );
+ expect(screen.getByRole('tab', { name: 'Overview' })).toHaveAttribute(
+ 'aria-selected',
+ 'true',
+ );
+ const details = screen.getByTestId('guest-technical-details');
+ expect(details).not.toHaveAttribute('open');
+ fireEvent.click(screen.getByRole('tab', { name: 'History' }));
+ expect(screen.getByLabelText('History range')).toHaveValue('24h');
+ });
+ });
+
it('hides the Identified Service card when the discovery record is null or empty', async () => {
discoveryApiMocks.getDiscovery.mockResolvedValueOnce(null);
render(() => <GuestDrawer guest={makeGuestWithDiscoveryTarget()} onClose={vi.fn()} />);
diff --git a/frontend-modern/src/components/Workloads/GuestDrawer.tsx b/frontend-modern/src/components/Workloads/GuestDrawer.tsx
index 1439f7a212..9a6165a1ca 100644
--- a/frontend-modern/src/components/Workloads/GuestDrawer.tsx
+++ b/frontend-modern/src/components/Workloads/GuestDrawer.tsx
@@ -11,12 +11,14 @@ import {
getGuestDrawerDeferredMetrics,
type GuestDrawerProps,
} from './guestDrawerModel';
+import { getCanonicalWorkloadId } from '@/utils/workloads';
+import { InlineNotice } from '@/components/shared/InlineNotice';
import { useGuestDrawerState } from './useGuestDrawerState';
import { GuestDrawerHistory, GuestDrawerHistoryRangeSelect } from './GuestDrawerHistory';
import { GuestDrawerOverview } from './GuestDrawerOverview';
import { GuestDrawerManage } from './GuestDrawerManage';
-export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
+const GuestDrawerContent: Component<GuestDrawerProps> = (props) => {
const {
activeTab,
agentHeading,
@@ -25,6 +27,10 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
backupPresentation,
discoveryAgentId,
discoveryIdentifiedSummary,
+ discoveryPanelKey,
+ discoveryReadError,
+ discoveryReadLoading,
+ retryDiscoveryRead,
discoveryLoadingState,
discoveryReadinessPresentation,
discoveryResourceId,
@@ -80,6 +86,20 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
</div>
)}
</Show>
+ <Show when={discoveryReadError()}>
+ {(message) => (
+ <InlineNotice
+ tone="warning"
+ role="status"
+ actionLabel={
+ discoveryReadLoading() ? 'Retrying service details...' : 'Retry service details'
+ }
+ actionOnClick={retryDiscoveryRead}
+ >
+ {message()}
+ </InlineNotice>
+ )}
+ </Show>
<Subtabs
class="mb-1"
ariaLabel="Guest drawer sections"
@@ -145,23 +165,25 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
{/* Always rendered, hidden via CSS. Wrapped in a local Suspense
so DiscoveryTab's createResource loading state doesn't bubble
up to the app-level Suspense and replace the entire page. */}
- {hasDiscoverySupport() && (
- <div
- class={activeTab() === 'discovery' ? '' : 'hidden'}
- style={{ 'overflow-anchor': 'none' }}
- >
- <Suspense fallback={<DiscoveryLoadingFallback text={discoveryLoadingState.text} />}>
- <DiscoveryTab
- resourceType={discoveryResourceType()!}
- agentId={discoveryAgentId()}
- resourceId={discoveryResourceId()}
- hostname={props.guest.name}
- canonicalResourceId={props.guest.id}
- showManualRunAction
- />
- </Suspense>
- </div>
- )}
+ <Show when={discoveryPanelKey()} keyed>
+ {(_targetKey) => (
+ <div
+ class={activeTab() === 'discovery' ? '' : 'hidden'}
+ style={{ 'overflow-anchor': 'none' }}
+ >
+ <Suspense fallback={<DiscoveryLoadingFallback text={discoveryLoadingState.text} />}>
+ <DiscoveryTab
+ resourceType={discoveryResourceType()!}
+ agentId={discoveryAgentId()}
+ resourceId={discoveryResourceId()}
+ hostname={props.guest.name}
+ canonicalResourceId={props.guest.id}
+ showManualRunAction
+ />
+ </Suspense>
+ </div>
+ )}
+ </Show>
<div class={activeTab() === 'manage' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
<Show when={activeTab() === 'manage'}>
@@ -179,3 +201,11 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
</section>
);
};
+
+// A new canonical guest must not inherit another guest's tabs, editable forms
+// or outstanding requests. Ordinary same-ID snapshots remain reactive/mounted.
+export const GuestDrawer: Component<GuestDrawerProps> = (props) => (
+ <Show when={getCanonicalWorkloadId(props.guest)} keyed>
+ {(_guestId) => <GuestDrawerContent {...props} />}
+ </Show>
+);
diff --git a/frontend-modern/src/components/Workloads/useGuestDrawerState.ts b/frontend-modern/src/components/Workloads/useGuestDrawerState.ts
index 969062cca9..ef40729969 100644
--- a/frontend-modern/src/components/Workloads/useGuestDrawerState.ts
+++ b/frontend-modern/src/components/Workloads/useGuestDrawerState.ts
@@ -1,6 +1,7 @@
import { createEffect, createMemo, createSignal } from 'solid-js';
import { getDiscovery } from '@/api/discovery';
+import { getAPIReadAccessErrorMessage } from '@/utils/apiAccessError';
import type { HistoryTimeRange } from '@/api/charts';
import { createNonSuspendingQuery } from '@/hooks/createNonSuspendingQuery';
import { useDiscoveryFeatureAvailability } from '@/components/Discovery/useDiscoveryFeatureAvailability';
@@ -138,18 +139,32 @@ export function useGuestDrawerState(props: GuestDrawerProps) {
>({
source: discoverySourceKey,
initialValue: null,
- cacheKey: (key) => `guest-drawer-discovery:${key.type}:${key.agent}:${key.resource}`,
- fetcher: async (key) => {
- try {
- return await getDiscovery(key.type, key.agent, key.resource);
- } catch {
- return null;
- }
- },
+ cacheKey: (key) =>
+ `guest-drawer-discovery:${JSON.stringify([guestId(), key.type, key.agent, key.resource])}`,
+ // Retained evidence belongs to this exact target, never its replacement.
+ // Let the query distinguish HTTP access denial from a transient failure;
+ // null is reserved for a successful read with no saved discovery.
+ retainPreviousValueOnSourceChange: false,
+ fetcher: (key) => getDiscovery(key.type, key.agent, key.resource),
});
const discoveryIdentifiedSummary = createMemo(() =>
hasDiscoverySupport() ? getDiscoveryIdentifiedSummary(discoveryRecord.value()) : null,
);
+ const discoveryPanelKey = createMemo(() => {
+ const key = discoverySourceKey();
+ return key ? JSON.stringify([key.type, key.agent, key.resource]) : null;
+ });
+ const discoveryReadError = createMemo(() => {
+ if (!hasDiscoverySupport() || !discoveryRecord.error()) return null;
+ const accessError = getAPIReadAccessErrorMessage(discoveryRecord.error());
+ if (accessError) return `Service details unavailable. ${accessError}`;
+ return discoveryIdentifiedSummary()
+ ? 'Service details could not be refreshed. Showing previously loaded service details.'
+ : 'Service details could not be loaded.';
+ });
+ const retryDiscoveryRead = () => {
+ if (!discoveryRecord.loading()) void discoveryRecord.refetch();
+ };
const discoveryReadinessPresentation = createMemo(() =>
hasDiscoverySupport()
? getDiscoveryReadinessPresentation(props.guest.discoveryReadiness, true)
@@ -177,6 +192,10 @@ export function useGuestDrawerState(props: GuestDrawerProps) {
backupPresentation,
discoveryAgentId,
discoveryIdentifiedSummary,
+ discoveryPanelKey,
+ discoveryReadError,
+ discoveryReadLoading: discoveryRecord.loading,
+ retryDiscoveryRead,
discoveryReadinessPresentation,
discoveryLoadingState: getDiscoveryLoadingState(),
discoveryResourceId,