Skip to content

Commit 201083e

Browse files
committed
refactor: retain renderer state in a frame context
1 parent ba2d1bd commit 201083e

16 files changed

Lines changed: 1276 additions & 383 deletions

‎.changeset/stable-render-frames.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@bomb.sh/tty": patch
3+
---
4+
5+
Fixes stale element bounds in `@bomb.sh/tty`: `result.info.get(id)` returns
6+
`undefined` for elements absent from the latest render.
7+
8+
Fixes the caret cursor remaining visible after a resize when the next render in
9+
the default mode omits the caret.

‎specs/transitions-spec.md‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -460,26 +460,24 @@ Each handler:
460460
2. Applies its easing curve to progress.
461461
3. Lerps each property named in the `properties` bitmask from `initial` to
462462
`target`.
463-
4. Increments the Term context's `animating_count` unless progress is 1.0.
463+
4. Increments the current frame's `animating_count` unless progress is 1.0.
464464
5. Returns `true` if progress is 1.0 (transition complete), `false` otherwise.
465465

466-
At the start of each `render()`, the Term resets `animating_count` to zero. At
467-
the end, the value is copied into the result struct as the `animating` flag
468-
(`true` if count > 0).
466+
At the start of each `render()`, the current frame's `animating_count` is reset
467+
to zero. At the end, the value is copied into the result struct as the
468+
`animating` flag (`true` if count > 0).
469469

470470
### 12.3 Per-Term isolation
471471

472-
The `animating_count` lives on the Term's C-side context, not as module-level
473-
state. Multiple Terms created in the same process remain isolated.
472+
The `animating_count` belongs to a frame owned by the Term's C-side context.
473+
Multiple Terms created in the same process remain isolated.
474474

475475
### 12.4 Resolving the active Term inside the handler
476476

477477
Clay's transition-handler signature does not carry a `userData` pointer or
478-
element ID. Each `reduce()` call records the currently-active Term pointer in a
479-
module-level variable (`ct_active_context`) and clears it at the end. The
480-
handler reads this variable to reach the Term's `animating_count`. A single
481-
render pass cannot overlap with another (renders are synchronous), so there is
482-
no concurrency concern.
478+
element ID. The handler obtains the active Clay context through
479+
`Clay_GetCurrentContext()` and reads the owning Term from the context's error
480+
handler `userData`. It increments that Term's current frame counter.
483481

484482
---
485483

0 commit comments

Comments
 (0)