Skip to content

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

fix(settings): correct migration panel to use new API endpoint

Steven Enamakel3a06a29a65d8
diff --git a/app/src/components/settings/panels/MigrationPanel.tsx b/app/src/components/settings/panels/MigrationPanel.tsx
index aa0f7aef61..31202e442d 100644
--- a/app/src/components/settings/panels/MigrationPanel.tsx
+++ b/app/src/components/settings/panels/MigrationPanel.tsx
@@ -1,30 +1,61 @@
import debug from 'debug';
+import { Bot, Download, Eye, Feather, type LucideIcon } from 'lucide-react';
import { useCallback, useState } from 'react';
+import { cn } from '../../../lib/cn';
import { useT } from '../../../lib/i18n/I18nContext';
import {
type MigrationReport,
openhumanMigrateHermes,
openhumanMigrateOpenclaw,
} from '../../../utils/tauriCommands/core';
-import PanelPage from '../../layout/PanelPage';
-import { Alert, AlertDescription } from '../../ui';
-import Button from '../../ui/Button';
-import { SettingsSection, SettingsSelect, SettingsTextField } from '../controls';
+import {
+ Alert,
+ AlertDescription,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogRoot,
+ AlertDialogTitle,
+ AlertTitle,
+ Badge,
+ Button,
+ Card,
+ Field,
+ RadioGroupItem,
+ RadioGroupRoot,
+ TextField,
+} from '../../ui';
+import { Spinner } from '../../ui/icons';
import SettingsPanel from '../layout/SettingsPanel';
const log = debug('migration-panel');
type Vendor = 'openclaw' | 'hermes';
-interface MigrationPanelProps {
- /** When true, render without the SettingsHeader chrome (used when embedded
- * inside the onboarding custom wizard). Mirrors the embed contract used
- * by VoicePanel / MemoryDataPanel. */
- embedded?: boolean;
-}
+const VENDORS: { value: Vendor; labelKey: string; descKey: string; icon: LucideIcon }[] = [
+ {
+ value: 'openclaw',
+ labelKey: 'migration.vendor.openclaw',
+ descKey: 'migration.vendor.openclawDesc',
+ icon: Bot,
+ },
+ {
+ value: 'hermes',
+ labelKey: 'migration.vendor.hermes',
+ descKey: 'migration.vendor.hermesDesc',
+ icon: Feather,
+ },
+];
-const MigrationPanel = ({ embedded = false }: MigrationPanelProps = {}) => {
+/**
+ * Settings → Import. Two steps on one page: pick a source and preview what it
+ * would bring over, then import. Import stays locked until a Preview of the
+ * exact same vendor + path has succeeded, and asks for confirmation first.
+ */
+const MigrationPanel = () => {
const { t } = useT();
const [vendor, setVendor] = useState<Vendor>('openclaw');
@@ -41,6 +72,7 @@ const MigrationPanel = ({ embedded = false }: MigrationPanelProps = {}) => {
const [appliedReport, setAppliedReport] = useState<MigrationReport | null>(null);
const [isPreviewing, setIsPreviewing] = useState(false);
const [isApplying, setIsApplying] = useState(false);
+ const [confirmOpen, setConfirmOpen] = useState(false);
const [error, setError] = useState<string | null>(null);
const normalizedSource = sourcePath.trim() || undefined;
@@ -94,23 +126,10 @@ const MigrationPanel = ({ embedded = false }: MigrationPanelProps = {}) => {
} finally {
setIsPreviewing(false);
}
- }, [runMigrationRpc]);
+ }, [runMigrationRpc, vendor, normalizedSource]);
const runApply = useCallback(async () => {
if (!canApply || previewReport == null) return;
- const summary = previewReport.stats;
- const totalPlanned = summary.from_sqlite + summary.from_markdown - summary.skipped_unchanged;
- const template = t(
- totalPlanned === 1 ? 'migration.confirmImport.singular' : 'migration.confirmImport.plural'
- );
- const ok = window.confirm(
- template
- .replace('{count}', String(totalPlanned))
- .replace('{source}', previewReport.source_workspace)
- .replace('{target}', previewReport.target_workspace)
- );
- if (!ok) return;
-
setError(null);
setIsApplying(true);
try {
@@ -128,46 +147,78 @@ const MigrationPanel = ({ embedded = false }: MigrationPanelProps = {}) => {
setError(message);
} finally {
setIsApplying(false);
+ setConfirmOpen(false);
}
- }, [runMigrationRpc, previewReport, canApply, t]);
+ }, [runMigrationRpc, previewReport, canApply, vendor, normalizedSource]);
const reportToRender = appliedReport ?? previewReport;
+ const plannedCount = previewReport
+ ? previewReport.stats.from_sqlite +
+ previewReport.stats.from_markdown -
+ previewReport.stats.skipped_unchanged
+ : 0;
- const body = (
- <>
- {/* The card fills the pane, but a paragraph does not want to: at this
- pane width an uncapped line runs past 180 characters. */}
- <p className="max-w-[68ch] text-sm text-content-secondary">{t('migration.description')}</p>
-
- <SettingsSection>
- <div className="p-4 space-y-5" data-testid="migration-form">
- {/* The card fills the pane; each field takes the width its own value
- needs. A two-option vendor picker a metre wide puts its label and
- its value at opposite ends of an empty control; a workspace path is
- long and genuinely uses the room. Sized per field, not uniformly.
- NOTE: the sibling Core connection panel runs its URL and token
- fields at full width, so the app has no settled rule here yet. */}
- <div className="max-w-sm space-y-1">
- <label className="block text-xs font-medium text-content-secondary">
- {t('migration.vendorLabel')}
- </label>
- <SettingsSelect
- aria-label={t('migration.vendorLabel')}
- data-testid="migration-vendor-select"
- value={vendor}
- onChange={e => setVendor(e.target.value as Vendor)}
- inputSize="sm"
- className="w-full">
- <option value="openclaw">{t('migration.vendor.openclaw')}</option>
- <option value="hermes">{t('migration.vendor.hermes')}</option>
- </SettingsSelect>
- </div>
+ return (
+ <SettingsPanel description={t('migration.description')}>
+ {/* ── Source: which assistant, where it lives, and the two actions ── */}
+ <Card
+ title={t('migration.sourceHeading')}
+ description={t('pages.settings.account.migrationDesc')}
+ data-testid="migration-form">
+ <div className="p-4">
+ <RadioGroupRoot
+ value={vendor}
+ onValueChange={next => setVendor(next as Vendor)}
+ aria-label={t('migration.vendorLabel')}
+ className="grid gap-2 sm:grid-cols-2"
+ data-testid="migration-vendor-select">
+ {VENDORS.map(({ value, labelKey, descKey, icon: Icon }) => {
+ const selected = vendor === value;
+ const inputId = `migration-vendor-${value}`;
+ return (
+ <label
+ key={value}
+ htmlFor={inputId}
+ className={cn(
+ 'flex cursor-pointer items-center gap-3 rounded-xl border px-3.5 py-3 transition-colors',
+ selected
+ ? 'border-primary-500 bg-primary-50 ring-1 ring-primary-500 dark:bg-primary-500/10'
+ : 'border-line bg-surface hover:border-line-strong hover:bg-surface-hover'
+ )}>
+ <span
+ className={cn(
+ 'flex h-9 w-9 shrink-0 items-center justify-center rounded-lg',
+ selected
+ ? 'bg-primary-500 text-content-inverted'
+ : 'bg-surface-muted text-content-secondary'
+ )}>
+ <Icon className="h-4.5 w-4.5" aria-hidden />
+ </span>
+ <span className="min-w-0 flex-1">
+ <span className="block text-sm font-semibold text-content">{t(labelKey)}</span>
+ <span className="mt-0.5 block text-xs text-content-muted">{t(descKey)}</span>
+ </span>
+ <RadioGroupItem
+ id={inputId}
+ value={value}
+ data-testid={`migration-vendor-option-${value}`}
+ className="shrink-0"
+ />
+ </label>
+ );
+ })}
+ </RadioGroupRoot>
+ </div>
- <div className="max-w-2xl space-y-1">
- <label className="block text-xs font-medium text-content-secondary">
- {t('migration.sourceLabel')}
- </label>
- <SettingsTextField
+ <Field
+ stacked
+ htmlFor="migration-source"
+ label={t('migration.sourceLabel')}
+ description={t('migration.sourceHint')}
+ control={
+ <TextField
+ id="migration-source"
+ mono
data-testid="migration-source-input"
value={sourcePath}
onChange={e => setSourcePath(e.target.value)}
@@ -176,44 +227,39 @@ const MigrationPanel = ({ embedded = false }: MigrationPanelProps = {}) => {
? t('migration.sourcePlaceholderHermes')
: t('migration.sourcePlaceholder')
}
- aria-label={t('migration.sourceLabel')}
- inputSize="sm"
className="w-full"
/>
- <p className="text-[11px] text-content-muted">{t('migration.sourceHint')}</p>
- </div>
+ }
+ />
- <div className="flex flex-wrap gap-2">
+ <div className="flex flex-wrap items-center justify-between gap-3 px-4 py-3">
+ <p className="max-w-[60ch] text-xs text-content-muted">
+ {t('migration.applyDisclaimer')}
+ </p>
+ <div className="flex shrink-0 gap-2">
<Button
type="button"
- variant="primary"
+ variant="secondary"
size="sm"
+ leadingIcon={isPreviewing ? <Spinner /> : <Eye className="h-3.5 w-3.5" aria-hidden />}
data-testid="migration-preview-button"
onClick={() => void runPreview()}
disabled={isPreviewing || isApplying}>
{isPreviewing ? t('migration.previewRunning') : t('migration.previewAction')}
</Button>
- {/* Was an amber wash over `variant="tertiary"`, which bypassed the
- danger tone and used the warning ramp. Disabled, that wash read
- as a broken button rather than a locked one; the gate is
- explained in the line below the row instead. */}
<Button
type="button"
variant="primary"
- tone="danger"
size="sm"
+ leadingIcon={<Download className="h-3.5 w-3.5" aria-hidden />}
data-testid="migration-apply-button"
- onClick={() => void runApply()}
+ onClick={() => setConfirmOpen(true)}
disabled={!canApply}>
- {isApplying ? t('migration.applyRunning') : t('migration.applyAction')}
+ {t('migration.applyAction')}
</Button>
</div>
-
- <p className="max-w-[68ch] text-[11px] text-content-muted">
- {t('migration.applyDisclaimer')}
- </p>
</div>
- </SettingsSection>
+ </Card>
{error != null && (
<Alert variant="destructive" density="compact" data-testid="migration-error">
@@ -221,75 +267,131 @@ const MigrationPanel = ({ embedded = false }: MigrationPanelProps = {}) => {
</Alert>
)}
+ {/* ── Report: what a preview found, or what an import copied ─────── */}
{reportToRender != null && (
- <section
+ <Card
+ title={
+ appliedReport != null
+ ? t('migration.reportTitleApplied')
+ : t('migration.reportTitlePreview')
+ }
+ description={
+ appliedReport != null
+ ? t('migration.report.appliedHint')
+ : t('migration.report.previewHint')
+ }
+ headerRight={
+ <Badge variant={appliedReport != null ? 'success' : 'neutral'}>
+ {appliedReport != null ? t('migration.badgeImported') : t('migration.badgePreview')}
+ </Badge>
+ }
data-testid={
appliedReport != null ? 'migration-report-applied' : 'migration-report-preview'
- }
- className="bg-surface rounded-lg border border-line p-4 space-y-3">
- <h3 className="text-sm font-semibold text-content">
- {appliedReport != null
- ? t('migration.reportTitleApplied')
- : t('migration.reportTitlePreview')}
- </h3>
- <dl className="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1 text-xs">
- <dt className="text-content-muted">{t('migration.report.source')}</dt>
- <dd className="text-content break-all" data-testid="migration-report-source">
- {reportToRender.source_workspace}
- </dd>
- <dt className="text-content-muted">{t('migration.report.target')}</dt>
- <dd className="text-content break-all" data-testid="migration-report-target">
- {reportToRender.target_workspace}
- </dd>
- <dt className="text-content-muted">{t('migration.report.fromSqlite')}</dt>
- <dd className="text-content">{reportToRender.stats.from_sqlite}</dd>
- <dt className="text-content-muted">{t('migration.report.fromMarkdown')}</dt>
- <dd className="text-content">{reportToRender.stats.from_markdown}</dd>
- <dt className="text-content-muted">{t('migration.report.imported')}</dt>
- <dd className="text-content" data-testid="migration-report-imported">
- {reportToRender.stats.imported}
- </dd>
- <dt className="text-content-muted">{t('migration.report.skippedUnchanged')}</dt>
- <dd className="text-content">{reportToRender.stats.skipped_unchanged}</dd>
- <dt className="text-content-muted">{t('migration.report.renamedConflicts')}</dt>
- <dd className="text-content">{reportToRender.stats.renamed_conflicts}</dd>
+ }>
+ <dl className="grid grid-cols-2 gap-2 p-4 sm:grid-cols-5">
+ {[
+ { key: 'migration.report.fromSqlite', value: reportToRender.stats.from_sqlite },
+ { key: 'migration.report.fromMarkdown', value: reportToRender.stats.from_markdown },
+ {
+ key: 'migration.report.imported',
+ value: reportToRender.stats.imported,
+ testId: 'migration-report-imported',
+ },
+ {
+ key: 'migration.report.skippedUnchanged',
+ value: reportToRender.stats.skipped_unchanged,
+ },
+ {
+ key: 'migration.report.renamedConflicts',
+ value: reportToRender.stats.renamed_conflicts,
+ },
+ ].map(stat => (
+ <div key={stat.key} className="rounded-lg bg-surface-muted px-3 py-2.5">
+ <dd
+ className="text-lg font-semibold tabular-nums text-content"
+ data-testid={stat.testId}>
+ {stat.value}
+ </dd>
+ <dt className="mt-0.5 text-[11px] leading-tight text-content-muted">
+ {t(stat.key)}
+ </dt>
+ </div>
+ ))}
</dl>
-
+ <Field
+ label={t('migration.report.source')}
+ control={
+ <span
+ className="max-w-[60%] break-all text-right font-mono text-xs text-content"
+ data-testid="migration-report-source">
+ {reportToRender.source_workspace}
+ </span>
+ }
+ />
+ <Field
+ label={t('migration.report.target')}
+ control={
+ <span
+ className="max-w-[60%] break-all text-right font-mono text-xs text-content"
+ data-testid="migration-report-target">
+ {reportToRender.target_workspace}
+ </span>
+ }
+ />
{reportToRender.warnings.length > 0 && (
- <div className="space-y-1">
- <p className="text-xs font-medium text-content-secondary">
- {t('migration.report.warnings')}
- </p>
- <ul
- data-testid="migration-report-warnings"
- className="text-xs text-content-secondary list-disc list-inside space-y-0.5">
- {reportToRender.warnings.map((w, i) => (
- <li key={i}>{w}</li>
- ))}
- </ul>
+ <div className="p-4">
+ <Alert variant="warning" density="compact">
+ <div className="space-y-1">
+ <AlertTitle>{t('migration.report.warnings')}</AlertTitle>
+ <ul
+ data-testid="migration-report-warnings"
+ className="list-inside list-disc space-y-0.5">
+ {reportToRender.warnings.map((w, i) => (
+ <li key={i}>{w}</li>
+ ))}
+ </ul>
+ </div>
+ </Alert>
</div>
)}
-
- <p className="max-w-[68ch] text-[11px] text-content-muted">
- {appliedReport != null
- ? t('migration.report.appliedHint')
- : t('migration.report.previewHint')}
- </p>
- </section>
+ </Card>
)}
- </>
- );
- if (embedded) {
- return (
- <PanelPage className="z-10" contentClassName="">
- <div className="space-y-5 p-6">{body}</div>
- </PanelPage>
- );
- }
-
- return (
- <SettingsPanel description={t('pages.settings.account.migrationDesc')}>{body}</SettingsPanel>
+ <AlertDialogRoot
+ open={confirmOpen}
+ onOpenChange={open => {
+ if (!isApplying) setConfirmOpen(open);
+ }}>
+ <AlertDialogContent className="max-w-md">
+ <AlertDialogTitle>{t('migration.confirmTitle')}</AlertDialogTitle>
+ <AlertDialogDescription className="whitespace-pre-line">
+ {previewReport &&
+ t(
+ plannedCount === 1
+ ? 'migration.confirmImport.singular'
+ : 'migration.confirmImport.plural'
+ )
+ .replace('{count}', String(plannedCount))
+ .replace('{source}', previewReport.source_workspace)
+ .replace('{target}', previewReport.target_workspace)}
+ </AlertDialogDescription>
+ <AlertDialogFooter>
+ <AlertDialogCancel disabled={isApplying}>{t('common.cancel')}</AlertDialogCancel>
+ <AlertDialogAction
+ disabled={isApplying}
+ data-testid="migration-confirm-button"
+ onClick={event => {
+ // Keep the dialog open until the import settles.
+ event.preventDefault();
+ void runApply();
+ }}>
+ {isApplying && <Spinner />}
+ {isApplying ? t('migration.applyRunning') : t('migration.applyAction')}
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialogRoot>
+ </SettingsPanel>
);
};