refactor(renderer): replace WeakMap theme propagation with stack#211
refactor(renderer): replace WeakMap theme propagation with stack#211RtlZeroMemory merged 2 commits intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughReplaces per-node WeakMap theme tracking in renderTree.ts with a stack-based Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/core/src/renderer/renderToDrawlist/renderTree.ts (1)
128-128: Add a dev guard for theme stack underflow on Line 128.
themeStack.pop() ?? themesilently falls back if stack alignment breaks, which can hide traversal bugs and produce hard-to-debug theming drift.Suggested hardening
- const currentTheme = themeStack.pop() ?? theme; + const poppedTheme = themeStack.pop(); + if (DEV_MODE && poppedTheme === undefined) { + warnDev("[rezi][render] theme stack underflow; falling back to root theme."); + } + const currentTheme = poppedTheme ?? theme;As per coding guidelines, all TypeScript changes must follow code-standards including strict error-handling patterns.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/core/src/renderer/renderToDrawlist/renderTree.ts` at line 128, The assignment "const currentTheme = themeStack.pop() ?? theme" can silently hide themeStack underflow; add a dev-only guard before popping themeStack in the renderTree logic (referencing themeStack, currentTheme, and theme) that checks themeStack.length > 0 and if not, throws or logs a clear error (using the project's dev flag like NODE_ENV or __DEV__) so traversal bugs surface during development, while in production still falling back to `theme`.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/core/src/renderer/renderToDrawlist/renderTree.ts`:
- Line 128: The assignment "const currentTheme = themeStack.pop() ?? theme" can
silently hide themeStack underflow; add a dev-only guard before popping
themeStack in the renderTree logic (referencing themeStack, currentTheme, and
theme) that checks themeStack.length > 0 and if not, throws or logs a clear
error (using the project's dev flag like NODE_ENV or __DEV__) so traversal bugs
surface during development, while in production still falling back to `theme`.
Summary
WeakMap<RuntimeInstance, Theme>theme propagation inrenderTree()themeStackparallel tonodeStack/styleStack/layoutStack/clipStackthemed,row,column,grid, andboxPerf rationale
Removed WeakMap from hot loop; replaced with stack; semantics preserved.
Validation
cd /home/k3nig/Rezi && npm testnode --import tsx --test --test-concurrency=1 packages/core/src/renderer/__tests__/render.golden.test.ts packages/core/src/renderer/__tests__/spinner.golden.test.tsSummary by CodeRabbit
Refactor
Chores