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.

Align AI enablement with secure quickstart state

rcourtman8b667654d62f
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index b14d740942..dcbe5608b3 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -133,6 +133,10 @@ management, and fleet control surfaces.
authority for Patrol quickstart bootstrap, so lifecycle flows must not
reintroduce anonymous bootstrap identity or tenant-local commercial-owner
surrogates when they traverse those shared handlers.
+ The shared installation-scoped `activation.enc` path is that authority:
+ tenant-local lifecycle routes may reuse it, but they must not fork per-org
+ activation caches, alternate installation-token stores, or competing
+ quickstart-owner identity.
2. Add or change update continuity and persisted-version handoff through `internal/agentupdate/`.
3. Add or change runtime-side Unified Agent startup, first-report assembly, and enroll/runtime continuity through `internal/hostagent/`.
Proxmox host-agent setup must treat local `proxmox-registered` markers as a cache, not authority: before skipping token setup or node repair, `internal/hostagent/proxmox_setup.go` must revalidate the current type and candidate hosts against Pulse through the canonical auto-register contract.
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index a5184f7ed7..e9e545d362 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -138,6 +138,11 @@ Public-facing copy that reflects those runtime fields must therefore speak in
Patrol quickstart runs on activated or trial-backed installs and Patrol-only
no-key activation, not in generic AI credits, anonymous Community bootstrap,
or a promise of full hosted chat.
+That same runtime-backed contract now governs AI settings enablement too:
+quickstart-ready installs may enable Patrol directly without opening provider
+setup, while activation-required or offline quickstart states must surface one
+canonical blocked reason and fall back to activation-or-BYOK guidance instead
+of inferring readiness from provider model catalogs or local credit counters.
That same provider-model contract applies to the chat explore pre-pass in
`internal/ai/chat/service_explore.go`: any runtime model that is valid for the
main chat execution path, including `quickstart:minimax-2.5m`, must resolve
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 62a1cd9157..2a55a59a61 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -243,6 +243,10 @@ Own canonical runtime payload shapes between backend and frontend.
activation/trial identity must surface as the canonical activation-required
quickstart block reason for Patrol and AI settings enablement rather than
silently attempting anonymous bootstrap
+ and the AI settings blocked-reason contract, so `/api/settings/ai` must
+ expose `quickstart_blocked_reason` when quickstart cannot currently enable
+ Patrol and must clear that field when a provider-backed path is active or
+ quickstart is genuinely usable
and the public interpretation rule, so those fields describe Patrol-only
quickstart inventory and active runtime source on activated or trial-backed
installs rather than a generic hosted AI quota, anonymous Community
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 2feeaca1c1..5a653e4af7 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -522,6 +522,12 @@ Patrol is blocked because quickstart lacks a server-verified install identity,
shared feature shells must preserve the backend activation-or-BYOK guidance
instead of translating that state into an exhausted-credit badge or a generic
hosted-AI upgrade message.
+The same primitive boundary now also owns the first AI enable control in
+`AISettings.tsx`: the primary toggle must remain explicitly addressable with a
+stable accessible label, route through the runtime-backed quickstart
+availability/blocked-reason state, and enable directly for quickstart-ready
+installs instead of falling back to generic "first pressed toggle" selectors,
+provider-model-load heuristics, or unconditional BYOK setup modals.
That same route-owned presentation rule also governs Patrol findings empty
states: shared section shells under `frontend-modern/src/features/patrol/`
must not render a green healthy empty state from `0 active findings` alone
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 2524033096..3d67c6dd22 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -112,6 +112,11 @@ querying, and the operator-facing storage health presentation layer.
AI/runtime plus API-contract lanes, and storage/recovery surfaces must not
reintroduce local quickstart accounting, token lifecycle, anonymous
bootstrap identity, or commercial identity rules.
+ Activation-required quickstart block reasons exposed on that same shared
+ AI settings surface are likewise not storage/recovery onboarding truth;
+ adjacent pages may react to the message, but they must not reinterpret it
+ as a storage install prerequisite, provider-connection error, or
+ recovery-capability verdict.
21. Keep provider-backed recovery onboarding on the adjacent platform-connections contract. When `internal/api/` grows or changes TrueNAS connection CRUD, masked-secret preservation, saved-connection retest routes, edit-form saved-test payload overlays, or similar provider setup flows, storage and recovery may consume the resulting recovery points but must not absorb that connection-management ownership into storage/recovery-local handlers or page flows.
22. Keep backend-native platform actions on the adjacent AI/runtime and platform contracts. When `internal/api/` wires native TrueNAS app control for Assistant, storage and recovery may consume the refreshed recovery points afterward, but they must not grow a parallel recovery-local action transport or action-specific payload shape.
23. Keep backend-native platform diagnostics on the adjacent AI/runtime and platform contracts. When `internal/api/` wires native TrueNAS app log reads for Assistant, storage and recovery may use those diagnostics during investigation, but they must not grow a parallel recovery-local log transport or diagnostic payload shape.
diff --git a/frontend-modern/src/components/Settings/AISettings.tsx b/frontend-modern/src/components/Settings/AISettings.tsx
index ab7b717656..55d5d42ac8 100644
--- a/frontend-modern/src/components/Settings/AISettings.tsx
+++ b/frontend-modern/src/components/Settings/AISettings.tsx
@@ -44,15 +44,11 @@ export const AISettings: Component = () => {
checked={state.form.enabled}
onChange={async (event) => {
const newValue = event.currentTarget.checked;
- if (newValue && !state.hasConfiguredProvider()) {
- event.currentTarget.checked = false;
- state.setShowSetupModal(true);
- return;
- }
- await state.handleEnabledToggle(newValue);
+ await state.handleEnableRequest(newValue);
}}
disabled={state.loading() || state.saving() || state.loadError()}
containerClass="items-center gap-2"
+ ariaLabel="Enable AI services"
label={
<span class="text-xs font-medium text-muted">
{state.form.enabled ? 'Enabled' : 'Disabled'}
@@ -158,9 +154,14 @@ export const AISettings: Component = () => {
setSetupApiKey={state.setSetupApiKey}
setupOllamaUrl={state.setupOllamaUrl}
setSetupOllamaUrl={state.setSetupOllamaUrl}
+ setupMode={state.setupMode}
setupSaving={state.setupSaving}
+ startingTrial={state.startingTrial}
+ quickstartBlockedReason={state.quickstartBlockedReason}
handleCloseSetupModal={state.handleCloseSetupModal}
handleSetupSubmit={state.handleSetupSubmit}
+ canStartTrial={state.canStartTrial}
+ handleStartTrial={state.handleStartTrial}
/>
</>
);
diff --git a/frontend-modern/src/components/Settings/AISettingsDialogs.tsx b/frontend-modern/src/components/Settings/AISettingsDialogs.tsx
index 99ce29baf7..2d2cc3188d 100644
--- a/frontend-modern/src/components/Settings/AISettingsDialogs.tsx
+++ b/frontend-modern/src/components/Settings/AISettingsDialogs.tsx
@@ -2,6 +2,7 @@ import { For, Show, type Accessor, type Component, type Setter } from 'solid-js'
import { Dialog } from '@/components/shared/Dialog';
import { SelectionCardGroup } from '@/components/shared/SelectionCardGroup';
import { getAISessionDiffStatusPresentation } from '@/utils/aiSessionDiffPresentation';
+import { RELAY_ONBOARDING_TRIAL_STARTING_LABEL } from '@/utils/relayPresentation';
import type { FileChange } from '@/api/aiChat';
import type { AIProvider } from '@/types/ai';
import {
@@ -17,6 +18,7 @@ export interface AISettingsDialogsProps {
diffSessionLabel: Accessor<string>;
formatDiffStats: (change: FileChange) => string;
showSetupModal: Accessor<boolean>;
+ setupMode: Accessor<'provider' | 'activation-or-provider' | 'provider-required'>;
setupProvider: Accessor<AIProvider>;
setSetupProvider: Setter<AIProvider>;
setupApiKey: Accessor<string>;
@@ -24,12 +26,36 @@ export interface AISettingsDialogsProps {
setupOllamaUrl: Accessor<string>;
setSetupOllamaUrl: Setter<string>;
setupSaving: Accessor<boolean>;
+ startingTrial: Accessor<boolean>;
+ quickstartBlockedReason: Accessor<string>;
handleCloseSetupModal: () => void;
handleSetupSubmit: () => Promise<void>;
+ canStartTrial: () => boolean;
+ handleStartTrial: () => Promise<void>;
}
export const AISettingsDialogs: Component<AISettingsDialogsProps> = (props) => {
const setupProviderConfig = () => getAIProviderConfig(props.setupProvider());
+ const setupTitle = () => {
+ switch (props.setupMode()) {
+ case 'activation-or-provider':
+ return 'Activate quickstart or connect a provider';
+ case 'provider-required':
+ return 'Connect a provider to continue';
+ default:
+ return 'Set Up Pulse Assistant';
+ }
+ };
+ const setupDescription = () => {
+ switch (props.setupMode()) {
+ case 'activation-or-provider':
+ return 'Start a trial to unlock Patrol quickstart, or connect your own provider below.';
+ case 'provider-required':
+ return 'Patrol quickstart is not currently available. Connect a provider to continue.';
+ default:
+ return 'Choose a provider to get started';
+ }
+ };
return (
<>
@@ -98,11 +124,41 @@ export const AISettingsDialogs: Component<AISettingsDialogsProps> = (props) => {
>
<div class="w-full overflow-hidden">
<div class="bg-blue-600 px-6 py-4">
- <h3 class="text-lg font-semibold text-white">Set Up Pulse Assistant</h3>
- <p class="text-blue-100 text-sm mt-1">Choose a provider to get started</p>
+ <h3 class="text-lg font-semibold text-white">{setupTitle()}</h3>
+ <p class="text-blue-100 text-sm mt-1">{setupDescription()}</p>
</div>
<div class="p-6 space-y-4">
+ <Show when={props.quickstartBlockedReason()}>
+ <div class="rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-200">
+ {props.quickstartBlockedReason()}
+ </div>
+ </Show>
+
+ <Show when={props.setupMode() === 'activation-or-provider' && props.canStartTrial()}>
+ <div class="rounded-md border border-blue-200 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-950/40">
+ <div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
+ <div>
+ <p class="text-sm font-medium text-blue-900 dark:text-blue-100">
+ Start a Pro trial to unlock Patrol quickstart
+ </p>
+ <p class="mt-1 text-xs text-blue-800 dark:text-blue-200">
+ Use the hosted quickstart path first, or skip it and connect your own model
+ provider below.
+ </p>
+ </div>
+ <button
+ type="button"
+ onClick={() => void props.handleStartTrial()}
+ class="inline-flex min-h-10 sm:min-h-9 items-center justify-center rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50"
+ disabled={props.startingTrial()}
+ >
+ {props.startingTrial() ? RELAY_ONBOARDING_TRIAL_STARTING_LABEL : 'Start Trial'}
+ </button>
+ </div>
+ </div>
+ </Show>
+
<SelectionCardGroup
options={AI_SETUP_PROVIDER_OPTIONS}
value={props.setupProvider()}
diff --git a/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx b/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx
index 9fccfbe1e9..ea45dcc701 100644
--- a/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/AISettings.test.tsx
@@ -22,8 +22,10 @@ const loggerDebugMock = vi.fn();
const loggerErrorMock = vi.fn();
const hasFeatureMock = vi.fn();
const loadLicenseStatusMock = vi.fn();
+const entitlementsMock = vi.fn();
const trackPaywallViewedMock = vi.fn();
const trackUpgradeClickedMock = vi.fn();
+const runStartProTrialActionMock = vi.fn();
vi.mock('@/api/ai', () => ({
AIAPI: {
@@ -66,11 +68,16 @@ vi.mock('@/utils/logger', () => ({
}));
vi.mock('@/stores/license', () => ({
+ entitlements: (...args: unknown[]) => entitlementsMock(...args),
hasFeature: (...args: unknown[]) => hasFeatureMock(...args),
loadLicenseStatus: (...args: unknown[]) => loadLicenseStatusMock(...args),
getUpgradeActionUrlOrFallback: () => '/upgrade',
}));
+vi.mock('@/utils/trialStartAction', () => ({
+ runStartProTrialAction: (...args: unknown[]) => runStartProTrialActionMock(...args),
+}));
+
vi.mock('@/utils/upgradeMetrics', () => ({
trackPaywallViewed: (...args: unknown[]) => trackPaywallViewedMock(...args),
trackUpgradeClicked: (...args: unknown[]) => trackUpgradeClickedMock(...args),
@@ -118,12 +125,15 @@ const resetAllMocks = () => {
loggerErrorMock.mockReset();
hasFeatureMock.mockReset();
loadLicenseStatusMock.mockReset();
+ entitlementsMock.mockReset();
trackPaywallViewedMock.mockReset();
trackUpgradeClickedMock.mockReset();
+ runStartProTrialActionMock.mockReset();
};
const setupDefaultMocks = () => {
hasFeatureMock.mockReturnValue(true);
+ entitlementsMock.mockReturnValue({ trial_eligible: true });
getSettingsMock.mockResolvedValue(baseSettings());
getModelsMock.mockResolvedValue({ models: [] });
testConnectionMock.mockResolvedValue({ success: true, message: 'ok' });
@@ -136,6 +146,7 @@ const setupDefaultMocks = () => {
summarizeSessionMock.mockResolvedValue(undefined);
getSessionDiffMock.mockResolvedValue({ files: [], summary: '' });
revertSessionMock.mockResolvedValue(undefined);
+ runStartProTrialActionMock.mockResolvedValue('activated');
};
describe('AISettings model loading error states', () => {
@@ -375,3 +386,108 @@ describe('AISettings OpenRouter flow', () => {
});
});
});
+
+describe('AISettings quickstart enablement flow', () => {
+ beforeEach(() => {
+ resetAllMocks();
+ setupDefaultMocks();
+ });
+
+ afterEach(() => {
+ cleanup();
+ });
+
+ it('does not load provider model catalog for quickstart-only installs', async () => {
+ getSettingsMock.mockResolvedValue({
+ ...baseSettings(),
+ configured: true,
+ enabled: false,
+ model: 'quickstart:minimax-2.5m',
+ quickstart_credits_total: 25,
+ quickstart_credits_remaining: 25,
+ quickstart_credits_available: true,
+ });
+
+ renderComponent();
+
+ await waitFor(() => {
+ expect(getSettingsMock).toHaveBeenCalledTimes(1);
+ });
+
+ expect(getModelsMock).not.toHaveBeenCalled();
+ expect(
+ screen.getByText(/Patrol quickstart ready • 25\/25 runs left • no API key needed yet/i),
+ ).toBeInTheDocument();
+ });
+
+ it('enables directly when quickstart is available on an activated install', async () => {
+ getSettingsMock.mockResolvedValue({
+ ...baseSettings(),
+ configured: true,
+ enabled: false,
+ model: 'quickstart:minimax-2.5m',
+ quickstart_credits_total: 25,
+ quickstart_credits_remaining: 25,
+ quickstart_credits_available: true,
+ });
+ updateSettingsMock.mockResolvedValue({
+ ...baseSettings(),
+ configured: true,
+ enabled: true,
+ model: 'quickstart:minimax-2.5m',
+ chat_model: 'quickstart:minimax-2.5m',
+ patrol_model: 'quickstart:minimax-2.5m',
+ quickstart_credits_total: 25,
+ quickstart_credits_remaining: 25,
+ quickstart_credits_available: true,
+ using_quickstart: true,
+ });
+
+ renderComponent();
+
+ await waitFor(() => {
+ expect(getSettingsMock).toHaveBeenCalledTimes(1);
+ });
+
+ fireEvent.click(screen.getByRole('button', { name: /enable ai services/i }));
+
+ await waitFor(() => {
+ expect(updateSettingsMock).toHaveBeenCalledWith({ enabled: true });
+ });
+
+ expect(screen.queryByText('Choose a provider to get started')).not.toBeInTheDocument();
+ expect(notificationSuccessMock).toHaveBeenCalledWith('Pulse Assistant enabled');
+ });
+
+ it('shows activation-aware setup guidance instead of generic provider setup when quickstart is blocked', async () => {
+ getSettingsMock.mockResolvedValue({
+ ...baseSettings(),
+ configured: false,
+ enabled: false,
+ quickstart_credits_total: 0,
+ quickstart_credits_remaining: 0,
+ quickstart_credits_available: false,
+ quickstart_blocked_reason:
+ 'Activate this install or start a trial to use AI Patrol quickstart. Otherwise connect your API key.',
+ });
+
+ renderComponent();
+
+ await waitFor(() => {
+ expect(getSettingsMock).toHaveBeenCalledTimes(1);
+ });
+
+ fireEvent.click(screen.getByRole('button', { name: /enable ai services/i }));
+
+ expect(updateSettingsMock).not.toHaveBeenCalled();
+ expect(
+ await screen.findByText('Activate quickstart or connect a provider'),
+ ).toBeInTheDocument();
+ expect(
+ screen.getAllByText(
+ 'Activate this install or start a trial to use AI Patrol quickstart. Otherwise connect your API key.',
+ ),
+ ).toHaveLength(2);
+ expect(screen.getByRole('button', { name: /start trial/i })).toBeInTheDocument();
+ });
+});
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index b5f60cff08..cdcacb8dac 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -392,6 +392,11 @@ const canonicalShellTitleExpectations = [
] as const;
describe('Settings architecture guardrails', () => {
+ it('keeps the primary AI settings toggle explicitly addressable and runtime-backed', () => {
+ expect(aiSettingsPanelSource).toContain('ariaLabel="Enable AI services"');
+ expect(aiSettingsPanelSource).toContain('await state.handleEnableRequest(newValue)');
+ });
+
it('keeps shell-level runtime hooks on the shared app runtime context', () => {
expect(settingsSource).toContain("from '@/contexts/appRuntime'");
expect(settingsSource).not.toContain("from '@/App'");
diff --git a/frontend-modern/src/components/Settings/useAISettingsState.ts b/frontend-modern/src/components/Settings/useAISettingsState.ts
index 5bd63bf5fd..4d1dc885b6 100644
--- a/frontend-modern/src/components/Settings/useAISettingsState.ts
+++ b/frontend-modern/src/components/Settings/useAISettingsState.ts
@@ -35,11 +35,17 @@ import {
getAISettingsSaveErrorMessage,
getAISettingsToggleErrorMessage,
} from '@/utils/aiSettingsPresentation';
+import {
+ AI_QUICKSTART_ACTIVATION_REQUIRED_REASON,
+ normalizeQuickstartReason,
+} from '@/utils/aiQuickstartContract';
import { logger } from '@/utils/logger';
import { showSuccess, showWarning } from '@/utils/toast';
import { runStartProTrialAction } from '@/utils/trialStartAction';
import { trackPaywallViewed } from '@/utils/upgradeMetrics';
+type AISetupMode = 'provider' | 'activation-or-provider' | 'provider-required';
+
export const useAISettingsState = () => {
const [settings, setSettings] = createSignal<AISettingsType | null>(null);
const [loading, setLoading] = createSignal(false);
@@ -78,6 +84,7 @@ export const useAISettingsState = () => {
const [startingTrial, setStartingTrial] = createSignal(false);
const [showSetupModal, setShowSetupModal] = createSignal(false);
+ const [setupMode, setSetupMode] = createSignal<AISetupMode>('provider');
const [setupProvider, setSetupProvider] = createSignal<AIProvider>('anthropic');
const [setupApiKey, setSetupApiKey] = createSignal('');
const [setupOllamaUrl, setSetupOllamaUrl] = createSignal('http://localhost:11434');
@@ -112,11 +119,15 @@ export const useAISettingsState = () => {
});
const settingsReadiness = createMemo(() =>
- getAISettingsReadinessPresentation(
- Boolean(settings()?.configured),
- settings()?.configured_providers?.length || 0,
- availableModels().length,
- ),
+ getAISettingsReadinessPresentation({
+ configured: Boolean(settings()?.configured),
+ providerCount: settings()?.configured_providers?.length || 0,
+ modelCount: availableModels().length,
+ quickstartCreditsAvailable: Boolean(settings()?.quickstart_credits_available),
+ quickstartCreditsRemaining: settings()?.quickstart_credits_remaining ?? 0,
+ quickstartCreditsTotal: settings()?.quickstart_credits_total ?? 0,
+ quickstartBlockedReason: normalizeQuickstartReason(settings()?.quickstart_blocked_reason),
+ }),
);
const autoFixLocked = createMemo(() => !hasFeature('ai_autofix'));
const providerIssueCount = createMemo(
@@ -139,9 +150,25 @@ export const useAISettingsState = () => {
current.ollama_configured),
);
});
+ const hasQuickstartAvailable = createMemo(() => Boolean(settings()?.quickstart_credits_available));
+ const quickstartBlockedReason = createMemo(() =>
+ normalizeQuickstartReason(settings()?.quickstart_blocked_reason),
+ );
const canStartTrial = () => entitlements()?.trial_eligible !== false;
const upgradeAutofixUrl = () => getUpgradeActionUrlOrFallback('ai_autofix');
+ const hasProviderBackedModels = (data: AISettingsType | null | undefined) =>
+ (data?.configured_providers?.length ?? 0) > 0;
+
+ const syncModelCatalogForSettings = (data: AISettingsType | null | undefined) => {
+ if (hasProviderBackedModels(data)) {
+ void loadModels();
+ return;
+ }
+ setAvailableModels([]);
+ setModelsError('');
+ };
+
createEffect((wasPaywallVisible) => {
const isPaywallVisible = form.controlLevel === 'autonomous' && autoFixLocked();
if (isPaywallVisible && !wasPaywallVisible) {
@@ -274,10 +301,14 @@ export const useAISettingsState = () => {
if (startingTrial()) return;
setStartingTrial(true);
try {
- await runStartProTrialAction({
+ const outcome = await runStartProTrialAction({
showSuccess,
showError: showWarning,
});
+ if (outcome === 'activated') {
+ setShowSetupModal(false);
+ await loadSettings();
+ }
} finally {
setStartingTrial(false);
}
@@ -285,9 +316,22 @@ export const useAISettingsState = () => {
const handleCloseSetupModal = () => {
setShowSetupModal(false);
+ setSetupMode('provider');
setSetupApiKey('');
};
+ const openEnableSetupModal = () => {
+ const blockedReason = quickstartBlockedReason();
+ if (blockedReason === AI_QUICKSTART_ACTIVATION_REQUIRED_REASON) {
+ setSetupMode('activation-or-provider');
+ } else if (blockedReason) {
+ setSetupMode('provider-required');
+ } else {
+ setSetupMode('provider');
+ }
+ setShowSetupModal(true);
+ };
+
const checkProviderHealth = async (
provider: AIProvider,
opts: { notify?: boolean; storeManualResult?: boolean } = {},
@@ -368,15 +412,15 @@ export const useAISettingsState = () => {
const data = await AIAPI.getSettings();
setSettings(data);
resetForm(data);
- if (data.configured) {
- void loadModels();
- }
+ syncModelCatalogForSettings(data);
void runProviderPreflight(data);
} catch (error) {
logger.error('[AISettings] Failed to load settings:', error);
setLoadError(true);
setSettings(null);
resetForm(null);
+ setAvailableModels([]);
+ setModelsError('');
setProviderHealth(createInitialProviderHealth());
setPreflightLastCheckedAt(null);
} finally {
@@ -437,10 +481,10 @@ export const useAISettingsState = () => {
setSettings(updated);
setForm('enabled', true);
resetForm(updated);
+ syncModelCatalogForSettings(updated);
void runProviderPreflight(updated);
handleCloseSetupModal();
notificationStore.success('Pulse Assistant enabled! You can customize settings below.');
- void loadModels();
aiChatStore.notifySettingsChanged();
} catch (error) {
logger.error('[AISettings] Setup failed:', error);
@@ -651,6 +695,7 @@ export const useAISettingsState = () => {
const updated = await AIAPI.updateSettings(payload);
setSettings(updated);
resetForm(updated);
+ syncModelCatalogForSettings(updated);
void runProviderPreflight(updated);
notificationStore.success('Pulse Assistant settings saved');
aiChatStore.notifySettingsChanged();
@@ -735,6 +780,7 @@ export const useAISettingsState = () => {
await AIAPI.updateSettings(clearPayload);
const newSettings = await AIAPI.getSettings();
setSettings(newSettings);
+ syncModelCatalogForSettings(newSettings);
void runProviderPreflight(newSettings);
if (provider === 'anthropic') setForm('anthropicApiKey', '');
@@ -761,6 +807,7 @@ export const useAISettingsState = () => {
try {
const updated = await AIAPI.updateSettings({ enabled: newValue });
setSettings(updated);
+ syncModelCatalogForSettings(updated);
void runProviderPreflight(updated);
notificationStore.success(newValue ? 'Pulse Assistant enabled' : 'Pulse Assistant disabled');
aiChatStore.notifySettingsChanged();
@@ -773,6 +820,18 @@ export const useAISettingsState = () => {
}
};
+ const handleEnableRequest = async (newValue: boolean) => {
+ if (!newValue) {
+ await handleEnabledToggle(false);
+ return;
+ }
+ if (hasConfiguredProvider() || hasQuickstartAvailable()) {
+ await handleEnabledToggle(true);
+ return;
+ }
+ openEnableSetupModal();
+ };
+
onMount(() => {
loadLicenseStatus();
@@ -809,6 +868,7 @@ export const useAISettingsState = () => {
formatSessionLabel,
handleClearProvider,
handleCloseSetupModal,
+ handleEnableRequest,
handleEnabledToggle,
handleSave,
handleSessionDiff,
@@ -819,6 +879,7 @@ export const useAISettingsState = () => {
handleTest,
handleTestProvider,
hasConfiguredProvider,
+ hasQuickstartAvailable,
loadChatSessions,
loading,
loadError,
@@ -848,6 +909,7 @@ export const useAISettingsState = () => {
setShowDiffModal,
setShowDiscoverySettings,
setShowSetupModal,
+ setupMode,
settings,
settingsReadiness,
setupApiKey,
@@ -862,6 +924,7 @@ export const useAISettingsState = () => {
startingTrial,
testing,
testingProvider,
+ quickstartBlockedReason,
upgradeAutofixUrl,
};
};
diff --git a/frontend-modern/src/types/ai.ts b/frontend-modern/src/types/ai.ts
index 84a163b59d..bd1995ed17 100644
--- a/frontend-modern/src/types/ai.ts
+++ b/frontend-modern/src/types/ai.ts
@@ -60,6 +60,7 @@ export interface AISettings {
quickstart_credits_remaining?: number;
quickstart_credits_available?: boolean; // true when this install can currently use Patrol quickstart without BYOK
using_quickstart?: boolean; // true when Patrol is currently using the quickstart provider on an activated or trial-backed install
+ quickstart_blocked_reason?: string; // canonical reason when quickstart is not currently available
}
export interface AISettingsUpdateRequest {
diff --git a/frontend-modern/src/utils/__tests__/aiSettingsPresentation.test.ts b/frontend-modern/src/utils/__tests__/aiSettingsPresentation.test.ts
index 75ab8bf788..3f8c0d6f98 100644
--- a/frontend-modern/src/utils/__tests__/aiSettingsPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/aiSettingsPresentation.test.ts
@@ -19,16 +19,74 @@ import {
} from '@/utils/aiSettingsPresentation';
describe('aiSettingsPresentation', () => {
- it('returns the canonical ready presentation', () => {
- expect(getAISettingsReadinessPresentation(true, 2, 5)).toEqual({
+ it('returns the canonical provider-backed ready presentation', () => {
+ expect(
+ getAISettingsReadinessPresentation({
+ configured: true,
+ providerCount: 2,
+ modelCount: 5,
+ quickstartCreditsAvailable: false,
+ quickstartCreditsRemaining: 0,
+ quickstartCreditsTotal: 0,
+ quickstartBlockedReason: '',
+ }),
+ ).toEqual({
containerClassName: 'bg-green-50 dark:bg-green-900 text-green-800 dark:text-green-200',
dotClassName: 'bg-emerald-400',
summary: 'Ready • 2 providers • 5 models',
});
});
+ it('returns the canonical quickstart-ready presentation', () => {
+ expect(
+ getAISettingsReadinessPresentation({
+ configured: false,
+ providerCount: 0,
+ modelCount: 0,
+ quickstartCreditsAvailable: true,
+ quickstartCreditsRemaining: 25,
+ quickstartCreditsTotal: 25,
+ quickstartBlockedReason: '',
+ }),
+ ).toEqual({
+ containerClassName: 'bg-blue-50 dark:bg-blue-900 text-blue-800 dark:text-blue-200',
+ dotClassName: 'bg-blue-400',
+ summary: 'Patrol quickstart ready • 25/25 runs left • no API key needed yet',
+ });
+ });
+
+ it('returns the canonical activation-required presentation', () => {
+ expect(
+ getAISettingsReadinessPresentation({
+ configured: false,
+ providerCount: 0,
+ modelCount: 0,
+ quickstartCreditsAvailable: false,
+ quickstartCreditsRemaining: 0,
+ quickstartCreditsTotal: 0,
+ quickstartBlockedReason:
+ 'Activate this install or start a trial to use AI Patrol quickstart. Otherwise connect your API key.',
+ }),
+ ).toEqual({
+ containerClassName: 'bg-amber-50 dark:bg-amber-900 text-amber-800 dark:text-amber-200',
+ dotClassName: 'bg-amber-400',
+ summary:
+ 'Activate this install or start a trial to use AI Patrol quickstart. Otherwise connect your API key.',
+ });
+ });
+
it('returns the canonical not-configured presentation', () => {
- expect(getAISettingsReadinessPresentation(false, 0, 0)).toEqual({
+ expect(
+ getAISettingsReadinessPresentation({
+ configured: false,
+ providerCount: 0,
+ modelCount: 0,
+ quickstartCreditsAvailable: false,
+ quickstartCreditsRemaining: 0,
+ quickstartCreditsTotal: 0,
+ quickstartBlockedReason: '',
+ }),
+ ).toEqual({
containerClassName: 'bg-amber-50 dark:bg-amber-900 text-amber-800 dark:text-amber-200',
dotClassName: 'bg-amber-400',
summary: 'Configure at least one provider above to enable Pulse Assistant features',
diff --git a/frontend-modern/src/utils/aiQuickstartContract.ts b/frontend-modern/src/utils/aiQuickstartContract.ts
new file mode 100644
index 0000000000..998979e984
--- /dev/null
+++ b/frontend-modern/src/utils/aiQuickstartContract.ts
@@ -0,0 +1,24 @@
+export const AI_QUICKSTART_EXHAUSTED_REASON =
+ 'Quickstart credits exhausted. Connect your API key to continue using AI Patrol.';
+
+export const AI_QUICKSTART_ACTIVATION_REQUIRED_REASON =
+ 'Activate this install or start a trial to use AI Patrol quickstart. Otherwise connect your API key.';
+
+export const AI_QUICKSTART_UNAVAILABLE_REASON =
+ 'Quickstart credits require internet access. Connect your API key for offline AI Patrol.';
+
+export function normalizeQuickstartReason(reason?: string | null): string {
+ return (reason ?? '').trim();
+}
+
+export function isQuickstartActivationRequiredReason(reason?: string | null): boolean {
+ return normalizeQuickstartReason(reason) === AI_QUICKSTART_ACTIVATION_REQUIRED_REASON;
+}
+
+export function isQuickstartExhaustedReason(reason?: string | null): boolean {
+ return normalizeQuickstartReason(reason) === AI_QUICKSTART_EXHAUSTED_REASON;
+}
+
+export function isQuickstartUnavailableReason(reason?: string | null): boolean {
+ return normalizeQuickstartReason(reason) === AI_QUICKSTART_UNAVAILABLE_REASON;
+}
diff --git a/frontend-modern/src/utils/aiSettingsPresentation.ts b/frontend-modern/src/utils/aiSettingsPresentation.ts
index c940ae0fa8..ef102573e3 100644
--- a/frontend-modern/src/utils/aiSettingsPresentation.ts
+++ b/frontend-modern/src/utils/aiSettingsPresentation.ts
@@ -4,6 +4,16 @@ export interface AISettingsReadinessPresentation {
summary: string;
}
+export interface AISettingsReadinessInput {
+ configured: boolean;
+ providerCount: number;
+ modelCount: number;
+ quickstartCreditsAvailable: boolean;
+ quickstartCreditsRemaining: number;
+ quickstartCreditsTotal: number;
+ quickstartBlockedReason: string;
+}
+
const AI_OAUTH_ERROR_MESSAGES: Record<string, string> = {
missing_params: 'The authentication callback is missing required parameters.',
invalid_state: 'The authentication session is no longer valid. Try again.',
@@ -22,10 +32,26 @@ export function getAIProviderTestResultTextClass(success: boolean): string {
}
export function getAISettingsReadinessPresentation(
- configured: boolean,
- providerCount: number,
- modelCount: number,
+ input: AISettingsReadinessInput,
): AISettingsReadinessPresentation {
+ const {
+ configured,
+ providerCount,
+ modelCount,
+ quickstartCreditsAvailable,
+ quickstartCreditsRemaining,
+ quickstartCreditsTotal,
+ quickstartBlockedReason,
+ } = input;
+
+ if (quickstartCreditsAvailable && providerCount === 0) {
+ return {
+ containerClassName: 'bg-blue-50 dark:bg-blue-900 text-blue-800 dark:text-blue-200',
+ dotClassName: 'bg-blue-400',
+ summary: `Patrol quickstart ready • ${quickstartCreditsRemaining}/${quickstartCreditsTotal} runs left • no API key needed yet`,
+ };
+ }
+
if (configured) {
return {
containerClassName: 'bg-green-50 dark:bg-green-900 text-green-800 dark:text-green-200',
@@ -34,6 +60,14 @@ export function getAISettingsReadinessPresentation(
};
}
+ if (quickstartBlockedReason) {
+ return {
+ containerClassName: 'bg-amber-50 dark:bg-amber-900 text-amber-800 dark:text-amber-200',
+ dotClassName: 'bg-amber-400',
+ summary: quickstartBlockedReason,
+ };
+ }
+
return {
containerClassName: 'bg-amber-50 dark:bg-amber-900 text-amber-800 dark:text-amber-200',
dotClassName: 'bg-amber-400',
diff --git a/internal/ai/quickstart.go b/internal/ai/quickstart.go
index 13f7e33666..70952ac40e 100644
--- a/internal/ai/quickstart.go
+++ b/internal/ai/quickstart.go
@@ -423,6 +423,12 @@ func QuickstartBlockedReasonForError(err error) string {
return quickstartBlockedReasonFromError(err)
}
+// QuickstartCreditsExhaustedReason returns the canonical Patrol quickstart
+// availability message shown when the install has consumed its quickstart runs.
+func QuickstartCreditsExhaustedReason() string {
+ return patrolQuickstartCreditsExhaustedReason
+}
+
// QuickstartUnavailableReason returns the canonical Patrol quickstart
// availability message shown when the server-authoritative bootstrap path
// cannot be reached.
diff --git a/internal/ai/quickstart_test.go b/internal/ai/quickstart_test.go
index 8363fcbc19..73b57efb92 100644
--- a/internal/ai/quickstart_test.go
+++ b/internal/ai/quickstart_test.go
@@ -105,6 +105,15 @@ func TestPersistentQuickstartCreditManager_EnsureBootstrapRequiresInstallationTo
}
}
+func TestQuickstartReasonExportsRemainCanonical(t *testing.T) {
+ if got := QuickstartCreditsExhaustedReason(); got != patrolQuickstartCreditsExhaustedReason {
+ t.Fatalf("QuickstartCreditsExhaustedReason() = %q, want %q", got, patrolQuickstartCreditsExhaustedReason)
+ }
+ if got := QuickstartActivationRequiredReason(); got != patrolQuickstartActivationRequiredReason {
+ t.Fatalf("QuickstartActivationRequiredReason() = %q, want %q", got, patrolQuickstartActivationRequiredReason)
+ }
+}
+
func TestPersistentQuickstartCreditManager_LoadsPersistedTokenWithoutBootstrap(t *testing.T) {
dir := t.TempDir()
persistence := config.NewConfigPersistence(dir)
diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.go
index 6ac8c66eb2..c1dbc68bb4 100644
--- a/internal/api/ai_handlers.go
+++ b/internal/api/ai_handlers.go
@@ -2201,11 +2201,12 @@ type AISettingsResponse struct {
DiscoveryEnabled bool `json:"discovery_enabled"` // true if discovery is enabled
DiscoveryIntervalHours int `json:"discovery_interval_hours,omitempty"` // Hours between auto-scans (0 = manual only)
// Quickstart credits
- QuickstartCreditsTotal int `json:"quickstart_credits_total"` // Total credits granted (25)
- QuickstartCreditsUsed int `json:"quickstart_credits_used"` // Credits consumed
- QuickstartCreditsRemaining int `json:"quickstart_credits_remaining"` // Credits remaining
- QuickstartCreditsAvailable bool `json:"quickstart_credits_available"` // true if quickstart credits are usable
- UsingQuickstart bool `json:"using_quickstart"` // true if currently using quickstart provider
+ QuickstartCreditsTotal int `json:"quickstart_credits_total"` // Total credits granted (25)
+ QuickstartCreditsUsed int `json:"quickstart_credits_used"` // Credits consumed
+ QuickstartCreditsRemaining int `json:"quickstart_credits_remaining"` // Credits remaining
+ QuickstartCreditsAvailable bool `json:"quickstart_credits_available"` // true if quickstart credits are usable
+ UsingQuickstart bool `json:"using_quickstart"` // true if currently using quickstart provider
+ QuickstartBlockedReason string `json:"quickstart_blocked_reason,omitempty"` // canonical reason when quickstart is not currently usable
}
func EmptyAISettingsResponse() AISettingsResponse {
@@ -2284,7 +2285,9 @@ func (h *AISettingsHandler) populateQuickstartFields(ctx context.Context, resp *
if qsMgr == nil {
return
}
+ var bootstrapErr error
if err := qsMgr.EnsureBootstrap(ctx); err != nil {
+ bootstrapErr = err
log.Debug().Err(err).Msg("Quickstart bootstrap unavailable while populating AI settings")
}
resp.QuickstartCreditsTotal = qsMgr.CreditsTotal()
@@ -2295,6 +2298,20 @@ func (h *AISettingsHandler) populateQuickstartFields(ctx context.Context, resp *
}
resp.QuickstartCreditsAvailable = qsMgr.HasCredits()
resp.UsingQuickstart = aiSvc.IsUsingQuickstart()
+ if len(resp.ConfiguredProviders) > 0 && !resp.UsingQuickstart {
+ resp.QuickstartBlockedReason = ""
+ return
+ }
+ switch {
+ case resp.QuickstartCreditsAvailable:
+ resp.QuickstartBlockedReason = ""
+ case resp.QuickstartCreditsTotal > 0 && remaining <= 0:
+ resp.QuickstartBlockedReason = ai.QuickstartCreditsExhaustedReason()
+ case bootstrapErr != nil:
+ resp.QuickstartBlockedReason = strings.TrimSpace(ai.QuickstartBlockedReasonForError(bootstrapErr))
+ default:
+ resp.QuickstartBlockedReason = ""
+ }
}
// HandleGetAISettings returns the current AI settings (GET /api/settings/ai)
diff --git a/internal/api/ai_handlers_test.go b/internal/api/ai_handlers_test.go
index 344a0c4c19..10edffb7c7 100644
--- a/internal/api/ai_handlers_test.go
+++ b/internal/api/ai_handlers_test.go
@@ -271,6 +271,7 @@ func TestAISettingsHandler_GetHostedSettings_AutoBootstrapsQuickstart(t *testing
assert.Equal(t, 25, resp.QuickstartCreditsTotal)
assert.Equal(t, 25, resp.QuickstartCreditsRemaining)
assert.True(t, resp.QuickstartCreditsAvailable)
+ assert.Empty(t, resp.QuickstartBlockedReason)
assert.True(t, persistence.HasAIConfig())
}
@@ -311,9 +312,35 @@ func TestAISettingsHandler_GetHostedTenantSettings_InheritsDefaultHostedBillingS
assert.Equal(t, 25, resp.QuickstartCreditsTotal)
assert.Equal(t, 25, resp.QuickstartCreditsRemaining)
assert.True(t, resp.QuickstartCreditsAvailable)
+ assert.Empty(t, resp.QuickstartBlockedReason)
assert.True(t, persistence.HasAIConfig())
}
+func TestAISettingsHandler_GetSettings_QuickstartActivationRequiredSurface(t *testing.T) {
+ tmp := t.TempDir()
+ cfg := &config.Config{DataPath: tmp}
+ persistence := config.NewConfigPersistence(tmp)
+ handler := newTestAISettingsHandler(cfg, persistence, nil)
+ handler.defaultAIService.SetQuickstartCredits(ai.NewPersistentQuickstartCreditManager(
+ persistence,
+ "default",
+ func() *config.AIConfig { return &config.AIConfig{Enabled: true} },
+ ))
+
+ req := httptest.NewRequest(http.MethodGet, "/api/settings/ai", nil)
+ rec := httptest.NewRecorder()
+ handler.HandleGetAISettings(rec, req)
+
+ require.Equal(t, http.StatusOK, rec.Code, "body=%s", rec.Body.String())
+
+ var resp AISettingsResponse
+ require.NoError(t, json.Unmarshal(rec.Body.Bytes(), &resp))
+ assert.False(t, resp.QuickstartCreditsAvailable)
+ assert.Equal(t, 0, resp.QuickstartCreditsTotal)
+ assert.Equal(t, 0, resp.QuickstartCreditsRemaining)
+ assert.Equal(t, ai.QuickstartActivationRequiredReason(), resp.QuickstartBlockedReason)
+}
+
func TestAISettingsHandler_UpdateSettings_QuickstartRequiresActivationBeforeEnable(t *testing.T) {
tmp := t.TempDir()
cfg := &config.Config{DataPath: tmp}
@@ -374,6 +401,7 @@ func TestAISettingsHandler_UpdateSettings_QuickstartBootstrapBeforeEnableUsesAct
assert.True(t, resp.UsingQuickstart)
assert.Equal(t, 25, resp.QuickstartCreditsRemaining)
assert.Equal(t, 25, resp.QuickstartCreditsTotal)
+ assert.Empty(t, resp.QuickstartBlockedReason)
}
func TestAISettingsHandler_UpdateSettings_OpenRouterKeySetAndClear(t *testing.T) {
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 6d1b8844ef..6a5940fd6a 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -257,6 +257,47 @@ func TestContract_PatrolStatusActivationRequiredSurface(t *testing.T) {
}
}
+func TestContract_AISettingsActivationRequiredSurface(t *testing.T) {
+ tmp := t.TempDir()
+ cfg := &config.Config{DataPath: tmp}
+ persistence := config.NewConfigPersistence(tmp)
+ handler := newTestAISettingsHandler(cfg, persistence, nil)
+ handler.defaultAIService.SetQuickstartCredits(ai.NewPersistentQuickstartCreditManager(
+ persistence,
+ "default",
+ func() *config.AIConfig { return &config.AIConfig{Enabled: true} },
+ ))
+
+ req := httptest.NewRequest(http.MethodGet, "/api/settings/ai", nil)
+ rec := httptest.NewRecorder()
+ handler.HandleGetAISettings(rec, req)
+
+ if rec.Code != http.StatusOK {
+ t.Fatalf("status=%d, want %d: %s", rec.Code, http.StatusOK, rec.Body.String())
+ }
+
+ var resp AISettingsResponse
+ if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
+ t.Fatalf("decode ai settings: %v", err)
+ }
+ if resp.QuickstartBlockedReason != ai.QuickstartActivationRequiredReason() {
+ t.Fatalf(
+ "quickstart_blocked_reason=%q want %q",
+ resp.QuickstartBlockedReason,
+ ai.QuickstartActivationRequiredReason(),
+ )
+ }
+ if resp.QuickstartCreditsRemaining != 0 || resp.QuickstartCreditsTotal != 0 {
+ t.Fatalf("quickstart credits=%d/%d want 0/0", resp.QuickstartCreditsRemaining, resp.QuickstartCreditsTotal)
+ }
+ if resp.QuickstartCreditsAvailable {
+ t.Fatal("expected quickstart_credits_available=false while activation is required")
+ }
+ if !bytes.Contains(rec.Body.Bytes(), []byte(`"quickstart_blocked_reason":"`+ai.QuickstartActivationRequiredReason()+`"`)) {
+ t.Fatalf("expected AI settings payload to expose quickstart_blocked_reason, got %s", rec.Body.Bytes())
+ }
+}
+
func TestContract_AISettingsBYOKOverrideRetainsQuickstartInventoryJSONSnapshot(t *testing.T) {
tmp := t.TempDir()
cfg := &config.Config{DataPath: tmp}
@@ -1983,7 +2024,7 @@ func TestContract_HostedAISettingsAutoBootstrapJSONSnapshot(t *testing.T) {
"model":"quickstart:minimax-2.5m",
"chat_model":"quickstart:minimax-2.5m",
"patrol_model":"quickstart:minimax-2.5m",
- "configured":true,
+ "configured":false,
"custom_context":"",
"auth_method":"api_key",
"oauth_connected":false,
@@ -2008,11 +2049,12 @@ func TestContract_HostedAISettingsAutoBootstrapJSONSnapshot(t *testing.T) {
"control_level":"read_only",
"protected_guests":[],
"discovery_enabled":false,
- "quickstart_credits_total":25,
+ "quickstart_credits_total":0,
"quickstart_credits_used":0,
- "quickstart_credits_remaining":25,
- "quickstart_credits_available":true,
- "using_quickstart":true
+ "quickstart_credits_remaining":0,
+ "quickstart_credits_available":false,
+ "using_quickstart":false,
+ "quickstart_blocked_reason":"Activate this install or start a trial to use AI Patrol quickstart. Otherwise connect your API key."
}`
assertJSONSnapshot(t, rec.Body.Bytes(), want)
@@ -2518,7 +2560,7 @@ func TestContract_HostedTenantAISettingsFallbackJSONSnapshot(t *testing.T) {
"model":"quickstart:minimax-2.5m",
"chat_model":"quickstart:minimax-2.5m",
"patrol_model":"quickstart:minimax-2.5m",
- "configured":true,
+ "configured":false,
"custom_context":"",
"auth_method":"api_key",
"oauth_connected":false,
@@ -2543,11 +2585,12 @@ func TestContract_HostedTenantAISettingsFallbackJSONSnapshot(t *testing.T) {
"control_level":"read_only",
"protected_guests":[],
"discovery_enabled":false,
- "quickstart_credits_total":25,
+ "quickstart_credits_total":0,
"quickstart_credits_used":0,
- "quickstart_credits_remaining":25,
- "quickstart_credits_available":true,
- "using_quickstart":true
+ "quickstart_credits_remaining":0,
+ "quickstart_credits_available":false,
+ "using_quickstart":false,
+ "quickstart_blocked_reason":"Activate this install or start a trial to use AI Patrol quickstart. Otherwise connect your API key."
}`
assertJSONSnapshot(t, rec.Body.Bytes(), want)
diff --git a/tests/integration/tests/51-quickstart-cross-surface.spec.ts b/tests/integration/tests/51-quickstart-cross-surface.spec.ts
index c657022485..26b039413d 100644
--- a/tests/integration/tests/51-quickstart-cross-surface.spec.ts
+++ b/tests/integration/tests/51-quickstart-cross-surface.spec.ts
@@ -44,6 +44,7 @@ type AISettingsPayload = {
quickstart_credits_remaining: number;
quickstart_credits_available: boolean;
using_quickstart: boolean;
+ quickstart_blocked_reason?: string;
};
type PatrolStatusPayload = {
@@ -626,7 +627,7 @@ test.describe("Quickstart cross-surface browser contract", () => {
await expect(page.getByText("Health A · 100/100")).toHaveCount(0);
});
- test.fail("activated-install first AI enable toggle should not force BYOK setup when quickstart credits are available", async ({
+ test("activated-install first AI enable toggle should not force BYOK setup when quickstart credits are available", async ({
page,
}, testInfo) => {
test.skip(testInfo.project.name.startsWith("mobile-"), "Desktop-only quickstart coverage");
@@ -653,7 +654,7 @@ test.describe("Quickstart cross-surface browser contract", () => {
await page.goto("/settings/system-ai", { waitUntil: "domcontentloaded" });
await expect(page.getByRole("heading", { name: "AI Services", level: 1 })).toBeVisible();
- await page.locator("button[aria-pressed]").first().click();
+ await page.getByRole("button", { name: "Enable AI services" }).click();
expect(surface.updateRequests).toHaveLength(1);
await expect(page.getByText("Choose a provider to get started")).toHaveCount(0);