[READ-ONLY] Mirror of https://github.com/bombshell-dev/tty. Platform independent 2D layout engine for terminal applications based on Clay
5

Configure Feed

Select the types of activity you want to include in your feed.

✨ reset deltaTime to 0 after idle (preserve transitions across long gaps)

Charles Lowell (Apr 22, 2026, 7:34 PM -0500) cbd6109d c18a97b2

+20 -5
+15 -3
specs/transitions-spec.md
··· 108 108 seconds since the previous render. That value is passed to the layout 109 109 engine to advance any in-flight transitions. 110 110 111 + If the previous render reported `animating=false`, the Term passes 112 + `deltaTime=0` to the layout engine on the current render, regardless of 113 + wall-clock time elapsed. The rationale: Clay is delta-based and has no 114 + concept of when a transition began. Idle time between renders must not 115 + count toward any subsequent transition's elapsed clock, otherwise a long 116 + idle gap followed by a mutation would cause the transition to complete 117 + instantly. Passing `deltaTime=0` on the first frame of any new transition 118 + gives it a clean elapsed=0 starting point; real deltas resume once the 119 + previous render signals `animating=true`. 120 + 111 121 The caller MAY override the computed delta via an explicit `deltaTime` 112 122 option on `render()`. Use cases include deterministic testing, snapshot 113 123 rendering, and compute-only renders where the caller is querying bounds ··· 209 219 210 220 Each `render()` call advances transitions by its `deltaTime`: 211 221 212 - - If `deltaTime` is omitted, Term computes it as the monotonic wall-clock 213 - time elapsed since the previous `render()` call. 214 - - If `deltaTime` is provided, it is used verbatim for that frame. 222 + - If `deltaTime` is provided explicitly, it is used verbatim. 223 + - Otherwise, if the previous render reported `animating=false`, 224 + `deltaTime=0` (see §4.2 for rationale). 225 + - Otherwise, `deltaTime` is the monotonic wall-clock time elapsed since 226 + the previous `render()` call. 215 227 216 228 On every `render()` call, Term captures the current monotonic timestamp as 217 229 the reference point for the next implicit delta. The two modes can be
+5 -2
term.ts
··· 81 81 let pressed = new Set<string>(); 82 82 let wasDown = false; 83 83 let lastRenderAt: number | undefined; 84 + let wasAnimating = false; 84 85 85 86 return { 86 87 render(ops: Op[], options?: RenderOptions): RenderResult { ··· 91 92 let dt: number; 92 93 if (options?.deltaTime !== undefined) { 93 94 dt = options.deltaTime; 94 - } else if (lastRenderAt === undefined) { 95 + } else if (!wasAnimating || lastRenderAt === undefined) { 95 96 dt = 0; 96 97 } else { 97 98 dt = now - lastRenderAt; ··· 165 166 }); 166 167 } 167 168 168 - return { output, events, info, errors, animating: native.animating(statePtr) > 0 }; 169 + let animating = native.animating(statePtr) > 0; 170 + wasAnimating = animating; 171 + return { output, events, info, errors, animating }; 169 172 }, 170 173 }; 171 174 }