Repository navigation
refactor: freeze components after create and use copy_with for mutations - #6468
FarhanAliRaza wants to merge 25 commits into
Conversation
Components are now immutable after construction (children stored as tuples, __setattr__ blocks writes outside a small cache allowlist). Compile-time edits go through a new copy_with() helper instead of mutating shared instances, replacing the PageContext.own() page-local clone mechanism so components can be safely reused across pages without deep copies.
# Conflicts: # reflex/experimental/memo.py
Confidence Score: 4/5
[High impact] Freezes components after creation and requires copy_with for mutations. The PR does not appear safe to merge until document-root refs, text-area padding, and the exact-output testing requirement are addressed. Findings
SummaryThe PR stores component children as tuples and replaces compile-time mutation with copied components. It also updates component wrappers, styling and memoization paths, and moves DataEditor callback coverage into the Playwright suite.
Reviews (7) · Last reviewed commit: "Move the data editor callback check into..." · Reviewed by Greptile |
| props = { | ||
| attr.removesuffix("_"): getattr(self, attr) for attr in self.get_props() | ||
| } | ||
| props["columns"] = columns | ||
| props["data"] = data | ||
| return super()._render(props=props) |
There was a problem hiding this comment.
ref silently dropped when DataTable has an id
Component._render(props=None) auto-populates ref via self.ref / self.get_ref() only in the props is None branch. DataTable._render now builds the props dict itself and passes it to super()._render(props=props), which takes the else branch and skips that logic entirely. Any DataTable constructed with an explicit id would previously have had a React ref included in the rendered output; that ref is silently absent now.
Merging this PR will degrade performance by 4.29%1 warning
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Bypass __setattr__'s freeze guard during init via vars(self).update(...); a brand-new instance can't be frozen, so the per-attribute check is pure overhead. Applied in BaseComponent.__init__, Component.__init__, and Component._create. In Component.__init__: - Lazily allocate event_triggers only when a trigger is actually seen; most components have none, so the up-front dict copy was wasted work. - Single-pass kwargs loop that handles event triggers, var props, and unknown on_* errors inline instead of double-iterating. - Defer the _validate_children imports until after the fast no-op exit.
5500fc4 to
d1d22c5
Compare
Use so an explicitly-passed empty event_triggers dict still gets copied instead of being dropped. Rename the local to to avoid shadowing the imported helper.
Move ``merge_component_style`` from ``compiler/utils`` onto ``Component._merge_app_style`` so the styling logic lives next to the component, and let callers in the compiler plugin and root-style helper hit it directly. Drop ``pop(..., None)`` on cache attrs in favor of a set-intersection ``del`` (cheaper when the keys are absent), fold the ``Input``/``Div`` ``copy_with(special_props=...)`` pairs in ``Upload`` into a single ``create`` call, swap the ``DataTable`` render dict for ``remove_props``/``add_props`` on the parent, and rewrite the app-wrapper loop to seed from the first wrapper instead of carrying a ``None`` guard. Also strip stale internal comments now that the surrounding code is self-explanatory.
Components are frozen after create(), so add_hooks() can no longer unfreeze self to wire compile-time props. DataEditor now derives its getData callback name deterministically (length-prefixed md5 of columns/data) at create() time and emits the matching hook, so the rendered prop and the hook agree without mutating the frozen instance. Identical editors share one callback and dedupe; the length prefix keeps the digest input injective so distinct bindings can't collide.
| """ | ||
| object.__setattr__(self, "_frozen", True) | ||
|
|
||
| def copy_with(self, **updates: Any) -> Self: |
There was a problem hiding this comment.
This PR changes component definitions, including the new copy_with API, but does not update pyi_hashes.json. The repository requires running uv run python scripts/make_pyi.py after adding or modifying components and committing the updated hash manifest, not generated .pyi files. Please satisfy that requirement before merging.
Context Used: CLAUDE.md (source)
Comments Outside DiffThese findings could not be posted inline.
|
There was a problem hiding this comment.
8 issues found across 44 files
You’re at about 92% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="reflex/compiler/utils.py">
<violation number="1" location="reflex/compiler/utils.py:681">
P2: `_literalize_static_ids` no longer handles components embedded in `Var` props. Rebuild the `VarData` and its `components` entries with literalized copies, as `Bare._add_style_recursive` does, so head components reachable through `Bare.contents` do not retain `useRef` hooks.</violation>
</file>
<file name="packages/reflex-components-dataeditor/src/reflex_components_dataeditor/dataeditor.py">
<violation number="1" location="packages/reflex-components-dataeditor/src/reflex_components_dataeditor/dataeditor.py:598">
P2: This derived prop becomes stale when a caller uses `copy_with()` to replace `columns` or `data`: the rendered `get_cell_content` keeps the old digest, but `add_hooks()` emits a function using the new digest, so the grid references an undeclared callback. Recompute `get_cell_content` whenever either input is copied, or make hook generation use the stored callback consistently.</violation>
</file>
<file name="tests/units/compiler/test_compiler_utils.py">
<violation number="1" location="tests/units/compiler/test_compiler_utils.py:211">
P3: `result._get_all_hooks()` only descends into `children`, but `script` lives in the `content` prop, so this assertion passes for the unliteralized `head` as well and never exercises the copy path the test claims to check. Assert on refs instead, since `Component._get_all_refs()` does traverse components stored as props: `assert not result._get_all_refs()` alongside the existing render assertions (optionally `assert "ref_prop_probe" in head._get_all_refs()` on the original).</violation>
</file>
<file name="packages/reflex-components-core/src/reflex_components_core/base/bare.py">
<violation number="1" location="packages/reflex-components-core/src/reflex_components_core/base/bare.py:227">
P2: This bypasses `_get_all_var_data()`, so styling stops reaching components carried by converted or cached/composed Vars when their components exist only in the merged metadata. Use `self.contents._get_all_var_data()` here so the recursive rebuild sees the same embedded components as the other Bare traversal methods.</violation>
</file>
<file name="packages/reflex-components-radix/src/reflex_components_radix/themes/components/text_area.py">
<violation number="1" location="packages/reflex-components-radix/src/reflex_components_radix/themes/components/text_area.py:115">
P2: Switching `self.style.pop("padding")` to `self.style.get("padding")` changes rendered output: the padding key now stays in `self.style`, so `_merge_app_style` (component.py `new_style.update(self.style)`) and `format_as_emotion` emit it as a top-level rule for the component root *in addition* to the `& textarea` rule. Previously the pop removed it, so only the inner `& textarea` element was padded. If the root element wraps the textarea, both now receive padding (double spacing); at minimum the rendered style set for TextArea changes as a side effect of an immutability refactor. Build a cleaned style without the key and pass it through `copy_with`, as `DebounceInput.create` does with `cleaned_child_style`, so the padding stays immutable while the component root keeps its original (unpadded) style.</violation>
</file>
<file name="packages/reflex-components-radix/src/reflex_components_radix/themes/components/icon_button.py">
<violation number="1" location="packages/reflex-components-radix/src/reflex_components_radix/themes/components/icon_button.py:79">
P2: `RADIX_TO_LUCIDE_SIZE[props["size"]]` raises a raw `KeyError` when a user passes any string that is not "1"-"4" (e.g. size="5"), since the value is validated only by a dict lookup on this line. Raise a clear `ValueError` listing the accepted sizes instead of surfacing the incidental KeyError.</violation>
</file>
<file name="tests/units/components/datadisplay/test_dataeditor.py">
<violation number="1" location="tests/units/components/datadisplay/test_dataeditor.py:66">
P3: The docstring and test name claim the compiler's hook dedupe collapses the two editors to a single declaration, but the assertions only compare names and hook bodies; compiler dedupe is never exercised (no render/compile step), so the test passes even if dedupe breaks. Either assert the hook appears once when both grids compile into the same page, or reword the docstring/name to what is actually verified.</violation>
</file>
<file name="packages/reflex-components-core/src/reflex_components_core/el/elements/forms.py">
<violation number="1" location="packages/reflex-components-core/src/reflex_components_core/el/elements/forms.py:315">
P3: `copy_with` writes values straight into `__dict__`, so `handle_submit_unique_name` ends up as a raw `str` even though the field is declared `Var[str]`. Every other prop assignment goes through `_post_init`'s `LiteralVar.create` wrapping, so this value is the only prop on the form that is not a `Var`. Wrap it with `LiteralVar.create(...)` to keep the field consistent with its declared type and with any Var-based prop consumers.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| ) | ||
| if any(a is not b for a, b in zip(children, component.children, strict=True)): | ||
| updates["children"] = children | ||
| for prop, value in component._iter_set_props(): |
There was a problem hiding this comment.
P2: _literalize_static_ids no longer handles components embedded in Var props. Rebuild the VarData and its components entries with literalized copies, as Bare._add_style_recursive does, so head components reachable through Bare.contents do not retain useRef hooks.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At reflex/compiler/utils.py, line 681:
<comment>`_literalize_static_ids` no longer handles components embedded in `Var` props. Rebuild the `VarData` and its `components` entries with literalized copies, as `Bare._add_style_recursive` does, so head components reachable through `Bare.contents` do not retain `useRef` hooks.</comment>
<file context>
@@ -678,20 +660,30 @@ def compile_experimental_function_memo(
+ )
+ if any(a is not b for a, b in zip(children, component.children, strict=True)):
+ updates["children"] = children
+ for prop, value in component._iter_set_props():
+ if isinstance(value, Component):
+ updated = _literalize_static_ids(value)
</file context>
| # Wire the getData callback name (referenced by add_hooks) into the prop | ||
| # so the rendered JSX and the emitted hook agree. Derived deterministically | ||
| # so no compile-time mutation of the frozen component is needed. | ||
| grid = grid.copy_with( |
There was a problem hiding this comment.
P2: This derived prop becomes stale when a caller uses copy_with() to replace columns or data: the rendered get_cell_content keeps the old digest, but add_hooks() emits a function using the new digest, so the grid references an undeclared callback. Recompute get_cell_content whenever either input is copied, or make hook generation use the stored callback consistently.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/reflex-components-dataeditor/src/reflex_components_dataeditor/dataeditor.py, line 598:
<comment>This derived prop becomes stale when a caller uses `copy_with()` to replace `columns` or `data`: the rendered `get_cell_content` keeps the old digest, but `add_hooks()` emits a function using the new digest, so the grid references an undeclared callback. Recompute `get_cell_content` whenever either input is copied, or make hook generation use the stored callback consistently.</comment>
<file context>
@@ -573,6 +592,14 @@ def create(cls, *children, extended_cell_types: bool = False, **props) -> Compon
+ # Wire the getData callback name (referenced by add_hooks) into the prop
+ # so the rendered JSX and the emitted hook agree. Derived deterministically
+ # so no compile-time mutation of the frozen component is needed.
+ grid = grid.copy_with(
+ get_cell_content=Var(
+ _js_expr=cls._data_callback_name(grid.columns, grid.data)
</file context>
| return new_self | ||
| if not isinstance(self.contents, Var): | ||
| return new_self | ||
| var_data = self.contents._var_data |
There was a problem hiding this comment.
P2: This bypasses _get_all_var_data(), so styling stops reaching components carried by converted or cached/composed Vars when their components exist only in the merged metadata. Use self.contents._get_all_var_data() here so the recursive rebuild sees the same embedded components as the other Bare traversal methods.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/reflex-components-core/src/reflex_components_core/base/bare.py, line 227:
<comment>This bypasses `_get_all_var_data()`, so styling stops reaching components carried by converted or cached/composed Vars when their components exist only in the merged metadata. Use `self.contents._get_all_var_data()` here so the recursive rebuild sees the same embedded components as the other Bare traversal methods.</comment>
<file context>
@@ -217,22 +218,44 @@ def _add_style_recursive(
- return new_self
+ if not isinstance(self.contents, Var):
+ return new_self
+ var_data = self.contents._var_data
+ if not var_data or not var_data.components:
+ return new_self
</file context>
| var_data = self.contents._var_data | |
| var_data = self.contents._get_all_var_data() |
| head = HeadContainer.create(content=script) | ||
| result = utils._without_static_id_refs(head) | ||
|
|
||
| assert not result._get_all_hooks() |
There was a problem hiding this comment.
P3: result._get_all_hooks() only descends into children, but script lives in the content prop, so this assertion passes for the unliteralized head as well and never exercises the copy path the test claims to check. Assert on refs instead, since Component._get_all_refs() does traverse components stored as props: assert not result._get_all_refs() alongside the existing render assertions (optionally assert "ref_prop_probe" in head._get_all_refs() on the original).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/units/compiler/test_compiler_utils.py, line 211:
<comment>`result._get_all_hooks()` only descends into `children`, but `script` lives in the `content` prop, so this assertion passes for the unliteralized `head` as well and never exercises the copy path the test claims to check. Assert on refs instead, since `Component._get_all_refs()` does traverse components stored as props: `assert not result._get_all_refs()` alongside the existing render assertions (optionally `assert "ref_prop_probe" in head._get_all_refs()` on the original).</comment>
<file context>
@@ -194,3 +195,21 @@ def test_document_root_controls_preserve_no_id_and_page_refs():
+ head = HeadContainer.create(content=script)
+ result = utils._without_static_id_refs(head)
+
+ assert not result._get_all_hooks()
+ assert 'id:"prop-probe"' in str(result.render())
+ assert "ref_prop_probe" not in str(result.render())
</file context>
| assert not result._get_all_hooks() | |
| assert not result._get_all_refs() |
| Their hook bodies are equal, so the compiler's hook dedupe collapses them to a | ||
| single function declaration rather than emitting a duplicate. |
There was a problem hiding this comment.
P3: The docstring and test name claim the compiler's hook dedupe collapses the two editors to a single declaration, but the assertions only compare names and hook bodies; compiler dedupe is never exercised (no render/compile step), so the test passes even if dedupe breaks. Either assert the hook appears once when both grids compile into the same page, or reword the docstring/name to what is actually verified.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At tests/units/components/datadisplay/test_dataeditor.py, line 66:
<comment>The docstring and test name claim the compiler's hook dedupe collapses the two editors to a single declaration, but the assertions only compare names and hook bodies; compiler dedupe is never exercised (no render/compile step), so the test passes even if dedupe breaks. Either assert the hook appears once when both grids compile into the same page, or reword the docstring/name to what is actually verified.</comment>
<file context>
@@ -17,6 +47,62 @@ def test_dataeditor():
+def test_identical_editors_share_callback_and_dedupe():
+ """Editors with identical columns/data share a name and a byte-identical hook.
+
+ Their hook bodies are equal, so the compiler's hook dedupe collapses them to a
+ single function declaration rather than emitting a duplicate.
+ """
</file context>
| Their hook bodies are equal, so the compiler's hook dedupe collapses them to a | |
| single function declaration rather than emitting a duplicate. | |
| Their hook bodies are identical, the precondition for the compiler's hook | |
| dedupe to collapse them into a single function declaration. |
| ).hexdigest() | ||
| return form | ||
| return form.copy_with( | ||
| handle_submit_unique_name=md5( |
There was a problem hiding this comment.
P3: copy_with writes values straight into __dict__, so handle_submit_unique_name ends up as a raw str even though the field is declared Var[str]. Every other prop assignment goes through _post_init's LiteralVar.create wrapping, so this value is the only prop on the form that is not a Var. Wrap it with LiteralVar.create(...) to keep the field consistent with its declared type and with any Var-based prop consumers.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/reflex-components-core/src/reflex_components_core/el/elements/forms.py, line 315:
<comment>`copy_with` writes values straight into `__dict__`, so `handle_submit_unique_name` ends up as a raw `str` even though the field is declared `Var[str]`. Every other prop assignment goes through `_post_init`'s `LiteralVar.create` wrapping, so this value is the only prop on the form that is not a `Var`. Wrap it with `LiteralVar.create(...)` to keep the field consistent with its declared type and with any Var-based prop consumers.</comment>
<file context>
@@ -311,10 +311,11 @@ def create(cls, *children, **props):
- ).hexdigest()
- return form
+ return form.copy_with(
+ handle_submit_unique_name=md5(
+ str(form._get_all_hooks()).encode("utf-8")
+ ).hexdigest()
</file context>
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
You’re at about 92% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/reflex-components-internal/pyproject.toml">
<violation number="1" location="packages/reflex-components-internal/pyproject.toml:12">
P1: This dev pin breaks the internal package's auto-release path: `auto_release_internal.yml` bypasses materialization, while `publish.yml` rejects the pin with `check-dev-pins`, so this source-triggered release cannot publish. Use a published `reflex-base` floor for internal releases or add the release-time repinning step to the internal path before the gate.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| requires-python = ">=3.10" | ||
| dependencies = [ | ||
| "reflex >= 0.9.4", | ||
| "reflex-base >= 0.9.12.post57.dev0", |
There was a problem hiding this comment.
P1: This dev pin breaks the internal package's auto-release path: auto_release_internal.yml bypasses materialization, while publish.yml rejects the pin with check-dev-pins, so this source-triggered release cannot publish. Use a published reflex-base floor for internal releases or add the release-time repinning step to the internal path before the gate.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/reflex-components-internal/pyproject.toml, line 12:
<comment>This dev pin breaks the internal package's auto-release path: `auto_release_internal.yml` bypasses materialization, while `publish.yml` rejects the pin with `check-dev-pins`, so this source-triggered release cannot publish. Use a published `reflex-base` floor for internal releases or add the release-time repinning step to the internal path before the gate.</comment>
<file context>
@@ -9,6 +9,7 @@ maintainers = [{ name = "Khaleel Al-Adhami", email = "khaleel@reflex.dev" }]
requires-python = ">=3.10"
dependencies = [
"reflex >= 0.9.4",
+ "reflex-base >= 0.9.12.post57.dev0",
]
</file context>
Resolve conflicts with main and adapt main's new code to frozen components: - convert the memoize plugin's in-place child and key writes to copy_with - take main's DataEditor, whose getData callback no longer writes to the component, and drop the reflex-components-dataeditor fragment and floor - keep main's _memo_analysis_key cache in _CACHE_ATTRS and drop the custom __copy__ check, since emission no longer copies the memo root - keep the identity of an unchanged tree when lifting rest props - rebuild a Bare's VarData with its field dependencies and app wraps - re-floor reflex-base to 0.11.1.dev0
rx.list.item wrote as_ to a Text child and display to an Icon child's style, and rx.auto_scroll(key=...) wrote _memoization_mode after create. The first two raised on frozen components and the icon write changed the caller's component. Build modified copies with copy_with instead.
add_style read the padding without removing it from the root, so the root and the inner textarea were both padded. Move it once in _post_init, before the component freezes, which also gives a debounced text area the same padding as an uncontrolled one.
add_style wrote data-* entries into custom_attrs during the style pass, which changed a frozen component's dict in place. Derive them from the props in _post_init, before the component freezes.
_add_style_recursive returns a new component, and the compiler threw the result away. Memo emission already applies the app style to the fallback, so remove the call and test that emission styles a standalone memo.
A frozen component raised AttributeError on any write, which broke apps that set attributes after create, with no fallback. The write now applies, drops the render caches and logs a deprecation pointing to copy_with(). Component.set() goes back to updating in place, so callers that ignore its result keep their props, and markdown builds its copies with copy_with().
The helper returns a copy and no longer needs the page context to clone the component.
Replace the substring and membership checks on rendered props, hooks and render dicts with comparisons against the complete expected values.
Split the base fragments into the deprecated attribute writes and the remaining breaking changes, drop the bugfix fragments that described breakage this change had introduced, note the debounced text area padding, and add fragments for markdown, whose reflex-base floor rises for copy_with.
Setting them in _post_init left a copy_with(variant=...) copy with the old data-variant. Add them to the rendered tag instead, so each copy renders the attributes of its own props.
| for prop, value in component._iter_set_props(): | ||
| if isinstance(value, Component): | ||
| updated = _literalize_static_ids(value) | ||
| if updated is not value: | ||
| updates[prop] = updated |
There was a problem hiding this comment.
When a head component holds a component with a static ID inside a Var-valued prop, this traversal skips it because the prop value is not directly a Component. The nested component keeps its ref hook, so document-root compilation rejects the head component with “You cannot use stateful components or hooks in the document root.”
Knowledge Base Used:
| padding = self.style.pop("padding", None) | ||
| if padding is not None and "& textarea" not in self.style: | ||
| self.style["& textarea"] = {"padding": padding} |
There was a problem hiding this comment.
When a text area has both padding and an existing & textarea style selector, this code removes the padding but skips adding it to the selector. The requested padding is absent from the rendered style.
Knowledge Base Used: Styling and theming
There was a problem hiding this comment.
1 existing issue remains and 2 new issues found across 37 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/reflex-base/src/reflex_base/components/component.py">
<violation number="1">
P2: `set(children=...)` no longer preserves the tuple invariant: a list is assigned directly and remains mutable on the created component. Normalize `children` to a tuple before applying the in-place compatibility write, as `__init__` and `copy_with()` do.</violation>
</file>
<file name="packages/reflex-components-internal/news/6468.misc.md">
<violation number="1" location="packages/reflex-components-internal/news/6468.misc.md:1">
P3: Remove this news fragment: `reflex-components-internal` is an internal package, and the release configuration explicitly excludes internal packages from changelog/news-fragment processing. Put any user-facing `SimpleIcon` note in the published package that exposes it instead.
(Based on your team's feedback about internal package news fragments.) [b8acdacc-a184-4655-9fbb-11d01f46db76]</violation>
</file>
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
View guided diff | Re-trigger cubic
| @@ -15,7 +15,7 @@ | |||
| from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence | |||
There was a problem hiding this comment.
P2: set(children=...) no longer preserves the tuple invariant: a list is assigned directly and remains mutable on the created component. Normalize children to a tuple before applying the in-place compatibility write, as __init__ and copy_with() do.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/reflex-base/src/reflex_base/components/component.py, line 450:
<comment>`set(children=...)` no longer preserves the tuple invariant: a list is assigned directly and remains mutable on the created component. Normalize `children` to a tuple before applying the in-place compatibility write, as `__init__` and `copy_with()` do.</comment>
<file context>
@@ -416,24 +428,27 @@ def copy_with(self, **updates: Any) -> Self:
"""
- return self.copy_with(**kwargs)
+ for key, value in kwargs.items():
+ setattr(self, key, value)
+ return self
</file context>
| from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence | |
| if key == "children": | |
| value = tuple(value) | |
| setattr(self, key, value) |
| @@ -0,0 +1 @@ | |||
| `SimpleIcon` sets its icon tag with `copy_with()` instead of changing the created component. | |||
There was a problem hiding this comment.
P3: Remove this news fragment: reflex-components-internal is an internal package, and the release configuration explicitly excludes internal packages from changelog/news-fragment processing. Put any user-facing SimpleIcon note in the published package that exposes it instead.
(Based on your team's feedback about internal package news fragments.) [b8acdacc-a184-4655-9fbb-11d01f46db76]
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/reflex-components-internal/news/6468.misc.md, line 1:
<comment>Remove this news fragment: `reflex-components-internal` is an internal package, and the release configuration explicitly excludes internal packages from changelog/news-fragment processing. Put any user-facing `SimpleIcon` note in the published package that exposes it instead.
(Based on your team's feedback about internal package news fragments.) [b8acdacc-a184-4655-9fbb-11d01f46db76]</comment>
<file context>
@@ -0,0 +1 @@
+`SimpleIcon` sets its icon tag with `copy_with()` instead of changing the created component.
</file context>
The test still expected this branch's earlier DataEditor, with hash-named callbacks declared by add_hooks and shared by identical editors. The merge with main took main's DataEditor, whose getCellContent Var carries a useCallback hook with a unique name per editor, so the hex pattern matched fragments of those names. Assert that each editor's prop names a callback declared exactly once.
The Selenium test failed in CI before it reached the page: the app-harness job has no Chrome for Selenium, and main runs every browser test through Playwright. Add an /editors page with three editors to main's data editor app, check that each getCellContent names a callback declared exactly once, and check that all three grids mount without a page error.
| referenced = re.findall(r"getCellContent:(getData_[a-z]+)\b", web_sources) | ||
| declared = re.findall(r"const (getData_[a-z]+) = useCallback\(", web_sources) |
There was a problem hiding this comment.
Partial compiled-output assertions The new test extracts callback names with regexes instead of checking the complete generated JavaScript. It can pass even when the surrounding output is wrong. Repository testing guidelines require comparing produced output in full after normalizing run-dependent values; this requirement must be satisfied before merging.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Components are now immutable after construction (children stored as tuples, setattr blocks writes outside a small cache allowlist). Compile-time edits go through a new copy_with() helper instead of mutating shared instances, replacing the PageContext.own() page-local clone mechanism so components can be safely reused across pages without deep copies.
All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission:
Changes To Core Features:
fixes #6214
fixes ENG-9146