perf(ui): enforce 750 ms live update cadence

Use one 750 ms interval for running download snapshots, progress updates, the bandwidth chart, and the header speed sparkline across every queue size. Remove the extra active-download renderer delay and add timing regressions for small, medium, and large queues.
This commit is contained in:
Sucukdeluxe
2026-08-20 05:23:59 +02:00
parent 08f017e8c4
commit 10528a2696
5 changed files with 59 additions and 21 deletions
+12 -1
View File
@@ -50,10 +50,21 @@ describe("desktop shell", () => {
expect(getSnapshotRenderDelay(2_470, true, "statistics")).toBe(800);
});
it("renders medium download queues immediately after their calm half-second snapshot", () => {
it("renders medium download queues immediately after their calm 750 ms snapshot", () => {
expect(getSnapshotRenderDelay(661, true, "downloads")).toBe(0);
});
it("does not add renderer delay after the 750 ms manager cadence for a small active queue", () => {
expect(getSnapshotRenderDelay(69, true, "downloads")).toBe(0);
});
it("redraws the header speed sparkline on the same 750 ms cadence", () => {
const source = readFileSync(new URL("../src/renderer/App.tsx", import.meta.url), "utf8");
const sparklineBlock = source.slice(source.indexOf("const DownloadSpeedSparkline"), source.indexOf("const initialCollectorTabs"));
expect(sparklineBlock).toContain("window.setInterval(tick, 750)");
});
it("keeps application menus mounted for animated opening and closing", () => {
const source = readFileSync(new URL("../src/renderer/App.tsx", import.meta.url), "utf8");
const css = readFileSync(new URL("../src/renderer/styles.css", import.meta.url), "utf8");
+38
View File
@@ -45,6 +45,44 @@ describe("runWithLimitedConcurrency", () => {
});
});
describe("download live update cadence", () => {
it.each([69, 661, 2_470])("emits a running queue snapshot no sooner than 750 ms for %i items", async (itemCount) => {
vi.useFakeTimers();
try {
const root = fs.mkdtempSync(path.join(os.tmpdir(), "rd-live-cadence-"));
tempDirs.push(root);
const session = emptySession();
session.running = true;
const manager = new DownloadManager(defaultSettings(), session, createStoragePaths(path.join(root, "state")));
const internal = manager as unknown as {
emitState: () => void;
itemCount: number;
session: typeof session;
stateEmitTimer: NodeJS.Timeout | null;
};
internal.itemCount = itemCount;
internal.session.running = true;
if (internal.stateEmitTimer) {
clearTimeout(internal.stateEmitTimer);
internal.stateEmitTimer = null;
}
let emitted = 0;
manager.on("state", () => {
emitted += 1;
});
internal.emitState();
await vi.advanceTimersByTimeAsync(749);
expect(emitted).toBe(0);
await vi.advanceTimersByTimeAsync(1);
expect(emitted).toBe(1);
} finally {
vi.useRealTimers();
}
});
});
describe("resolveUnrestrictTimeoutBudgetMs", () => {
it("covers the complete provider plan and each later Real-Debrid account attempt", () => {
const settings = {
+1 -1
View File
@@ -507,7 +507,7 @@ describe("bandwidth chart palette", () => {
expect(chartBlock).toContain('role="img"');
expect(chartBlock).toContain('aria-label="Bandbreitenverlauf der letzten 60 Sekunden"');
expect(chartBlock).toContain('window.matchMedia("(prefers-reduced-motion: reduce)")');
expect(chartBlock).toContain("reducedMotion ? 1000 : 500");
expect(chartBlock).toContain("reducedMotion ? 1000 : 750");
});
it("asks for confirmation before deleting all saved download statistics", () => {