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 cluster install dismissal keyboard-safe across async results

pulse-triage[bot]1ec45d9743ca
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 8311a06f92..598722b1e5 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -15,6 +15,19 @@
## Purpose
+### Cluster installation keyboard continuity
+
+`ClusterAgentDeployDialog` keeps one mounted dismissal button while loading,
+selection, checking, installation and final results change its label. A focused
+Install action hands focus to that button before it disappears, without moving
+scroll; asynchronous completion never steals focus. Close/Cancel and the scoped
+installer hand-off remain available without starting another install, and
+closing an accepted run still does not cancel it. This is keyboard continuity,
+not a change to job admission, token scope or native installation acceptance.
+`frontend-modern/src/components/Settings/__tests__/ClusterAgentDeployDialog.test.tsx`
+pins delayed candidate responses, safe fallbacks and both successful and failed
+terminal projections alongside the existing installed-only-after-reporting flow.
+
### Source-record lookup preserves report admission
Host and Docker report admission still performs canonical host-view matching
diff --git a/frontend-modern/src/components/Settings/ClusterAgentDeployDialog.tsx b/frontend-modern/src/components/Settings/ClusterAgentDeployDialog.tsx
index 9f2335b62f..369b60e1fe 100644
--- a/frontend-modern/src/components/Settings/ClusterAgentDeployDialog.tsx
+++ b/frontend-modern/src/components/Settings/ClusterAgentDeployDialog.tsx
@@ -128,6 +128,7 @@ export const ClusterAgentDeployDialog: Component<ClusterAgentDeployDialogProps>
const [selected, setSelected] = createSignal<ReadonlySet<string>>(new Set());
const [progress, setProgress] = createSignal<Record<string, ClusterAgentDeployNodeProgress>>({});
const [failure, setFailure] = createSignal('');
+ let dismissButton: HTMLButtonElement | undefined;
// A run keeps going after the dialog closes. The install continues on the
// server, and abandoning the browser side mid-run would skip starting the
@@ -493,24 +494,35 @@ export const ClusterAgentDeployDialog: Component<ClusterAgentDeployDialogProps>
Use the installer instead
</Button>
</Show>
+ {/* Keep the focused dismissal control mounted through async phase changes. */}
+ <Button
+ ref={(element) => {
+ dismissButton = element;
+ }}
+ type="button"
+ variant="outline"
+ onClick={props.onClose}
+ >
+ {phase() === 'select' ? 'Cancel' : 'Close'}
+ </Button>
<Show when={phase() === 'select'}>
- <Button type="button" variant="outline" onClick={props.onClose}>
- Cancel
- </Button>
<Button
type="button"
variant="primary"
disabled={selectedCount() === 0}
- onClick={() => void install()}
+ onClick={(event) => {
+ // The install action disappears while its run continues. Hand
+ // keyboard focus to the stable control, without moving scroll
+ // or stealing focus when this action was not focused.
+ if (document.activeElement === event.currentTarget) {
+ dismissButton?.focus({ preventScroll: true });
+ }
+ void install();
+ }}
>
{selectedCount() === 1 ? 'Install on 1 node' : `Install on ${selectedCount()} nodes`}
</Button>
</Show>
- <Show when={phase() !== 'select'}>
- <Button type="button" variant="outline" onClick={props.onClose}>
- Close
- </Button>
- </Show>
</div>
</Card>
</Dialog>
diff --git a/frontend-modern/src/components/Settings/__tests__/ClusterAgentDeployDialog.test.tsx b/frontend-modern/src/components/Settings/__tests__/ClusterAgentDeployDialog.test.tsx
index 321346bb79..e7bc398ace 100644
--- a/frontend-modern/src/components/Settings/__tests__/ClusterAgentDeployDialog.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/ClusterAgentDeployDialog.test.tsx
@@ -45,6 +45,16 @@ const job = (
targets: ClusterDeployJob['targets'],
): ClusterDeployJob => ({ id, clusterId: 'homelab', status, targets });
+const deferred = <T,>() => {
+ let resolve!: (value: T) => void;
+ let reject!: (error: Error) => void;
+ const promise = new Promise<T>((accept, fail) => {
+ resolve = accept;
+ reject = fail;
+ });
+ return { promise, resolve, reject };
+};
+
const renderDialog = (props: Partial<Parameters<typeof ClusterAgentDeployDialog>[0]> = {}) => {
const onClose = vi.fn();
const onUseInstaller = vi.fn();
@@ -69,6 +79,116 @@ describe('ClusterAgentDeployDialog', () => {
});
afterEach(() => cleanup());
+ it('keeps the focused Close control when loaded candidates change its label to Cancel', async () => {
+ const load = deferred<ClusterDeployCandidates>();
+ api.getCandidates.mockReturnValue(load.promise);
+ const { onClose } = renderDialog();
+ const dismiss = screen.getByRole('button', { name: 'Close' });
+ dismiss.focus();
+ load.resolve(candidates());
+
+ await waitFor(() => expect(screen.getByRole('button', { name: 'Cancel' })).toBe(dismiss));
+ expect(dismiss).toHaveFocus();
+ fireEvent.click(dismiss);
+ expect(onClose).toHaveBeenCalledTimes(1);
+ expect(api.createPreflight).not.toHaveBeenCalled();
+ });
+
+ it.each(['offline', 'ambiguous'] as const)(
+ 'keeps dismissal focus when loading ends in the %s installer fallback',
+ async (result) => {
+ const load = deferred<ClusterDeployCandidates>();
+ api.getCandidates.mockReturnValue(load.promise);
+ const { onClose, onUseInstaller } = renderDialog();
+ const dismiss = screen.getByRole('button', { name: 'Close' });
+ dismiss.focus();
+ if (result === 'offline') load.resolve(candidates({ sourceAgents: [] }));
+ else load.reject(new Error('More than one Proxmox connection reports this cluster.'));
+
+ const manual = await screen.findByRole('button', { name: 'Use the installer instead' });
+ expect(screen.getByRole('button', { name: 'Close' })).toBe(dismiss);
+ expect(dismiss).toHaveFocus();
+ fireEvent.click(manual);
+ expect(onClose).toHaveBeenCalledTimes(1);
+ expect(onUseInstaller).toHaveBeenCalledTimes(1);
+ expect(api.createPreflight).not.toHaveBeenCalled();
+ },
+ );
+
+ it.each(['succeeded', 'failed'] as const)(
+ 'hands focused Install to stable dismissal through checking, installation and %s',
+ async (outcome) => {
+ const check = deferred<ClusterDeployJob>();
+ const completion = deferred<ClusterDeployJob>();
+ api.getCandidates.mockResolvedValueOnce(candidates()).mockResolvedValue(
+ candidates({
+ nodes: candidates().nodes!.map((node) =>
+ node.nodeId === 'n-delly2' ? { ...node, hasAgent: true, deployable: false } : node,
+ ),
+ }),
+ );
+ api.createPreflight.mockResolvedValue({ preflightId: 'focus-pf', status: 'running' });
+ api.getPreflight.mockReturnValue(check.promise);
+ api.createJob.mockResolvedValue({
+ jobId: 'focus-job',
+ acceptedTargets: ['n-delly2'],
+ skippedTargets: [],
+ });
+ api.getJob.mockReturnValue(completion.promise);
+ const { onInstalled } = renderDialog({ preselectNodeName: 'delly2' });
+ const install = await screen.findByRole('button', { name: 'Install on 1 node' });
+ const dismiss = screen.getByRole('button', { name: 'Cancel' });
+ install.focus();
+ fireEvent.click(install);
+ expect(screen.getByRole('button', { name: 'Close' })).toBe(dismiss);
+ expect(dismiss).toHaveFocus();
+
+ await waitFor(() => expect(api.getPreflight).toHaveBeenCalledTimes(1));
+ check.resolve(
+ job('focus-pf', 'succeeded', [
+ {
+ id: 'focus-check',
+ nodeId: 'n-delly2',
+ nodeName: 'delly2',
+ nodeIP: '192.168.0.111',
+ status: 'ready',
+ },
+ ]),
+ );
+ await waitFor(() => expect(api.getJob).toHaveBeenCalledTimes(1));
+ expect(dismiss).toHaveFocus();
+ completion.resolve(
+ job('focus-job', outcome, [
+ {
+ id: 'focus-target',
+ nodeId: 'n-delly2',
+ nodeName: 'delly2',
+ nodeIP: '192.168.0.111',
+ status: outcome === 'succeeded' ? 'succeeded' : 'failed_permanent',
+ },
+ ]),
+ );
+ await screen.findByText(outcome === 'succeeded' ? 'Reporting' : 'Failed');
+ expect(screen.getByRole('button', { name: 'Close' })).toBe(dismiss);
+ expect(dismiss).toHaveFocus();
+ expect(api.createJob).toHaveBeenCalledTimes(1);
+ expect(onInstalled).toHaveBeenCalledTimes(outcome === 'succeeded' ? 1 : 0);
+ },
+ );
+
+ it('does not steal focus for an install action that was not focused', async () => {
+ api.getCandidates.mockResolvedValue(candidates());
+ api.createPreflight.mockRejectedValue(new Error('Source agent is not connected'));
+ renderDialog({ preselectNodeName: 'delly2' });
+ const install = await screen.findByRole('button', { name: 'Install on 1 node' });
+ const dismiss = screen.getByRole('button', { name: 'Cancel' });
+ dismiss.focus();
+ fireEvent.click(install);
+ await screen.findByRole('alert');
+ expect(dismiss).toHaveFocus();
+ expect(api.createJob).not.toHaveBeenCalled();
+ });
+
it('lists uncovered nodes, preselects the installable ones, and explains the rest', async () => {
api.getCandidates.mockResolvedValue(candidates());
renderDialog();