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.

Checkpoint current workspace progress

rcourtman6e8a7ae5fc09
diff --git a/docs/release-control/v6/internal/status.json b/docs/release-control/v6/internal/status.json
index 1f17c365ad..f7c7e2a2c7 100644
--- a/docs/release-control/v6/internal/status.json
+++ b/docs/release-control/v6/internal/status.json
@@ -2971,16 +2971,16 @@
{
"id": "assistant-backend-handoff-policy-boundary-tests",
"run": [
- "go",
- "test",
- "./internal/ai",
- "./internal/ai/chat",
- "./internal/api",
- "-run",
- "TestBuildPatrolRunAssistantHandoffUsesBackendSafeRunContext|TestFSM|TestService_ExecuteStream_InteractiveChatLetsModelChooseTools|TestHandleChat_|TestContract_AIHandler",
- "-count=1"
- ]
- },
+ "go",
+ "test",
+ "./internal/ai",
+ "./internal/ai/chat",
+ "./internal/api",
+ "-run",
+ "TestBuildPatrolRunAssistantHandoffUsesBackendSafeRunContext|TestFSM|TestService_ExecuteStream_InteractiveChatLetsModelChooseTools|TestHandleChat_|TestContract_AIHandler",
+ "-count=1"
+ ]
+ },
{
"id": "assistant-chat-model-owned-routing-tests",
"run": [
@@ -6446,7 +6446,21 @@
],
"coverage_gaps": [],
"candidate_lanes": [],
- "work_claims": [],
+ "work_claims": [
+ {
+ "id": "codex-lane-l6",
+ "agent_id": "codex",
+ "summary": "Fix workload discovery settings persistence and per-guest manual discovery control",
+ "target_id": "v6-product-lane-expansion",
+ "claimed_at": "2026-05-15T21:36:03Z",
+ "heartbeat_at": "2026-05-15T21:36:03Z",
+ "expires_at": "2026-05-15T23:36:03Z",
+ "work_item": {
+ "kind": "lane",
+ "id": "L6"
+ }
+ }
+ ],
"open_decisions": [],
"source_of_truth_file": "docs/release-control/v6/internal/SOURCE_OF_TRUTH.md",
"resolved_decisions": [
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index fe57c91ae0..1fc1ed8228 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -154,7 +154,7 @@ runtime cost control, and shared AI transport surfaces.
divergence must be sourced from canonical `ReadState.DockerHosts()` views,
with model-shaped data limited to the watcher adapter input rather than
direct `StateSnapshot.DockerHosts` reads in the Patrol run loop.
-4. Keep discovery scheduling authoritative through `internal/config/ai.go`: `discovery_enabled` and `discovery_interval_hours` must govern both lightweight infrastructure discovery and deep service-discovery background loops
+4. Keep discovery scheduling authoritative through `internal/config/ai.go`: `discovery_enabled` and `discovery_interval_hours` must govern both lightweight infrastructure discovery and deep service-discovery background loops. `internal/api/ai_handlers.go` must preserve an explicitly supplied `discovery_interval_hours: 0` as the manual-only setting and may only apply the 24-hour default when discovery is enabled without an explicit interval payload.
5. Preserve auditability for outbound model-bound context exports and keep the export record aligned with the prompt boundary that actually reaches the provider
External provider-bound unified-resource context must enforce the same
data-handling policy the export audit records: `local-only` resources are
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 57ca46a835..6c1400984a 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -1362,6 +1362,12 @@ the canonical monitored-system blocked payload.
backend contract must keep provider test routes bound to the selected
provider's configured model instead of whichever other provider currently
owns the default `model` field.
+ Discovery scheduling is part of that same AI settings payload contract:
+ settings saves from `frontend-modern/src/components/Settings/useAISettingsState.ts`
+ must send `discovery_enabled` and `discovery_interval_hours` together as
+ explicit form truth, and the backend must persist a provided
+ `discovery_interval_hours: 0` as manual-only rather than replacing it with
+ the automatic-scan default.
25. Keep shared AI runtime reads centralized on that same governed contract:
`frontend-modern/src/stores/aiRuntimeState.ts` is the canonical frontend
read owner for `/api/settings/ai` and `/api/ai/models`. AI-owned consumers
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 9c83733959..8dfcb4a9b4 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -885,7 +885,11 @@ AI runtime.
Runtime controls inside `frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx`
must likewise describe discovery as workload discovery that supplies
concrete service context to Pulse Assistant and Patrol, not as a generic
- AI context feature. Assistant-only controls inside the shared shell, such
+ AI context feature. `frontend-modern/src/components/Settings/useAISettingsState.ts`
+ must save workload discovery enablement and interval as one explicit
+ settings pair so selecting "Every 6 hours" or "Manual only" round-trips
+ through `/api/settings/ai` without depending on stale read-side diffing.
+ Assistant-only controls inside the shared shell, such
as execution permissions and session maintenance, must stay explicitly
labeled as Pulse Assistant controls, while Patrol schedule and autonomy
continue to live on Patrol-owned surfaces rather than drifting back into
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 7f56341e57..ddea801c64 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -960,7 +960,10 @@ app-container routing and Docker-only actions. `frontend-modern/src/hooks/useWor
canonical app-container navigation path while keeping Docker runtime action
identifiers explicit. Discovery affordances on the Workloads drawer must follow
the canonical `discoveryTarget` contract, not generic app-container host
-fallbacks. TrueNAS app-containers may reuse runtime metadata such as image and
+fallbacks. Guest-drawer manual discovery run controls must route through the
+shared `DiscoveryTab` manual-run action and the canonical target identifiers
+instead of adding Workloads-local discovery trigger state. TrueNAS
+app-containers may reuse runtime metadata such as image and
runtime strings, but they must not inherit Docker-only update affordances or
agent-only Discovery tabs on the Workloads row path unless the unified
resource contract explicitly supplies discovery ownership.
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index fc8071297e..04d90a6155 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -310,7 +310,7 @@ AI-only summary payloads, or page-local heuristics.
the actual protection boundary behind a broader count phrase.
6. Add canonical governed name-resolution or policy-aware resource lookup behavior through `internal/unifiedresources/resolve.go` and `internal/unifiedresources/resolve_context.go`
7. Add or change resource drawer timeline/facet/action-history presentation through `frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx`, `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx`, `frontend-modern/src/components/Infrastructure/ResourceDetailDrawerDebugTab.tsx`, `frontend-modern/src/components/Docker/SwarmServicesDrawer.tsx`, `frontend-modern/src/components/Kubernetes/K8sDeploymentsDrawer.tsx`, `frontend-modern/src/components/Kubernetes/K8sNamespacesDrawer.tsx`, `frontend-modern/src/components/PMG/PMGInstanceDrawer.tsx`, `frontend-modern/src/components/PMG/MailGateway.tsx`, `frontend-modern/src/components/PMG/PMGInstancePanel.tsx`, `frontend-modern/src/components/Infrastructure/ResourceActionHistory.tsx`, `frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts`, `frontend-modern/src/components/Infrastructure/ResourceFacetSummary.tsx`, `frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts`, and the governed `internal/api/resources.go` facet/timeline plus `internal/api/activity_audit_handlers.go` action-audit contracts together
-8. Add or change discovery-support runtime under the resource drawer through `frontend-modern/src/components/Discovery/DiscoveryTab.tsx` for shell/presentation ownership and `frontend-modern/src/components/Discovery/useDiscoveryTabState.ts` for fetch, websocket-progress, and notes-mutation ownership
+8. Add or change discovery-support runtime under the resource drawer through `frontend-modern/src/components/Discovery/DiscoveryTab.tsx` for shell/presentation ownership and `frontend-modern/src/components/Discovery/useDiscoveryTabState.ts` for fetch, websocket-progress, manual-run triggering, and notes-mutation ownership. Embedded drawers may expose the top-level run action through this shared Discovery tab, but they must still call the canonical discovery trigger state path instead of introducing drawer-local API mutations.
9. Keep dashboard and infrastructure freshness on the canonical unified-resource
ownership path. `frontend-modern/src/stores/websocket.ts`,
`frontend-modern/src/utils/resourceStateAdapters.ts`, and
diff --git a/frontend-modern/src/components/Discovery/DiscoveryTab.tsx b/frontend-modern/src/components/Discovery/DiscoveryTab.tsx
index ade1bf9749..9efaae90bf 100644
--- a/frontend-modern/src/components/Discovery/DiscoveryTab.tsx
+++ b/frontend-modern/src/components/Discovery/DiscoveryTab.tsx
@@ -29,6 +29,8 @@ interface DiscoveryTabProps {
hostname: string;
/** Whether commands are enabled for this agent (from agent config) */
commandsEnabled?: boolean;
+ /** Show the primary run action at the top of embedded drawer contexts. */
+ showManualRunAction?: boolean;
}
const toSentence = (text?: string): string => {
@@ -40,6 +42,7 @@ const toSentence = (text?: string): string => {
export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
const {
+ canTriggerDiscovery,
connectedAgents,
discovery,
discoveryInfo,
@@ -90,13 +93,25 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
const confidenceInfo = createMemo(() => {
const current = discovery();
- if (discovery.loading || !current || current.confidence === undefined || current.confidence === null) {
+ if (
+ discovery.loading ||
+ !current ||
+ current.confidence === undefined ||
+ current.confidence === null
+ ) {
return null;
}
return getConfidenceLevel(current.confidence);
});
const commandSettingsTarget = getDiscoveryCommandSettingsTarget();
const apiAccessSettingsTarget = getDiscoveryApiAccessSettingsTarget();
+ const showManualRunAction = () => props.showManualRunAction === true;
+ const manualRunSummary = createMemo(() => {
+ if (discovery.loading) return 'Checking saved discovery state';
+ const updatedAt = discovery()?.updated_at;
+ if (updatedAt) return `Last run: ${formatDiscoveryAge(updatedAt)}`;
+ return 'No saved discovery run for this resource';
+ });
// `whitespace-normal` on the wrapper neutralises the `.table-fixed td/th`
// global rule (white-space: nowrap) that bleeds into expanded-row content
@@ -139,6 +154,43 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
</div>
</Show>
+ <Show when={showManualRunAction()}>
+ <div class="rounded border border-border bg-surface p-3 shadow-sm">
+ <div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
+ <div>
+ <div class="text-xs font-medium text-base-content">Discovery run</div>
+ <p class="mt-0.5 text-xs text-muted">{manualRunSummary()}</p>
+ </div>
+ <button
+ type="button"
+ onClick={() => handleTriggerDiscovery(true)}
+ disabled={isScanning() || !canTriggerDiscovery()}
+ class="inline-flex min-h-9 items-center justify-center gap-1.5 rounded border border-border bg-surface px-3 py-1.5 text-xs font-medium text-base-content transition-colors hover:bg-surface-hover disabled:cursor-not-allowed disabled:opacity-50"
+ >
+ <Show
+ when={isScanning()}
+ fallback={
+ <>
+ <svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
+ />
+ </svg>
+ Run Discovery
+ </>
+ }
+ >
+ <span class="h-3.5 w-3.5 animate-spin rounded-full border-2 border-slate-500 border-t-transparent" />
+ Scanning...
+ </Show>
+ </button>
+ </div>
+ </div>
+ </Show>
+
{/* "What Discovery Does" explanation - shown when no discovery exists yet */}
<Show when={!discovery() && !isScanning() && !showLoadingSpinner() && showExplanation()}>
<div class="rounded border border-amber-200 bg-amber-50 p-3 shadow-sm dark:border-amber-800 dark:bg-amber-900">
@@ -159,9 +211,7 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
</svg>
<div class="text-xs text-amber-800 dark:text-amber-200">
<p class="font-medium mb-1">What Discovery Does</p>
- <p class="text-amber-700 dark:text-amber-300">
- {DISCOVERY_ANALYSIS_EXPLANATION}
- </p>
+ <p class="text-amber-700 dark:text-amber-300">{DISCOVERY_ANALYSIS_EXPLANATION}</p>
</div>
</div>
<button
@@ -493,22 +543,24 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
</Show>
</Show>
- <button
- onClick={() => handleTriggerDiscovery(true)}
- disabled={isScanning()}
- class="px-4 py-2 bg-blue-600 text-white text-sm rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
- >
- {isScanning() ? (
- <span class="flex items-center">
- <span class="animate-spin h-4 w-4 border-2 border-white border-t-transparent rounded-full mr-2"></span>
- Scanning...
- </span>
- ) : discovery.loading ? (
- 'Run Discovery Now'
- ) : (
- 'Run Discovery'
- )}
- </button>
+ <Show when={!showManualRunAction()}>
+ <button
+ onClick={() => handleTriggerDiscovery(true)}
+ disabled={isScanning()}
+ class="px-4 py-2 bg-blue-600 text-white text-sm rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
+ >
+ {isScanning() ? (
+ <span class="flex items-center">
+ <span class="animate-spin h-4 w-4 border-2 border-white border-t-transparent rounded-full mr-2"></span>
+ Scanning...
+ </span>
+ ) : discovery.loading ? (
+ 'Run Discovery Now'
+ ) : (
+ 'Run Discovery'
+ )}
+ </button>
+ </Show>
</div>
</Show>
@@ -539,20 +591,22 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
</p>
</Show>
</div>
- <button
- onClick={() => handleTriggerDiscovery(true)}
- disabled={isScanning()}
- class="px-4 py-2 bg-blue-600 text-white text-sm rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
- >
- {isScanning() ? (
- <span class="flex items-center justify-center">
- <span class="animate-spin h-4 w-4 border-2 border-white border-t-transparent rounded-full mr-2"></span>
- Scanning...
- </span>
- ) : (
- 'Re-scan Discovery'
- )}
- </button>
+ <Show when={!showManualRunAction()}>
+ <button
+ onClick={() => handleTriggerDiscovery(true)}
+ disabled={isScanning()}
+ class="px-4 py-2 bg-blue-600 text-white text-sm rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
+ >
+ {isScanning() ? (
+ <span class="flex items-center justify-center">
+ <span class="animate-spin h-4 w-4 border-2 border-white border-t-transparent rounded-full mr-2"></span>
+ Scanning...
+ </span>
+ ) : (
+ 'Re-scan Discovery'
+ )}
+ </button>
+ </Show>
</div>
</Show>
@@ -746,9 +800,7 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
<Show
when={d().user_notes}
fallback={
- <p class="text-xs text-muted italic">
- {getDiscoveryNotesEmptyState().text}
- </p>
+ <p class="text-xs text-muted italic">{getDiscoveryNotesEmptyState().text}</p>
}
>
<p class="text-xs text-muted whitespace-pre-wrap">{d().user_notes}</p>
@@ -836,40 +888,44 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
</Show>
{/* Footer with Update button */}
- <div class="flex items-center justify-between pt-2 border-t border-border">
+ <div
+ class={`flex items-center pt-2 border-t border-border ${showManualRunAction() ? 'justify-start' : 'justify-between'}`}
+ >
<span class="text-xs text-muted">
Last updated: {formatDiscoveryAge(d().updated_at)}
</span>
- <button
- onClick={() => handleTriggerDiscovery(true)}
- disabled={isScanning()}
- class="px-3 py-1.5 bg-surface-hover text-base-content text-xs rounded hover:bg-surface-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-1.5"
- >
- <Show
- when={isScanning()}
- fallback={
- <>
- <svg
- class="w-3.5 h-3.5"
- fill="none"
- viewBox="0 0 24 24"
- stroke="currentColor"
- >
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- stroke-width="2"
- d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
- />
- </svg>
- Update Discovery
- </>
- }
+ <Show when={!showManualRunAction()}>
+ <button
+ onClick={() => handleTriggerDiscovery(true)}
+ disabled={isScanning()}
+ class="px-3 py-1.5 bg-surface-hover text-base-content text-xs rounded hover:bg-surface-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center gap-1.5"
>
- <span class="animate-spin h-3.5 w-3.5 border-2 border-slate-500 border-t-transparent rounded-full"></span>
- Scanning...
- </Show>
- </button>
+ <Show
+ when={isScanning()}
+ fallback={
+ <>
+ <svg
+ class="w-3.5 h-3.5"
+ fill="none"
+ viewBox="0 0 24 24"
+ stroke="currentColor"
+ >
+ <path
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ stroke-width="2"
+ d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
+ />
+ </svg>
+ Update Discovery
+ </>
+ }
+ >
+ <span class="animate-spin h-3.5 w-3.5 border-2 border-slate-500 border-t-transparent rounded-full"></span>
+ Scanning...
+ </Show>
+ </button>
+ </Show>
</div>
</div>
)}
diff --git a/frontend-modern/src/components/Discovery/__tests__/DiscoveryTab.test.tsx b/frontend-modern/src/components/Discovery/__tests__/DiscoveryTab.test.tsx
index fb200d5d2a..84a830dd2a 100644
--- a/frontend-modern/src/components/Discovery/__tests__/DiscoveryTab.test.tsx
+++ b/frontend-modern/src/components/Discovery/__tests__/DiscoveryTab.test.tsx
@@ -1,5 +1,6 @@
-import { cleanup, render, screen } from '@solidjs/testing-library';
+import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
import { afterEach, describe, expect, it, vi } from 'vitest';
+import type { ResourceDiscovery } from '@/types/discovery';
vi.mock('@/api/discovery', () => {
const never = new Promise<null>(() => undefined);
@@ -32,6 +33,55 @@ describe('DiscoveryTab', () => {
expect(await screen.findByRole('button', { name: 'Run Discovery Now' })).toBeInTheDocument();
});
+ it('shows a drawer run action and triggers discovery for the current resource', async () => {
+ const discovered: ResourceDiscovery = {
+ id: 'discovery-1',
+ resource_type: 'agent',
+ resource_id: 'agent-1',
+ target_id: 'agent-1',
+ agent_id: 'agent-1',
+ hostname: 'pve1',
+ service_type: 'database',
+ service_name: 'postgresql',
+ service_version: '16.1',
+ category: 'database',
+ cli_access: 'psql',
+ facts: [],
+ config_paths: [],
+ data_paths: [],
+ log_paths: [],
+ ports: [],
+ user_notes: '',
+ user_secrets: {},
+ confidence: 0.72,
+ ai_reasoning: '',
+ discovered_at: '2026-04-15T00:00:00Z',
+ updated_at: '2026-04-15T00:00:00Z',
+ scan_duration: 12,
+ };
+ vi.mocked(discoveryApi.getDiscovery).mockResolvedValue(discovered);
+ vi.mocked(discoveryApi.triggerDiscovery).mockResolvedValue(discovered);
+
+ render(() => (
+ <DiscoveryTab
+ resourceType="agent"
+ agentId="agent-1"
+ resourceId="agent-1"
+ hostname="pve1"
+ showManualRunAction
+ />
+ ));
+
+ fireEvent.click(await screen.findByRole('button', { name: 'Run Discovery' }));
+
+ await waitFor(() => {
+ expect(discoveryApi.triggerDiscovery).toHaveBeenCalledWith('agent', 'agent-1', 'agent-1', {
+ force: true,
+ hostname: 'pve1',
+ });
+ });
+ });
+
it('uses canonical settings copy for disabled command guidance', async () => {
vi.mocked(discoveryApi.getDiscovery).mockResolvedValue(null);
diff --git a/frontend-modern/src/components/Discovery/useDiscoveryTabState.ts b/frontend-modern/src/components/Discovery/useDiscoveryTabState.ts
index ed306393b1..d21b042337 100644
--- a/frontend-modern/src/components/Discovery/useDiscoveryTabState.ts
+++ b/frontend-modern/src/components/Discovery/useDiscoveryTabState.ts
@@ -77,6 +77,7 @@ export function useDiscoveryTabState(props: DiscoveryTabStateProps) {
return agents.length === 1;
});
+ const canTriggerDiscovery = createMemo(() => Boolean(targetAgentId()));
const [discovery, { refetch, mutate }] = createResource(discoverySourceKey, async () => {
const agentId = targetAgentId();
@@ -247,7 +248,9 @@ export function useDiscoveryTabState(props: DiscoveryTabStateProps) {
(current.log_paths && current.log_paths.length > 0);
const hasCliAccess = Boolean(current.cli_access);
- return Boolean(hasServiceName || hasConfidence || hasPorts || hasFacts || hasPaths || hasCliAccess);
+ return Boolean(
+ hasServiceName || hasConfidence || hasPorts || hasFacts || hasPaths || hasCliAccess,
+ );
});
const validDiscovery = createMemo(() =>
@@ -256,6 +259,7 @@ export function useDiscoveryTabState(props: DiscoveryTabStateProps) {
return {
connectedAgents,
+ canTriggerDiscovery,
discovery,
discoveryInfo,
editingNotes,
diff --git a/frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx b/frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx
index e204eb2663..8bfad5aea5 100644
--- a/frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx
+++ b/frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx
@@ -98,7 +98,7 @@ export const AIRuntimeControlsSection: Component<AIRuntimeControlsSectionProps>
<FormSelect
id="ai-workload-discovery-scan-interval"
label="Scan Interval"
- value={state.form.discoveryIntervalHours}
+ value={String(state.form.discoveryIntervalHours)}
onChange={(e) =>
state.setForm('discoveryIntervalHours', parseInt(e.currentTarget.value, 10))
}
@@ -108,12 +108,12 @@ export const AIRuntimeControlsSection: Component<AIRuntimeControlsSectionProps>
labelClass="text-xs font-medium text-muted w-32 flex-shrink-0"
selectBaseClass="flex-1 px-2 py-1 text-sm border border-border rounded bg-surface"
>
- <option value={0}>Manual only</option>
- <option value={6}>Every 6 hours</option>
- <option value={12}>Every 12 hours</option>
- <option value={24}>Every 24 hours</option>
- <option value={48}>Every 2 days</option>
- <option value={168}>Every 7 days</option>
+ <option value="0">Manual only</option>
+ <option value="6">Every 6 hours</option>
+ <option value="12">Every 12 hours</option>
+ <option value="24">Every 24 hours</option>
+ <option value="48">Every 2 days</option>
+ <option value="168">Every 7 days</option>
</FormSelect>
<p class="text-[10px] text-muted ml-32 pl-3">
{state.form.discoveryIntervalHours === 0
@@ -249,9 +249,7 @@ export const AIRuntimeControlsSection: Component<AIRuntimeControlsSectionProps>
selectBaseClass="flex-1 min-h-10 sm:min-h-9 px-2 py-2 text-sm border border-border rounded bg-surface"
>
<option value="read_only">Read-only - Pulse Assistant can observe only</option>
- <option value="controlled">
- Controlled - Pulse Assistant asks before actions
- </option>
+ <option value="controlled">Controlled - Pulse Assistant asks before actions</option>
<Show when={showAutonomousControlOption()}>
<option value="autonomous">
Autonomous - Pulse Assistant can run eligible actions
diff --git a/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx b/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx
index d7bbf58277..528ea3a48c 100644
--- a/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx
@@ -417,6 +417,55 @@ describe('AISettings load failure error state', () => {
});
});
+describe('AISettings workload discovery persistence', () => {
+ beforeEach(() => {
+ resetAllMocks();
+ setupDefaultMocks();
+ });
+
+ afterEach(() => {
+ cleanup();
+ });
+
+ it('saves workload discovery enablement and scan interval as an explicit pair', async () => {
+ getSettingsMock.mockResolvedValue({
+ ...baseSettings(),
+ discovery_enabled: true,
+ discovery_interval_hours: 24,
+ });
+ updateSettingsMock.mockImplementation(async (payload: Record<string, unknown>) => ({
+ ...baseSettings(),
+ discovery_enabled: payload.discovery_enabled as boolean,
+ discovery_interval_hours: payload.discovery_interval_hours as number,
+ }));
+
+ renderComponent();
+
+ await waitFor(() => {
+ expect(screen.getByRole('button', { name: /Workload Discovery 24h/i })).toBeInTheDocument();
+ });
+ fireEvent.click(screen.getByRole('button', { name: /Workload Discovery 24h/i }));
+ const intervalSelect = screen.getByLabelText('Scan Interval');
+ expect(intervalSelect).toHaveValue('24');
+
+ fireEvent.change(intervalSelect, {
+ target: { value: '6' },
+ });
+ expect(intervalSelect).toHaveValue('6');
+
+ fireEvent.click(screen.getByRole('button', { name: /save changes/i }));
+
+ await waitFor(() => {
+ expect(updateSettingsMock).toHaveBeenCalledWith(
+ expect.objectContaining({
+ discovery_enabled: true,
+ discovery_interval_hours: 6,
+ }),
+ );
+ });
+ });
+});
+
describe('AISettings OpenRouter flow', () => {
beforeEach(() => {
resetAllMocks();
diff --git a/frontend-modern/src/components/Settings/useAISettingsState.ts b/frontend-modern/src/components/Settings/useAISettingsState.ts
index 8fe8d03666..872a9cb659 100644
--- a/frontend-modern/src/components/Settings/useAISettingsState.ts
+++ b/frontend-modern/src/components/Settings/useAISettingsState.ts
@@ -923,12 +923,8 @@ export const useAISettingsState = () => {
payload.protected_guests = newProtected;
}
- if (form.discoveryEnabled !== (settings()?.discovery_enabled ?? false)) {
- payload.discovery_enabled = form.discoveryEnabled;
- }
- if (form.discoveryIntervalHours !== (settings()?.discovery_interval_hours ?? 0)) {
- payload.discovery_interval_hours = form.discoveryIntervalHours;
- }
+ payload.discovery_enabled = form.discoveryEnabled;
+ payload.discovery_interval_hours = form.discoveryIntervalHours;
const updated = await AIAPI.updateSettings(payload);
setSettings(updated);
diff --git a/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx b/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx
index c5efa9d4b3..b7b10f64a6 100644
--- a/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx
+++ b/frontend-modern/src/components/Workloads/GuestDrawer.test.tsx
@@ -38,11 +38,13 @@ vi.mock('../Discovery/DiscoveryTab', () => ({
agentId?: string;
resourceId: string;
hostname: string;
+ showManualRunAction?: boolean;
}) => (
<div data-testid="discovery-tab">
<span data-testid="disc-resource-type">{props.resourceType}</span>
<span data-testid="disc-agent-id">{props.agentId}</span>
<span data-testid="disc-resource-id">{props.resourceId}</span>
+ <span data-testid="disc-manual-run-action">{String(props.showManualRunAction)}</span>
</div>
),
}));
@@ -671,6 +673,7 @@ describe('GuestDrawer', () => {
expect(screen.getByTestId('disc-resource-type').textContent).toBe('vm');
expect(screen.getByTestId('disc-agent-id').textContent).toBe('pve1');
expect(screen.getByTestId('disc-resource-id').textContent).toBe('101');
+ expect(screen.getByTestId('disc-manual-run-action').textContent).toBe('true');
});
it('passes correct resourceType and agentId for app-container', () => {
diff --git a/frontend-modern/src/components/Workloads/GuestDrawer.tsx b/frontend-modern/src/components/Workloads/GuestDrawer.tsx
index a175e10352..5054bf765a 100644
--- a/frontend-modern/src/components/Workloads/GuestDrawer.tsx
+++ b/frontend-modern/src/components/Workloads/GuestDrawer.tsx
@@ -143,6 +143,7 @@ export const GuestDrawer: Component<GuestDrawerProps> = (props) => {
agentId={discoveryAgentId()}
resourceId={discoveryResourceId()}
hostname={props.guest.name}
+ showManualRunAction
/>
</Suspense>
</div>
diff --git a/frontend-modern/src/components/shared/HistoryChartTooltip.tsx b/frontend-modern/src/components/shared/HistoryChartTooltip.tsx
index fea3d2a226..8f98275b04 100644
--- a/frontend-modern/src/components/shared/HistoryChartTooltip.tsx
+++ b/frontend-modern/src/components/shared/HistoryChartTooltip.tsx
@@ -15,9 +15,10 @@ interface HistoryChartTooltipProps {
export const HistoryChartTooltip: Component<HistoryChartTooltipProps> = (props) => {
return (
<svg
- class="pointer-events-none absolute inset-0 h-full w-full overflow-visible"
+ class="pointer-events-none absolute left-0 top-0 overflow-visible"
+ width={props.chartWidth}
+ height={props.chartHeight}
viewBox={`0 0 ${props.chartWidth} ${props.chartHeight}`}
- preserveAspectRatio="none"
aria-hidden="true"
>
<Show when={props.hoveredPoint}>
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 949839d29b..8f0f668432 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -1082,8 +1082,12 @@ describe('shared primitive guardrails', () => {
expect(historyChartTooltipSource).toContain('formatHistoryChartTooltipValue');
expect(historyChartTooltipSource).toContain('getHistoryChartTooltipLayout');
expect(historyChartTooltipSource).toContain('foreignObject');
+ expect(historyChartTooltipSource).toContain('width={props.chartWidth}');
+ expect(historyChartTooltipSource).toContain('height={props.chartHeight}');
expect(historyChartTooltipSource).toContain('new Date(point().timestamp).toLocaleString()');
expect(historyChartTooltipSource).not.toContain('<Portal>');
+ expect(historyChartTooltipSource).not.toContain('absolute inset-0 h-full w-full');
+ expect(historyChartTooltipSource).not.toContain('preserveAspectRatio="none"');
expect(historyChartTooltipSource).not.toContain('style={');
expect(historyChartTooltipSource).not.toContain('ChartsAPI.getMetricsHistory');
});
diff --git a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx
index 1a13f56513..0e031c8f55 100644
--- a/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/HistoryChart.test.tsx
@@ -102,8 +102,12 @@ describe('HistoryChart', () => {
expect(historyChartTooltipSource).toContain('formatHistoryChartTooltipValue');
expect(historyChartTooltipSource).toContain('getHistoryChartTooltipLayout');
expect(historyChartTooltipSource).toContain('foreignObject');
+ expect(historyChartTooltipSource).toContain('width={props.chartWidth}');
+ expect(historyChartTooltipSource).toContain('height={props.chartHeight}');
expect(historyChartTooltipSource).toContain('new Date(point().timestamp).toLocaleString()');
expect(historyChartTooltipSource).not.toContain('<Portal>');
+ expect(historyChartTooltipSource).not.toContain('absolute inset-0 h-full w-full');
+ expect(historyChartTooltipSource).not.toContain('preserveAspectRatio="none"');
expect(historyChartTooltipSource).not.toContain('style={');
expect(historyChartTooltipSource).not.toContain('ChartsAPI.getMetricsHistory');
});
diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.go
index 55e73a7d83..e3178ceedf 100644
--- a/internal/api/ai_handlers.go
+++ b/internal/api/ai_handlers.go
@@ -2794,9 +2794,9 @@ func (h *AISettingsHandler) HandleUpdateAISettings(w http.ResponseWriter, r *htt
settings.DiscoveryIntervalHours = *req.DiscoveryIntervalHours
}
- // Auto-default discovery interval to 24h when enabled with no interval set.
- // Without this, enabling discovery with interval=0 silently stays in manual-only mode.
- if settings.DiscoveryEnabled && settings.DiscoveryIntervalHours == 0 {
+ // Auto-default discovery interval only when enabling without an explicit interval.
+ // A provided interval of 0 is the canonical manual-only setting and must persist.
+ if req.DiscoveryEnabled != nil && *req.DiscoveryEnabled && req.DiscoveryIntervalHours == nil && settings.DiscoveryIntervalHours == 0 {
settings.DiscoveryIntervalHours = 24
}
diff --git a/internal/api/ai_handlers_patrol_test.go b/internal/api/ai_handlers_patrol_test.go
index ec5ed74285..104d0ca50a 100644
--- a/internal/api/ai_handlers_patrol_test.go
+++ b/internal/api/ai_handlers_patrol_test.go
@@ -65,6 +65,76 @@ func TestAISettingsHandler_PatrolInterval_SpecificCheck(t *testing.T) {
}
}
+func TestAISettingsHandler_DiscoveryIntervalPersistsExplicitSettings(t *testing.T) {
+ t.Parallel()
+
+ tests := []struct {
+ name string
+ intervalHours int
+ }{
+ {name: "six hour automatic scan", intervalHours: 6},
+ {name: "manual only", intervalHours: 0},
+ }
+
+ for _, tt := range tests {
+ tt := tt
+ t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
+
+ tmp := t.TempDir()
+ cfg := &config.Config{DataPath: tmp}
+ persistence := config.NewConfigPersistence(tmp)
+ handler := newTestAISettingsHandler(cfg, persistence, nil)
+
+ body, _ := json.Marshal(AISettingsUpdateRequest{
+ DiscoveryEnabled: ptr(true),
+ DiscoveryIntervalHours: ptr(tt.intervalHours),
+ })
+ req := newLoopbackRequest(http.MethodPut, "/api/settings/ai", bytes.NewReader(body))
+ rec := httptest.NewRecorder()
+ handler.HandleUpdateAISettings(rec, req)
+
+ if rec.Code != http.StatusOK {
+ t.Fatalf("PUT status = %d, body=%s", rec.Code, rec.Body.String())
+ }
+
+ var updateResp AISettingsResponse
+ if err := json.Unmarshal(rec.Body.Bytes(), &updateResp); err != nil {
+ t.Fatalf("decode update: %v", err)
+ }
+ if !updateResp.DiscoveryEnabled {
+ t.Fatalf("expected DiscoveryEnabled=true in update response")
+ }
+ if updateResp.DiscoveryIntervalHours != tt.intervalHours {
+ t.Fatalf("expected update DiscoveryIntervalHours=%d, got %d", tt.intervalHours, updateResp.DiscoveryIntervalHours)
+ }
+
+ saved, err := persistence.LoadAIConfig()
+ if err != nil {
+ t.Fatalf("load saved AI config: %v", err)
+ }
+ if saved.DiscoveryIntervalHours != tt.intervalHours {
+ t.Fatalf("expected persisted DiscoveryIntervalHours=%d, got %d", tt.intervalHours, saved.DiscoveryIntervalHours)
+ }
+
+ getReq := newLoopbackRequest(http.MethodGet, "/api/settings/ai", nil)
+ getRec := httptest.NewRecorder()
+ handler.HandleGetAISettings(getRec, getReq)
+ if getRec.Code != http.StatusOK {
+ t.Fatalf("GET status = %d, body=%s", getRec.Code, getRec.Body.String())
+ }
+
+ var getResp AISettingsResponse
+ if err := json.Unmarshal(getRec.Body.Bytes(), &getResp); err != nil {
+ t.Fatalf("decode get: %v", err)
+ }
+ if getResp.DiscoveryIntervalHours != tt.intervalHours {
+ t.Fatalf("expected GET DiscoveryIntervalHours=%d, got %d", tt.intervalHours, getResp.DiscoveryIntervalHours)
+ }
+ })
+ }
+}
+
func TestAISettingsHandler_PatrolEnabled_ResponseReflectsToggleImmediately(t *testing.T) {
t.Parallel()