Skip to content

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

fix(insights): handle missing memory source gracefully

Steven Enamakel9762a28d903b
diff --git a/app/src/components/intelligence/MemoryInsights.tsx b/app/src/components/intelligence/MemoryInsights.tsx
index 1813dd2b53..4b74d896c5 100644
--- a/app/src/components/intelligence/MemoryInsights.tsx
+++ b/app/src/components/intelligence/MemoryInsights.tsx
@@ -291,7 +291,8 @@ export function MemoryInsights({ relations, loading }: MemoryInsightsProps) {
<div className={`space-y-1.5 ${isExpanded ? 'max-h-80 overflow-y-auto pr-1' : ''}`}>
{previewItems.map((item, idx) => (
- <InsightItemRow key={`${item.subject}-${item.predicate}-${item.object}-${idx}`}
+ <InsightItemRow
+ key={`${item.subject}-${item.predicate}-${item.object}-${idx}`}
item={item}
/>
))}
diff --git a/app/src/components/intelligence/MemorySourceRow.tsx b/app/src/components/intelligence/MemorySourceRow.tsx
index a19846fceb..bf3c9b44aa 100644
--- a/app/src/components/intelligence/MemorySourceRow.tsx
+++ b/app/src/components/intelligence/MemorySourceRow.tsx
@@ -8,10 +8,10 @@
*/
import { useT } from '../../lib/i18n/I18nContext';
import {
- SOURCE_KIND_ICONS,
- SOURCE_KIND_LABEL_KEYS,
type FreshnessLabel,
type MemorySourceEntry,
+ SOURCE_KIND_ICONS,
+ SOURCE_KIND_LABEL_KEYS,
type SourceStatus,
} from '../../services/memorySourcesService';
import type { ToastNotification } from '../../types/intelligence';
@@ -29,7 +29,11 @@ import {
WarnIcon,
} from './memorySourcesIcons';
import { relativeTimestamp, sourceDetail } from './memorySourcesRowHelpers';
-import { STAGE_FALLBACK_PERCENT, type SyncProgress, type SyncResult } from './memorySourcesSyncTypes';
+import {
+ STAGE_FALLBACK_PERCENT,
+ type SyncProgress,
+ type SyncResult,
+} from './memorySourcesSyncTypes';
import {
deriveSourcePipelineHealth,
pipelineIssueMessageKey,
@@ -113,181 +117,181 @@ export function MemorySourceRow({
onOpenChange={() => onToggleSettings(source.id)}
className="flex flex-col gap-2">
<div className="flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between">
- <div className="min-w-0 flex-1">
- <div className="flex flex-wrap items-center gap-2">
- <span className="text-base">{icon}</span>
- <span
- className={`truncate text-sm font-medium ${
- source.enabled ? 'text-content' : 'text-content-faint line-through'
- }`}>
- {source.label}
- </span>
- <span className="rounded-md bg-surface-subtle px-1.5 py-0.5 text-[10px] font-medium text-content-muted">
- {kindLabel}
- </span>
- {status &&
- status.chunks_synced > 0 &&
- (ingestedOnly ? (
- <IngestedOnlyPill sourceId={source.id} />
- ) : (
- <FreshnessPill freshness={status.freshness} />
- ))}
- </div>
- {detail && <p className="mt-0.5 truncate pl-7 text-xs text-content-faint">{detail}</p>}
- {progress && (
- <div className="mt-2 pl-7">
- <div className="flex items-center gap-2 text-xs text-content-muted">
- <span className="capitalize">{progress.stage}</span>
- {progress.percent !== null && (
- <span className="font-medium text-primary-600 dark:text-primary-400">
- {progress.percent}%
- </span>
- )}
- {progress.detail && (
- <span className="truncate text-content-faint">{progress.detail}</span>
- )}
- </div>
- <div className="mt-1 h-1.5 w-full overflow-hidden rounded-full bg-surface-strong">
- <div
- className="h-full rounded-full bg-primary-500 transition-all duration-300"
- style={{
- width: `${progress.percent ?? STAGE_FALLBACK_PERCENT[progress.stage] ?? 2}%`,
- }}
- />
- </div>
+ <div className="min-w-0 flex-1">
+ <div className="flex flex-wrap items-center gap-2">
+ <span className="text-base">{icon}</span>
+ <span
+ className={`truncate text-sm font-medium ${
+ source.enabled ? 'text-content' : 'text-content-faint line-through'
+ }`}>
+ {source.label}
+ </span>
+ <span className="rounded-md bg-surface-subtle px-1.5 py-0.5 text-[10px] font-medium text-content-muted">
+ {kindLabel}
+ </span>
+ {status &&
+ status.chunks_synced > 0 &&
+ (ingestedOnly ? (
+ <IngestedOnlyPill sourceId={source.id} />
+ ) : (
+ <FreshnessPill freshness={status.freshness} />
+ ))}
</div>
- )}
- {!progress && result && (
- <div className="mt-2 pl-7" data-testid={`memory-source-result-${source.id}`}>
- {result.kind === 'success' ? (
- <span className="inline-flex items-center gap-1 rounded-md bg-sage-100 px-2 py-0.5 text-xs font-medium text-sage-700 dark:bg-sage-500/20 dark:text-sage-300">
- <CheckIcon />
- {result.items && result.items > 0
- ? `${result.items.toLocaleString()} ${t('memorySources.sync.itemsSynced')}`
- : t('memorySources.sync.upToDate')}
- </span>
- ) : (
- <span
- className="inline-flex items-start gap-1 rounded-md bg-coral-50 px-2 py-0.5 text-xs font-medium text-coral-700 dark:bg-coral-500/10 dark:text-coral-300"
- title={result.reason ?? undefined}>
- <WarnIcon />
- <span className="break-words">
- {t('memorySources.sync.failedLabel')}
- {result.reason ? `: ${result.reason}` : ''}
+ {detail && <p className="mt-0.5 truncate pl-7 text-xs text-content-faint">{detail}</p>}
+ {progress && (
+ <div className="mt-2 pl-7">
+ <div className="flex items-center gap-2 text-xs text-content-muted">
+ <span className="capitalize">{progress.stage}</span>
+ {progress.percent !== null && (
+ <span className="font-medium text-primary-600 dark:text-primary-400">
+ {progress.percent}%
+ </span>
+ )}
+ {progress.detail && (
+ <span className="truncate text-content-faint">{progress.detail}</span>
+ )}
+ </div>
+ <div className="mt-1 h-1.5 w-full overflow-hidden rounded-full bg-surface-strong">
+ <div
+ className="h-full rounded-full bg-primary-500 transition-all duration-300"
+ style={{
+ width: `${progress.percent ?? STAGE_FALLBACK_PERCENT[progress.stage] ?? 2}%`,
+ }}
+ />
+ </div>
+ </div>
+ )}
+ {!progress && result && (
+ <div className="mt-2 pl-7" data-testid={`memory-source-result-${source.id}`}>
+ {result.kind === 'success' ? (
+ <span className="inline-flex items-center gap-1 rounded-md bg-sage-100 px-2 py-0.5 text-xs font-medium text-sage-700 dark:bg-sage-500/20 dark:text-sage-300">
+ <CheckIcon />
+ {result.items && result.items > 0
+ ? `${result.items.toLocaleString()} ${t('memorySources.sync.itemsSynced')}`
+ : t('memorySources.sync.upToDate')}
</span>
- </span>
- )}
- </div>
- )}
- {!progress &&
- !result &&
- status &&
- (status.chunks_synced > 0 || status.chunks_pending > 0) && (
- <div className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 pl-7 text-xs text-content-muted">
- <span>
- {status.chunks_synced.toLocaleString()} {t('sync.chunks')}
- </span>
- {lastSync && (
- <span>
- {t('sync.lastChunk')} {lastSync}
- </span>
- )}
- {status.chunks_pending > 0 && (
- <span>
- {status.chunks_pending.toLocaleString()} {t('sync.pending')}
+ ) : (
+ <span
+ className="inline-flex items-start gap-1 rounded-md bg-coral-50 px-2 py-0.5 text-xs font-medium text-coral-700 dark:bg-coral-500/10 dark:text-coral-300"
+ title={result.reason ?? undefined}>
+ <WarnIcon />
+ <span className="break-words">
+ {t('memorySources.sync.failedLabel')}
+ {result.reason ? `: ${result.reason}` : ''}
+ </span>
</span>
)}
</div>
)}
- {ingestedOnly && (
- <div
- className="mt-2 flex flex-col gap-1 rounded-md border border-amber-200 bg-amber-50 px-2.5 py-1.5 pl-7 text-xs text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200"
- data-testid={`memory-source-pipeline-warning-${source.id}`}
- role="status">
- {health.issues.map(issue => (
- <div key={issue} className="flex items-start gap-1.5">
- <WarnIcon />
- <span className="break-words">{t(pipelineIssueMessageKey(issue))}</span>
+ {!progress &&
+ !result &&
+ status &&
+ (status.chunks_synced > 0 || status.chunks_pending > 0) && (
+ <div className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 pl-7 text-xs text-content-muted">
+ <span>
+ {status.chunks_synced.toLocaleString()} {t('sync.chunks')}
+ </span>
+ {lastSync && (
+ <span>
+ {t('sync.lastChunk')} {lastSync}
+ </span>
+ )}
+ {status.chunks_pending > 0 && (
+ <span>
+ {status.chunks_pending.toLocaleString()} {t('sync.pending')}
+ </span>
+ )}
</div>
- ))}
- <div className="mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 pl-[18px]">
- {health.authRelated && !isAuthenticated && (
+ )}
+ {ingestedOnly && (
+ <div
+ className="mt-2 flex flex-col gap-1 rounded-md border border-amber-200 bg-amber-50 px-2.5 py-1.5 pl-7 text-xs text-amber-800 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-200"
+ data-testid={`memory-source-pipeline-warning-${source.id}`}
+ role="status">
+ {health.issues.map(issue => (
+ <div key={issue} className="flex items-start gap-1.5">
+ <WarnIcon />
+ <span className="break-words">{t(pipelineIssueMessageKey(issue))}</span>
+ </div>
+ ))}
+ <div className="mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 pl-[18px]">
+ {health.authRelated && !isAuthenticated && (
+ <Button
+ variant="tertiary"
+ size="xs"
+ onClick={onSignIn}
+ data-testid={`memory-source-signin-${source.id}`}
+ className="h-auto px-0 font-medium text-amber-900 underline underline-offset-2 hover:bg-transparent hover:text-amber-950 dark:text-amber-100 dark:hover:text-content-inverted">
+ {t('sync.pipeline.signInToEnable')}
+ </Button>
+ )}
<Button
variant="tertiary"
size="xs"
- onClick={onSignIn}
- data-testid={`memory-source-signin-${source.id}`}
+ onClick={onViewHealth}
+ data-testid={`memory-source-view-health-${source.id}`}
className="h-auto px-0 font-medium text-amber-900 underline underline-offset-2 hover:bg-transparent hover:text-amber-950 dark:text-amber-100 dark:hover:text-content-inverted">
- {t('sync.pipeline.signInToEnable')}
+ {t('sync.pipeline.viewHealth')}
</Button>
- )}
- <Button
- variant="tertiary"
- size="xs"
- onClick={onViewHealth}
- data-testid={`memory-source-view-health-${source.id}`}
- className="h-auto px-0 font-medium text-amber-900 underline underline-offset-2 hover:bg-transparent hover:text-amber-950 dark:text-amber-100 dark:hover:text-content-inverted">
- {t('sync.pipeline.viewHealth')}
- </Button>
+ </div>
</div>
- </div>
- )}
- </div>
- <div className="flex shrink-0 items-center gap-2">
- <CollapsibleTrigger asChild>
+ )}
+ </div>
+ <div className="flex shrink-0 items-center gap-2">
+ <CollapsibleTrigger asChild>
+ <Button
+ iconOnly
+ variant="tertiary"
+ size="xs"
+ title={t('memorySources.settings.button')}
+ aria-label={t('memorySources.settings.button')}
+ data-testid={`memory-source-settings-${source.id}`}
+ className={
+ settingsExpanded
+ ? 'bg-primary-100 text-primary-600 dark:bg-primary-500/20 dark:text-primary-400'
+ : 'text-content-faint hover:text-content-secondary'
+ }>
+ <GearIcon />
+ </Button>
+ </CollapsibleTrigger>
+ <Button
+ variant="primary"
+ size="sm"
+ onClick={() => onSync(source)}
+ disabled={!source.enabled || isSyncing}
+ title={t('sync.sync')}
+ data-testid={`memory-source-sync-${source.toolkit ?? source.kind}`}
+ leadingIcon={isSyncing ? <Spinner /> : <SyncIcon />}>
+ {isSyncing ? t('sync.syncing') : t('sync.sync')}
+ </Button>
+ <Button
+ variant="secondary"
+ size="sm"
+ onClick={() => onBuild(source)}
+ disabled={!source.enabled || isBuilding || isSyncing}
+ title={t('memorySources.build.title')}
+ leadingIcon={isBuilding ? <Spinner /> : <BuildIcon />}
+ className="border-primary-300 text-primary-600 hover:bg-primary-50
+ dark:border-primary-500/30 dark:text-primary-400 dark:hover:bg-primary-500/10">
+ {isBuilding ? t('memorySources.build.building') : t('memorySources.build.title')}
+ </Button>
+ <Switch
+ id={`memory-source-toggle-${source.id}`}
+ checked={source.enabled}
+ onCheckedChange={() => onToggle(source)}
+ aria-label={source.enabled ? t('memorySources.disable') : t('memorySources.enable')}
+ />
<Button
iconOnly
variant="tertiary"
+ tone="danger"
size="xs"
- title={t('memorySources.settings.button')}
- aria-label={t('memorySources.settings.button')}
- data-testid={`memory-source-settings-${source.id}`}
- className={
- settingsExpanded
- ? 'bg-primary-100 text-primary-600 dark:bg-primary-500/20 dark:text-primary-400'
- : 'text-content-faint hover:text-content-secondary'
- }>
- <GearIcon />
+ onClick={() => onRemove(source)}
+ title={t('memorySources.remove')}
+ aria-label={t('memorySources.remove')}>
+ <TrashIcon />
</Button>
- </CollapsibleTrigger>
- <Button
- variant="primary"
- size="sm"
- onClick={() => onSync(source)}
- disabled={!source.enabled || isSyncing}
- title={t('sync.sync')}
- data-testid={`memory-source-sync-${source.toolkit ?? source.kind}`}
- leadingIcon={isSyncing ? <Spinner /> : <SyncIcon />}>
- {isSyncing ? t('sync.syncing') : t('sync.sync')}
- </Button>
- <Button
- variant="secondary"
- size="sm"
- onClick={() => onBuild(source)}
- disabled={!source.enabled || isBuilding || isSyncing}
- title={t('memorySources.build.title')}
- leadingIcon={isBuilding ? <Spinner /> : <BuildIcon />}
- className="border-primary-300 text-primary-600 hover:bg-primary-50
- dark:border-primary-500/30 dark:text-primary-400 dark:hover:bg-primary-500/10">
- {isBuilding ? t('memorySources.build.building') : t('memorySources.build.title')}
- </Button>
- <Switch
- id={`memory-source-toggle-${source.id}`}
- checked={source.enabled}
- onCheckedChange={() => onToggle(source)}
- aria-label={source.enabled ? t('memorySources.disable') : t('memorySources.enable')}
- />
- <Button
- iconOnly
- variant="tertiary"
- tone="danger"
- size="xs"
- onClick={() => onRemove(source)}
- title={t('memorySources.remove')}
- aria-label={t('memorySources.remove')}>
- <TrashIcon />
- </Button>
- </div>
+ </div>
</div>
<CollapsibleContent>
<SourceSettingsPanel