Skip to content

feat(agera,kida,nanoviews): bottom-up deferred effect scopes - #189

Merged
dangreen merged 1 commit into
mainfrom
feat/bottom-up-defer-scopes
Aug 8, 2026
Merged

feat(agera,kida,nanoviews): bottom-up deferred effect scopes#189
dangreen merged 1 commit into
mainfrom
feat/bottom-up-defer-scopes

Conversation

@dangreen

@dangreen dangreen commented Aug 8, 2026

Copy link
Copy Markdown
Member

Redesign of the deferred-effect-scope mechanism: view effects now start bottom-up (children before parents) and are destroyed children-first, while store effects keep their current behavior.

  • rework the defer layer into a LazyMode one-shot token state machine (LAZY -> STARTED -> STOPPED): two-pass start runs children before parents, stop is total and children-first, moveScope is removed
  • boundDeferScope anchors pin the swap position structurally; swaps destroy the previous content first, while its DOM is still attached
  • for_ owns its rows: free-standing row scopes are started and stopped in visual order via the items list; an eager teardown holder guarantees row cleanup even for periods stopped before their first start
  • kida unsafeRun switches the DI context without untracking; mount/unmount are batched, so the DI context and render writes never leak into the flush
  • fix zombie effects after mid-start teardown, a checkDirty crash on emptied pending scopes, stuck mounted(true) on discarded subscriptions and incomplete cleanup of effects disposed during their own warmup

Verified with the full test chain (agera 113, kida 61, nanoviews 72, store 57), size-limit across all packages and a real-browser benchmark at parity.

🤖 Generated with Claude Code

- rework the defer layer into a LazyMode one-shot token state machine (LAZY -> STARTED -> STOPPED): two-pass start runs children before parents, stop is total and children-first, `moveScope` is removed
- `boundDeferScope` anchors pin the swap position structurally; swaps destroy the previous content first, while its DOM is still attached
- `for_` owns its rows: free-standing row scopes are started and stopped in visual order via the items list; an eager teardown holder guarantees row cleanup even for periods stopped before their first start
- kida `unsafeRun` switches the DI context without untracking; mount/unmount are batched, so the DI context and render writes never leak into the flush
- fix zombie effects after mid-start teardown, a `checkDirty` crash on emptied pending scopes, stuck `mounted(true)` on discarded subscriptions and incomplete cleanup of effects disposed during their own warmup
@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.64286% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.23%. Comparing base (468a293) to head (02a7655).

Files with missing lines Patch % Lines
packages/nanoviews/src/internals/flow/loop.ts 92.50% 1 Missing and 2 partials ⚠️
packages/agera/src/internals/system.ts 96.66% 1 Missing and 1 partial ⚠️
packages/nanoviews/src/component/context.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #189      +/-   ##
==========================================
+ Coverage   83.96%   84.23%   +0.26%     
==========================================
  Files         138      138              
  Lines        2988     3026      +38     
  Branches      564      565       +1     
==========================================
+ Hits         2509     2549      +40     
+ Misses        340      339       -1     
+ Partials      139      138       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dangreen
dangreen merged commit dd3169f into main Aug 8, 2026
10 checks passed
@dangreen
dangreen deleted the feat/bottom-up-defer-scopes branch August 8, 2026 21:24
@github-actions github-actions Bot mentioned this pull request Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant