Skip to content

Commit eaf7f41

Browse files
committed
fix(ui): end the Sync now wait on any new sync report
A requested sync that fails the same way as before now ends the wait too.
1 parent f88f15b commit eaf7f41

6 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎crates/sqlbuild-orchestration/src/platform/_helpers/recent_health.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::store::main::decode_row::decode_row;
99
use crate::store::main::query::query;
1010
use crate::store::models::{ControlTransaction, Parameter};
1111

12-
/// At most 100, newest first, from every retained day (a sync follows only runs) plus each instance's last check-in.
12+
/// At most 100, newest first, from the health retention window (a sync follows only runs) plus instance check-ins.
1313
pub(crate) async fn recent_health(
1414
transaction: ControlTransaction,
1515
location_id: Uuid,

‎ui/src/lib/api/http-locations.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('warehouseSyncOf', () => {
7373
sync('2026-11-08T12:01:00Z', 'catalog', null),
7474
sync('2026-11-08T12:00:00Z', 'statistics', 'delivery')
7575
]);
76-
expect(result).toEqual({ lastSyncedAt: '2026-11-08T12:02:00Z', lastError: 'catalog: failed while reading the warehouse' });
76+
expect(result).toEqual({ lastSyncedAt: '2026-11-08T12:02:00Z', lastError: 'catalog: failed while reading the warehouse', lastReportedAt: '2026-11-08T12:03:00Z' });
7777
});
7878

7979
it("gives each table its newest sync, the time it last synced cleanly, and where the state tables are read from", () => {

‎ui/src/lib/api/http-locations.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export function warehouseSyncOf(observations: Wire['LocationHealthObservation'][
167167
const failing = [...newest.values()].flatMap((s) => (s.report.health.failure ? [`${s.report.health.table}: failed while ${SYNC_STAGE[s.report.health.failure]}`] : []));
168168
return {
169169
lastSyncedAt: syncs.find((s) => !s.report.health.failure)?.received_at ?? null,
170-
lastError: failing.length ? failing.sort().join('\n') : null
170+
lastError: failing.length ? failing.sort().join('\n') : null,
171+
lastReportedAt: syncs[0].received_at
171172
};
172173
}

‎ui/src/lib/api/mock/mock-client.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ export class MockApiClient implements ApiClient {
338338
this.#require('connection.test');
339339
const sync = this.#sync(scope);
340340
setTimeout(() => {
341-
Object.assign(sync, { lastSyncedAt: new Date().toISOString(), lastError: null });
341+
const now = new Date().toISOString();
342+
Object.assign(sync, { lastSyncedAt: now, lastError: null, lastReportedAt: now });
342343
this.changes.emit(`warehouse_sync:${scope.locationId}`);
343344
}, 1500);
344345
return this.#reply(undefined);

‎ui/src/lib/api/types.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ export type WarehouseSync = {
6666
lastSyncedAt: Iso | null;
6767
/** Why the latest sync failed; null when it succeeded. */
6868
lastError: string | null;
69+
/** When the newest sync report arrived, failed or not; a new one means a requested sync has finished. */
70+
lastReportedAt?: Iso | null;
6971
};
7072

7173
/** The one target a location is deployed against, e.g. `prod` on Snowflake. */

‎ui/src/lib/components/platform/warehouse-sync-now.svelte‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
let requested = $state<{ at: number; seen: string } | null>(null);
2121
let failure = $state<string | null>(null);
2222
const last = $derived(sync.data ?? null);
23-
const reportOf = (report: typeof last) => `${report?.lastSyncedAt ?? ''}|${report?.lastError ?? ''}`;
23+
const reportOf = (report: typeof last) => `${report?.lastReportedAt ?? ''}|${report?.lastSyncedAt ?? ''}|${report?.lastError ?? ''}`;
2424
const pending = $derived(requested !== null && reportOf(last) === requested.seen && app.now - requested.at < 5 * 60_000);
2525
2626
async function request() {

0 commit comments

Comments
 (0)