Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(desktop): show sync progress while the first enable runs
vastsa9903a006edac
diff --git a/apps/desktop/src/components/settings/ConfigSyncPage.tsx b/apps/desktop/src/components/settings/ConfigSyncPage.tsxindex 2f116b66f..5818671ef 100644--- a/apps/desktop/src/components/settings/ConfigSyncPage.tsx+++ b/apps/desktop/src/components/settings/ConfigSyncPage.tsx@@ -380,10 +380,13 @@ 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.+ // The report only exists for a sync this page started: an automatic run stays+ // quiet, and no report outlives the request that produced it. Enabling a+ // vault runs the same full sync as "sync now", so both operations are watched.const syncProgress =- busy === "sync" && progress ? configSyncProgressView(progress) : null;+ (busy === "sync" || busy === "configure") && progress+ ? configSyncProgressView(progress)+ : null;return (<div className="settings-stack settings-config-sync">@@ -552,6 +555,55 @@ export function ConfigSyncPage() {) : null}</SettingsCard>+ {/* A sync this page started reports itself here, above the cards: the+ first enable is the slowest sync of all, and it runs while the status+ card below has nothing to show yet. */}+ {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}+{configured ? (<><SettingsCard title={t("settings.configSync.statusTitle")}>@@ -572,51 +624,6 @@ 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/styles/settings.css b/apps/desktop/src/styles/settings.cssindex f96a77288..4f80c32e6 100644--- a/apps/desktop/src/styles/settings.css+++ b/apps/desktop/src/styles/settings.css@@ -509,11 +509,15 @@/** 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.+ * It sits between the cards rather than inside one, because the first enable —+ * the slowest sync of all — runs before the status card exists. The page stack+ * spaces the cards around it, so only the inset that lines it up with their+ * content is left here.*/.settings-config-sync-progress {display: grid;gap: 8px;- margin: 0 16px 14px;+ margin: 0 16px;}.settings-config-sync-progress-head {diff --git a/apps/desktop/test/config-sync-settings.test.mjs b/apps/desktop/test/config-sync-settings.test.mjsindex b36bab750..eb91de857 100644--- a/apps/desktop/test/config-sync-settings.test.mjs+++ b/apps/desktop/test/config-sync-settings.test.mjs@@ -78,15 +78,39 @@ test("a running sync reports progress across the existing host bridge", () => {);});-test("the sync card follows progress only while its own sync is running", () => {+test("the sync page follows progress while it runs a sync of its own", () => {// Automatic syncs stay silent, and the subscription is dropped with the page.assert.match(syncPage, /useEffect\(\(\) => api\.onConfigSyncProgress\(/);- assert.match(syncPage, /busy === "sync" && progress/);+ // Enabling a vault runs the same full sync as "sync now", so both gate it.+ assert.match(+ syncPage,+ /\(busy === "sync" \|\| busy === "configure"\) && 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 progress line renders before the status card a first enable has not built", () => {+ // The slowest sync of all is the first enable: it runs while `configured` is+ // still false, and the status card does not exist yet. So the line cannot sit+ // inside the `{configured ? …}` block that owns that card. Source order pins+ // it: the line appears exactly once, earlier than the gate.+ const marker = 'className="settings-config-sync-progress"';+ const progressAt = syncPage.indexOf(marker);+ const configuredAt = syncPage.indexOf("{configured ? (");+ assert.equal(+ syncPage.split(marker).length - 1,+ 1,+ "the page renders exactly one progress line",+ );+ assert.ok(configuredAt > 0, "the configured gate is still rendered");+ assert.ok(+ progressAt > 0 && progressAt < configuredAt,+ "the progress line must render before the {configured ? …} gate",+ );+});+test("the sync card reports each phase with a readable fraction", () => {assert.match(syncPage, /t\(syncProgress\.phaseKey\)/);assert.match(syncPage, /settings\.configSync\.progressTitle/);diff --git a/packages/shared/src/types/config-sync.ts b/packages/shared/src/types/config-sync.tsindex 13e3ccee9..5e1f3f910 100644--- a/packages/shared/src/types/config-sync.ts+++ b/packages/shared/src/types/config-sync.ts@@ -58,10 +58,12 @@ export type ConfigSyncPhase =** 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+ * — objects for `download`/`upload` (the device tips being read, in append-only+ * mode) and entities for `capture`/`merge`/`apply`, while `cleanup` reports the+ * phase without counting it — and `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, because a+ * remote manifest names resources by id rather than by length — and* `bytesTotal === 0` means the byte count is not known.*/export type ConfigSyncProgress = {