print out server sync only once progress is made
All checks were successful
Generic zig build / build (push) Successful in 1m45s
Generic zig build / deploy (push) Successful in 16s

This commit is contained in:
Emil Lerch 2026-04-25 07:17:30 -07:00
parent f99ec545ad
commit 74fa8d91fa
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -129,47 +129,38 @@ pub const LoadProgress = struct {
pub const AggregateProgress = struct {
color: bool,
last_phase: ?zfin.DataService.AggregateProgressCallback.Phase = null,
last_completed: usize = 0,
fn onProgress(ctx: *anyopaque, completed: usize, total: usize, phase: zfin.DataService.AggregateProgressCallback.Phase) void {
const self: *AggregateProgress = @ptrCast(@alignCast(ctx));
// Track phase transitions for newlines
const phase_changed = self.last_phase == null or self.last_phase.? != phase;
self.last_phase = phase;
var buf: [256]u8 = undefined;
var writer = std.fs.File.stderr().writer(&buf);
const out = &writer.interface;
const w = &writer.interface;
switch (phase) {
.cache_check => {
// Brief phase, no output needed
},
.cache_check => {},
.server_sync => {
// Single updating line with carriage return
if (self.color) fmt.ansiSetFg(out, CLR_MUTED[0], CLR_MUTED[1], CLR_MUTED[2]) catch {};
out.print("\r Syncing from server... [{d}/{d}]", .{ completed, total }) catch {};
if (self.color) fmt.ansiReset(out) catch {};
out.flush() catch {};
if (completed != self.last_completed) {
if (self.color) fmt.ansiSetFg(w, CLR_MUTED[0], CLR_MUTED[1], CLR_MUTED[2]) catch {};
w.print(" Syncing from server... [{d}/{d}]\n", .{ completed, total }) catch {};
if (self.color) fmt.ansiReset(w) catch {};
w.flush() catch {};
self.last_completed = completed;
}
},
.provider_fetch => {
if (phase_changed) {
// Clear the server sync line and print newline
out.print("\r\x1b[K", .{}) catch {}; // clear line
if (self.color) fmt.ansiSetFg(out, CLR_MUTED[0], CLR_MUTED[1], CLR_MUTED[2]) catch {};
out.print(" Synced {d} from server, fetching remaining from providers...\n", .{completed}) catch {};
if (self.color) fmt.ansiReset(out) catch {};
out.flush() catch {};
}
},
.complete => {
// Final newline if we were on server_sync line
if (self.last_phase != null and
(self.last_phase.? == .server_sync or self.last_phase.? == .cache_check))
{
out.print("\r\x1b[K", .{}) catch {}; // clear line
if (self.color) fmt.ansiSetFg(w, CLR_MUTED[0], CLR_MUTED[1], CLR_MUTED[2]) catch {};
w.print(" Synced {d} from server, fetching remaining from providers...\n", .{completed}) catch {};
if (self.color) fmt.ansiReset(w) catch {};
w.flush() catch {};
}
},
.complete => {},
}
}