feat(ui): list failed targets on the Sync page's Last sync card

The card showed "partial" and a target count, but not which targets
failed, so finding them meant opening the log. It now adds a Failed row
naming the targets from the log's failed_targets, or the count for
entries written before that field existed.
This commit is contained in:
Willie
2026-09-30 03:30:08 +08:00
parent 5dfd63d5e9
commit 9f8eccab8e
13 changed files with 46 additions and 0 deletions
+1
View File
@@ -1700,6 +1700,7 @@
"sync.last.targets": "Ziele",
"sync.last.took": "Dauer",
"sync.last.error": "Fehler",
"sync.last.failed": "Fehlgeschlagen",
"sync.last.never": "Es wurde noch nicht synchronisiert.",
"sync.last.openLog": "Log öffnen",
"gitSync.changes.title": "Änderungen auf diesem Rechner",
+1
View File
@@ -1700,6 +1700,7 @@
"sync.last.targets": "Targets",
"sync.last.took": "Took",
"sync.last.error": "Error",
"sync.last.failed": "Failed",
"sync.last.never": "No sync has run yet.",
"sync.last.openLog": "Open log",
"gitSync.changes.title": "Changes on this machine",
+1
View File
@@ -1700,6 +1700,7 @@
"sync.last.targets": "Destinos",
"sync.last.took": "Duración",
"sync.last.error": "Error",
"sync.last.failed": "Fallidos",
"sync.last.never": "Aún no se ha sincronizado.",
"sync.last.openLog": "Abrir log",
"gitSync.changes.title": "Cambios en esta máquina",
+1
View File
@@ -1700,6 +1700,7 @@
"sync.last.targets": "هدف‌ها",
"sync.last.took": "مدت",
"sync.last.error": "خطا",
"sync.last.failed": "ناموفق",
"sync.last.never": "هنوز همگام‌سازی انجام نشده است.",
"sync.last.openLog": "باز کردن log",
"gitSync.changes.title": "تغییرات روی این دستگاه",
+1
View File
@@ -1700,6 +1700,7 @@
"sync.last.targets": "Cibles",
"sync.last.took": "Durée",
"sync.last.error": "Erreur",
"sync.last.failed": "Échecs",
"sync.last.never": "Aucune synchronisation pour l'instant.",
"sync.last.openLog": "Ouvrir le log",
"gitSync.changes.title": "Changements sur cette machine",
+1
View File
@@ -1700,6 +1700,7 @@
"sync.last.targets": "Target",
"sync.last.took": "Durasi",
"sync.last.error": "Galat",
"sync.last.failed": "Gagal",
"sync.last.never": "Belum pernah sinkronisasi.",
"sync.last.openLog": "Buka log",
"gitSync.changes.title": "Perubahan di mesin ini",
+1
View File
@@ -1700,6 +1700,7 @@
"sync.last.targets": "ターゲット",
"sync.last.took": "所要時間",
"sync.last.error": "エラー",
"sync.last.failed": "失敗",
"sync.last.never": "まだ同期していません。",
"sync.last.openLog": "log を開く",
"gitSync.changes.title": "このマシンでの変更",
+1
View File
@@ -1700,6 +1700,7 @@
"sync.last.targets": "대상",
"sync.last.took": "소요 시간",
"sync.last.error": "오류",
"sync.last.failed": "실패",
"sync.last.never": "아직 동기화한 적이 없습니다.",
"sync.last.openLog": "log 열기",
"gitSync.changes.title": "이 컴퓨터의 변경 사항",
+1
View File
@@ -1700,6 +1700,7 @@
"sync.last.targets": "Destinos",
"sync.last.took": "Duração",
"sync.last.error": "Erro",
"sync.last.failed": "Falharam",
"sync.last.never": "Nenhuma sincronização ainda.",
"sync.last.openLog": "Abrir log",
"gitSync.changes.title": "Alterações nesta máquina",
+1
View File
@@ -1700,6 +1700,7 @@
"sync.last.targets": "目标",
"sync.last.took": "耗时",
"sync.last.error": "错误",
"sync.last.failed": "失败",
"sync.last.never": "尚未同步过。",
"sync.last.openLog": "打开日志",
"gitSync.changes.title": "本机上的变更",
+1
View File
@@ -1700,6 +1700,7 @@
"sync.last.targets": "目標",
"sync.last.took": "耗時",
"sync.last.error": "錯誤",
"sync.last.failed": "失敗",
"sync.last.never": "尚未同步過。",
"sync.last.openLog": "開啟日誌",
"gitSync.changes.title": "這台電腦上的變更",
+28
View File
@@ -49,3 +49,31 @@ describe('Sync page folder conflicts', () => {
await waitFor(() => expect(api.updateTarget).toHaveBeenCalledWith('codex', { skills_enabled: false }));
});
});
describe('Sync page last sync', () => {
const renderPage = () => render(
<MemoryRouter>
<QueryClientProvider client={new QueryClient()}><I18nProvider><ToastProvider><SyncPage /></ToastProvider></I18nProvider></QueryClientProvider>
</MemoryRouter>,
);
beforeEach(() => {
vi.clearAllMocks();
vi.mocked(api.listTargets).mockResolvedValue({ targets: [target('codex')], sourceSkillCount: 3 });
vi.mocked(api.diff).mockResolvedValue({ diffs: [], ignored_count: 0, ignored_skills: [], ignore_root: '', ignore_repos: [] });
vi.mocked(api.diffExtras).mockResolvedValue({ extras: [] });
vi.mocked(mcpApi.list).mockResolvedValue({ paths: {}, source: { targets: [], servers: {} } } as never);
});
it('names the targets the last sync failed', async () => {
vi.mocked(api.listLog).mockResolvedValue({ entries: [{ ts: '2026-09-30T00:00:00Z', cmd: 'sync', status: 'partial', args: { targets_total: 3, targets_failed: 2, failed_targets: ['codex', 'cursor'] } }] } as never);
renderPage();
expect((await screen.findByText('Failed')).nextElementSibling).toHaveTextContent('codex and cursor');
});
it('counts the failed targets when an older entry has no names', async () => {
vi.mocked(api.listLog).mockResolvedValue({ entries: [{ ts: '2026-09-30T00:00:00Z', cmd: 'sync', status: 'partial', args: { targets_total: 3, targets_failed: 1 } }] } as never);
renderPage();
expect((await screen.findByText('Failed')).nextElementSibling).toHaveTextContent('1');
});
});
+7
View File
@@ -376,6 +376,13 @@ export default function SyncPage() {
<dt>{t('sync.last.when')}</dt>
<dd title={formatDateTime(last.ts, locale)}>{formatRelativeTime(last.ts, locale)}</dd>
{typeof last.args?.targets_total === 'number' && <><dt>{t('sync.last.targets')}</dt><dd>{last.args.targets_total}</dd></>}
{last.args?.targets_failed > 0 && (
<>
<dt>{t('sync.last.failed')}</dt>
{/* Entries written before failed_targets existed only have the count. */}
<dd className="break-words text-bad">{Array.isArray(last.args?.failed_targets) && last.args.failed_targets.length > 0 ? joinList(last.args.failed_targets, locale) : last.args?.targets_failed}</dd>
</>
)}
{typeof last.ms === 'number' && <><dt>{t('sync.last.took')}</dt><dd className="font-mono">{(last.ms / 1000).toFixed(1)} s</dd></>}
{last.msg && <><dt>{t('sync.last.error')}</dt><dd className="break-words text-bad">{last.msg}</dd></>}
</dl>