From 42fdd5ed2a67cb1273fba5522229b941c9e1e9dc Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Tue, 24 Mar 2026 19:00:26 +0200 Subject: [PATCH] fix(site): clamp SmoothText dtMs to prevent animation budget inflation (#23498) After a long requestAnimationFrame pause (e.g. backgrounded tab), the time delta can be very large, causing the character budget to spike and bypass smooth rendering entirely. Clamp to 100ms. Extracted from #23236. --- .../pages/AgentsPage/components/AgentDetail/SmoothText.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/site/src/pages/AgentsPage/components/AgentDetail/SmoothText.ts b/site/src/pages/AgentsPage/components/AgentDetail/SmoothText.ts index cc4c3f9764..968a225de4 100644 --- a/site/src/pages/AgentsPage/components/AgentDetail/SmoothText.ts +++ b/site/src/pages/AgentsPage/components/AgentDetail/SmoothText.ts @@ -170,10 +170,14 @@ export class SmoothTextEngine { * Advance the presentation clock by a timestep. */ tick(dtMs: number): number { - if (dtMs <= 0) { + if (dtMs <= 0 || Number.isNaN(dtMs)) { return this.visibleLengthValue; } + // Clamp to prevent charBudget inflation after long + // background periods where RAF was paused by the browser. + dtMs = Math.min(100, dtMs); + if (!this.isStreaming || this.bypassSmoothing) { return this.visibleLengthValue; }