Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(desktop): show cloud sync progress while it runs
vastsa8f9a2ecacde4
diff --git a/apps/desktop/electron/main/runtime/host.ts b/apps/desktop/electron/main/runtime/host.tsindex b56755875..95bdcfcc1 100644--- a/apps/desktop/electron/main/runtime/host.ts+++ b/apps/desktop/electron/main/runtime/host.ts@@ -304,6 +304,11 @@ export function createHostRuntime({sendToRenderer(IPC.event.plansChanged, params);} else if (method === "configSync.changed") {sendToRenderer(IPC.event.configSyncChanged, params);+ } else if (method === "configSync.progress") {+ // A sync is one request that answers only when it is over, so these+ // reports are the only thing the page has to show while it runs. The+ // request's own answer is still the outcome.+ sendToRenderer(IPC.event.configSyncProgress, params);}});h.onExit(({ code, signal, intentional }) => {diff --git a/apps/desktop/src/components/settings/ConfigSyncPage.tsx b/apps/desktop/src/components/settings/ConfigSyncPage.tsxindex 1ef776277..2f116b66f 100644--- a/apps/desktop/src/components/settings/ConfigSyncPage.tsx+++ b/apps/desktop/src/components/settings/ConfigSyncPage.tsx@@ -5,6 +5,7 @@ import type {ConfigSyncCategorySelection,ConfigSyncHistoryEntry,ConfigSyncPendingApproval,+ ConfigSyncProgress,ConfigSyncRemoteMode,ConfigSyncState,} from "@pi-desktop/shared";@@ -12,6 +13,7 @@ import { api } from "../../lib/api";import { Badge, Button, Field, Input, PasswordInput, cx } from "../ui";import { IconCloudDown, IconRefresh, IconShield, IconTrash } from "../icons";import { SettingsCard, SettingsRow } from "../../features/settings/primitives";+import { configSyncProgressView } from "../../features/settings/config-sync-progress";import { SettingsMenuSelect } from "./SettingsMenuSelect";const CATEGORIES: Array<{@@ -72,6 +74,8 @@ export function ConfigSyncPage() {| "disconnect"| null>(null);+ /** The last progress the host reported for a manual sync, if one is running. */+ const [progress, setProgress] = useState<ConfigSyncProgress | null>(null);const [history, setHistory] = useState<ConfigSyncHistoryEntry[]>([]);const [error, setError] = useState<string | null>(null);const [notice, setNotice] = useState<string | null>(null);@@ -143,6 +147,10 @@ export function ConfigSyncPage() {});}, [refresh]);+ // The report is only shown while the page is running a sync itself, so an+ // automatic run stays silent; the subscription is dropped with the page.+ useEffect(() => api.onConfigSyncProgress((next) => setProgress(next)), []);+const updateForm = (key: keyof typeof form, value: string) =>setForm((current) => ({ ...current, [key]: value }));@@ -218,6 +226,9 @@ export function ConfigSyncPage() {setError(cause instanceof Error ? cause.message : String(cause));await refresh();} finally {+ // The request's own answer ends the run: once it has settled, whatever+ // the last report said is already stale.+ setProgress(null);setBusy(null);}};@@ -369,6 +380,10 @@ export function ConfigSyncPage() {const locked = state?.locked === true;const categories = selection;const isHttpEndpoint = /^http:\/\//i.test(form.endpoint.trim());+ // The report only exists for a sync this page started: an automatic run+ // stays quiet, and no report outlives the request that produced it.+ const syncProgress =+ busy === "sync" && progress ? configSyncProgressView(progress) : null;return (<div className="settings-stack settings-config-sync">@@ -557,6 +572,51 @@ export function ConfigSyncPage() {<span className="settings-config-sync-error">{state.lastError}</span></SettingsRow>) : null}+ {syncProgress ? (+ <div className="settings-config-sync-progress">+ <div className="settings-config-sync-progress-head">+ <span className="settings-config-sync-progress-title">+ {t("settings.configSync.progressTitle")}+ </span>+ <span className="settings-config-sync-progress-phase" role="status">+ {t(syncProgress.phaseKey)}+ </span>+ </div>+ {syncProgress.determinate ? (+ <div+ className="settings-config-sync-progress-bar"+ role="progressbar"+ aria-label={t("settings.configSync.progressTitle")}+ aria-valuemin={0}+ aria-valuemax={100}+ aria-valuenow={syncProgress.percent}+ aria-valuetext={syncProgress.fraction ?? undefined}+ >+ <span+ className="settings-config-sync-progress-bar-fill"+ style={{ width: `${syncProgress.percent}%` }}+ />+ </div>+ ) : null}+ {syncProgress.determinate ? (+ <div className="settings-config-sync-progress-figures">+ {syncProgress.objects ? (+ <span>+ {t(+ "settings.configSync.progress.objects",+ syncProgress.objects,+ )}+ </span>+ ) : null}+ {syncProgress.bytes ? (+ <span>+ {t("settings.configSync.progress.bytes", syncProgress.bytes)}+ </span>+ ) : null}+ </div>+ ) : null}+ </div>+ ) : null}{locked ? (<SettingsRowtitle={t("settings.configSync.unlockTitle")}diff --git a/apps/desktop/src/features/settings/config-sync-progress.ts b/apps/desktop/src/features/settings/config-sync-progress.tsnew file mode 100644index 000000000..106d1d422--- /dev/null+++ b/apps/desktop/src/features/settings/config-sync-progress.ts@@ -0,0 +1,104 @@+/**+ * What the sync card shows while a manual sync runs.+ *+ * `configSync.syncNow` is a single request that answers only once the whole+ * sync is over, so everything the card draws between the click and that answer+ * comes from `configSync.progress` reports: the phase, the units that phase+ * counted, and the bytes it moved. Turning one report into the fraction, the+ * figure line and the text a screen reader reads is pure transformation, so it+ * lives here rather than in the page that owns the subscription.+ */+import type { ConfigSyncPhase, ConfigSyncProgress } from "@pi-desktop/shared";++/** The catalog key naming each phase. */+export const CONFIG_SYNC_PHASE_KEYS: Record<ConfigSyncPhase, string> = {+ capture: "settings.configSync.progress.phase.capture",+ download: "settings.configSync.progress.phase.download",+ merge: "settings.configSync.progress.phase.merge",+ upload: "settings.configSync.progress.phase.upload",+ apply: "settings.configSync.progress.phase.apply",+ cleanup: "settings.configSync.progress.phase.cleanup",+};++/** What the card renders for one report. */+export type ConfigSyncProgressView = {+ /** The catalog key for the phase the host is in. */+ phaseKey: string;+ /** True when the report announced a total, in bytes or in units. */+ determinate: boolean;+ /** 0-100, clamped; 0 while the report announced no total. */+ percent: number;+ /**+ * The fraction read out for `aria-valuenow`, in the same order as the figure+ * line. Null while the report announced no total.+ */+ fraction: string | null;+ /** Bytes moved, when the report announced a byte total. */+ bytes: { done: string; total: string } | null;+ /** Units the phase counted, when the report announced a unit total. */+ objects: { done: number; total: number } | null;+};++/**+ * A byte count a person can read. A sync reports the same value as a running+ * count and as a total, so unlike a catalog size this has no "unknown"+ * reading: a phase that has moved nothing has moved zero bytes.+ */+export function formatBytes(bytes: number): string {+ const value = Number.isFinite(bytes) && bytes > 0 ? bytes : 0;+ if (value < 1024) return `${Math.round(value)} B`;+ if (value < 1024 * 1024) return `${(value / 1024).toFixed(1)} KB`;+ if (value < 1024 * 1024 * 1024) return `${(value / (1024 * 1024)).toFixed(2)} MB`;+ return `${(value / (1024 * 1024 * 1024)).toFixed(2)} GB`;+}++/** A report's own count, or 0 when the host sent nothing usable. */+function count(value: number | undefined): number {+ return typeof value === "number" && Number.isFinite(value) && value > 0+ ? value+ : 0;+}++function percentOf(done: number, total: number): number {+ return Math.min(100, Math.max(0, Math.round((done / total) * 100)));+}++/**+ * An announced byte total leads the reading, because one large object can+ * dominate a phase whose unit count already looks finished. Otherwise the unit+ * pair leads, and a report that announced neither stays indeterminate: the card+ * then reports activity instead of a fraction it would have to invent.+ */+export function configSyncProgressView(+ progress: ConfigSyncProgress,+): ConfigSyncProgressView {+ const bytesTotal = count(progress.bytesTotal);+ const bytesDone = count(progress.bytesDone);+ const unitTotal = count(progress.total);+ const unitDone = count(progress.done);++ const bytes =+ bytesTotal > 0+ ? { done: formatBytes(bytesDone), total: formatBytes(bytesTotal) }+ : null;+ const objects = unitTotal > 0 ? { done: unitDone, total: unitTotal } : null;+ const percent =+ bytesTotal > 0+ ? percentOf(bytesDone, bytesTotal)+ : unitTotal > 0+ ? percentOf(unitDone, unitTotal)+ : 0;++ return {+ phaseKey: CONFIG_SYNC_PHASE_KEYS[progress.phase],+ determinate: bytes !== null || objects !== null,+ percent,+ fraction: bytes+ ? `${bytes.done} / ${bytes.total}`+ : objects+ ? `${objects.done} / ${objects.total}`+ : null,+ bytes,+ objects,+ };+}diff --git a/apps/desktop/src/lib/api.ts b/apps/desktop/src/lib/api.tsindex daf193388..e97a0492e 100644--- a/apps/desktop/src/lib/api.ts+++ b/apps/desktop/src/lib/api.ts@@ -117,6 +117,7 @@ import type {ConfigSyncMapProjectInput,ConfigSyncConfigureInput,ConfigSyncRestoreInput,+ ConfigSyncProgress,ConfigSyncState,TrustedExtensionStatusEvent,TrustedExtensionUiPrompt,@@ -1539,6 +1540,12 @@ export const api = {listener(payload as ConfigSyncState),);},+ onConfigSyncProgress: (listener: (progress: ConfigSyncProgress) => void) => {+ if (!window.piDesktop?.on) return () => undefined;+ return window.piDesktop.on(IPC.event.configSyncProgress, (payload) =>+ listener(payload as ConfigSyncProgress),+ );+ },onPluginLauncherShown: (listener: () => void) => {if (!window.piDesktop?.on) return () => undefined;return window.piDesktop.on(IPC.event.pluginLauncherShown, () => listener());diff --git a/apps/desktop/src/styles/settings.css b/apps/desktop/src/styles/settings.cssindex a5c94407b..f96a77288 100644--- a/apps/desktop/src/styles/settings.css+++ b/apps/desktop/src/styles/settings.css@@ -506,6 +506,59 @@color: var(--ds-danger);}+/*+ * A manual sync reports itself while its request is still open: the phase it+ * is in, a bar once it announced a total, and the figures it has moved so far.+ */+.settings-config-sync-progress {+ display: grid;+ gap: 8px;+ margin: 0 16px 14px;+}++.settings-config-sync-progress-head {+ display: flex;+ align-items: baseline;+ justify-content: space-between;+ gap: 10px;+}++.settings-config-sync-progress-title {+ color: var(--ds-text-primary);+ font-size: var(--text-sm-plus);+ font-weight: var(--font-weight-medium-plus);+}++.settings-config-sync-progress-phase {+ color: var(--ds-text-secondary);+ font-size: var(--text-sm);+}++.settings-config-sync-progress-bar {+ position: relative;+ height: 6px;+ overflow: hidden;+ border-radius: var(--radius-full);+ background: color-mix(in oklab, var(--ds-text-primary) 10%, transparent);+}++.settings-config-sync-progress-bar-fill {+ display: block;+ height: 100%;+ border-radius: inherit;+ background: var(--ds-accent);+ transition: width var(--motion-duration-normal) var(--motion-ease-out);+}++.settings-config-sync-progress-figures {+ display: flex;+ align-items: baseline;+ gap: 12px;+ color: var(--ds-text-muted);+ font-size: var(--text-sm);+ font-variant-numeric: tabular-nums;+}+.settings-config-sync-categories {display: grid;grid-template-columns: repeat(2, minmax(0, 1fr));diff --git a/apps/desktop/test/config-sync-progress.test.mjs b/apps/desktop/test/config-sync-progress.test.mjsnew file mode 100644index 000000000..302cf530e--- /dev/null+++ b/apps/desktop/test/config-sync-progress.test.mjs@@ -0,0 +1,102 @@+/**+ * The sync card's progress reading: which fraction a report produces, and when+ * the card reports activity instead of a number.+ *+ * `configSync.syncNow` is one request, so the report is the only thing the card+ * draws while it runs. The rules live in a pure module so they can be asserted+ * here instead of through the page that owns the subscription.+ */+import assert from "node:assert/strict";+import { register } from "node:module";+import { dirname, join } from "node:path";+import test from "node:test";+import { fileURLToPath, pathToFileURL } from "node:url";++const here = dirname(fileURLToPath(import.meta.url));+register(pathToFileURL(join(here, "helpers/ts-import-hooks.mjs")));+const { CONFIG_SYNC_PHASE_KEYS, configSyncProgressView, formatBytes } =+ await import("../src/features/settings/config-sync-progress.ts");++const report = (phase, extra = {}) => ({+ phase,+ done: 0,+ total: 0,+ bytesDone: 0,+ bytesTotal: 0,+ ...extra,+});++test("every phase names a catalog key", () => {+ assert.deepEqual(Object.keys(CONFIG_SYNC_PHASE_KEYS).sort(), [+ "apply",+ "capture",+ "cleanup",+ "download",+ "merge",+ "upload",+ ]);+ for (const [phase, key] of Object.entries(CONFIG_SYNC_PHASE_KEYS)) {+ assert.equal(+ key,+ `settings.configSync.progress.phase.${phase}`,+ `${phase} must resolve to its own catalog entry`,+ );+ }+});++test("an announced byte total decides the reading", () => {+ const view = configSyncProgressView(+ report("upload", { done: 3, total: 12, bytesDone: 3_355_443, bytesTotal: 16_777_216 }),+ );++ assert.equal(view.determinate, true);+ assert.equal(view.percent, 20);+ assert.deepEqual(view.bytes, { done: "3.20 MB", total: "16.00 MB" });+ assert.deepEqual(view.objects, { done: 3, total: 12 });+ assert.equal(view.fraction, "3.20 MB / 16.00 MB");+});++test("a download without a byte total falls back to the object count", () => {+ // `download` reports bytesDone alone, so the phase's units are the only+ // fraction the card can honestly show.+ const view = configSyncProgressView(+ report("download", { done: 12, total: 45, bytesDone: 3_145_728 }),+ );++ assert.equal(view.determinate, true);+ assert.equal(view.percent, 27);+ assert.equal(view.bytes, null);+ assert.deepEqual(view.objects, { done: 12, total: 45 });+ assert.equal(view.fraction, "12 / 45");+});++test("a report with no announced total stays indeterminate", () => {+ // merge and cleanup are always counted per run, not per unit; so is a phase+ // whose total the host has not learned yet.+ const view = configSyncProgressView(report("merge", { done: 4, bytesDone: 512 }));++ assert.equal(view.determinate, false);+ assert.equal(view.percent, 0);+ assert.equal(view.fraction, null);+ assert.equal(view.bytes, null);+ assert.equal(view.objects, null);+ assert.equal(view.phaseKey, "settings.configSync.progress.phase.merge");+});++test("a fraction that overshoots its total stays a valid percentage", () => {+ const view = configSyncProgressView(+ report("capture", { done: 11, total: 10, bytesDone: 5, bytesTotal: 4 }),+ );++ assert.equal(view.percent, 100);+ assert.equal(configSyncProgressView(report("capture", { total: 10 })).percent, 0);+});++test("byte figures read at every scale and never invent a size", () => {+ assert.equal(formatBytes(0), "0 B");+ assert.equal(formatBytes(512), "512 B");+ assert.equal(formatBytes(3_145_728), "3.00 MB");+ assert.equal(formatBytes(2_147_483_648), "2.00 GB");+ assert.equal(formatBytes(Number.NaN), "0 B");+ assert.equal(formatBytes(-1), "0 B");+});diff --git a/apps/desktop/test/config-sync-settings.test.mjs b/apps/desktop/test/config-sync-settings.test.mjsindex 749465ab0..b36bab750 100644--- a/apps/desktop/test/config-sync-settings.test.mjs+++ b/apps/desktop/test/config-sync-settings.test.mjs@@ -2,6 +2,11 @@ import assert from "node:assert/strict";import { readFile } from "node:fs/promises";import test from "node:test";import { loadStyles } from "./helpers/styles.mjs";+import {+ CONFIG_SYNC_RPC_TIMEOUT_MS,+ DEFAULT_RPC_TIMEOUT_MS,+ rpcTimeoutMs,+} from "@pi-desktop/shared";const read = (relativePath) =>readFile(new URL(relativePath, import.meta.url), "utf8");@@ -11,6 +16,13 @@ const settingsIndex = await read("../src/lib/settings-search.ts");const syncPage = await read("../src/components/settings/ConfigSyncPage.tsx");const syncIpc = await read("../electron/main/ipc/config-sync-ipc.ts");const styles = await loadStyles();+const syncProtocol = await read("../../../packages/shared/src/protocol.ts");+const rpcTimeouts = await read("../../../packages/shared/src/rpc-timeouts.ts");+const hostRuntime = await read("../electron/main/runtime/host.ts");+const api = await read("../src/lib/api.ts");+const progressModel = await read(+ "../src/features/settings/config-sync-progress.ts",+);test("cloud sync is a searchable settings destination", () => {assert.match(settingsPage, /tab === "sync" && <ConfigSyncPage \/>/);@@ -48,3 +60,85 @@ test("cloud sync settings remain usable on narrow surfaces", () => {);assert.match(styles, /\.settings-config-sync-approval \{[\s\S]*flex-direction: column;/s);});++test("a running sync reports progress across the existing host bridge", () => {+ // The sync is one request, so the report has to travel the same+ // notification path the change notice already uses.+ assert.match(+ syncProtocol,+ /configSyncProgress: "pi-desktop\/configSync\/event\/progress"/,+ );+ assert.match(+ hostRuntime,+ /method === "configSync\.progress"[\s\S]{0,400}sendToRenderer\(IPC\.event\.configSyncProgress/,+ );+ assert.match(+ api,+ /onConfigSyncProgress: \(listener: \(progress: ConfigSyncProgress\) => void\)/,+ );+});++test("the sync card follows progress only while its own sync is running", () => {+ // Automatic syncs stay silent, and the subscription is dropped with the page.+ assert.match(syncPage, /useEffect\(\(\) => api\.onConfigSyncProgress\(/);+ assert.match(syncPage, /busy === "sync" && progress/);+ // The request's own answer ends the run, so the last report is cleared when+ // it settles instead of outliving the sync it described.+ assert.match(syncPage, /setProgress\(null\);/);+});++test("the sync card reports each phase with a readable fraction", () => {+ assert.match(syncPage, /t\(syncProgress\.phaseKey\)/);+ assert.match(syncPage, /settings\.configSync\.progressTitle/);+ assert.match(syncPage, /settings\.configSync\.progress\.objects/);+ assert.match(syncPage, /settings\.configSync\.progress\.bytes/);+ assert.match(+ progressModel,+ /import type \{ ConfigSyncPhase, ConfigSyncProgress \} from "@pi-desktop\/shared";/,+ );+ assert.match(progressModel, /^export const CONFIG_SYNC_PHASE_KEYS/m);+ for (const phase of [+ "capture",+ "download",+ "merge",+ "upload",+ "apply",+ "cleanup",+ ]) {+ assert.match(+ progressModel,+ new RegExp(`settings\\.configSync\\.progress\\.phase\\.${phase}`),+ );+ }+});++test("the sync card exposes the fraction to assistive technology", () => {+ assert.match(syncPage, /role="progressbar"/);+ assert.match(syncPage, /aria-valuemin=\{0\}/);+ assert.match(syncPage, /aria-valuemax=\{100\}/);+ assert.match(syncPage, /aria-valuenow=\{syncProgress\.percent\}/);+ assert.match(+ syncPage,+ /aria-valuetext=\{syncProgress\.fraction \?\? undefined\}/,+ );+ // A report with no announced total draws no bar: the phase name stays the+ // only status text, so the card never shows an invented fraction.+ assert.match(syncPage, /\{syncProgress\.determinate \? \(/);+ assert.match(+ styles,+ /\.settings-config-sync-progress-bar \{[\s\S]*?border-radius: var\(--radius-full\);/,+ );+ assert.match(styles, /\.settings-config-sync-progress-figures \{/);+});++test("a manual sync outlasts the flat default transport deadline", () => {+ // The host cannot cancel a run that is already under way, so a deadline that+ // fires while it is still working would only report a failure that is not+ // one; the report events carry liveness instead.+ assert.match(rpcTimeouts, /CONFIG_SYNC_RPC_TIMEOUT_MS = 1_800_000/);+ assert.match(rpcTimeouts, /method === "configSync\.syncNow"/);+ assert.equal(rpcTimeoutMs("configSync.syncNow", {}), CONFIG_SYNC_RPC_TIMEOUT_MS);+ assert.ok(CONFIG_SYNC_RPC_TIMEOUT_MS > DEFAULT_RPC_TIMEOUT_MS);+ // Every other config-sync call keeps the shared default.+ assert.equal(rpcTimeoutMs("configSync.getState", {}), DEFAULT_RPC_TIMEOUT_MS);+});diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.tsindex 0f2eecaea..641481486 100644--- a/packages/i18n/src/locales/de/index.ts+++ b/packages/i18n/src/locales/de/index.ts@@ -732,6 +732,19 @@ sklm: {save: "Save and sync",configured: "Cloud sync configuration saved.",syncNow: "Sync now",+ progressTitle: "Synchronisierung läuft…",+ progress: {+ phase: {+ capture: "Lokale Änderungen werden erfasst",+ download: "Remote-Änderungen werden geladen",+ merge: "Änderungen werden zusammengeführt",+ upload: "Änderungen werden hochgeladen",+ apply: "Änderungen werden angewendet",+ cleanup: "Aufräumen",+ },+ objects: "{{done}} / {{total}}",+ bytes: "{{done}} / {{total}}",+ },statusTitle: "Sync status",statusLabel: "Current state",lastSuccess: "Last successful run: {{date}}",diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.tsindex 9423e4605..551ef68be 100644--- a/packages/i18n/src/locales/en/index.ts+++ b/packages/i18n/src/locales/en/index.ts@@ -979,6 +979,19 @@ sklm: {save: "Save and sync",configured: "Cloud sync configuration saved.",syncNow: "Sync now",+ progressTitle: "Syncing…",+ progress: {+ phase: {+ capture: "Collecting local changes",+ download: "Downloading remote changes",+ merge: "Merging changes",+ upload: "Uploading changes",+ apply: "Applying changes",+ cleanup: "Cleaning up",+ },+ objects: "{{done}} / {{total}}",+ bytes: "{{done}} / {{total}}",+ },statusTitle: "Sync status",statusLabel: "Current state",lastSuccess: "Last successful run: {{date}}",diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.tsindex 8d504fb8b..cba2f5032 100644--- a/packages/i18n/src/locales/es/index.ts+++ b/packages/i18n/src/locales/es/index.ts@@ -732,6 +732,19 @@ sklm: {save: "Save and sync",configured: "Cloud sync configuration saved.",syncNow: "Sync now",+ progressTitle: "Sincronizando…",+ progress: {+ phase: {+ capture: "Recopilando cambios locales",+ download: "Descargando cambios remotos",+ merge: "Combinando cambios",+ upload: "Subiendo cambios",+ apply: "Aplicando cambios",+ cleanup: "Limpiando",+ },+ objects: "{{done}} / {{total}}",+ bytes: "{{done}} / {{total}}",+ },statusTitle: "Sync status",statusLabel: "Current state",lastSuccess: "Last successful run: {{date}}",diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.tsindex 0dfb1a3b5..30536d9dd 100644--- a/packages/i18n/src/locales/fr/index.ts+++ b/packages/i18n/src/locales/fr/index.ts@@ -732,6 +732,19 @@ sklm: {save: "Save and sync",configured: "Cloud sync configuration saved.",syncNow: "Sync now",+ progressTitle: "Synchronisation…",+ progress: {+ phase: {+ capture: "Collecte des modifications locales",+ download: "Téléchargement des modifications distantes",+ merge: "Fusion des modifications",+ upload: "Envoi des modifications",+ apply: "Application des modifications",+ cleanup: "Nettoyage",+ },+ objects: "{{done}} / {{total}}",+ bytes: "{{done}} / {{total}}",+ },statusTitle: "Sync status",statusLabel: "Current state",lastSuccess: "Last successful run: {{date}}",diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.tsindex 55a78d048..d498d4fed 100644--- a/packages/i18n/src/locales/ko/index.ts+++ b/packages/i18n/src/locales/ko/index.ts@@ -740,6 +740,19 @@ sklm: {save: "Save and sync",configured: "Cloud sync configuration saved.",syncNow: "Sync now",+ progressTitle: "동기화 중…",+ progress: {+ phase: {+ capture: "로컬 변경 사항 수집 중",+ download: "원격 변경 사항 내려받는 중",+ merge: "변경 사항 병합 중",+ upload: "변경 사항 업로드 중",+ apply: "변경 사항 적용 중",+ cleanup: "정리 중",+ },+ objects: "{{done}} / {{total}}",+ bytes: "{{done}} / {{total}}",+ },statusTitle: "Sync status",statusLabel: "Current state",lastSuccess: "Last successful run: {{date}}",diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.tsindex ccd90c65f..ca6a22e2e 100644--- a/packages/i18n/src/locales/tr/index.ts+++ b/packages/i18n/src/locales/tr/index.ts@@ -735,6 +735,19 @@ sklm: {save: "Kaydet ve senkronize et",configured: "Bulut senkronizasyonu yapılandırması kaydedildi.",syncNow: "Şimdi senkronize et",+ progressTitle: "Senkronize ediliyor…",+ progress: {+ phase: {+ capture: "Yerel değişiklikler toplanıyor",+ download: "Uzak değişiklikler indiriliyor",+ merge: "Değişiklikler birleştiriliyor",+ upload: "Değişiklikler yükleniyor",+ apply: "Değişiklikler uygulanıyor",+ cleanup: "Temizleniyor",+ },+ objects: "{{done}} / {{total}}",+ bytes: "{{done}} / {{total}}",+ },statusTitle: "Senkronizasyon durumu",statusLabel: "Geçerli durum",lastSuccess: "Son başarılı çalışma: {{date}}",diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.tsindex f63a6ed77..1d8bba741 100644--- a/packages/i18n/src/locales/zh-CN/index.ts+++ b/packages/i18n/src/locales/zh-CN/index.ts@@ -721,6 +721,19 @@ sklm: {save: "保存并同步",configured: "云同步配置已保存。",syncNow: "立即同步",+ progressTitle: "正在同步…",+ progress: {+ phase: {+ capture: "正在收集本地改动",+ download: "正在下载远程改动",+ merge: "正在合并改动",+ upload: "正在上传改动",+ apply: "正在应用改动",+ cleanup: "正在清理",+ },+ objects: "{{done}} / {{total}}",+ bytes: "{{done}} / {{total}}",+ },statusTitle: "同步状态",statusLabel: "当前状态",lastSuccess: "上次成功运行:{{date}}",diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.tsindex 693177d71..100c9e8e4 100644--- a/packages/i18n/src/locales/zh-TW/index.ts+++ b/packages/i18n/src/locales/zh-TW/index.ts@@ -721,6 +721,19 @@ sklm: {save: "儲存並同步",configured: "雲端同步設定已儲存。",syncNow: "立即同步",+ progressTitle: "正在同步…",+ progress: {+ phase: {+ capture: "正在收集本機變更",+ download: "正在下載遠端變更",+ merge: "正在合併變更",+ upload: "正在上傳變更",+ apply: "正在套用變更",+ cleanup: "正在清理",+ },+ objects: "{{done}} / {{total}}",+ bytes: "{{done}} / {{total}}",+ },statusTitle: "同步狀態",statusLabel: "目前狀態",lastSuccess: "上次成功執行:{{date}}",diff --git a/packages/shared/src/protocol.test.ts b/packages/shared/src/protocol.test.tsindex 7f9175def..2eccdedb7 100644--- a/packages/shared/src/protocol.test.ts+++ b/packages/shared/src/protocol.test.ts@@ -15,6 +15,7 @@ import {isGlobalPermissionMode,isToolsOutputParams,AGENT_COMPACT_RPC_TIMEOUT_MS,+ CONFIG_SYNC_RPC_TIMEOUT_MS,COMMAND_RPC_BUFFER_MS,COMPACTION_SUMMARY_MAX_RETRIES,COMPACTION_SUMMARY_RETRY_BUDGET_MS,@@ -292,4 +293,20 @@ describe("Plan protocol contracts", () => {rpcTimeoutMs("tools.execute", { toolName: "plugin_advisor_ask", timeoutMs: 0 }),).toBe(310_000);});++ it("lets a whole cloud sync finish instead of failing on a lost reply", () => {+ // The sync is one request that answers only when every phase is done, and+ // the host keeps running after a transport deadline fires. The progress+ // reports are the liveness signal, so the deadline is only a ceiling that+ // stops a genuinely lost answer from hanging the caller forever.+ expect(IPC.event.configSyncProgress).toBe(+ "pi-desktop/configSync/event/progress",+ );+ expect(IPC_WHITELIST.has(IPC.event.configSyncProgress)).toBe(true);+ expect(CONFIG_SYNC_RPC_TIMEOUT_MS).toBe(1_800_000);+ expect(rpcTimeoutMs("configSync.syncNow", {})).toBe(+ CONFIG_SYNC_RPC_TIMEOUT_MS,+ );+ expect(rpcTimeoutMs("configSync.getState", {})).toBe(130_000);+ });});diff --git a/packages/shared/src/protocol.ts b/packages/shared/src/protocol.tsindex 2cfc2d2dd..2529e1ba9 100644--- a/packages/shared/src/protocol.ts+++ b/packages/shared/src/protocol.ts@@ -343,6 +343,8 @@ export const IPC = {/** Host-originated app settings mutation (e.g. plugin `app.setTheme`). */settingsChanged: "pi-desktop/app/event/settingsChanged",configSyncChanged: "pi-desktop/configSync/event/changed",+ /** What a running sync is doing, while it is still running. */+ configSyncProgress: "pi-desktop/configSync/event/progress",extensionsUiPrompt: "pi-desktop/extensions/event/uiPrompt",extensionsStatus: "pi-desktop/extensions/event/status",pluginLauncherShown: "pi-desktop/pluginLauncher/event/shown",diff --git a/packages/shared/src/rpc-timeouts.ts b/packages/shared/src/rpc-timeouts.tsindex 20475b453..b754263e2 100644--- a/packages/shared/src/rpc-timeouts.ts+++ b/packages/shared/src/rpc-timeouts.ts@@ -64,6 +64,18 @@ export const AGENT_COMPACT_RPC_TIMEOUT_MS =(1 + COMPACTION_SUMMARY_MAX_RETRIES) * STREAM_IDLE_TIMEOUT_MS +COMPACTION_SUMMARY_RETRY_BUDGET_MS +COMMAND_RPC_BUFFER_MS;++/**+ * `configSync.syncNow` runs a whole sync in one request: a sequence of network+ * round trips whose steps the host reports through `configSync.progress`. The+ * host cannot cancel a run that is already under way and keeps going after a+ * transport deadline expires, so the progress events are the liveness signal+ * and the deadline only exists to stop a promise hanging forever when the+ * response is genuinely lost. No part of the run has a wall clock the+ * transport could read, so this is a ceiling for the whole run, not a measured+ * budget.+ */+export const CONFIG_SYNC_RPC_TIMEOUT_MS = 1_800_000;const MAX_TIMER_DELAY_MS = 2_147_483_647;function isRecord(value: unknown): value is Record<string, unknown> {@@ -94,14 +106,16 @@ export function isRpcTimeoutError(error: unknown): boolean {* effective execution timeout — plus transport slack, so the transport never* gives up before host-core reports its own timeout. A manual context* checkpoint carries the same property against the sidecar's summary request- * (`AGENT_COMPACT_RPC_TIMEOUT_MS`). Every call has a finite deadline so a lost- * response cannot leave a pending promise forever.+ * (`AGENT_COMPACT_RPC_TIMEOUT_MS`), and a manual cloud sync carries it against+ * the whole remote run (`CONFIG_SYNC_RPC_TIMEOUT_MS`). Every call has a finite+ * deadline so a lost response cannot leave a pending promise forever.*/export function rpcTimeoutMs(method: string,params: unknown,): number {if (method === "agent.compact") return AGENT_COMPACT_RPC_TIMEOUT_MS;+ if (method === "configSync.syncNow") return CONFIG_SYNC_RPC_TIMEOUT_MS;if (method !== "tools.execute") return DEFAULT_RPC_TIMEOUT_MS;const input = isRecord(params) ? params : undefined;diff --git a/packages/shared/src/types/config-sync.ts b/packages/shared/src/types/config-sync.tsindex 46bfd96a5..13e3ccee9 100644--- a/packages/shared/src/types/config-sync.ts+++ b/packages/shared/src/types/config-sync.ts@@ -39,6 +39,38 @@ export type ConfigSyncRemoteMode = "strict" | "appendOnly";export type ConfigSyncCategorySelection = Record<ConfigSyncCategory, boolean>;+/**+ * The step a run is in. `capture` collects the local snapshot, `download` reads+ * the remote revision's resources, `merge` reconciles both, `upload` writes the+ * merged revision's resources, `apply` writes the result locally, and `cleanup`+ * deletes revisions the retention window no longer keeps.+ */+export type ConfigSyncPhase =+ | "capture"+ | "download"+ | "merge"+ | "upload"+ | "apply"+ | "cleanup";++/**+ * What a running sync is doing, reported while it runs.+ *+ * The sync is a single request, so without these the interface has nothing to+ * show between the click and the answer. `done`/`total` are that phase's units+ * (objects for `download`/`upload`, entities for `capture`/`apply`, and always+ * 0 for `merge`/`cleanup`); `total === 0` means the size of the phase is not+ * known in advance. `bytesDone`/`bytesTotal` are a byte pair that only+ * `upload` reports in full — `download` reports `bytesDone` alone — and+ * `bytesTotal === 0` means the byte count is not known.+ */+export type ConfigSyncProgress = {+ phase: ConfigSyncPhase;+ done: number;+ total: number;+ bytesDone: number;+ bytesTotal: number;+};export type ConfigSyncPreferences = {endpoint: string;username: string;