Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(privacy): correct privacy panel to show saved state after toggling

Steven Enamakel28ff585774d5
diff --git a/app/src/components/settings/panels/PrivacyPanel.tsx b/app/src/components/settings/panels/PrivacyPanel.tsx
index 6cac4de0cd..da6d79cf6e 100644
--- a/app/src/components/settings/panels/PrivacyPanel.tsx
+++ b/app/src/components/settings/panels/PrivacyPanel.tsx
@@ -1,84 +1,14 @@
-import debug from 'debug';
-import { useEffect, useState } from 'react';
-
import { useT } from '../../../lib/i18n/I18nContext';
import { useCoreState } from '../../../providers/CoreStateProvider';
-import {
- type Capability,
- type CapabilityPrivacy,
- listCapabilities,
- type PrivacyDataKind,
-} from '../../../utils/tauriCommands/aboutApp';
-import {
- SettingsBadge,
- type SettingsBadgeVariant,
- SettingsRow,
- SettingsSection,
- SettingsSwitch,
-} from '../controls';
+import { SettingsRow, SettingsSection, SettingsSwitch } from '../controls';
import SettingsPanel from '../layout/SettingsPanel';
import PrivacyModeSection from './PrivacyModeSection';
-const log = debug('privacy-panel');
-
-interface AnnotatedCapability extends Capability {
- privacy: CapabilityPrivacy;
-}
-
-const KIND_BADGE_VARIANT: Record<PrivacyDataKind, SettingsBadgeVariant> = {
- raw: 'success',
- derived: 'warning',
- credentials: 'neutral',
- diagnostics: 'primary',
- metadata: 'neutral',
-};
-
-function kindLabel(kind: PrivacyDataKind, t: (key: string) => string): string {
- switch (kind) {
- case 'raw':
- return t('privacy.dataKind.raw');
- case 'derived':
- return t('privacy.dataKind.derived');
- case 'credentials':
- return t('privacy.dataKind.credentials');
- case 'diagnostics':
- return t('privacy.dataKind.diagnostics');
- case 'metadata':
- return t('privacy.dataKind.metadata');
- }
-}
-
const PrivacyPanel = () => {
const { snapshot, setAnalyticsEnabled } = useCoreState();
const analyticsEnabled = snapshot.analyticsEnabled;
const { t } = useT();
- const [capabilities, setCapabilities] = useState<AnnotatedCapability[]>([]);
- const [loadState, setLoadState] = useState<'loading' | 'ready' | 'error'>('loading');
-
- useEffect(() => {
- let cancelled = false;
- log('[privacy] fetching capability catalog');
- listCapabilities()
- .then(items => {
- if (cancelled) return;
- const annotated = items.filter(
- (c): c is AnnotatedCapability => c.privacy !== undefined && c.privacy !== null
- );
- log('[privacy] catalog ready', { total: items.length, annotated: annotated.length });
- setCapabilities(annotated);
- setLoadState('ready');
- })
- .catch(err => {
- if (cancelled) return;
- console.warn('[privacy] failed to load capability catalog:', err);
- setLoadState('error');
- });
- return () => {
- cancelled = true;
- };
- }, []);
-
const handleToggleAnalytics = async () => {
const newValue = !analyticsEnabled;
try {
@@ -96,52 +26,6 @@ const PrivacyPanel = () => {
{/* Privacy Mode selector (#4435) — data-egress posture */}
<PrivacyModeSection />
- {/* What leaves my computer */}
- <SettingsSection title={t('privacy.whatLeavesComputer')}>
- {loadState === 'loading' && (
- <p className="p-4 text-xs text-content-muted">{t('privacy.loading')}</p>
- )}
- {loadState === 'error' && (
- <p className="p-4 text-xs text-content-muted" data-testid="privacy-load-error">
- {t('privacy.loadError')}
- </p>
- )}
- {loadState === 'ready' && capabilities.length === 0 && (
- <p className="p-4 text-xs text-content-muted">{t('privacy.noCapabilities')}</p>
- )}
- {loadState === 'ready' && capabilities.length > 0 && (
- <ul data-testid="privacy-capability-list">
- {capabilities.map(cap => (
- <li key={cap.id} className="p-4" data-testid={`privacy-row-${cap.id}`}>
- <div className="flex items-start justify-between gap-3">
- <div className="flex-1 min-w-0">
- <p className="text-sm font-medium text-content">{cap.name}</p>
- <p className="text-xs text-content-muted mt-1 leading-relaxed">
- {cap.description}
- </p>
- {cap.privacy.destinations.length > 0 && (
- <p className="text-xs text-content-faint mt-1">
- {t('privacy.sentTo')}: {cap.privacy.destinations.join(', ')}
- </p>
- )}
- </div>
- <div className="flex flex-col items-end gap-1 shrink-0">
- <SettingsBadge variant={KIND_BADGE_VARIANT[cap.privacy.data_kind]}>
- {kindLabel(cap.privacy.data_kind, t)}
- </SettingsBadge>
- <span className="text-[10px] text-content-muted">
- {cap.privacy.leaves_device
- ? t('privacy.leavesDevice')
- : t('privacy.staysLocal')}
- </span>
- </div>
- </div>
- </li>
- ))}
- </ul>
- )}
- </SettingsSection>
-
{/* Analytics Section */}
<SettingsSection title={t('privacy.anonymizedAnalytics')}>
<SettingsRow