Skip to content

Commit ee50949

Browse files
committed
fix(server): defer incomplete upgrade spinner labels
1 parent 605b48b commit ee50949

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

‎apps/server/src/provider/providerMaintenanceRunner.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,30 @@ describe("providerMaintenanceRunner", () => {
416416
}
417417
});
418418

419+
it("defers progress while an ANSI redraw sequence is incomplete", () => {
420+
for (const sequence of ["\u001b[1G", "\u001b[0G", "\u001b[G", "\u001b[1G\u001b[0J"]) {
421+
for (let boundary = 1; boundary < sequence.length; boundary++) {
422+
const split = ProviderMaintenanceRunner.splitOutputLines(
423+
"",
424+
`Downloading\n◒ Upgrading${sequence.slice(0, boundary)}`,
425+
);
426+
assert.strictEqual(ProviderMaintenanceRunner.toProgressLine(split.partialLine), null);
427+
assert.strictEqual(
428+
ProviderMaintenanceRunner.toProgressLine(split.lines[0] ?? ""),
429+
"Downloading",
430+
);
431+
const completed = ProviderMaintenanceRunner.splitOutputLines(
432+
split.partialLine,
433+
`${sequence.slice(boundary)}◐ Upgrading.`,
434+
);
435+
assert.strictEqual(
436+
ProviderMaintenanceRunner.toProgressLine(completed.partialLine),
437+
"◐ Upgrading.",
438+
);
439+
}
440+
}
441+
});
442+
419443
it.effect("aborts without running when the installation changed since the advisory", () => {
420444
const calls: Array<string> = [];
421445
return Effect.gen(function* () {

‎apps/server/src/provider/providerMaintenanceRunner.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,14 @@ export function splitOutputLines(
215215
}
216216

217217
export function toProgressLine(line: string): string | null {
218+
if (
219+
line.endsWith("\u001b") ||
220+
line.endsWith("\u001b[") ||
221+
line.endsWith("\u001b[0") ||
222+
line.endsWith("\u001b[1")
223+
) {
224+
return null;
225+
}
218226
const text = NodeUtil.stripVTControlCharacters(line).replace(/\s+/g, " ").trim();
219227
if (text.length === 0) {
220228
return null;

0 commit comments

Comments
 (0)