The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(settings): correct background loop controls in usage panel
Steven Enamakelc9fd65b82a4a
diff --git a/app/src/components/settings/panels/UsagePanel.tsx b/app/src/components/settings/panels/UsagePanel.tsxindex b34d9ce203..a5f4b206e8 100644--- a/app/src/components/settings/panels/UsagePanel.tsx+++ b/app/src/components/settings/panels/UsagePanel.tsx@@ -1,11 +1,8 @@-import { useEffect, useState } from 'react';import { useLocation, useNavigate } from 'react-router-dom';import { useT } from '../../../lib/i18n/I18nContext';-import { type AISettings, loadAISettings } from '../../../services/api/aiSettingsApi';import CostDashboardPanel from '../../dashboard/CostDashboardPanel';import UsageLogPanel from '../../dashboard/UsageLogPanel';-import { Alert, AlertDescription, CenteredLoadingState } from '../../ui';import SettingsTabbedPage from '../layout/SettingsTabbedPage';import BackgroundLoopControls from './ai/BackgroundLoopControls';import TokenUsagePanel from './TokenUsagePanel';@@ -70,49 +67,11 @@ const UsagePanel = () => {);};-/**- * Background-activity tab body. Fetches the AI settings snapshot (routing map- * + cloud providers) that BackgroundLoopControls needs — lazily, only when- * this tab is mounted, so the default Costs tab doesn't pay for it.- */-const BackgroundActivityTab = () => {- const { t } = useT();- const [snapshot, setSnapshot] = useState<AISettings | null>(null);- const [loadError, setLoadError] = useState<string | null>(null);-- useEffect(() => {- let cancelled = false;- loadAISettings()- .then(s => {- if (!cancelled) setSnapshot(s);- })- .catch(err => {- if (!cancelled) setLoadError(err instanceof Error ? err.message : String(err));- });- return () => {- cancelled = true;- };- }, []);-- return (- <div className="space-y-4" data-testid="usage-background-tab">- {loadError && (- <Alert variant="destructive" density="compact">- <AlertDescription>{loadError}</AlertDescription>- </Alert>- )}- {snapshot ? (- <BackgroundLoopControls- view="all"- hideHeader- routing={snapshot.routing}- cloudProviders={snapshot.cloudProviders}- />- ) : !loadError ? (- <CenteredLoadingState label={t('common.loading')} />- ) : null}- </div>- );-};+/** Background-activity tab body: the loop map plus the credit ledger. */+const BackgroundActivityTab = () => (+ <div className="space-y-4" data-testid="usage-background-tab">+ <BackgroundLoopControls view="all" hideHeader />+ </div>+);export default UsagePanel;diff --git a/app/src/components/settings/panels/__tests__/AIPanel.test.tsx b/app/src/components/settings/panels/__tests__/AIPanel.test.tsxindex 173a0feb45..c35db134a4 100644--- a/app/src/components/settings/panels/__tests__/AIPanel.test.tsx+++ b/app/src/components/settings/panels/__tests__/AIPanel.test.tsx@@ -2163,11 +2163,7 @@ describe('AIPanel', () => {it('renders background loop diagnostics with newest spend row and budget math', async () => {// BackgroundLoopControls was moved out of AIPanel into standalone panels.renderWithProviders(- <BackgroundLoopControls- view="all"- routing={baseSettings.routing}- cloudProviders={baseSettings.cloudProviders}- />+ <BackgroundLoopControls view="all" />);await waitFor(() => expect(screen.getByText('Background loops')).toBeInTheDocument());diff --git a/app/src/components/settings/panels/__tests__/UsagePanel.test.tsx b/app/src/components/settings/panels/__tests__/UsagePanel.test.tsxindex c1a2cc56d7..4cc5bb2eae 100644--- a/app/src/components/settings/panels/__tests__/UsagePanel.test.tsx+++ b/app/src/components/settings/panels/__tests__/UsagePanel.test.tsx@@ -59,8 +59,6 @@ describe('UsagePanel', () => {expect(screen.getByTestId('usage-tab-costs')).toHaveAttribute('aria-selected', 'true');expect(screen.getByTestId('usage-tab-background')).toHaveAttribute('aria-selected', 'false');expect(screen.getByTestId('stub-cost-dashboard')).toHaveAttribute('data-embedded', 'true');- // Costs tab must not pay for the AI-settings snapshot.- expect(mockLoad).not.toHaveBeenCalled();});test('#tokens hash selects the Token savings tab with the embedded TokenJuice panel', () => {diff --git a/app/src/components/settings/panels/ai/BackgroundLoopControls.tsx b/app/src/components/settings/panels/ai/BackgroundLoopControls.tsxindex 19e5c0f8e1..2c6bf71410 100644--- a/app/src/components/settings/panels/ai/BackgroundLoopControls.tsx+++ b/app/src/components/settings/panels/ai/BackgroundLoopControls.tsx@@ -18,12 +18,9 @@ import {type TeamUsage,} from '../../../../services/api/creditsApi';import { Badge, Button, Card, StatusLine } from '../../../ui';-import type { RoutingMap } from './aiPanelTypes';import {activeConnection,- type BackgroundLoopProviderView,COMPOSIO_PERIODIC_TICK_MINUTES,- describeProvider,formatCount,spendAmount,summarizeSpendByAction,@@ -38,13 +35,9 @@ const log = debug('settings:background-loops');type BackgroundLoopControlsView = 'all' | 'ledger';export const BackgroundLoopControls = ({- routing,- cloudProviders,view = 'all',hideHeader = false,}: {- routing: RoutingMap;- cloudProviders: BackgroundLoopProviderView[];view?: BackgroundLoopControlsView;hideHeader?: boolean;}) => {diff --git a/app/src/components/settings/panels/ai/backgroundLoopPrimitives.tsx b/app/src/components/settings/panels/ai/backgroundLoopPrimitives.tsxindex 0a8c74a495..5a7ae486f6 100644--- a/app/src/components/settings/panels/ai/backgroundLoopPrimitives.tsx+++ b/app/src/components/settings/panels/ai/backgroundLoopPrimitives.tsx@@ -4,7 +4,6 @@*/import type { ComposioConnection } from '../../../../lib/composio/types';import type { CreditTransaction } from '../../../../services/api/creditsApi';-import type { ProviderRef } from './aiPanelTypes';export const USD = new Intl.NumberFormat('en-US', {style: 'currency',@@ -99,24 +98,6 @@ export function summarizeSpendSample(transactions: CreditTransaction[]) {return { rows, total, avgRowUsd, sampleHours, spendPerHour, rowsPerHour };}-/** Minimal cloud-provider shape consumed by `describeProvider` — only- * slug/label/id are read. Accepting this narrower shape lets external panels- * (UsagePanel) feed in the API view (`CloudProviderView`) without copying the- * AIPanel-internal extras (`authStyle`, `maskedKey`). */-export type BackgroundLoopProviderView = { id: string; slug: string; label: string };--export function describeProvider(- ref: ProviderRef,- providers: BackgroundLoopProviderView[]-): string {- if (ref.kind === 'openhuman') return 'Managed · OpenHuman';- if (ref.kind === 'default') return 'Default route';- if (ref.kind === 'local') return `Local ${ref.model}`;- if (ref.kind === 'claude-code') return `Claude Code CLI ${ref.model || 'default model'}`;- const provider = providers.find(p => p.slug === ref.providerSlug);- return `${provider?.label ?? ref.providerSlug} ${ref.model || 'custom model'}`;-}-export const MetricTile = ({label,value,