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
chore(settings): remove unused background loop controls and calendar helper
Steven Enamakel8d02334260d3
diff --git a/app/src/components/settings/panels/AIPanel.tsx b/app/src/components/settings/panels/AIPanel.tsxindex 03f6a75f9e..e22c3926f0 100644--- a/app/src/components/settings/panels/AIPanel.tsx+++ b/app/src/components/settings/panels/AIPanel.tsx@@ -970,11 +970,6 @@ const activeConnection = (connection: ComposioConnection): boolean => {const normalizedToolkit = (connection: ComposioConnection): string =>connection.toolkit.toLowerCase().replace(/[^a-z0-9]/g, '');-const isCalendarConnection = (connection: ComposioConnection): boolean => {- const toolkit = normalizedToolkit(connection);- return toolkit === 'googlecalendar' || toolkit === 'calendar';-};-function summarizeSpendByAction(transactions: CreditTransaction[]): Array<[string, number, number]> {@@ -1034,451 +1029,6 @@ function describeProvider(ref: ProviderRef, providers: BackgroundLoopProviderViereturn `${provider?.label ?? ref.providerSlug} ${ref.model || 'custom model'}`;}-const LoopToggle = ({- label,- description,- checked,- busy,- onToggle,-}: {- label: string;- description: string;- checked: boolean;- busy: boolean;- onToggle: () => void;-}) => (- <div className="flex items-center justify-between gap-3 rounded-lg border border-line bg-surface px-3 py-2">- <div className="min-w-0">- <div className="text-sm font-medium text-content">{label}</div>- <div className="text-xs text-content-muted">{description}</div>- </div>- <SettingsSwitch- id={`loop-toggle-${label.toLowerCase().replace(/[^a-z0-9]/g, '-')}`}- checked={checked}- onCheckedChange={onToggle}- disabled={busy}- aria-label={label}- />- </div>-);--const MetricTile = ({- label,- value,- detail,-}: {- label: string;- value: string;- detail?: string;-}) => (- <div className="min-w-0 overflow-hidden rounded-md bg-surface-muted px-3 py-2">- <div className="truncate text-[10px] font-semibold uppercase tracking-wide text-content-faint">- {label}- </div>- <div className="mt-1 truncate text-sm font-semibold text-content">{value}</div>- {detail ? <div className="mt-0.5 truncate text-[11px] text-content-muted">{detail}</div> : null}- </div>-);--const FormulaRow = ({ label, value, detail }: { label: string; value: string; detail: string }) => (- <div className="min-w-0 overflow-hidden rounded-md border border-line bg-surface px-3 py-2">- <div className="flex items-center justify-between gap-3">- <span className="min-w-0 truncate text-xs font-medium text-content">{label}</span>- <span className="shrink-0 font-mono text-xs text-content-secondary">{value}</span>- </div>- <div className="mt-1 truncate text-[11px] text-content-muted">{detail}</div>- </div>-);--type BackgroundLoopControlsView = 'all' | 'ledger';--/** Minimal cloud-provider shape consumed by the loop map's `describeProvider`- * helper — 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`). */-type BackgroundLoopProviderView = { id: string; slug: string; label: string };--export const BackgroundLoopControls = ({- routing,- cloudProviders,- view = 'all',- hideHeader = false,-}: {- routing: RoutingMap;- cloudProviders: BackgroundLoopProviderView[];- view?: BackgroundLoopControlsView;- hideHeader?: boolean;-}) => {- const { t } = useT();- const [usage, setUsage] = useState<TeamUsage | null>(null);- const [transactions, setTransactions] = useState<CreditTransaction[]>([]);- const [connections, setConnections] = useState<ComposioConnection[]>([]);- const [loading, setLoading] = useState(true);- const [error, setError] = useState<string>('');-- const refresh = useCallback(async () => {- setLoading(true);- setError('');- const [usageResult, transactionsResult, connectionsResult] = await Promise.allSettled([- creditsApi.getTeamUsage(),- creditsApi.getTransactions(200, 0),- listComposioConnections(),- ]);-- if (usageResult.status === 'fulfilled') {- setUsage(usageResult.value);- }-- if (transactionsResult.status === 'fulfilled') {- setTransactions(transactionsResult.value.transactions ?? []);- }-- if (connectionsResult.status === 'fulfilled') {- setConnections(connectionsResult.value.connections ?? []);- }- setLoading(false);- }, []);-- useEffect(() => {- // eslint-disable-next-line react-hooks/set-state-in-effect- void refresh();- }, [refresh]);-- const spendSample = summarizeSpendSample(transactions);- const spendRows = spendSample.rows;- const actionSummary = summarizeSpendByAction(transactions);- const hourSummary = summarizeSpendByHour(transactions);- const latestSpend = spendRows[0] ?? null;- const activeConnections = connections.filter(activeConnection);- // The heartbeat planner and the subconscious tick were removed with the- // subconscious domain, so neither contributes scheduled wakeups or calendar- // reads any more. Kept as named zeros so the ledger arithmetic below still- // reads as "everything that runs in the background", rather than silently- // dropping the terms.- const heartbeatTicksPerWeek = 0;- const calendarPlannerCallsPerWeek = 0;- const composioPeriodicTicksPerWeek = Math.ceil(WEEK_MINUTES / COMPOSIO_PERIODIC_TICK_MINUTES);- const learningTicksPerWeek = Math.ceil(WEEK_MINUTES / LEARNING_REBUILD_MINUTES);- const memoryPollsPerWeek = Math.ceil((WEEK_MINUTES * 60 * MEMORY_WORKERS) / MEMORY_POLL_SECONDS);- const composioConnectionScansPerWeek = composioPeriodicTicksPerWeek * activeConnections.length;- const backgroundApiReadsPerWeek = calendarPlannerCallsPerWeek + composioConnectionScansPerWeek;- const backgroundWakeupsPerWeek =- heartbeatTicksPerWeek +- composioPeriodicTicksPerWeek +- learningTicksPerWeek +- memoryPollsPerWeek;- const scheduledCallsPerRemainingDollar =- usage && usage.remainingUsd > 0 ? backgroundApiReadsPerWeek / usage.remainingUsd : null;- const estimatedRowsLeft =- usage && spendSample.avgRowUsd > 0- ? Math.floor(usage.remainingUsd / spendSample.avgRowUsd)- : null;- const estimatedRowsPerBudget =- usage && spendSample.avgRowUsd > 0- ? Math.floor(usage.cycleBudgetUsd / spendSample.avgRowUsd)- : null;- const projectedHoursLeft =- usage && spendSample.spendPerHour > 0 ? usage.remainingUsd / spendSample.spendPerHour : null;- const projectionAnchorMs = latestSpend ? new Date(latestSpend.createdAt).getTime() : Number.NaN;- const projectedExhaustAt =- projectedHoursLeft !== null && Number.isFinite(projectionAnchorMs)- ? new Date(projectionAnchorMs + projectedHoursLeft * 3_600_000).toLocaleString([], {- month: 'short',- day: 'numeric',- hour: 'numeric',- minute: '2-digit',- })- : 'n/a';-- const loops = [- {- name: 'Memory tree workers',- enabled: true,- cadence: 'queue',- route: describeProvider(routing.memory, cloudProviders),- work: 'Extracts chunks, seals branches, runs daily digests, routes topics.',- risk: `${MEMORY_WORKERS} workers poll every ${MEMORY_POLL_SECONDS}s; LLM calls only when queue has extract/seal/digest/topic jobs.`,- },- {- name: 'Reflection rebuild',- enabled: true,- cadence: '30 min',- route: describeProvider(routing.learning, cloudProviders),- work: 'Refreshes reflection state after memory activity.',- risk: `${formatCount(learningTicksPerWeek)} wakeups/week; LLM work only when rebuild needs reflection.`,- },- {- name: 'Composio sync',- enabled: true,- cadence: '20 min',- route: 'Integration APIs',- work: 'Polls connected tools when provider sync is due.',- risk: `${formatCount(composioPeriodicTicksPerWeek)} wakeups/week; scans ${activeConnections.length} active connection(s).`,- },- ];-- const showLedger = view === 'all' || view === 'ledger';- const gridCols =- view === 'all' ? 'md:grid-cols-[minmax(0,1fr)_minmax(260px,0.8fr)]' : 'grid-cols-1';-- return (- <div className="space-y-4">- {!hideHeader && (- <div className="border-b border-line pb-2">- <h2 className="text-base font-semibold text-content">- {t('settings.ai.backgroundLoops')}- </h2>- <p className="mt-0.5 text-xs text-content-muted">- {t('settings.ai.backgroundLoopsDesc')}- </p>- </div>- )}-- {error && <SettingsStatusLine saving={false} error={error} savedNote={null} savingLabel="" />}-- <section className={`grid gap-3 ${gridCols}`}>- <div className="overflow-hidden rounded-lg border border-line bg-surface-muted">- <div className="flex items-center justify-between gap-3 border-b border-line px-3 py-2">- <span className="text-xs font-semibold uppercase tracking-wide text-content-faint">- {t('settings.ai.loopMap')}- </span>- <Button- type="button"- variant="secondary"- size="xs"- onClick={() => void refresh()}- disabled={loading}>- {t('common.refresh')}- </Button>- </div>- <div className="divide-y divide-line dark:divide-neutral-800">- {loops.map(loop => (- <div key={loop.name} className="grid gap-2 px-3 py-3 md:grid-cols-[150px_1fr]">- <div className="min-w-0">- <div className="truncate text-sm font-medium text-content">{loop.name}</div>- <div className="mt-0.5 flex flex-wrap gap-1 text-[11px] text-content-muted">- <span>{loop.enabled ? t('settings.ai.on') : t('settings.ai.off')}</span>- <span>{loop.cadence}</span>- </div>- </div>- <div className="min-w-0 text-xs text-content-secondary">- <div>{loop.work}</div>- <div className="mt-1 font-mono text-[11px] text-content-muted">- {t('settings.ai.routeLabel').replace('{route}', loop.route)}- </div>- <div className="mt-1 text-content-muted">{loop.risk}</div>- </div>- </div>- ))}- </div>- </div>-- {showLedger && (- <div className="rounded-lg border border-line bg-surface p-3">- <div className="flex items-center justify-between gap-3">- <div>- <div className="text-sm font-semibold text-content">- {t('settings.ai.recentUsageLedger')}- </div>- <div className="text-xs text-content-muted">- {t('settings.ai.recentUsageLedgerDesc')}- </div>- </div>- <Button- type="button"- variant="secondary"- size="xs"- onClick={() => void refresh()}- disabled={loading}>- {t('common.reload')}- </Button>- </div>-- <div className="mt-3 grid grid-cols-2 gap-2 md:grid-cols-3">- <MetricTile- label={t('settings.ai.weekBudget')}- value={usage ? formatUsd(usage.cycleBudgetUsd) : 'n/a'}- detail={`resets ${formatDateTime(usage?.cycleEndsAt)}`}- />- <MetricTile- label={t('settings.ai.cycleRemaining')}- value={usage ? formatUsd(usage.remainingUsd) : 'n/a'}- detail={usage ? `${formatUsd(usage.cycleSpentUsd)} used` : undefined}- />- <MetricTile- label={t('settings.ai.cycleTotalSpend')}- value={usage ? formatUsd(usage.insights.totals.totalUsd) : 'n/a'}- detail={- usage- ? `inference ${formatUsd(usage.insights.totals.inferenceUsd)} + integrations ${formatUsd(usage.insights.totals.integrationsUsd)}`- : undefined- }- />- <MetricTile- label={t('settings.ai.avgSpendRow')}- value={spendSample.avgRowUsd > 0 ? formatUsd(spendSample.avgRowUsd) : 'n/a'}- detail={`${spendRows.length} recent spend rows`}- />- <MetricTile- label={t('settings.ai.backgroundApiReads')}- value={`${formatCount(backgroundApiReadsPerWeek)}/week`}- detail={`${formatCount(calendarPlannerCallsPerWeek)} planner + ${formatCount(composioConnectionScansPerWeek)} sync`}- />- <MetricTile- label={t('settings.ai.backgroundWakeups')}- value={`${formatCount(backgroundWakeupsPerWeek)}/week`}- detail={`${formatCount(memoryPollsPerWeek)} memory polls`}- />- </div>-- <div className="mt-3 rounded-lg border border-line bg-surface-muted p-3">- <div className="text-[10px] font-semibold uppercase tracking-wide text-content-faint">- {t('settings.ai.budgetMath')}- </div>- <div className="mt-2 grid gap-2">- <FormulaRow- label={t('settings.ai.rowsLeft')}- value={estimatedRowsLeft !== null ? formatCount(estimatedRowsLeft) : 'n/a'}- detail={- estimatedRowsLeft !== null- ? `remaining / avg row = ${formatUsd(usage?.remainingUsd ?? 0)} / ${formatUsd(spendSample.avgRowUsd)}`- : 'Need recent spend rows to estimate.'- }- />- <FormulaRow- label={t('settings.ai.rowsPerFullWeekBudget')}- value={- estimatedRowsPerBudget !== null ? formatCount(estimatedRowsPerBudget) : 'n/a'- }- detail={- estimatedRowsPerBudget !== null- ? `cycle budget / avg row = ${formatUsd(usage?.cycleBudgetUsd ?? 0)} / ${formatUsd(spendSample.avgRowUsd)}`- : 'Need recent spend rows to estimate.'- }- />- <FormulaRow- label={t('settings.ai.sampleBurnRate')}- value={- spendSample.spendPerHour > 0- ? `${formatUsd(spendSample.spendPerHour)}/hr`- : 'n/a'- }- detail={- spendSample.sampleHours > 0- ? `${formatCount(spendSample.rowsPerHour)} rows/hr across ${spendSample.sampleHours.toFixed(1)}h sample`- : 'Need timestamps from at least two spend rows.'- }- />- <FormulaRow- label={t('settings.ai.projectedEmpty')}- value={projectedExhaustAt}- detail={- projectedHoursLeft !== null- ? `${projectedHoursLeft.toFixed(1)}h after latest spend at recent burn rate`- : 'No projection without recent hourly spend.'- }- />- <FormulaRow- label={t('settings.ai.apiReadsPerDollarRemaining')}- value={- scheduledCallsPerRemainingDollar !== null- ? `${formatCount(scheduledCallsPerRemainingDollar)} reads/$`- : 'n/a'- }- detail={- usage- ? `background API reads/week / remaining = ${formatCount(backgroundApiReadsPerWeek)} / ${formatUsd(usage.remainingUsd)}`- : 'Need usage response to estimate.'- }- />- </div>- </div>-- <div className="mt-3 rounded-lg border border-line bg-surface-muted p-3">- <div className="text-[10px] font-semibold uppercase tracking-wide text-content-faint">- {t('settings.ai.loopCallBudget')}- </div>- <div className="mt-2 grid gap-2">- <FormulaRow- label={t('settings.ai.composioSyncScans')}- value={`${formatCount(composioConnectionScansPerWeek)}/week`}- detail={`${activeConnections.length} active integration connection(s) scanned every ${COMPOSIO_PERIODIC_TICK_MINUTES} min`}- />- <FormulaRow- label={t('settings.ai.totalBackgroundApiReadBudget')}- value={`${formatCount(backgroundApiReadsPerWeek)}/week`}- detail={`calendar planner reads + periodic integration scans; excludes user-initiated chat tools`}- />- <FormulaRow- label={t('settings.ai.memoryWorkerPolls')}- value={`${formatCount(memoryPollsPerWeek)}/week max`}- detail={`${MEMORY_WORKERS} workers * ${MEMORY_POLL_SECONDS}s poll; LLM calls only for queued jobs`}- />- </div>- </div>-- {latestSpend && (- <div className="mt-3 rounded-md border border-line bg-surface-muted px-3 py-2 text-xs text-content-secondary">- {t('settings.ai.latestSpend')- .replace('{amount}', formatUsd(spendAmount(latestSpend)))- .replace('{time}', new Date(latestSpend.createdAt).toLocaleString())- .replace('{action}', latestSpend.action)}- </div>- )}-- <div className="mt-3 space-y-3">- <div>- <div className="text-[10px] font-semibold uppercase tracking-wide text-content-faint">- {t('settings.ai.topActions')}- </div>- <div className="mt-1 space-y-1">- {actionSummary.length > 0 ? (- actionSummary.map(([action, count, total]) => (- <div- key={action}- className="flex items-center justify-between gap-2 text-xs text-content-secondary">- <span className="truncate font-mono">{action}</span>- <span className="shrink-0 text-content-muted">- {count} / {formatUsd(total)}- </span>- </div>- ))- ) : (- <div className="text-xs text-content-muted">{t('settings.ai.noSpendRows')}</div>- )}- </div>- </div>-- <div>- <div className="text-[10px] font-semibold uppercase tracking-wide text-content-faint">- {t('settings.ai.topHours')}- </div>- <div className="mt-1 space-y-1">- {hourSummary.length > 0 ? (- hourSummary.map(([hour, total]) => (- <div- key={hour}- className="flex items-center justify-between gap-2 text-xs text-content-secondary">- <span>{hour}</span>- <span className="font-mono text-content-muted">{formatUsd(total)}</span>- </div>- ))- ) : (- <div className="text-xs text-content-muted">- {t('settings.ai.noHourlySpend')}- </div>- )}- </div>- </div>- </div>- </div>- )}- </section>- </div>- );-};-// CloudProviderCard was removed alongside the list-based auth UI. The new// chip layout (ProviderToggleChip) covers the same affordances with less// chrome. CloudProviderEditor still exists for the advanced add/edit flow,