[codex] fix foreach memo style cache#6513
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Greptile SummaryThis PR fixes a bug where
Confidence Score: 5/5This PR is safe to merge; changes are limited to cache-clearing logic in component.py and a new regression test with no risky side-effects. The fix is minimal and targeted: _clear_compile_caches() only removes opt-in cached attributes that are lazily recomputed on next access, so clearing them can never corrupt state — only trigger a fresh recompute. The recursive style application already correctly propagates through children. The regression test confirms the exact failure mode from the bug report is resolved, and no existing tests are touched. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Compiler
participant ForeachMemo
participant Component
participant Cache
Compiler->>ForeachMemo: preview snapshot (auto-memo)
ForeachMemo->>Component: __copy__()
Component->>Cache: _clear_compile_caches()
Note over Cache: _cached_render_result cleared
Compiler->>Component: _add_style_recursive(style)
Component->>Component: "self.style = new_style"
Component->>Cache: _clear_compile_caches()
Note over Cache: stale pre-style render discarded
loop children
Component->>Component: child._add_style_recursive(style)
Component->>Cache: child._clear_compile_caches()
end
Compiler->>ForeachMemo: compile_memo_components()
ForeachMemo->>Component: render()
Component->>Cache: recompute with updated style
Cache-->>ForeachMemo: styled render result ✓
Reviews (1): Last reviewed commit: "fix foreach memo style cache" | Re-trigger Greptile |
Summary
rx.foreachmemo outputFixes #6512
Testing
uv run pytest tests/units/compiler/test_memoize_plugin.py tests/units/components/test_component.py::test_add_style_foreachuv run ruff check packages/reflex-base/src/reflex_base/components/component.py tests/units/compiler/test_memoize_plugin.pyuv run pyright packages/reflex-base/src/reflex_base/components/component.py tests/units/compiler/test_memoize_plugin.py400pxwith matching default accordion styles