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.

Fix remembered login and Patrol readiness copy

rcourtman64f0711f5122
diff --git a/frontend-modern/src/components/Login.tsx b/frontend-modern/src/components/Login.tsx
index 117af2707d..e3cd5351f1 100644
--- a/frontend-modern/src/components/Login.tsx
+++ b/frontend-modern/src/components/Login.tsx
@@ -1,6 +1,7 @@
import { Component, createSignal, Show, For, onMount, lazy, Suspense } from 'solid-js';
import { logger } from '@/utils/logger';
import { apiClient, apiFetchJSON } from '@/utils/apiClient';
+import { STORAGE_KEYS } from '@/utils/localStorage';
import Globe from 'lucide-solid/icons/globe';
import Key from 'lucide-solid/icons/key';
import { LoadingSpinner } from '@/components/shared/LoadingSpinner';
@@ -15,6 +16,39 @@ interface LoginProps {
import type { SecurityStatus, SSOProviderInfo } from '@/types/config';
+function getBrowserStorage(kind: 'localStorage' | 'sessionStorage'): Storage | undefined {
+ if (typeof window === 'undefined') return undefined;
+ try {
+ return window[kind];
+ } catch {
+ return undefined;
+ }
+}
+
+function readRememberedUsername(): string {
+ const storage = getBrowserStorage('localStorage');
+ if (!storage) return '';
+ try {
+ return (storage.getItem(STORAGE_KEYS.REMEMBERED_LOGIN_USERNAME) || '').trim();
+ } catch {
+ return '';
+ }
+}
+
+function persistRememberedUsername(username: string, remember: boolean): void {
+ const storage = getBrowserStorage('localStorage');
+ if (!storage) return;
+ try {
+ if (remember) {
+ storage.setItem(STORAGE_KEYS.REMEMBERED_LOGIN_USERNAME, username);
+ } else {
+ storage.removeItem(STORAGE_KEYS.REMEMBERED_LOGIN_USERNAME);
+ }
+ } catch {
+ // Ignore storage failures (private browsing, quota, managed browsers).
+ }
+}
+
export const Login: Component<LoginProps> = (props) => {
const [username, setUsername] = createSignal('');
const [password, setPassword] = createSignal('');
@@ -67,6 +101,12 @@ export const Login: Component<LoginProps> = (props) => {
};
onMount(async () => {
+ const rememberedUsername = readRememberedUsername();
+ if (rememberedUsername) {
+ setUsername(rememberedUsername);
+ setRememberMe(true);
+ }
+
const params = new URLSearchParams(window.location.search);
// Handle OIDC callback
@@ -185,10 +225,11 @@ export const Login: Component<LoginProps> = (props) => {
if (response.ok && data.success) {
// Credentials are valid; persist username for convenience and rely on session cookie
try {
- sessionStorage.setItem('pulse_auth_user', usernameValue);
+ getBrowserStorage('sessionStorage')?.setItem(STORAGE_KEYS.AUTH_USER, usernameValue);
} catch (_err) {
// Ignore storage failures (private browsing, etc.)
}
+ persistRememberedUsername(usernameValue, rememberMe());
props.onLogin();
} else if (response.status === 403) {
// Account is locked
@@ -200,7 +241,7 @@ export const Login: Component<LoginProps> = (props) => {
setError(data.message || 'Account temporarily locked due to too many failed attempts.');
}
// Clear the input fields
- setUsername('');
+ if (!rememberMe()) setUsername('');
setPassword('');
} else if (response.status === 429) {
// Rate limited
@@ -217,7 +258,7 @@ export const Login: Component<LoginProps> = (props) => {
setError(data.message || 'Invalid username or password');
}
// Clear the input fields
- setUsername('');
+ if (!rememberMe()) setUsername('');
setPassword('');
} else {
setError(data.message || 'Server error. Please try again.');
diff --git a/frontend-modern/src/components/__tests__/Login.test.tsx b/frontend-modern/src/components/__tests__/Login.test.tsx
index 22d45dbf8b..64888c8699 100644
--- a/frontend-modern/src/components/__tests__/Login.test.tsx
+++ b/frontend-modern/src/components/__tests__/Login.test.tsx
@@ -1,7 +1,8 @@
import { afterEach, describe, expect, it, vi, beforeEach } from 'vitest';
-import { cleanup, render, screen } from '@solidjs/testing-library';
+import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
import { Login } from '@/components/Login';
import loginSource from '@/components/Login.tsx?raw';
+import { STORAGE_KEYS } from '@/utils/localStorage';
// Mock fetch globally
const mockFetch = vi.fn();
@@ -23,6 +24,7 @@ Object.defineProperty(window, 'matchMedia', {
});
// Mock localStorage
+let mockLocalStorageData: Record<string, string>;
const mockLocalStorage = {
getItem: vi.fn(),
setItem: vi.fn(),
@@ -36,8 +38,23 @@ window.history.replaceState = vi.fn();
describe('Login', () => {
beforeEach(() => {
+ mockLocalStorageData = {};
mockFetch.mockReset();
mockLocalStorage.getItem.mockReset();
+ mockLocalStorage.getItem.mockImplementation((key: string) => mockLocalStorageData[key] ?? null);
+ mockLocalStorage.setItem.mockReset();
+ mockLocalStorage.setItem.mockImplementation((key: string, value: string) => {
+ mockLocalStorageData[key] = value;
+ });
+ mockLocalStorage.removeItem.mockReset();
+ mockLocalStorage.removeItem.mockImplementation((key: string) => {
+ delete mockLocalStorageData[key];
+ });
+ mockLocalStorage.clear.mockReset();
+ mockLocalStorage.clear.mockImplementation(() => {
+ mockLocalStorageData = {};
+ });
+ window.sessionStorage.clear();
// Default mock for security status
mockFetch.mockResolvedValue({
ok: true,
@@ -173,6 +190,91 @@ describe('Login', () => {
expect(screen.getAllByText('demo')).toHaveLength(2);
});
+ it('restores the remembered username without storing a password', async () => {
+ mockLocalStorageData[STORAGE_KEYS.REMEMBERED_LOGIN_USERNAME] = 'johannes';
+ const mockOnLogin = vi.fn();
+ const securityStatus = {
+ hasAuthentication: true,
+ hideLocalLogin: false,
+ ssoEnabled: false,
+ };
+
+ render(() => (
+ <Login onLogin={mockOnLogin} hasAuth={true} securityStatus={securityStatus as any} />
+ ));
+
+ const usernameInput = (await screen.findByPlaceholderText('Username')) as HTMLInputElement;
+ expect(usernameInput.value).toBe('johannes');
+ expect(screen.getByLabelText('Remember me')).toBeChecked();
+ expect((screen.getByPlaceholderText('Password') as HTMLInputElement).value).toBe('');
+ });
+
+ it('stores the username after a successful remembered login', async () => {
+ const mockOnLogin = vi.fn();
+ mockFetch.mockResolvedValueOnce(
+ new Response(JSON.stringify({ success: true }), {
+ status: 200,
+ headers: { 'Content-Type': 'application/json' },
+ }),
+ );
+ const securityStatus = {
+ hasAuthentication: true,
+ hideLocalLogin: false,
+ ssoEnabled: false,
+ };
+
+ render(() => (
+ <Login onLogin={mockOnLogin} hasAuth={true} securityStatus={securityStatus as any} />
+ ));
+
+ fireEvent.input(await screen.findByPlaceholderText('Username'), {
+ target: { value: 'johannes' },
+ });
+ fireEvent.input(screen.getByPlaceholderText('Password'), { target: { value: 'secret' } });
+ fireEvent.click(screen.getByLabelText('Remember me'));
+ fireEvent.click(screen.getByRole('button', { name: /sign in to pulse/i }));
+
+ await waitFor(() => expect(mockOnLogin).toHaveBeenCalledOnce());
+ expect(window.sessionStorage.getItem(STORAGE_KEYS.AUTH_USER)).toBe('johannes');
+ expect(mockLocalStorage.setItem).toHaveBeenCalledWith(
+ STORAGE_KEYS.REMEMBERED_LOGIN_USERNAME,
+ 'johannes',
+ );
+ });
+
+ it('clears a previously remembered username after a successful non-remembered login', async () => {
+ mockLocalStorageData[STORAGE_KEYS.REMEMBERED_LOGIN_USERNAME] = 'old-user';
+ const mockOnLogin = vi.fn();
+ mockFetch.mockResolvedValueOnce(
+ new Response(JSON.stringify({ success: true }), {
+ status: 200,
+ headers: { 'Content-Type': 'application/json' },
+ }),
+ );
+ const securityStatus = {
+ hasAuthentication: true,
+ hideLocalLogin: false,
+ ssoEnabled: false,
+ };
+
+ render(() => (
+ <Login onLogin={mockOnLogin} hasAuth={true} securityStatus={securityStatus as any} />
+ ));
+
+ const rememberCheckbox = await screen.findByLabelText('Remember me');
+ fireEvent.click(rememberCheckbox);
+ fireEvent.input(screen.getByPlaceholderText('Username'), {
+ target: { value: 'new-user' },
+ });
+ fireEvent.input(screen.getByPlaceholderText('Password'), { target: { value: 'secret' } });
+ fireEvent.click(screen.getByRole('button', { name: /sign in to pulse/i }));
+
+ await waitFor(() => expect(mockOnLogin).toHaveBeenCalledOnce());
+ expect(mockLocalStorage.removeItem).toHaveBeenCalledWith(
+ STORAGE_KEYS.REMEMBERED_LOGIN_USERNAME,
+ );
+ });
+
it('routes login loading indicators through the shared LoadingSpinner primitive', () => {
expect(loginSource).toContain("from '@/components/shared/LoadingSpinner'");
expect(loginSource).toContain('<LoadingSpinner size="lg" tone="info"');
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx
index 9441d03f3c..dec13b1380 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceBanners.tsx
@@ -164,8 +164,8 @@ export function PatrolIntelligenceBanners(props: { state: PatrolIntelligenceStat
}`}
>
{state.patrolReadiness()?.status === 'not_ready'
- ? 'Provider issue'
- : 'Provider warning'}
+ ? 'Patrol model issue'
+ : 'Patrol model warning'}
</p>
<p
class={`text-xs ${
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
index 5c051f5b11..ae78d6343a 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceHeader.tsx
@@ -100,12 +100,12 @@ export function PatrolIntelligenceHeader(props: { state: PatrolIntelligenceState
fallback={
<A
href={providerSetupAction.href}
- aria-label={`Fix Patrol provider: ${state.triggerPatrolDisabledReason() || 'Provider needs attention'}`}
+ aria-label={`Check Patrol model: ${state.triggerPatrolDisabledReason() || 'Patrol model needs attention'}`}
title={state.triggerPatrolDisabledReason() || 'Open Provider & Models'}
class={className}
>
<SettingsIcon class="w-4 h-4" />
- Fix provider
+ Check model
</A>
}
>
diff --git a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
index 612e0ac72e..6d0c8808a2 100644
--- a/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
+++ b/frontend-modern/src/features/patrol/PatrolIntelligenceWorkspace.tsx
@@ -301,8 +301,10 @@ export function PatrolIntelligenceWorkspace(props: { state: PatrolIntelligenceSt
<div class="rounded-md border border-border bg-surface-alt p-4">
<div class="flex flex-wrap items-start justify-between gap-3">
<div class="min-w-0 max-w-2xl">
- <h3 class="text-sm font-semibold text-base-content">Provider needs attention</h3>
- <p class="mt-2 text-xs text-muted">Issue: {setupReason()}</p>
+ <h3 class="text-sm font-semibold text-base-content">
+ Patrol model needs attention
+ </h3>
+ <p class="mt-2 text-xs text-muted">Patrol check: {setupReason()}</p>
</div>
<ButtonLink href={setupAction.href} variant="primary" size="sm" class="gap-1.5">
<SettingsIcon class="h-4 w-4" aria-hidden="true" />
diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.test.ts b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.test.ts
index 696ef908e5..3ab85cf58a 100644
--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.test.ts
+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceHeader.test.ts
@@ -77,8 +77,8 @@ describe('PatrolIntelligenceHeader', () => {
expect(headerSource).toContain("state.patrolReadiness()?.status === 'not_ready'");
expect(headerSource).toContain('getPatrolProviderSettingsAction');
expect(headerSource).toContain('providerSetupAction.href');
- expect(headerSource).toContain('Fix provider');
- expect(headerSource).toContain('Fix Patrol provider:');
+ expect(headerSource).toContain('Check model');
+ expect(headerSource).toContain('Check Patrol model:');
expect(headerSource).toContain('runButtonDisabled');
expect(headerSource).not.toContain('!state.canTriggerPatrol() ||');
});
diff --git a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceWorkspace.test.ts b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceWorkspace.test.ts
index fb634ad57e..62a8da4a3f 100644
--- a/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceWorkspace.test.ts
+++ b/frontend-modern/src/features/patrol/__tests__/PatrolIntelligenceWorkspace.test.ts
@@ -63,14 +63,14 @@ describe('PatrolIntelligenceWorkspace trust strip', () => {
'Open work Patrol can ' +
'watch, investigate, ask you to approve, or record under your Patrol mode.';
expect(workspaceSource).not.toContain(removedAllModeCopy);
- expect(workspaceSource).toContain('Provider needs attention');
- expect(workspaceSource).toContain('Issue:');
+ expect(workspaceSource).toContain('Patrol model needs attention');
+ expect(workspaceSource).toContain('Patrol check:');
expect(workspaceSource).toContain('getPatrolProviderSettingsAction');
expect(workspaceSource).toContain('<Show when={!isSetupOnly()}>');
expect(workspaceSource).not.toContain('showControls={!state.selectedRun() && !isSetupOnly()}');
- expect(PATROL_WORKSPACE_SETUP_TITLE).toBe('Fix provider');
+ expect(PATROL_WORKSPACE_SETUP_TITLE).toBe('Check Patrol model');
expect(PATROL_WORKSPACE_SETUP_DESCRIPTION).toBe(
- 'Open Provider & Models, then run Patrol from this page.',
+ 'Provider checks can pass while Patrol still needs a tool-call check. Open Provider & Models, then click Check Patrol model.',
);
expect(PATROL_WORKSPACE_QUEUE_TITLE).toBe('Open work');
expect(workspaceSource).not.toContain('Current Patrol findings');
diff --git a/frontend-modern/src/features/patrol/__tests__/patrolCommercialBoundary.test.ts b/frontend-modern/src/features/patrol/__tests__/patrolCommercialBoundary.test.ts
index 824f78a215..5af62b5965 100644
--- a/frontend-modern/src/features/patrol/__tests__/patrolCommercialBoundary.test.ts
+++ b/frontend-modern/src/features/patrol/__tests__/patrolCommercialBoundary.test.ts
@@ -58,7 +58,7 @@ describe('patrol commercial boundary', () => {
"state.patrolReadiness()?.status !== 'not_ready'",
);
expect(patrolIntelligenceBannersSource).toContain('<Show when={shouldShowReadinessAction()}>');
- expect(patrolIntelligenceHeaderSource).toContain('Fix provider');
+ expect(patrolIntelligenceHeaderSource).toContain('Check model');
});
it('does not carry the removed patrol configuration panel chrome', () => {
diff --git a/frontend-modern/src/features/patrol/patrolControlPresentation.ts b/frontend-modern/src/features/patrol/patrolControlPresentation.ts
index b820d6da7a..e4ea9788b3 100644
--- a/frontend-modern/src/features/patrol/patrolControlPresentation.ts
+++ b/frontend-modern/src/features/patrol/patrolControlPresentation.ts
@@ -39,10 +39,10 @@ export const PATROL_WORKSPACE_HISTORY_DESCRIPTION = 'Past checks and what Patrol
export const PATROL_WORKSPACE_RUN_RECORD_DESCRIPTION = 'What Patrol found during this run.';
-export const PATROL_WORKSPACE_SETUP_TITLE = 'Fix provider';
+export const PATROL_WORKSPACE_SETUP_TITLE = 'Check Patrol model';
export const PATROL_WORKSPACE_SETUP_DESCRIPTION =
- 'Open Provider & Models, then run Patrol from this page.';
+ 'Provider checks can pass while Patrol still needs a tool-call check. Open Provider & Models, then click Check Patrol model.';
export const PATROL_WORKSPACE_QUEUE_TITLE = 'Open work';
diff --git a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
index 768c3e23ee..6e488fecc8 100644
--- a/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
+++ b/frontend-modern/src/pages/__tests__/AIIntelligence.test.tsx
@@ -753,13 +753,15 @@ describe('AIIntelligence entitlement gating', () => {
render(() => <AIIntelligence />);
await waitFor(() => {
- expect(screen.getByRole('heading', { name: 'Fix provider' })).toBeInTheDocument();
+ expect(screen.getByRole('heading', { name: 'Check Patrol model' })).toBeInTheDocument();
});
expect(
- screen.getByText('Open Provider & Models, then run Patrol from this page.'),
+ screen.getByText(
+ 'Provider checks can pass while Patrol still needs a tool-call check. Open Provider & Models, then click Check Patrol model.',
+ ),
).toBeInTheDocument();
expect(
- screen.getByText(/Issue:\s*Selected model cannot run Patrol tools\./),
+ screen.getByText(/Patrol check:\s*Selected model cannot run Patrol tools\./),
).toBeInTheDocument();
expect(
screen.queryByText(
@@ -816,7 +818,7 @@ describe('AIIntelligence entitlement gating', () => {
render(() => <AIIntelligence />);
await waitFor(() => {
- expect(screen.getByText('Provider warning')).toBeInTheDocument();
+ expect(screen.getByText('Patrol model warning')).toBeInTheDocument();
});
expect(screen.queryByText('Patrol readiness warning')).not.toBeInTheDocument();
const runButtons = screen.getAllByRole('button', { name: /Run Patrol/i });
@@ -1847,20 +1849,24 @@ describe('AIIntelligence entitlement gating', () => {
render(() => <AIIntelligence />);
await waitFor(() => {
- expect(screen.getByRole('heading', { name: 'Fix provider' })).toBeInTheDocument();
+ expect(screen.getByRole('heading', { name: 'Check Patrol model' })).toBeInTheDocument();
});
expect(
screen.queryByText(/1 Patrol runtime issue · health score 60\/100/),
).not.toBeInTheDocument();
expect(
- screen.getByText('Open Provider & Models, then run Patrol from this page.'),
+ screen.getByText(
+ 'Provider checks can pass while Patrol still needs a tool-call check. Open Provider & Models, then click Check Patrol model.',
+ ),
+ ).toBeInTheDocument();
+ expect(
+ screen.getByRole('heading', { name: 'Patrol model needs attention' }),
).toBeInTheDocument();
- expect(screen.getByRole('heading', { name: 'Provider needs attention' })).toBeInTheDocument();
expect(
screen.queryByText('Fix the provider connection, then Patrol can check infrastructure.'),
).not.toBeInTheDocument();
- expect(screen.getByText('Issue: Provider billing or quota issue')).toBeInTheDocument();
+ expect(screen.getByText('Patrol check: Provider billing or quota issue')).toBeInTheDocument();
expect(screen.queryByText('Patrol setup issue')).not.toBeInTheDocument();
expect(screen.queryByText('Patrol readiness issue')).not.toBeInTheDocument();
expect(screen.getByRole('link', { name: 'Open Provider & Models' })).toHaveAttribute(
@@ -1946,10 +1952,10 @@ describe('AIIntelligence entitlement gating', () => {
render(() => <AIIntelligence />);
await waitFor(() => {
- expect(screen.getByText('Provider issue')).toBeInTheDocument();
+ expect(screen.getByText('Patrol model issue')).toBeInTheDocument();
});
expect(screen.getByRole('heading', { name: 'Open work' })).toBeInTheDocument();
- const providerActions = screen.getAllByRole('link', { name: /Fix Patrol provider/i });
+ const providerActions = screen.getAllByRole('link', { name: /Check Patrol model/i });
expect(providerActions.length).toBeGreaterThan(0);
expect(providerActions[0]).toHaveAttribute('href', '/settings/pulse-intelligence/provider');
expect(screen.queryByRole('link', { name: 'Open Provider & Models' })).not.toBeInTheDocument();
diff --git a/frontend-modern/src/useAppRuntimeState.ts b/frontend-modern/src/useAppRuntimeState.ts
index aa1555c38f..b7210354e5 100644
--- a/frontend-modern/src/useAppRuntimeState.ts
+++ b/frontend-modern/src/useAppRuntimeState.ts
@@ -97,7 +97,7 @@ export const useAppRuntimeState = () => {
}
try {
- return Boolean(window.sessionStorage.getItem('pulse_auth_user'));
+ return Boolean(window.sessionStorage.getItem(STORAGE_KEYS.AUTH_USER));
} catch {
return false;
}
diff --git a/frontend-modern/src/utils/apiClient.ts b/frontend-modern/src/utils/apiClient.ts
index ba181e54e6..8a47da47ac 100644
--- a/frontend-modern/src/utils/apiClient.ts
+++ b/frontend-modern/src/utils/apiClient.ts
@@ -5,6 +5,7 @@ import { logger } from '@/utils/logger';
import { STORAGE_KEYS } from '@/utils/localStorage';
const AUTH_STORAGE_KEY = STORAGE_KEYS.AUTH;
+const AUTH_USER_STORAGE_KEY = STORAGE_KEYS.AUTH_USER;
const ORG_STORAGE_KEY = STORAGE_KEYS.ORG_ID;
const ORG_HEADER_NAME = 'X-Pulse-Org-ID';
const ORG_COOKIE_NAME = 'pulse_org_id';
@@ -515,7 +516,7 @@ class ApiClient {
const storage = getSessionStorage();
if (!storage) return;
try {
- storage.removeItem('pulse_auth_user');
+ storage.removeItem(AUTH_USER_STORAGE_KEY);
} catch {
// Ignore storage quota errors
}
diff --git a/frontend-modern/src/utils/localStorage.ts b/frontend-modern/src/utils/localStorage.ts
index 74b69f6733..f7b6f49219 100644
--- a/frontend-modern/src/utils/localStorage.ts
+++ b/frontend-modern/src/utils/localStorage.ts
@@ -147,6 +147,8 @@ export function createLocalStorageStringSignal(
export const STORAGE_KEYS = {
// Authentication
AUTH: 'pulse_auth',
+ AUTH_USER: 'pulse_auth_user',
+ REMEMBERED_LOGIN_USERNAME: 'pulse_remembered_login_username',
ORG_ID: 'pulse_org_id',
SETUP_CREDENTIALS: 'pulse_setup_credentials',
SETUP_HANDOFF: 'pulse_setup_handoff',