Skip to content

Commit 61906e1

Browse files
committed
fix(server): keep latest provider upgrade spinner frame
1 parent d7a8d6f commit 61906e1

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,22 @@ describe("providerMaintenanceRunner", () => {
400400
assert.strictEqual(ProviderMaintenanceRunner.toProgressLine("x".repeat(300))?.length, 200);
401401
});
402402

403+
it("keeps only the latest installer spinner frame across chunk boundaries", () => {
404+
const output = "◒ Upgrading\u001b[1G\u001b[0J◐ Upgrading.\u001b[1G\u001b[0J◓ Upgrading..";
405+
for (let boundary = 0; boundary <= output.length; boundary++) {
406+
let partialLine = "";
407+
for (const chunk of [output.slice(0, boundary), output.slice(boundary)]) {
408+
const split = ProviderMaintenanceRunner.splitOutputLines(partialLine, chunk);
409+
partialLine = split.partialLine;
410+
}
411+
assert.strictEqual(
412+
ProviderMaintenanceRunner.toProgressLine(partialLine),
413+
"◓ Upgrading..",
414+
`chunk boundary ${boundary}`,
415+
);
416+
}
417+
});
418+
403419
it.effect("aborts without running when the installation changed since the advisory", () => {
404420
const calls: Array<string> = [];
405421
return Effect.gen(function* () {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ export function splitOutputLines(
206206
partialLine: string,
207207
text: string,
208208
): { readonly lines: ReadonlyArray<string>; readonly partialLine: string } {
209-
const parts = (partialLine + text).split(/\r\n|\r|\n/);
209+
// oxlint-disable-next-line no-control-regex -- ANSI cursor-to-column-1 redraws delimit spinner frames.
210+
const parts = (partialLine + text).split(/\r\n|\r|\n|\u001b\[(?:0|1)?G/);
210211
return { partialLine: (parts.pop() ?? "").slice(-UPDATE_PARTIAL_LINE_MAX_LENGTH), lines: parts };
211212
}
212213

0 commit comments

Comments
 (0)