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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Reframe provider usage for assistant and patrol
rcourtman465143380946
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 009189f682..4cdb19c854 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -102,6 +102,12 @@ That backend/runtime ownership does not require the Patrol product surface toinherit `AI` as its canonical browser route: the customer-facing shell may use`/patrol` while shared AI transport, provider settings, and payload contractsremain the governed technical boundary behind it.+That same operator-facing vocabulary rule applies to the runtime usage surface:+`frontend-modern/src/components/AI/AICostDashboard.tsx` must present provider+usage and spend backing Pulse Assistant and Patrol rather than generic `AI`+history, and `frontend-modern/src/utils/aiCostPresentation.ts` must own the+title, empty/loading states, budget note, and reset/export history messaging so+settings shells and runtime widgets do not fork their own usage wording.`internal/ai/` is the live backend AI engine. It owns chat execution, Patrolorchestration, findings generation, investigation support, quickstart anddiff --git a/frontend-modern/src/components/AI/AICostDashboard.tsx b/frontend-modern/src/components/AI/AICostDashboard.tsxindex 9bdb7eed11..71cf9db58d 100644--- a/frontend-modern/src/components/AI/AICostDashboard.tsx+++ b/frontend-modern/src/components/AI/AICostDashboard.tsx@@ -17,11 +17,25 @@ import { notificationStore } from '@/stores/notifications';import type { AICostSummary } from '@/types/ai';import { getAIProviderDisplayName } from '@/utils/aiProviderPresentation';import {+ AI_COST_ASSISTANT_USE_CASE_LABEL,+ AI_COST_BUDGET_LABEL,AI_COST_DAILY_TOKEN_EMPTY_STATE,AI_COST_DAILY_USD_EMPTY_STATE,AI_COST_EMPTY_STATE,+ AI_COST_PANEL_DESCRIPTION,+ AI_COST_PANEL_TITLE,+ AI_COST_PATROL_USE_CASE_LABEL,+ AI_COST_PROVIDER_MODEL_PAIR_LABEL,+ AI_COST_RESET_HISTORY_LABEL,+ buildAICostExportFilename,+ getAICostBudgetNote,+ getAICostExportHistoryErrorMessage,getAICostLoadingState,+ getAICostRefreshErrorMessage,getAICostRangeButtonClass,+ getAICostResetHistoryConfirmationMessage,+ getAICostResetHistoryErrorMessage,+ getAICostResetHistorySuccessMessage,} from '@/utils/aiCostPresentation';const usdFormatter = new Intl.NumberFormat(undefined, {@@ -154,7 +168,7 @@ export const AICostDashboard: Component = () => {logger.error('[AICostDashboard] Failed to load cost summary:', err);// Only show notification on refresh failures, not initial loadif (!isInitialLoad) {- notificationStore.error('Failed to refresh Pulse Assistant usage summary');+ notificationStore.error(getAICostRefreshErrorMessage());}const message =err instanceof Error && err.message ? err.message : 'Failed to load usage data';@@ -202,25 +216,15 @@ export const AICostDashboard: Component = () => {});const resetHistory = async () => {- if (- !confirm(- 'Reset Pulse Assistant usage history? A backup will be created in the Pulse config directory.',- )- )+ if (!confirm(getAICostResetHistoryConfirmationMessage()))return;try {const result = await AIAPI.resetCostHistory();- if (result.backup_file) {- notificationStore.success(- `Pulse Assistant usage history reset (backup: ${result.backup_file})`,- );- } else {- notificationStore.success('Pulse Assistant usage history reset');- }+ notificationStore.success(getAICostResetHistorySuccessMessage(result.backup_file));await loadSummary(days());} catch (err) {logger.error('[AICostDashboard] Failed to reset AI cost history:', err);- notificationStore.error('Failed to reset Pulse Assistant usage history');+ notificationStore.error(getAICostResetHistoryErrorMessage());}};@@ -234,14 +238,14 @@ export const AICostDashboard: Component = () => {const url = URL.createObjectURL(blob);const a = document.createElement('a');a.href = url;- a.download = `pulse-ai-usage-${new Date().toISOString().split('T')[0]}-${days()}d.${format}`;+ a.download = buildAICostExportFilename(days(), format);document.body.appendChild(a);a.click();a.remove();URL.revokeObjectURL(url);} catch (err) {logger.error('[AICostDashboard] Failed to export cost history:', err);- notificationStore.error('Failed to export Pulse Assistant usage history');+ notificationStore.error(getAICostExportHistoryErrorMessage());}};@@ -271,8 +275,8 @@ export const AICostDashboard: Component = () => {</svg></div><SectionHeader- title="Pulse Cost & Usage"- description="Token usage and estimated spend across providers"+ title={AI_COST_PANEL_TITLE}+ description={AI_COST_PANEL_DESCRIPTION}size="sm"class="flex-1"/>@@ -387,7 +391,7 @@ export const AICostDashboard: Component = () => {</div></div><div class="p-3 rounded-md bg-surface-alt border border-border">- <div class="text-xs text-muted">Model/provider pairs</div>+ <div class="text-xs text-muted">{AI_COST_PROVIDER_MODEL_PAIR_LABEL}</div><div class="text-lg font-semibold text-base-content">{formatNumber(data().provider_models.length)}</div>@@ -396,7 +400,7 @@ export const AICostDashboard: Component = () => {<div class="grid grid-cols-1 sm:grid-cols-3 gap-3"><div class="p-3 rounded-md bg-surface-alt border border-border">- <div class="text-xs text-muted">Chat</div>+ <div class="text-xs text-muted">{AI_COST_ASSISTANT_USE_CASE_LABEL}</div><div class="text-sm font-semibold text-base-content">{formatNumber(useCaseMap().get('chat')?.tokens ?? 0)} tokens</div>@@ -407,7 +411,7 @@ export const AICostDashboard: Component = () => {</div></div><div class="p-3 rounded-md bg-surface-alt border border-border">- <div class="text-xs text-muted">Patrol</div>+ <div class="text-xs text-muted">{AI_COST_PATROL_USE_CASE_LABEL}</div><div class="text-sm font-semibold text-base-content">{formatNumber(useCaseMap().get('patrol')?.tokens ?? 0)} tokens</div>@@ -418,7 +422,7 @@ export const AICostDashboard: Component = () => {</div></div><div class="p-3 rounded-md bg-surface-alt border border-border">- <div class="text-xs text-muted">Budget alert (USD per 30d)</div>+ <div class="text-xs text-muted">{AI_COST_BUDGET_LABEL}</div><div class="text-sm font-semibold text-base-content mt-1"><Showwhen={parsedBudgetUSD30d() != null}@@ -428,7 +432,7 @@ export const AICostDashboard: Component = () => {</Show></div><div class="text-[11px] text-muted mt-1">- Set in Pulse Assistant settings. Pro-rated for {days()}d:{' '}+ {getAICostBudgetNote(days())}{' '}<Show when={budgetForRange() != null} fallback={<span>—</span>}>{formatUSD(budgetForRange() ?? 0)}</Show>@@ -530,7 +534,7 @@ export const AICostDashboard: Component = () => {onClick={resetHistory}class={`min-h-10 sm:min-h-9 px-2.5 py-2 text-sm rounded border border-border hover:bg-surface-hover ${loading() ? 'opacity-60 cursor-not-allowed' : ''}`}>- Reset history+ {AI_COST_RESET_HISTORY_LABEL}</button></div></div>diff --git a/frontend-modern/src/components/AI/__tests__/AICostDashboard.test.tsx b/frontend-modern/src/components/AI/__tests__/AICostDashboard.test.tsxindex 1337f95e5b..07f814b6c8 100644--- a/frontend-modern/src/components/AI/__tests__/AICostDashboard.test.tsx+++ b/frontend-modern/src/components/AI/__tests__/AICostDashboard.test.tsx@@ -184,7 +184,7 @@ describe('AICostDashboard', () => {it('renders header with title', async () => {renderDashboard();await waitFor(() => {- expect(screen.getByText('Pulse Cost & Usage')).toBeInTheDocument();+ expect(screen.getByText('Provider Usage & Spend')).toBeInTheDocument();});});@@ -203,10 +203,10 @@ describe('AICostDashboard', () => {it('displays model/provider pair count', async () => {renderDashboard();await waitFor(() => {- expect(screen.getByText('Model/provider pairs')).toBeInTheDocument();+ expect(screen.getByText('Provider/model pairs')).toBeInTheDocument();});// Verify the count is rendered in the same card container- const pairCard = screen.getByText('Model/provider pairs').closest('.p-3')!;+ const pairCard = screen.getByText('Provider/model pairs').closest('.p-3')!;expect(pairCard.textContent).toContain('1');});@@ -227,7 +227,7 @@ describe('AICostDashboard', () => {it('displays chat and patrol token breakdowns', async () => {renderDashboard();await waitFor(() => {- expect(screen.getByText('Chat')).toBeInTheDocument();+ expect(screen.getByText('Pulse Assistant')).toBeInTheDocument();});expect(screen.getByText('36,000 tokens')).toBeInTheDocument();expect(screen.getByText('Patrol')).toBeInTheDocument();@@ -294,10 +294,10 @@ describe('AICostDashboard', () => {it('displays budget info from AI settings', async () => {renderDashboard();await waitFor(() => {- expect(screen.getByText('Budget alert (USD per 30d)')).toBeInTheDocument();+ expect(screen.getByText('30-day budget (USD)')).toBeInTheDocument();});// Budget is $10/30d — should show 10.00 formatted as currency- const budgetCard = screen.getByText('Budget alert (USD per 30d)').closest('.p-3')!;+ const budgetCard = screen.getByText('30-day budget (USD)').closest('.p-3')!;expect(budgetCard.textContent).toMatch(/10\.00/);});@@ -308,9 +308,9 @@ describe('AICostDashboard', () => {const firstMount = renderDashboard();await waitFor(() => {- expect(screen.getByText('Budget alert (USD per 30d)')).toBeInTheDocument();+ expect(screen.getByText('30-day budget (USD)')).toBeInTheDocument();});- let budgetCard = screen.getByText('Budget alert (USD per 30d)').closest('.p-3')!;+ let budgetCard = screen.getByText('30-day budget (USD)').closest('.p-3')!;expect(budgetCard.textContent).toMatch(/10\.00/);firstMount.unmount();@@ -320,7 +320,7 @@ describe('AICostDashboard', () => {await waitFor(() => {expect(getSettingsMock).toHaveBeenCalledTimes(2);});- budgetCard = screen.getByText('Budget alert (USD per 30d)').closest('.p-3')!;+ budgetCard = screen.getByText('30-day budget (USD)').closest('.p-3')!;expect(budgetCard.textContent).toMatch(/25\.00/);});@@ -496,9 +496,7 @@ describe('AICostDashboard', () => {expect(screen.getByText(/Couldn.t refresh/)).toBeInTheDocument();});// Should show notification for refresh failure- expect(notificationErrorMock).toHaveBeenCalledWith(- 'Failed to refresh Pulse Assistant usage summary',- );+ expect(notificationErrorMock).toHaveBeenCalledWith('Failed to refresh provider usage summary');// Retry button is presentexpect(screen.getByText('Retry')).toBeInTheDocument();});@@ -513,10 +511,12 @@ describe('AICostDashboard', () => {renderDashboard();// While loading, we see the shared usage-loading copy.- expect(screen.getByText('Loading usage data…')).toBeInTheDocument();+ expect(screen.getByText('Loading provider usage…')).toBeInTheDocument();// The empty state should not appear while loading.expect(- screen.queryByText('Usage data will appear here once activity is recorded.'),+ screen.queryByText(+ 'Provider usage data will appear here once Pulse Assistant or Patrol activity is recorded.',+ ),).not.toBeInTheDocument();// Now resolve — data appears@@ -538,7 +538,7 @@ describe('AICostDashboard', () => {expect(screen.getByText('Estimated spend')).toBeInTheDocument();});- fireEvent.click(screen.getByText('Reset history'));+ fireEvent.click(screen.getByText('Reset usage history'));await waitFor(() => {expect(resetCostHistoryMock).toHaveBeenCalled();@@ -559,10 +559,10 @@ describe('AICostDashboard', () => {expect(screen.getByText('Estimated spend')).toBeInTheDocument();});- fireEvent.click(screen.getByText('Reset history'));+ fireEvent.click(screen.getByText('Reset usage history'));await waitFor(() => {- expect(notificationSuccessMock).toHaveBeenCalledWith('Pulse Assistant usage history reset');+ expect(notificationSuccessMock).toHaveBeenCalledWith('Provider usage history reset');});});@@ -574,7 +574,7 @@ describe('AICostDashboard', () => {expect(screen.getByText('Estimated spend')).toBeInTheDocument();});- fireEvent.click(screen.getByText('Reset history'));+ fireEvent.click(screen.getByText('Reset usage history'));expect(resetCostHistoryMock).not.toHaveBeenCalled();});@@ -588,12 +588,10 @@ describe('AICostDashboard', () => {expect(screen.getByText('Estimated spend')).toBeInTheDocument();});- fireEvent.click(screen.getByText('Reset history'));+ fireEvent.click(screen.getByText('Reset usage history'));await waitFor(() => {- expect(notificationErrorMock).toHaveBeenCalledWith(- 'Failed to reset Pulse Assistant usage history',- );+ expect(notificationErrorMock).toHaveBeenCalledWith('Failed to reset provider usage history');});});@@ -668,9 +666,7 @@ describe('AICostDashboard', () => {fireEvent.click(screen.getByText('Export CSV'));await waitFor(() => {- expect(notificationErrorMock).toHaveBeenCalledWith(- 'Failed to export Pulse Assistant usage history',- );+ expect(notificationErrorMock).toHaveBeenCalledWith('Failed to export provider usage history');});});@@ -685,9 +681,7 @@ describe('AICostDashboard', () => {fireEvent.click(screen.getByText('Export JSON'));await waitFor(() => {- expect(notificationErrorMock).toHaveBeenCalledWith(- 'Failed to export Pulse Assistant usage history',- );+ expect(notificationErrorMock).toHaveBeenCalledWith('Failed to export provider usage history');});});@@ -743,7 +737,7 @@ describe('AICostDashboard', () => {renderDashboard();await waitFor(() => {expect(- screen.getByText('Daily token trend will appear here once activity is recorded.'),+ screen.getByText('Daily token trend will appear here once provider activity is recorded.'),).toBeInTheDocument();});});@@ -782,10 +776,10 @@ describe('AICostDashboard', () => {getSettingsMock.mockResolvedValue(baseSettings({ cost_budget_usd_30d: 0 }));renderDashboard();await waitFor(() => {- expect(screen.getByText('Budget alert (USD per 30d)')).toBeInTheDocument();+ expect(screen.getByText('30-day budget (USD)')).toBeInTheDocument();});// parsedBudgetUSD30d should return null for 0, so budget shows "—"- const budgetCard = screen.getByText('Budget alert (USD per 30d)').closest('.p-3')!;+ const budgetCard = screen.getByText('30-day budget (USD)').closest('.p-3')!;expect(budgetCard.textContent).toContain('—');});@@ -793,9 +787,9 @@ describe('AICostDashboard', () => {getSettingsMock.mockResolvedValue(baseSettings({ cost_budget_usd_30d: -5 }));renderDashboard();await waitFor(() => {- expect(screen.getByText('Budget alert (USD per 30d)')).toBeInTheDocument();+ expect(screen.getByText('30-day budget (USD)')).toBeInTheDocument();});- const budgetCard = screen.getByText('Budget alert (USD per 30d)').closest('.p-3')!;+ const budgetCard = screen.getByText('30-day budget (USD)').closest('.p-3')!;expect(budgetCard.textContent).toContain('—');});@@ -805,9 +799,9 @@ describe('AICostDashboard', () => {getSettingsMock.mockRejectedValue(new Error('Auth error'));renderDashboard();await waitFor(() => {- expect(screen.getByText('Budget alert (USD per 30d)')).toBeInTheDocument();+ expect(screen.getByText('30-day budget (USD)')).toBeInTheDocument();});- const budgetCard = screen.getByText('Budget alert (USD per 30d)').closest('.p-3')!;+ const budgetCard = screen.getByText('30-day budget (USD)').closest('.p-3')!;expect(budgetCard.textContent).toContain('—');});});diff --git a/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts b/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.tsindex 1b9095b7f9..af41bea0e8 100644--- a/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts+++ b/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts@@ -752,9 +752,16 @@ describe('monitored-system model guardrails', () => {expect(patrolSummaryPresentationSource).toContain('export const PATROL_NO_ISSUES_LABEL');expect(aiCostDashboardSource).toContain('getAICostRangeButtonClass');expect(aiCostDashboardSource).toContain('getAICostLoadingState');+ expect(aiCostDashboardSource).toContain('AI_COST_PANEL_TITLE');+ expect(aiCostDashboardSource).toContain('AI_COST_PANEL_DESCRIPTION');expect(aiCostDashboardSource).toContain('AI_COST_EMPTY_STATE');expect(aiCostDashboardSource).toContain('AI_COST_DAILY_USD_EMPTY_STATE');expect(aiCostDashboardSource).toContain('AI_COST_DAILY_TOKEN_EMPTY_STATE');+ expect(aiCostDashboardSource).toContain('getAICostRefreshErrorMessage');+ expect(aiCostDashboardSource).toContain('getAICostResetHistoryConfirmationMessage');+ expect(aiCostDashboardSource).toContain('getAICostResetHistorySuccessMessage');+ expect(aiCostDashboardSource).toContain('getAICostResetHistoryErrorMessage');+ expect(aiCostDashboardSource).toContain('getAICostExportHistoryErrorMessage');expect(aiCostDashboardSource).not.toContain('No usage data yet.');expect(aiCostDashboardSource).not.toContain('No daily USD trend yet.');expect(aiCostDashboardSource).not.toContain('No daily token trend yet.');@@ -765,6 +772,13 @@ describe('monitored-system model guardrails', () => {expect(aiCostPresentationSource).toContain('export const AI_COST_EMPTY_STATE');expect(aiCostPresentationSource).toContain('export const AI_COST_DAILY_USD_EMPTY_STATE');expect(aiCostPresentationSource).toContain('export const AI_COST_DAILY_TOKEN_EMPTY_STATE');+ expect(aiCostPresentationSource).toContain('export const AI_COST_PANEL_TITLE');+ expect(aiCostPresentationSource).toContain('export const AI_COST_PANEL_DESCRIPTION');+ expect(aiCostPresentationSource).toContain('export function getAICostRefreshErrorMessage');+ expect(aiCostPresentationSource).toContain('export function getAICostResetHistoryConfirmationMessage');+ expect(aiCostPresentationSource).toContain('export function getAICostResetHistorySuccessMessage');+ expect(aiCostPresentationSource).toContain('export function getAICostResetHistoryErrorMessage');+ expect(aiCostPresentationSource).toContain('export function getAICostExportHistoryErrorMessage');expect(rbacFeatureGateSectionSource).toContain('@/utils/upgradePresentation');expect(agentProfilesPanelStateSource).toContain('@/utils/upgradePresentation');expect(auditLogPanelSource).toContain('@/utils/upgradePresentation');@@ -1013,7 +1027,7 @@ describe('monitored-system model guardrails', () => {'const hasAgentFacet = (resource: Resource): boolean =>',);expect(infrastructureSelectorSource).not.toContain("resource.type === 'truenas'");- expect(infrastructureSelectorStateSource).toContain('useResources');+ expect(infrastructureSelectorStateSource).toContain('useUnifiedResources');expect(infrastructureSelectorModelSource).toContain('hasInfrastructureSelectorAgentFacet');expect(infrastructureSelectorModelSource).toContain('isAgentFacetInfrastructureResource');expect(infrastructureSelectorModelSource).not.toContain('if (hostLikeResources.length === 0');diff --git a/frontend-modern/src/utils/__tests__/aiCostPresentation.test.ts b/frontend-modern/src/utils/__tests__/aiCostPresentation.test.tsindex fc647b8a43..61448e3600 100644--- a/frontend-modern/src/utils/__tests__/aiCostPresentation.test.ts+++ b/frontend-modern/src/utils/__tests__/aiCostPresentation.test.ts@@ -1,10 +1,24 @@import { describe, expect, it } from 'vitest';import {+ AI_COST_ASSISTANT_USE_CASE_LABEL,+ AI_COST_BUDGET_LABEL,AI_COST_DAILY_TOKEN_EMPTY_STATE,AI_COST_DAILY_USD_EMPTY_STATE,AI_COST_EMPTY_STATE,+ AI_COST_PANEL_DESCRIPTION,+ AI_COST_PANEL_TITLE,+ AI_COST_PATROL_USE_CASE_LABEL,+ AI_COST_PROVIDER_MODEL_PAIR_LABEL,+ AI_COST_RESET_HISTORY_LABEL,+ buildAICostExportFilename,+ getAICostBudgetNote,+ getAICostExportHistoryErrorMessage,getAICostLoadingState,+ getAICostRefreshErrorMessage,getAICostRangeButtonClass,+ getAICostResetHistoryConfirmationMessage,+ getAICostResetHistoryErrorMessage,+ getAICostResetHistorySuccessMessage,} from '@/utils/aiCostPresentation';describe('aiCostPresentation', () => {@@ -14,16 +28,43 @@ describe('aiCostPresentation', () => {expect(getAICostRangeButtonClass(false, true)).toContain('cursor-not-allowed');});- it('exports canonical AI cost empty-state copy', () => {- expect(AI_COST_EMPTY_STATE).toBe('Usage data will appear here once activity is recorded.');+ it('exports canonical AI cost presentation copy', () => {+ expect(AI_COST_PANEL_TITLE).toBe('Provider Usage & Spend');+ expect(AI_COST_PANEL_DESCRIPTION).toBe(+ 'Token usage and estimated spend across providers backing Pulse Assistant and Patrol.',+ );+ expect(AI_COST_PROVIDER_MODEL_PAIR_LABEL).toBe('Provider/model pairs');+ expect(AI_COST_ASSISTANT_USE_CASE_LABEL).toBe('Pulse Assistant');+ expect(AI_COST_PATROL_USE_CASE_LABEL).toBe('Patrol');+ expect(AI_COST_BUDGET_LABEL).toBe('30-day budget (USD)');+ expect(AI_COST_RESET_HISTORY_LABEL).toBe('Reset usage history');+ expect(AI_COST_EMPTY_STATE).toBe(+ 'Provider usage data will appear here once Pulse Assistant or Patrol activity is recorded.',+ );expect(AI_COST_DAILY_USD_EMPTY_STATE).toBe(- 'Daily cost trend will appear here once activity is recorded.',+ 'Daily spend trend will appear here once provider activity is recorded.',);expect(AI_COST_DAILY_TOKEN_EMPTY_STATE).toBe(- 'Daily token trend will appear here once activity is recorded.',+ 'Daily token trend will appear here once provider activity is recorded.',);expect(getAICostLoadingState()).toEqual({- text: 'Loading usage data…',+ text: 'Loading provider usage…',});+ expect(getAICostRefreshErrorMessage()).toBe('Failed to refresh provider usage summary');+ expect(getAICostBudgetNote(7)).toBe(+ 'Configured in Assistant & Patrol settings. Pro-rated for 7d:',+ );+ expect(getAICostResetHistoryConfirmationMessage()).toBe(+ 'Reset provider usage history? A backup will be created in the Pulse config directory.',+ );+ expect(getAICostResetHistorySuccessMessage('/tmp/backup.json')).toBe(+ 'Provider usage history reset (backup: /tmp/backup.json)',+ );+ expect(getAICostResetHistorySuccessMessage()).toBe('Provider usage history reset');+ expect(getAICostResetHistoryErrorMessage()).toBe('Failed to reset provider usage history');+ expect(getAICostExportHistoryErrorMessage()).toBe('Failed to export provider usage history');+ expect(+ buildAICostExportFilename(30, 'csv', new Date('2026-03-01T12:00:00Z')),+ ).toBe('pulse-provider-usage-2026-03-01-30d.csv');});});diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex 9225987d2e..42f646bb70 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -4467,7 +4467,7 @@ describe('frontend resource type boundaries', () => {expect(patrolInvestigationContextModelSource).toContain('export function buildPatrolInvestigationContextSummary',);- expect(patrolInvestigationContextModelSource).toContain('governed resource');+ expect(patrolInvestigationContextModelSource).toContain('policy-covered resource');expect(patrolIntelligenceHeaderSource).toContain('buildPatrolScheduleOptions');expect(patrolIntelligenceHeaderSource).toContain('getAIQuickstartCreditsPresentation');expect(patrolIntelligenceSummarySource).toContain('getPatrolSummaryPresentation');@@ -4559,9 +4559,16 @@ describe('frontend resource type boundaries', () => {);expect(aiCostDashboardSource).toContain('getAICostRangeButtonClass');expect(aiCostDashboardSource).toContain('getAICostLoadingState');+ expect(aiCostDashboardSource).toContain('AI_COST_PANEL_TITLE');+ expect(aiCostDashboardSource).toContain('AI_COST_PANEL_DESCRIPTION');expect(aiCostDashboardSource).toContain('AI_COST_EMPTY_STATE');expect(aiCostDashboardSource).toContain('AI_COST_DAILY_USD_EMPTY_STATE');expect(aiCostDashboardSource).toContain('AI_COST_DAILY_TOKEN_EMPTY_STATE');+ expect(aiCostDashboardSource).toContain('getAICostRefreshErrorMessage');+ expect(aiCostDashboardSource).toContain('getAICostResetHistoryConfirmationMessage');+ expect(aiCostDashboardSource).toContain('getAICostResetHistorySuccessMessage');+ expect(aiCostDashboardSource).toContain('getAICostResetHistoryErrorMessage');+ expect(aiCostDashboardSource).toContain('getAICostExportHistoryErrorMessage');expect(aiCostDashboardSource).not.toContain('No usage data yet.');expect(aiCostDashboardSource).not.toContain('No daily USD trend yet.');expect(aiCostDashboardSource).not.toContain('No daily token trend yet.');@@ -4573,6 +4580,13 @@ describe('frontend resource type boundaries', () => {expect(aiCostPresentationSource).toContain('export function getAICostLoadingState');expect(aiCostPresentationSource).toContain('export const AI_COST_DAILY_USD_EMPTY_STATE');expect(aiCostPresentationSource).toContain('export const AI_COST_DAILY_TOKEN_EMPTY_STATE');+ expect(aiCostPresentationSource).toContain('export const AI_COST_PANEL_TITLE');+ expect(aiCostPresentationSource).toContain('export const AI_COST_PANEL_DESCRIPTION');+ expect(aiCostPresentationSource).toContain('export function getAICostRefreshErrorMessage');+ expect(aiCostPresentationSource).toContain('export function getAICostResetHistoryConfirmationMessage');+ expect(aiCostPresentationSource).toContain('export function getAICostResetHistorySuccessMessage');+ expect(aiCostPresentationSource).toContain('export function getAICostResetHistoryErrorMessage');+ expect(aiCostPresentationSource).toContain('export function getAICostExportHistoryErrorMessage');expect(modelSelectorSource).toContain('AI_CHAT_MODEL_SELECTOR_EMPTY_STATE');expect(modelSelectorSource).not.toContain('No matching models.');expect(aiChatPresentationSource).toContain('export const AI_CHAT_MODEL_SELECTOR_EMPTY_STATE');diff --git a/frontend-modern/src/utils/aiCostPresentation.ts b/frontend-modern/src/utils/aiCostPresentation.tsindex 444f871d0e..704472eb2e 100644--- a/frontend-modern/src/utils/aiCostPresentation.ts+++ b/frontend-modern/src/utils/aiCostPresentation.ts@@ -1,17 +1,60 @@import { segmentedButtonClass } from '@/utils/segmentedButton';-export const AI_COST_EMPTY_STATE = 'Usage data will appear here once activity is recorded.';+export const AI_COST_PANEL_TITLE = 'Provider Usage & Spend';+export const AI_COST_PANEL_DESCRIPTION =+ 'Token usage and estimated spend across providers backing Pulse Assistant and Patrol.';+export const AI_COST_PROVIDER_MODEL_PAIR_LABEL = 'Provider/model pairs';+export const AI_COST_ASSISTANT_USE_CASE_LABEL = 'Pulse Assistant';+export const AI_COST_PATROL_USE_CASE_LABEL = 'Patrol';+export const AI_COST_BUDGET_LABEL = '30-day budget (USD)';+export const AI_COST_RESET_HISTORY_LABEL = 'Reset usage history';+export const AI_COST_EMPTY_STATE =+ 'Provider usage data will appear here once Pulse Assistant or Patrol activity is recorded.';export const AI_COST_DAILY_USD_EMPTY_STATE =- 'Daily cost trend will appear here once activity is recorded.';+ 'Daily spend trend will appear here once provider activity is recorded.';export const AI_COST_DAILY_TOKEN_EMPTY_STATE =- 'Daily token trend will appear here once activity is recorded.';+ 'Daily token trend will appear here once provider activity is recorded.';export function getAICostLoadingState() {return {- text: 'Loading usage data…',+ text: 'Loading provider usage…',} as const;}+export function getAICostRefreshErrorMessage() {+ return 'Failed to refresh provider usage summary';+}++export function getAICostBudgetNote(rangeDays: number) {+ return `Configured in Assistant & Patrol settings. Pro-rated for ${rangeDays}d:`;+}++export function getAICostResetHistoryConfirmationMessage() {+ return 'Reset provider usage history? A backup will be created in the Pulse config directory.';+}++export function getAICostResetHistorySuccessMessage(backupFile?: string | null) {+ return backupFile+ ? `Provider usage history reset (backup: ${backupFile})`+ : 'Provider usage history reset';+}++export function getAICostResetHistoryErrorMessage() {+ return 'Failed to reset provider usage history';+}++export function getAICostExportHistoryErrorMessage() {+ return 'Failed to export provider usage history';+}++export function buildAICostExportFilename(+ rangeDays: number,+ format: 'csv' | 'json',+ now = new Date(),+) {+ return `pulse-provider-usage-${now.toISOString().split('T')[0]}-${rangeDays}d.${format}`;+}+export function getAICostRangeButtonClass(selected: boolean, disabled = false): string {return `min-h-10 sm:min-h-9 min-w-10 border px-2.5 py-2 text-sm ${segmentedButtonClass(selected, disabled)}`;}