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.

Stabilize managed dev runtime recovery

rcourtmanbce500732a7f
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index ba63cd27ba..43db564914 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -103,6 +103,12 @@ runtime cost control, and shared AI transport surfaces.
attached, the Assistant empty
message state must also remain source-named and must not fall back to generic
cluster/system starter prompts that compete with the attached briefing.
+ Structured Patrol run and Patrol configuration handoffs may render bounded,
+ redacted diagnostic lines in the drawer when they are opened directly from
+ Patrol runtime/configuration surfaces, but the attached headline must remain
+ source-owned (`Patrol run attached`, `Patrol configuration ... attached`)
+ and the drawer must still exclude raw provider payloads, commands, and
+ Patrol-authored remediation steps.
Reloaded Assistant sessions may consume the backend-owned
`handoff_summary` only as safe presentation state and a Patrol finding
pointer; hidden model context, command payloads, preflight data, and action
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 4a8609b1dc..85c0b858de 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -143,6 +143,11 @@ output or bypass the normal non-admin redaction path.
`/api/ai/patrol/runs` records may expose bounded `source` provenance so demo
evidence can be separated from live runtime assessment state without
changing the stable run payload shape.
+ The Patrol status payload's `trigger_status` object is the canonical
+ transport for alert/anomaly trigger queue and mode facts. Patrol summary UI
+ may present that state as factual trigger-mode context, but it must not infer
+ trigger enablement or queue state from settings payloads, route state, or
+ run-history labels.
7. `frontend-modern/src/api/rbac.ts` shared with `organization-settings`: the RBAC frontend client is both an organization settings control surface and a canonical API payload contract boundary.
8. `frontend-modern/src/api/security.ts` shared with `security-privacy`: the security frontend client is both a security/privacy control surface and a canonical API payload contract boundary.
9. `frontend-modern/src/api/updates.ts` shared with `deployment-installability`: the updates frontend client is both a deployment-installability control surface and a canonical API payload contract boundary.
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index aef14147f9..ad9057a227 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -382,6 +382,12 @@ or other self-hosted uncapped continuity plans.
also keep decorative icon titles out of tab accessible names, so hosted and
self-hosted chrome announce the canonical tab label plus meaningful badge
counts rather than duplicating branded SVG titles.
+ Retired operator top-level route compatibility in
+ `frontend-modern/src/App.tsx` must stay inside authenticated app-owned
+ surfaces such as Infrastructure, Workloads, Storage, and Recovery. Those
+ compatibility routes must not revive hosted signup, public Cloud trial,
+ pricing, or commercial acquisition surfaces inside the local product
+ runtime.
22. Keep the hosted account portal shell task-first and compact. Section
headers, billing action rows, and the maintained portal bundle under
`internal/cloudcp/portal/` may surface the facts an operator needs, but the
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 6f29419e2b..796f75fe97 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -193,6 +193,15 @@ server-side update execution surfaces.
backend process: a missing `./pulse` process may be tolerated only for the
short configured missing-process grace, after which the managed runtime must
restart it instead of waiting for the full HTTP warmup window.
+ Managed hot-dev first-run recovery is part of the same proof boundary:
+ non-production dev data directories must seed the deterministic E2E
+ bootstrap token when no token file exists, and browser helpers must prove
+ the target first-run handoff UI rendered instead of accepting a route match
+ while the setup wizard is still blocking the app.
+ Hot-dev must also recreate the local Pro audit signing key env binding when
+ first-run reset removes the runtime `.env`; otherwise the Pro backend fails
+ closed before binding the API port and the supervisor loops without ever
+ reaching browser-verifiable health.
6. Add or change governed release-promotion workflow inputs, operator-facing promotion metadata, the canonical version file, prerelease feedback intake prompts, artifact publication lineage enforcement, release note or changelog packet composition, or stable-promotion rehearsal summaries through `.github/workflows/create-release.yml`, `.github/workflows/helm-pages.yml`, `.github/workflows/publish-docker.yml`, `.github/workflows/publish-helm-chart.yml`, `.github/workflows/promote-floating-tags.yml`, `.github/workflows/release-dry-run.yml`, `.github/workflows/update-demo-server.yml`, `.github/ISSUE_TEMPLATE/v6_rc_feedback.yml`, `docs/RELEASE_NOTES.md`, `docs/releases/`, `docs/release-control/v6/internal/RELEASE_PROMOTION_POLICY.md`, `docs/release-control/v6/internal/PRE_RELEASE_CHECKLIST.md`, `docs/release-control/v6/internal/RC_TO_GA_REHEARSAL_TEMPLATE.md`, `scripts/check-workflow-dispatch-inputs.py`, `scripts/release_control/render_release_body.py`, `scripts/release_control/record_rc_to_ga_rehearsal.py`, `scripts/release_control/internal/record_rc_to_ga_rehearsal.py`, `scripts/release_control/release_promotion_policy_support.py`, `scripts/trigger-release.sh`, and `scripts/trigger-release-dry-run.sh`
That release-promotion boundary also owns prerelease note packet lineage:
shipped RC notes must remain historically accurate, the top-level
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 6c7a7d64cf..3a162515e4 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -278,6 +278,10 @@ metadata, but the shared drawer boundary must not turn those handoffs into
frontend-authored prompts, tool routes, or remediation plans; the configured
model owns tool choice and diagnostic reasoning after the request reaches the
AI runtime.
+The compact Patrol assessment strip may include factual recent activity mix and
+trigger-mode labels when those values are derived from the Patrol run-history
+and status payloads. Those labels are summary context inside the same strip,
+not a replacement status card, CTA band, or page-local nested card.
1. Add shared primitives in `frontend-modern/src/components/shared/`
Framed product table surfaces must consume the shared `TableCard` frame and
@@ -386,6 +390,12 @@ AI runtime.
frontend primitives must not register `/cloud` or `/cloud/signup` as public
product-runtime routes, because Cloud signup belongs to Pulse Account and
the Cloud control plane rather than a local in-product trial page.
+ Compatibility top-level operator routes such as `/infrastructure`,
+ `/workloads`, `/storage`, `/recovery`, and `/ceph` may remain registered in
+ `frontend-modern/src/App.tsx` only as thin routes into their owning product
+ surfaces or canonical redirect targets. They must not become preloaded
+ primary nav tabs, duplicate app shells, or local `NotFound` fallbacks for
+ still-supported operator destinations.
The same settings-shell boundary owns read-only landing posture: when the
session presentation policy says the operator cannot manage setup, `/settings`
and sidebar navigation must land on the canonical reporting/control surface
diff --git a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
index 20bd79018c..919b5be7d2 100644
--- a/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
+++ b/docs/release-control/v6/internal/subsystems/patrol-intelligence.md
@@ -60,6 +60,10 @@ Patrol-specific presentation helpers.
2. Add or change Patrol findings, approvals, investigation, or run-history presentation through `frontend-modern/src/components/AI/FindingsPanel.tsx` and `frontend-modern/src/components/patrol/`
3. Keep remediation execution badge copy and severity styling aligned through `frontend-modern/src/components/patrol/RemediationStatus.tsx` and `frontend-modern/src/utils/remediationPresentation.ts`
4. Add or change Patrol header, summary, status runtime-state presentation, or runtime provider action presentation through `frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx`, `frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx`, `frontend-modern/src/components/patrol/PatrolStatusBar.tsx`, `frontend-modern/src/utils/patrolRuntimePresentation.ts`, and `frontend-modern/src/utils/patrolRuntimeActions.ts`
+ Patrol summary presentation may show recent activity mix and trigger mode as
+ compact factual context sourced from Patrol run history and
+ `status.trigger_status`; it must not reintroduce status cards, suggested
+ actions, or a separate activity tab to explain the same facts.
5. Add or change Patrol header schedule and runtime presentation through `frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx`, `frontend-modern/src/utils/aiPatrolSchedulePresentation.ts`, and `frontend-modern/src/utils/patrolRuntimePresentation.ts`.
Patrol must not surface retired hosted-model credit badges or trial-like activation prompts in the normal self-hosted GA app, even when legacy transport fields are still present.
6. Keep Patrol and chat identifier-label presentation aligned through the shared `frontend-modern/src/utils/textPresentation.ts`
@@ -251,6 +255,11 @@ Patrol-specific presentation helpers.
with the same Patrol-owned visible briefing and approval-required posture
from current finding facts; it must not fall back to generic investigation
chat or invite execution from missing command details.
+ Patrol run-history Assistant handoffs are a separate run-context surface:
+ the visible drawer must keep the `Patrol run attached` headline, may show the
+ scoped run subject, safe runtime-failure/action label, and classified
+ redacted failure summary, and must continue to omit raw provider payloads,
+ command text, and remediation instructions.
If the live approval is gone but the structured action artifact payload is still
available, the recovery Assistant briefing must carry only safe action artifact
metadata such as description, target, risk, rationale, destructive posture,
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 02eef2a8ee..cf3128deca 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -156,6 +156,12 @@ a separate Docker-only or TrueNAS-local inventory path.
1. Add or change recovery-point persistence, rollups, or series derivation through `internal/recovery/`
2. Add or change recovery page UX through `frontend-modern/src/components/Recovery/` and keep canonical route/query/filter state ownership in `frontend-modern/src/features/recovery/useRecoverySurfaceState.ts`
+ `/recovery` remains a supported authenticated operator destination even
+ when Recovery is not a primary platform tab. Route compatibility in
+ `frontend-modern/src/App.tsx` must render the canonical Recovery surface
+ rather than `NotFound`, and `/storage` compatibility must likewise render
+ the Storage owner surface instead of duplicating storage/recovery state in
+ the app shell.
Recovery table surfaces must consume the frontend-primitives-owned
`TableCard` frame and `TableCardHeader` header band for protected-item,
recovery-event, and adjacent table-fallback chrome. Storage/recovery may own
diff --git a/frontend-modern/src/App.tsx b/frontend-modern/src/App.tsx
index cce6f2c99a..4d5249b5ca 100644
--- a/frontend-modern/src/App.tsx
+++ b/frontend-modern/src/App.tsx
@@ -40,14 +40,18 @@ import { useKeyboardShortcuts } from './hooks/useKeyboardShortcuts';
import { useKioskMode } from '@/hooks/useKioskMode';
import {
DOCKER_PATH,
+ INFRASTRUCTURE_PATH,
KUBERNETES_PATH,
PATROL_PATH,
PROXMOX_PATH,
+ RECOVERY_PATH,
TRUENAS_PATH,
VMWARE_PATH,
+ WORKLOADS_PATH,
buildDockerPath,
buildKubernetesPath,
buildProxmoxPath,
+ buildStoragePath,
buildTrueNASPath,
buildVmwarePath,
} from './routing/resourceLinks';
@@ -77,6 +81,22 @@ const AlertsPage = lazy(() =>
import('./pages/Alerts').then((module) => ({ default: module.Alerts })),
);
const SettingsPage = lazy(() => import('./components/Settings/Settings'));
+const InfrastructurePage = lazy(() => import('./features/infrastructure/InfrastructurePageSurface'));
+const WorkloadsPage = lazy(() =>
+ import('./components/Workloads/WorkloadsSurface').then((module) => ({
+ default: () => <module.WorkloadsSurface vms={[]} containers={[]} nodes={[]} useWorkloads />,
+ })),
+);
+const StoragePage = lazy(() =>
+ import('./components/Storage/Storage').then((module) => ({
+ default: () => <module.default />,
+ })),
+);
+const RecoveryPage = lazy(() =>
+ import('./components/Recovery/Recovery').then((module) => ({
+ default: () => <module.default />,
+ })),
+);
const ProxmoxPage = lazy(() => import('./pages/Proxmox'));
const DockerPage = lazy(() => import('./pages/Docker'));
const KubernetesPage = lazy(() => import('./pages/Kubernetes'));
@@ -94,6 +114,7 @@ const SetupCompletionPreviewPage = lazy(() =>
})),
);
const ROOT_PATROL_PATH = PATROL_PATH;
+const STORAGE_PATH = buildStoragePath();
const PRIMARY_INFRASTRUCTURE_ROUTE_BY_ID: Record<PrimaryInfrastructureNavId, string> = {
proxmox: buildProxmoxPath(),
@@ -528,6 +549,16 @@ function App() {
<Route path="/preview/setup-complete" component={SetupCompletionPreviewPage} />
<Route path="/login" component={RuntimeHomePage} />
<Route path="/" component={RuntimeHomePage} />
+ <Route path={INFRASTRUCTURE_PATH} component={InfrastructurePage} />
+ <Route path={`${INFRASTRUCTURE_PATH}/*`} component={InfrastructurePage} />
+ <Route path={WORKLOADS_PATH} component={WorkloadsPage} />
+ <Route path={`${WORKLOADS_PATH}/*`} component={WorkloadsPage} />
+ <Route path={STORAGE_PATH} component={StoragePage} />
+ <Route path={`${STORAGE_PATH}/*`} component={StoragePage} />
+ <Route path={RECOVERY_PATH} component={RecoveryPage} />
+ <Route path={`${RECOVERY_PATH}/*`} component={RecoveryPage} />
+ <Route path="/ceph" component={() => <Navigate href="/proxmox/ceph" />} />
+ <Route path="/ceph/*" component={() => <Navigate href="/proxmox/ceph" />} />
<Route path={PROXMOX_PATH} component={ProxmoxPage} />
<Route path={`${PROXMOX_PATH}/*`} component={ProxmoxPage} />
<Route path={DOCKER_PATH} component={DockerPage} />
diff --git a/frontend-modern/src/__tests__/App.architecture.test.ts b/frontend-modern/src/__tests__/App.architecture.test.ts
index f907c81bdb..5ac121685a 100644
--- a/frontend-modern/src/__tests__/App.architecture.test.ts
+++ b/frontend-modern/src/__tests__/App.architecture.test.ts
@@ -37,16 +37,27 @@ describe('App architecture', () => {
expect(routePreloadSource).toContain('ROOT_PROXMOX_PATH,');
expect(routePreloadSource).toContain('PATROL_PATH,');
// Legacy top-level routes (Infrastructure/Workloads/Storage/Recovery/Ceph)
- // were retired when primary nav moved to platform-first. Their preloaders
- // and route entries must not return.
+ // were retired as primary nav tabs when navigation moved to platform-first.
+ // Keep them out of shell preloading, but leave lightweight route
+ // compatibility wired through the current component-owned surfaces so
+ // deep links and managed-dev browser proofs do not land on Not Found.
expect(routePreloadSource).not.toContain('ROOT_INFRASTRUCTURE_PATH');
expect(routePreloadSource).not.toContain('ROOT_WORKLOADS_PATH');
expect(routePreloadSource).not.toContain('RECOVERY_ROUTE_PATH');
expect(routePreloadSource).not.toContain('STORAGE_PATH');
- expect(appSource).not.toContain('INFRASTRUCTURE_ROUTE_PATH');
- expect(appSource).not.toContain('ROOT_WORKLOADS_PATH');
- expect(appSource).not.toContain('RECOVERY_ROUTE_PATH');
- expect(appSource).not.toContain('STORAGE_PATH');
+ expect(appSource).toContain(
+ "const InfrastructurePage = lazy(() => import('./features/infrastructure/InfrastructurePageSurface'));",
+ );
+ expect(appSource).toContain("import('./components/Workloads/WorkloadsSurface')");
+ expect(appSource).toContain("import('./components/Storage/Storage')");
+ expect(appSource).toContain(
+ "import('./components/Recovery/Recovery')",
+ );
+ expect(appSource).toContain('<Route path={INFRASTRUCTURE_PATH} component={InfrastructurePage} />');
+ expect(appSource).toContain('<Route path={WORKLOADS_PATH} component={WorkloadsPage} />');
+ expect(appSource).toContain('<Route path={STORAGE_PATH} component={StoragePage} />');
+ expect(appSource).toContain('<Route path={RECOVERY_PATH} component={RecoveryPage} />');
+ expect(appSource).toContain('<Route path="/ceph" component={() => <Navigate href="/proxmox/ceph" />} />');
expect(appSource).toContain('await preloadRouteModule(route);');
expect(appRuntimeStateSource).not.toContain('preloadLazyRoutes');
expect(appRuntimeStateSource).not.toContain("import('@/pages/Alerts')");
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
index 54b35ea9da..0658ce3065 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/AIChat.test.tsx
@@ -72,22 +72,26 @@ const {
error: vi.fn(),
};
- const emptyChatContext = () => ({
- findingId: undefined,
- autonomousMode: undefined,
- context: undefined,
+ const emptyChatContext = () => ({
+ targetType: undefined,
+ targetId: undefined,
+ findingId: undefined,
+ autonomousMode: undefined,
+ context: undefined,
briefing: undefined,
handoffContext: undefined,
handoffResources: undefined,
handoffActions: undefined,
});
- const mockAiChatStore = {
- isOpenSignal: vi.fn(() => true),
- context: emptyChatContext() as {
- findingId?: string;
- autonomousMode?: boolean;
- context?: Record<string, unknown>;
+ const mockAiChatStore = {
+ isOpenSignal: vi.fn(() => true),
+ context: emptyChatContext() as {
+ targetType?: string;
+ targetId?: string;
+ findingId?: string;
+ autonomousMode?: boolean;
+ context?: Record<string, unknown>;
handoffContext?: string;
handoffResources?: Array<{
id: string;
@@ -387,6 +391,59 @@ describe('AIChat', () => {
);
});
+ it('renders Patrol configuration handoff details without replacing the attached headline', () => {
+ mockAiChatStore.context = {
+ targetType: 'patrol-configuration',
+ autonomousMode: false,
+ briefing: {
+ sourceLabel: 'Pulse Patrol',
+ title: 'Patrol configuration failure attached',
+ subject:
+ 'patrol_autonomy_pro_required: Investigation and auto-fix require Pulse Pro.',
+ statusLabel: 'HTTP 402 · model_unsupported_tools',
+ detailLines: ['Provider: openrouter'],
+ evidence: ['Command: sensitive or command detail withheld'],
+ safetyNote:
+ 'Assistant can explain the configuration state; provider changes remain operator-controlled.',
+ },
+ };
+
+ renderChat();
+
+ const context = screen.getByLabelText('Assistant context');
+ expect(context).toHaveTextContent('Patrol configuration failure attached');
+ expect(context).toHaveTextContent('patrol_autonomy_pro_required');
+ expect(context).toHaveTextContent('Provider: openrouter');
+ expect(context).toHaveTextContent('Command: sensitive or command detail withheld');
+ expect(context).toHaveTextContent('Approval required before any action.');
+ });
+
+ it('renders Patrol run handoff details without replacing the attached headline', () => {
+ mockAiChatStore.context = {
+ targetType: 'patrol-run',
+ autonomousMode: false,
+ briefing: {
+ sourceLabel: 'Pulse Patrol',
+ title: 'Patrol run attached',
+ subject: 'Scoped run run-alert-scoped',
+ statusLabel: 'error · Alert fired · Checked 2 resources',
+ detailLines: ['Runtime failure: Selected model does not support Patrol tools'],
+ actionLabel: 'Review Patrol runtime failure',
+ safetyNote:
+ 'Assistant can explain the Patrol run context; retries, configuration changes, and remediation remain operator-controlled.',
+ },
+ };
+
+ renderChat();
+
+ const context = screen.getByLabelText('Assistant context');
+ expect(context).toHaveTextContent('Patrol run attached');
+ expect(context).toHaveTextContent('Scoped run run-alert-scoped');
+ expect(context).toHaveTextContent('Review Patrol runtime failure');
+ expect(context).toHaveTextContent('Selected model does not support Patrol tools');
+ expect(context).toHaveTextContent('Approval required before any action.');
+ });
+
it('keeps Patrol action-artifact briefings compact in the sidebar', () => {
mockAiChatStore.context = {
autonomousMode: false,
diff --git a/frontend-modern/src/components/AI/Chat/index.tsx b/frontend-modern/src/components/AI/Chat/index.tsx
index 6181517f9e..7ecb55331c 100644
--- a/frontend-modern/src/components/AI/Chat/index.tsx
+++ b/frontend-modern/src/components/AI/Chat/index.tsx
@@ -66,6 +66,7 @@ import { formatIdentifierLabel } from '@/utils/textPresentation';
const MODEL_SESSION_STORAGE_KEY = 'pulse:ai_chat_models_by_session';
const DEFAULT_SESSION_KEY = '__default__';
const AI_CHAT_MIN_DOCKED_VIEWPORT_WIDTH = 1200;
+const STRUCTURED_PATROL_CONTEXT_TARGETS = new Set(['patrol-configuration', 'patrol-run']);
interface AIChatProps {
onClose: () => void;
@@ -77,6 +78,9 @@ const compactText = (items: Array<string | undefined>): string[] =>
const pluralizeCount = (count: number, singular: string, plural: string) =>
`${count} ${count === 1 ? singular : plural}`;
+const shouldShowStructuredPatrolContext = (targetType: string | undefined) =>
+ STRUCTURED_PATROL_CONTEXT_TARGETS.has(targetType ?? '');
+
const isPatrolFindingSessionHandoff = (summary: ChatSessionHandoffSummary) =>
summary.kind === 'patrol_finding' || Boolean(summary.finding_id);
@@ -511,12 +515,44 @@ export const AIChat: Component<AIChatProps> = (props) => {
const title = briefing.title?.trim() ?? '';
const subject = briefing.subject?.trim() ?? '';
+ if (shouldShowStructuredPatrolContext(aiChatStore.context.targetType)) {
+ return title || subject || 'Context attached';
+ }
if (subject && /attached|briefing/i.test(title)) {
return subject;
}
return title || subject || 'Context attached';
});
+ const contextBriefingDetailLines = createMemo(() => {
+ const briefing = contextBriefing();
+ if (!briefing) return [];
+ if (!shouldShowStructuredPatrolContext(aiChatStore.context.targetType)) return [];
+
+ const seen = new Set<string>();
+ const lines: string[] = [];
+ const addLine = (value: string | undefined) => {
+ const normalized = value?.trim();
+ if (!normalized || seen.has(normalized)) return;
+ seen.add(normalized);
+ lines.push(normalized);
+ };
+
+ const subject = briefing.subject?.trim();
+ if (subject !== contextBriefingTitle()) {
+ addLine(subject);
+ }
+ addLine(briefing.actionLabel);
+ for (const line of briefing.detailLines ?? []) {
+ addLine(line);
+ }
+ for (const line of briefing.evidence ?? []) {
+ addLine(line);
+ }
+ addLine(briefing.safetyNote);
+
+ return lines.slice(0, 8);
+ });
const contextBriefingNote = createMemo(() => {
if (hasScopedApprovalHandoff()) {
return 'Approval required before any action.';
@@ -1480,6 +1516,11 @@ export const AIChat: Component<AIChatProps> = (props) => {
<div class="mt-1 text-sm font-semibold text-base-content">
{contextBriefingTitle()}
</div>
+ <Show when={contextBriefingDetailLines().length > 0}>
+ <div class="mt-1 space-y-0.5 text-xs text-muted">
+ <For each={contextBriefingDetailLines()}>{(line) => <div>{line}</div>}</For>
+ </div>
+ </Show>
<Show when={contextBriefingNote()}>
<div class="mt-0.5 text-xs text-muted">{contextBriefingNote()}</div>
</Show>
diff --git a/frontend-modern/src/components/patrol/PatrolStatusBar.tsx b/frontend-modern/src/components/patrol/PatrolStatusBar.tsx
index 5d31484a4d..563ec20a03 100644
--- a/frontend-modern/src/components/patrol/PatrolStatusBar.tsx
+++ b/frontend-modern/src/components/patrol/PatrolStatusBar.tsx
@@ -211,13 +211,13 @@ export const PatrolStatusBar: Component<PatrolStatusBarProps> = (props) => {
<Show when={resolvedStats()!.activityBreakdownLabel}>
<span class="hidden sm:inline text-slate-300 ">|</span>
<span class="text-xs text-muted">
- Breakdown: {resolvedStats()!.activityBreakdownLabel}
+ Recent activity mix: {resolvedStats()!.activityBreakdownLabel}
</span>
</Show>
<Show when={triggerStatusSummary()}>
<span class="hidden sm:inline text-slate-300 ">|</span>
- <span class="text-xs text-muted">Scoped triggers: {triggerStatusSummary()}</span>
+ <span class="text-xs text-muted">Trigger mode: {triggerStatusSummary()}</span>
</Show>
</div>
</div>
diff --git a/frontend-modern/src/components/patrol/__tests__/PatrolStatusBar.test.tsx b/frontend-modern/src/components/patrol/__tests__/PatrolStatusBar.test.tsx
index 0b0dd8730f..1b9d789516 100644
--- a/frontend-modern/src/components/patrol/__tests__/PatrolStatusBar.test.tsx
+++ b/frontend-modern/src/components/patrol/__tests__/PatrolStatusBar.test.tsx
@@ -408,12 +408,12 @@ describe('PatrolStatusBar', () => {
await waitFor(() => {
expect(
- screen.getByText('Breakdown: 1 full, 1 alert-triggered, 1 anomaly-triggered'),
+ screen.getByText('Recent activity mix: 1 full, 1 alert-triggered, 1 anomaly-triggered'),
).toBeInTheDocument();
});
expect(
- screen.getByText('Scoped triggers: 4 queued · busy mode · anomalies off'),
+ screen.getByText('Trigger mode: 4 queued · busy mode · anomalies off'),
).toBeInTheDocument();
});
@@ -460,7 +460,7 @@ describe('PatrolStatusBar', () => {
expect(screen.getByText('Recent activity')).toBeInTheDocument();
});
- expect(screen.queryByText(/Scoped triggers:/)).not.toBeInTheDocument();
+ expect(screen.queryByText(/Trigger mode:/)).not.toBeInTheDocument();
setTriggerStatus({
running: true,
@@ -474,7 +474,7 @@ describe('PatrolStatusBar', () => {
await waitFor(() => {
expect(
- screen.getByText('Scoped triggers: 4 queued · busy mode · anomalies off'),
+ screen.getByText('Trigger mode: 4 queued · busy mode · anomalies off'),
).toBeInTheDocument();
});
});
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
index aeea2eac8b..30ea810533 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceSummary.tsx
@@ -6,6 +6,11 @@ import {
getPatrolRecencyPresentation,
getPatrolSummaryMetricState,
} from '@/utils/patrolSummaryPresentation';
+import {
+ formatPatrolActivityBreakdown,
+ getPatrolActivityBreakdown,
+ getPatrolTriggerStatusSummary,
+} from '@/utils/patrolRunPresentation';
import { getPatrolRuntimePresentation } from '@/utils/patrolRuntimePresentation';
import { formatRelativeTime } from '@/utils/format';
import type { PatrolIntelligenceState } from './usePatrolIntelligenceState';
@@ -97,6 +102,12 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
runs: state.patrolRunHistory.value() ?? [],
}),
);
+ const activityBreakdownLabel = createMemo(() =>
+ formatPatrolActivityBreakdown(getPatrolActivityBreakdown(state.patrolRunHistory.value() ?? [])),
+ );
+ const triggerStatusSummary = createMemo(() =>
+ getPatrolTriggerStatusSummary(state.patrolStatus()?.trigger_status),
+ );
const recency = createMemo(() =>
getPatrolRecencyPresentation({
runs: state.patrolRunHistory.value() ?? [],
@@ -205,6 +216,21 @@ export function PatrolIntelligenceSummary(props: { state: PatrolIntelligenceStat
</span>
<span class="font-semibold text-base-content">{compactAssessmentSummary()}</span>
</div>
+ <Show when={activityBreakdownLabel() || triggerStatusSummary()}>
+ <div class="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted">
+ <Show when={activityBreakdownLabel()}>
+ <span>Recent activity mix: {activityBreakdownLabel()}</span>
+ </Show>
+ <Show when={activityBreakdownLabel() && triggerStatusSummary()}>
+ <span aria-hidden="true" class="text-slate-300">
+ |
+ </span>
+ </Show>
+ <Show when={triggerStatusSummary()}>
+ <span>Trigger mode: {triggerStatusSummary()}</span>
+ </Show>
+ </div>
+ </Show>
</div>
</div>
</section>
diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
index 4e96a7249d..32b9b8b74f 100644
--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceSummary.test.tsx
@@ -24,6 +24,54 @@ describe('PatrolIntelligenceSummary', () => {
expect(screen.queryByTestId('patrol-assessment-assistant-button')).not.toBeInTheDocument();
});
+ it('surfaces recent activity mix and trigger mode in the compact assessment strip', () => {
+ const patrolState = {
+ ...createPatrolState(),
+ patrolRunHistory: makePatrolRunHistory([
+ makePatrolRunRecord({
+ id: 'run-alert-scoped',
+ started_at: todayAt(11, 0),
+ completed_at: todayAt(11, 2),
+ type: 'scoped',
+ trigger_reason: 'alert_fired',
+ new_findings: 1,
+ }),
+ makePatrolRunRecord({
+ id: 'run-anomaly-scoped',
+ started_at: todayAt(10, 15),
+ completed_at: todayAt(10, 16),
+ type: 'scoped',
+ trigger_reason: 'anomaly',
+ }),
+ makePatrolRunRecord({
+ id: 'run-full-review',
+ started_at: todayAt(9, 0),
+ completed_at: todayAt(9, 3),
+ type: 'full',
+ trigger_reason: 'scheduled',
+ }),
+ ]),
+ patrolStatus: () => ({
+ trigger_status: {
+ running: false,
+ pending_triggers: 4,
+ current_interval_ms: 10000,
+ recent_events: 12,
+ is_busy_mode: true,
+ alert_triggers_enabled: true,
+ anomaly_triggers_enabled: false,
+ },
+ }),
+ } as unknown as PatrolIntelligenceState;
+
+ render(() => <PatrolIntelligenceSummary state={patrolState} />);
+
+ expect(
+ screen.getByText('Recent activity mix: 1 full, 1 alert-triggered, 1 anomaly-triggered'),
+ ).toBeInTheDocument();
+ expect(screen.getByText('Trigger mode: 4 queued · busy mode · anomalies off')).toBeInTheDocument();
+ });
+
it('does not surface disabled run actions on the compact assessment strip', () => {
const patrolState = {
...createPatrolState(),
@@ -126,6 +174,12 @@ describe('PatrolIntelligenceSummary', () => {
});
});
+function todayAt(hours: number, minutes: number): string {
+ const value = new Date();
+ value.setHours(hours, minutes, 0, 0);
+ return value.toISOString();
+}
+
function createPatrolState(): PatrolIntelligenceState {
return {
activePatrolFindings: () => [
diff --git a/frontend-modern/src/stores/__tests__/websocket-resilience.test.ts b/frontend-modern/src/stores/__tests__/websocket-resilience.test.ts
index b8b0c0a0c8..bf9f6f7e87 100644
--- a/frontend-modern/src/stores/__tests__/websocket-resilience.test.ts
+++ b/frontend-modern/src/stores/__tests__/websocket-resilience.test.ts
@@ -172,6 +172,8 @@ describe('websocket store resilience', () => {
store.reconnect();
expect(previous!.close).toHaveBeenCalledWith(1000, 'Reconnecting');
expect(instances).toHaveLength(2);
+ expect(store.connected()).toBe(false);
+ expect(store.reconnecting()).toBe(true);
previous!.onclose?.({ code: 1000, reason: 'Reconnecting' } as CloseEvent);
vi.advanceTimersByTime(60000);
diff --git a/frontend-modern/src/stores/websocket.ts b/frontend-modern/src/stores/websocket.ts
index 814b7c5c89..254620bee1 100644
--- a/frontend-modern/src/stores/websocket.ts
+++ b/frontend-modern/src/stores/websocket.ts
@@ -780,12 +780,15 @@ export function createWebSocketStore(url: string) {
shutdown,
reconnect: () => {
if (isDisposed) return;
- ws?.close();
+ if (ws && (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING)) {
+ ws.close(1000, 'Reconnecting');
+ }
clearReconnectTimeout();
clearReconnectDelayTimeout();
reconnectAttempt = 0; // Reset attempts for manual reconnect
isReconnecting = false;
- setReconnecting(false);
+ setConnected(false);
+ setReconnecting(true);
connect();
},
switchUrl: (nextUrl: string) => {
diff --git a/scripts/hot-dev-bg.sh b/scripts/hot-dev-bg.sh
index d611ef5e54..2ac750cb59 100755
--- a/scripts/hot-dev-bg.sh
+++ b/scripts/hot-dev-bg.sh
@@ -789,9 +789,19 @@ restart_backend_bg() {
fail "Managed backend failed to recover after restart"
fi
- local backend_health_url backend_code
+ local backend_health_url backend_code checks
backend_health_url="http://127.0.0.1:${PULSE_DEV_API_PORT}/api/health"
- backend_code="$(http_status_code "${backend_health_url}")"
+ backend_code="000"
+ checks=180
+ while (( checks > 0 )); do
+ backend_code="$(http_status_code "${backend_health_url}")"
+ if http_status_ok "${backend_code}"; then
+ break
+ fi
+ sleep 0.5
+ checks=$((checks - 1))
+ done
+
if ! http_status_ok "${backend_code}"; then
fail "Managed backend listener recovered but health probe returned ${backend_code}"
fi
diff --git a/scripts/hot-dev.sh b/scripts/hot-dev.sh
index 3485c6e8de..ce6ef8f20a 100755
--- a/scripts/hot-dev.sh
+++ b/scripts/hot-dev.sh
@@ -149,6 +149,8 @@ sync_runtime_auth_env_overrides() {
fi
hot_dev_sync_auth_env_file "${runtime_env}" "${PULSE_AUTH_USER}" "${PULSE_AUTH_PASS}"
+ hot_dev_sync_audit_signing_env_file "${runtime_env}" "${PULSE_DATA_DIR}"
+ hot_dev_sync_bootstrap_token_file "${PULSE_DATA_DIR}"
log_info "Seeded managed dev auth defaults in ${runtime_env}"
}
diff --git a/scripts/lib/hot-dev-auth.sh b/scripts/lib/hot-dev-auth.sh
index a8d1c944ac..3a028b7a20 100644
--- a/scripts/lib/hot-dev-auth.sh
+++ b/scripts/lib/hot-dev-auth.sh
@@ -3,6 +3,7 @@
HOT_DEV_DEFAULT_AUTH_USER="admin"
HOT_DEV_DEFAULT_AUTH_PASSWORD="adminadminadmin"
HOT_DEV_DEFAULT_AUTH_HASH='$2a$12$J/Vu6FlBUJDTK.VAkysjB.AnvFOcijDbETyumhCB.nJVes5gvpiI6'
+HOT_DEV_DEFAULT_BOOTSTRAP_TOKEN="0123456789abcdef0123456789abcdef0123456789abcdef"
hot_dev_resolve_auth_user() {
printf '%s\n' "${HOT_DEV_AUTH_USER:-${HOT_DEV_DEFAULT_AUTH_USER}}"
@@ -63,3 +64,59 @@ hot_dev_sync_auth_env_file() {
mv "${tmp_file}" "${runtime_env}"
chmod 600 "${runtime_env}"
}
+
+hot_dev_read_or_create_audit_signing_key() {
+ local data_dir=$1
+ local key_file="${data_dir}/.audit-signing.key"
+
+ [[ -n "${data_dir}" ]] || return 1
+ mkdir -p "${data_dir}"
+ if [[ ! -s "${key_file}" ]]; then
+ openssl rand -hex 32 > "${key_file}"
+ chmod 600 "${key_file}"
+ fi
+ tr -d '\r\n' < "${key_file}"
+}
+
+hot_dev_sync_audit_signing_env_file() {
+ local runtime_env=$1
+ local data_dir=$2
+ local signing_key
+
+ [[ -n "${runtime_env}" ]] || return 0
+ [[ -n "${data_dir}" ]] || return 0
+ mkdir -p "$(dirname "${runtime_env}")"
+ if [[ -f "${runtime_env}" ]] && grep -q -E '^PULSE_AUDIT_SIGNING_KEY=' "${runtime_env}"; then
+ return 0
+ fi
+
+ signing_key="$(hot_dev_read_or_create_audit_signing_key "${data_dir}")"
+ {
+ if [[ -f "${runtime_env}" ]]; then
+ cat "${runtime_env}"
+ fi
+ printf "PULSE_AUDIT_SIGNING_KEY='%s'\n" "$(hot_dev_single_quote "${signing_key}")"
+ } > "${runtime_env}.audit.$$"
+ mv "${runtime_env}.audit.$$" "${runtime_env}"
+ chmod 600 "${runtime_env}"
+}
+
+hot_dev_sync_bootstrap_token_file() {
+ local data_dir=$1
+ local explicit_token="${PULSE_E2E_BOOTSTRAP_TOKEN:-}"
+ local token="${explicit_token:-${HOT_DEV_DEFAULT_BOOTSTRAP_TOKEN}}"
+ local token_file="${data_dir}/.bootstrap_token"
+
+ [[ -n "${data_dir}" ]] || return 0
+ [[ -n "${token}" ]] || return 0
+ if [[ -f "${token_file}" ]] && [[ ! -s "${token_file}" ]]; then
+ rm -f "${token_file}"
+ fi
+ if [[ -f "${token_file}" && -z "${explicit_token}" ]]; then
+ return 0
+ fi
+
+ mkdir -p "${data_dir}"
+ printf '%s\n' "${token}" > "${token_file}"
+ chmod 600 "${token_file}"
+}
diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.py
index 76ef312d6f..598045339f 100644
--- a/scripts/release_control/subsystem_lookup_test.py
+++ b/scripts/release_control/subsystem_lookup_test.py
@@ -3585,14 +3585,14 @@ class SubsystemLookupTest(unittest.TestCase):
)
self.assertEqual(
api_match["matched_contract_references"],
- [
- {
- "heading": "## Shared Boundaries",
- "path": "internal/api/access_control_handlers.go",
- "line": 224,
- "heading_line": 109,
- }
- ],
+ [
+ {
+ "heading": "## Shared Boundaries",
+ "path": "internal/api/access_control_handlers.go",
+ "line": 229,
+ "heading_line": 109,
+ }
+ ],
)
organization_match = by_subsystem["organization-settings"]
diff --git a/scripts/tests/test-hot-dev-auth.sh b/scripts/tests/test-hot-dev-auth.sh
index 9899227c8a..d6ede3dc24 100755
--- a/scripts/tests/test-hot-dev-auth.sh
+++ b/scripts/tests/test-hot-dev-auth.sh
@@ -132,11 +132,51 @@ EOF
assert_contains "managed-only sync rewrites auth password hash" "${output}" "PULSE_AUTH_PASS='${HOT_DEV_DEFAULT_AUTH_HASH}'"
}
+test_sync_audit_signing_env_file_restores_missing_key() {
+ local state_dir runtime_env output
+ state_dir="$(make_temp_dir)"
+ runtime_env="${state_dir}/.env"
+
+ cat > "${runtime_env}" <<'EOF'
+# Managed by hot-dev.sh for deterministic dev auth
+PULSE_AUTH_USER='admin'
+PULSE_AUTH_PASS='hash'
+EOF
+
+ output="$(
+ HOT_DEV_AUTH_LIB="${HOT_DEV_AUTH_LIB}" \
+ RUNTIME_ENV_PATH="${runtime_env}" \
+ DATA_DIR="${state_dir}" \
+ bash -lc '
+ source "${HOT_DEV_AUTH_LIB}"
+ hot_dev_sync_audit_signing_env_file "${RUNTIME_ENV_PATH}" "${DATA_DIR}"
+ key_line_count="$(grep -c "^PULSE_AUDIT_SIGNING_KEY=" "${RUNTIME_ENV_PATH}")"
+ key_value="$(grep "^PULSE_AUDIT_SIGNING_KEY=" "${RUNTIME_ENV_PATH}" | cut -d= -f2- | tr -d "\\047")"
+ key_file_value="$(cat "${DATA_DIR}/.audit-signing.key")"
+ mode="$(stat -f "%Lp" "${DATA_DIR}/.audit-signing.key" 2>/dev/null || stat -c "%a" "${DATA_DIR}/.audit-signing.key")"
+ hot_dev_sync_audit_signing_env_file "${RUNTIME_ENV_PATH}" "${DATA_DIR}"
+ key_line_count_after="$(grep -c "^PULSE_AUDIT_SIGNING_KEY=" "${RUNTIME_ENV_PATH}")"
+ printf "key_line_count=%s\n" "${key_line_count}"
+ printf "key_length=%s\n" "${#key_value}"
+ printf "key_matches_file=%s\n" "$([[ "${key_value}" == "${key_file_value}" ]] && printf yes || printf no)"
+ printf "key_line_count_after=%s\n" "${key_line_count_after}"
+ printf "mode=%s\n" "${mode}"
+ '
+ )"
+
+ assert_contains "audit signing sync appends one env key" "${output}" "key_line_count=1"
+ assert_contains "audit signing sync writes a 32-byte hex key" "${output}" "key_length=64"
+ assert_contains "audit signing sync persists the same key to file" "${output}" "key_matches_file=yes"
+ assert_contains "audit signing sync is idempotent" "${output}" "key_line_count_after=1"
+ assert_contains "audit signing key file is private" "${output}" "mode=600"
+}
+
source "${HOT_DEV_AUTH_LIB}"
test_default_auth_contract
test_custom_auth_banner_contract
test_sync_auth_env_file_preserves_non_auth_settings
test_sync_auth_env_file_handles_managed_only_env_under_errexit
+test_sync_audit_signing_env_file_restores_missing_key
if (( failures > 0 )); then
echo "FAIL: ${failures} hot-dev auth assertions failed" >&2
diff --git a/scripts/tests/test-hot-dev-bg.sh b/scripts/tests/test-hot-dev-bg.sh
index 9b39ed3eb2..32c9f7b915 100755
--- a/scripts/tests/test-hot-dev-bg.sh
+++ b/scripts/tests/test-hot-dev-bg.sh
@@ -704,6 +704,42 @@ test_hot_dev_script_ignores_test_only_backend_churn() {
assert_contains "hot-dev watcher suppresses source churn during managed verification" "${output}" 'verify_lock_active'
}
+test_hot_dev_auth_helper_seeds_deterministic_bootstrap_token() {
+ local test_dir output
+ test_dir="$(mktemp -d)"
+ temp_dirs+=("${test_dir}")
+
+ output="$(
+ HOT_DEV_AUTH_PATH="${ROOT_DIR}/scripts/lib/hot-dev-auth.sh" \
+ DATA_DIR="${test_dir}/data" \
+ bash -lc '
+ source "${HOT_DEV_AUTH_PATH}"
+ hot_dev_sync_bootstrap_token_file "${DATA_DIR}"
+ first="$(cat "${DATA_DIR}/.bootstrap_token")"
+ hot_dev_sync_bootstrap_token_file "${DATA_DIR}"
+ second="$(cat "${DATA_DIR}/.bootstrap_token")"
+ PULSE_E2E_BOOTSTRAP_TOKEN="custom-bootstrap-token"
+ hot_dev_sync_bootstrap_token_file "${DATA_DIR}"
+ explicit="$(cat "${DATA_DIR}/.bootstrap_token")"
+ rm -f "${DATA_DIR}/.bootstrap_token"
+ hot_dev_sync_bootstrap_token_file "${DATA_DIR}"
+ third="$(cat "${DATA_DIR}/.bootstrap_token")"
+ mode="$(stat -f "%Lp" "${DATA_DIR}/.bootstrap_token" 2>/dev/null || stat -c "%a" "${DATA_DIR}/.bootstrap_token")"
+ printf "first=%s\n" "${first}"
+ printf "second=%s\n" "${second}"
+ printf "explicit=%s\n" "${explicit}"
+ printf "third=%s\n" "${third}"
+ printf "mode=%s\n" "${mode}"
+ '
+ )"
+
+ assert_contains "hot-dev bootstrap seed uses deterministic default" "${output}" "first=0123456789abcdef0123456789abcdef0123456789abcdef"
+ assert_contains "hot-dev bootstrap seed preserves an existing token" "${output}" "second=0123456789abcdef0123456789abcdef0123456789abcdef"
+ assert_contains "hot-dev bootstrap seed lets e2e override replace an existing token" "${output}" "explicit=custom-bootstrap-token"
+ assert_contains "hot-dev bootstrap seed honors explicit e2e override when creating a token" "${output}" "third=custom-bootstrap-token"
+ assert_contains "hot-dev bootstrap token file is private" "${output}" "mode=600"
+}
+
test_hot_dev_reconciles_agent_reachable_bind_address() {
local output
@@ -1265,6 +1301,57 @@ test_backend_restart_requires_managed_runtime() {
assert_contains "backend restart returns failure without managed runtime" "${output}" "exit_code=1"
}
+test_backend_restart_waits_for_healthy_listener() {
+ local test_dir output
+ test_dir="$(mktemp -d)"
+ temp_dirs+=("${test_dir}")
+ mkdir -p "${test_dir}/tmp"
+ touch "${test_dir}/tmp/hot-dev.restart"
+
+ output="$(
+ HOT_DEV_BG_PATH="${HOT_DEV_BG}" \
+ bash -lc '
+ source "${HOT_DEV_BG_PATH}"
+ ROOT_DIR="'"${test_dir}"'"
+ LOG_FILE="'"${test_dir}"'/hot-dev-bg.log"
+ PULSE_DEV_API_PORT=7655
+ health_counter="'"${test_dir}"'/health-count"
+ listener_counter="'"${test_dir}"'/listener-count"
+ is_running(){ return 0; }
+ managed_session_pid(){ printf "4242\n"; }
+ first_managed_listener_pid(){
+ local count
+ count="$(cat "${listener_counter}" 2>/dev/null || printf "0")"
+ count=$((count + 1))
+ printf "%s\n" "${count}" > "${listener_counter}"
+ if (( count == 1 )); then
+ printf "1111\n"
+ else
+ printf "2222\n"
+ fi
+ }
+ wait_for_managed_listener(){ return 0; }
+ http_status_code(){
+ local count
+ count="$(cat "${health_counter}" 2>/dev/null || printf "0")"
+ count=$((count + 1))
+ printf "%s\n" "${count}" > "${health_counter}"
+ if (( count < 3 )); then
+ printf "000\n"
+ else
+ printf "200\n"
+ fi
+ }
+ sleep(){ :; }
+ restart_backend_bg
+ printf "health_checks=%s\n" "$(cat "${health_counter}")"
+ '
+ )"
+
+ assert_contains "backend restart reports healthy recovery" "${output}" "Managed backend recovered and is healthy on port 7655"
+ assert_contains "backend restart retries health until ready" "${output}" "health_checks=3"
+}
+
test_detects_unmanaged_listeners() {
local frontend_port backend_port status_output start_output
local state_dir
@@ -1332,6 +1419,7 @@ main() {
test_makefile_routes_managed_runtime_through_npm
test_hot_dev_script_advertises_foreground_escape_hatch
test_hot_dev_script_ignores_test_only_backend_churn
+ test_hot_dev_auth_helper_seeds_deterministic_bootstrap_token
test_hot_dev_reconciles_agent_reachable_bind_address
test_hot_dev_health_monitor_probes_api_health
test_hot_dev_bg_script_advertises_managed_entrypoint
@@ -1352,6 +1440,7 @@ main() {
test_clean_mock_alerts_prefers_managed_runtime
test_dev_check_uses_managed_runtime_status
test_backend_restart_requires_managed_runtime
+ test_backend_restart_waits_for_healthy_listener
test_status_without_runtime
test_detects_unmanaged_listeners
diff --git a/tests/integration/tests/16-dev-runtime-recovery.spec.ts b/tests/integration/tests/16-dev-runtime-recovery.spec.ts
index b889b69683..fda397aea6 100644
--- a/tests/integration/tests/16-dev-runtime-recovery.spec.ts
+++ b/tests/integration/tests/16-dev-runtime-recovery.spec.ts
@@ -83,7 +83,7 @@ test.describe.serial('Managed dev runtime recovery', () => {
test.skip(!truthy(process.env.PULSE_E2E_USE_HOT_DEV), 'Runs only against the managed hot-dev runtime');
let blockNextSocket = false;
- await page.routeWebSocket('/ws', async (ws) => {
+ await page.routeWebSocket('**/ws*', async (ws) => {
if (blockNextSocket) {
blockNextSocket = false;
await ws.close({ code: 1013, reason: 'test-stream-interruption' });
diff --git a/tests/integration/tests/17-recovery-layout.spec.ts b/tests/integration/tests/17-recovery-layout.spec.ts
index e3e82dc493..6217fe225f 100644
--- a/tests/integration/tests/17-recovery-layout.spec.ts
+++ b/tests/integration/tests/17-recovery-layout.spec.ts
@@ -199,11 +199,12 @@ test.describe("Recovery desktop layout guards", () => {
await page.goto("/recovery", { waitUntil: "domcontentloaded" });
await expect(page.getByTestId("recovery-page")).toBeVisible();
- const protectedRow = page
- .locator('[data-testid="recovery-page"] table tbody tr')
- .first();
- await expect(protectedRow).toBeVisible();
- await protectedRow.click();
+ const itemFilter = page.getByTestId("recovery-history-item-filter-trigger");
+ await expect(itemFilter).toBeVisible();
+ await itemFilter.click();
+ await page
+ .getByTestId("recovery-history-item-filter-option-res:vm-archive-01")
+ .click();
await expect(
page.getByTestId("recovery-history-item-filter-trigger"),
diff --git a/tests/integration/tests/18-patrol-runtime-state.spec.ts b/tests/integration/tests/18-patrol-runtime-state.spec.ts
index c5841edce5..092a3cdd91 100644
--- a/tests/integration/tests/18-patrol-runtime-state.spec.ts
+++ b/tests/integration/tests/18-patrol-runtime-state.spec.ts
@@ -989,6 +989,7 @@ test.describe("Patrol runtime-state browser contract", () => {
const assistantContext = page.getByLabel("Assistant context");
await expect(assistantContext).toBeVisible();
await expect(assistantContext).toContainText("Patrol run attached");
+ await expect(assistantContext).toContainText("Scoped run run-alert-scoped");
await expect(assistantContext).toContainText(
"Review Patrol runtime failure",
);
diff --git a/tests/integration/tests/helpers.ts b/tests/integration/tests/helpers.ts
index b1f9983cd6..aa856a379e 100644
--- a/tests/integration/tests/helpers.ts
+++ b/tests/integration/tests/helpers.ts
@@ -291,6 +291,10 @@ async function completeSetupWizard(
await bootstrapTokenInput.click();
await bootstrapTokenInput.fill("");
await bootstrapTokenInput.fill(bootstrapToken);
+ if ((await bootstrapTokenInput.inputValue()) !== bootstrapToken) {
+ await bootstrapTokenInput.fill("");
+ await bootstrapTokenInput.pressSequentially(bootstrapToken, { delay: 1 });
+ }
await expect(bootstrapTokenInput).toHaveValue(bootstrapToken);
};
@@ -651,6 +655,55 @@ export async function ensureFirstRunExperience(
completionTarget === "none"
? /\/(settings\/infrastructure|proxmox|nodes|hosts|docker|infrastructure)/
: SETUP_COMPLETION_HANDOFFS[completionTarget].urlPattern;
+ const targetPath =
+ completionTarget === "none"
+ ? "/settings/infrastructure"
+ : SETUP_COMPLETION_HANDOFFS[completionTarget].path;
+
+ const ensureTargetVisible = async () => {
+ if (completionTarget !== "sources") {
+ return true;
+ }
+ const addDialog = page.getByRole("dialog", {
+ name: "Add infrastructure",
+ });
+ if (await addDialog.isVisible().catch(() => false)) {
+ return true;
+ }
+ if (/\/settings\/infrastructure$/.test(page.url())) {
+ const addButton = page.getByRole("button", {
+ name: "Add infrastructure",
+ exact: true,
+ });
+ if (await addButton.isVisible().catch(() => false)) {
+ await addButton.click({ timeout: 10_000 });
+ }
+ }
+ return addDialog
+ .waitFor({ state: "visible", timeout: 15_000 })
+ .then(() => true)
+ .catch(() => false);
+ };
+
+ const completeViaAPIFallback = async () => {
+ const fallbackSetup = await completeFirstRunViaAPI(page, bootstrapToken);
+ rememberSetupCredentials(fallbackSetup);
+ if (!(await authenticateWithPrimaryAPIToken(page))) {
+ await login(page, {
+ ...E2E_CREDENTIALS,
+ ...fallbackSetup,
+ });
+ }
+ await page.goto(targetPath, { waitUntil: "domcontentloaded" });
+ await waitForAppShell(page);
+ await expect(page).toHaveURL(firstRunLandingPattern);
+ await expect(page.getByRole("main", { name: "Pulse Setup Wizard" })).not.toBeVisible({
+ timeout: 10_000,
+ });
+ if (!(await ensureTargetVisible())) {
+ throw new Error(`First-run setup did not render target UI at ${page.url()}`);
+ }
+ };
if (completionTarget === "none") {
const setup = await completeFirstRunViaAPI(page, bootstrapToken);
@@ -727,6 +780,9 @@ export async function ensureFirstRunExperience(
await expect(page).toHaveURL(firstRunLandingPattern);
}
if (!(await setupWizard.isVisible({ timeout: 500 }).catch(() => false))) {
+ if (!(await ensureTargetVisible())) {
+ await completeViaAPIFallback();
+ }
break;
}
const status = await getSecurityStatus(page).catch(() => ({}));
@@ -735,22 +791,7 @@ export async function ensureFirstRunExperience(
break;
}
if (setupAttempt === 1) {
- const fallbackSetup = await completeFirstRunViaAPI(page, bootstrapToken);
- rememberSetupCredentials(fallbackSetup);
- if (!(await authenticateWithPrimaryAPIToken(page))) {
- await login(page, {
- ...E2E_CREDENTIALS,
- ...fallbackSetup,
- });
- }
- const targetPath =
- completionTarget === "none"
- ? "/settings/infrastructure"
- : SETUP_COMPLETION_HANDOFFS[completionTarget].path;
- await page.goto(targetPath, { waitUntil: "domcontentloaded" });
- await waitForAppShell(page);
- await expect(page).toHaveURL(firstRunLandingPattern);
- await expect(setupWizard).not.toBeVisible({ timeout: 10_000 });
+ await completeViaAPIFallback();
break;
}
await page.goto("/");