Skip to content

refactor: freeze components after create and use copy_with for mutations - #6468

Open
FarhanAliRaza wants to merge 25 commits into
reflex-dev:mainfrom
FarhanAliRaza:immutability
Open

FarhanAliRaza wants to merge 25 commits into
reflex-dev:mainfrom
FarhanAliRaza:immutability

Conversation

@FarhanAliRaza

@FarhanAliRaza FarhanAliRaza commented May 7, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

fixes #6214
fixes ENG-9146

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.
@FarhanAliRaza
FarhanAliRaza requested a review from a team as a code owner May 7, 2026 15:52
# Conflicts:
#	reflex/experimental/memo.py
@FarhanAliRaza
FarhanAliRaza marked this pull request as draft May 7, 2026 15:57
@greptile-apps

greptile-apps Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5RetriggerView in Greptile

[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

  1. P1 Nested head refs remain ▶
  2. P2 Partial compiled-output assertions ▶
  3. P2 ref silently dropped when DataTable has an id ▶
  4. P2 Stub manifest not updated ▶
  5. P2 Text area padding disappears ▶

Summary

The 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.

  • The new generated-output assertion does not satisfy the repository’s exact-output testing requirement.
  • Previously reported nested head refs and text-area padding with an existing selector remain unresolved.

Reviews (7) · Last reviewed commit: "Move the data editor callback check into..." · Reviewed by Greptile

Comment on lines +129 to +134
props = {
attr.removesuffix("_"): getattr(self, attr) for attr in self.get_props()
}
props["columns"] = columns
props["data"] = data
return super()._render(props=props)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

@codspeed

codspeed Bot commented May 7, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 4.29%

1 warning

⚠️ 20 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

❌ 2 regressed benchmarks
✅ 144 untouched benchmarks
⏩ 8 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_arithmetic_operations[state] 11.4 ms 11.9 ms -4.37%
❌ test_arithmetic_operations[bare] 11.4 ms 11.9 ms -4.21%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing FarhanAliRaza:immutability (0748f30) with main (8e0e881)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

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.
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.
@FarhanAliRaza
FarhanAliRaza marked this pull request as ready for review May 11, 2026 18:56
FarhanAliRaza and others added 6 commits May 12, 2026 00:01
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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Stub manifest not updated

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)

@greptile-apps

greptile-apps Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P1 Match comparison can raise packages/reflex-base/src/reflex_base/components/component.py:186 ▶

    Comparing two separately created Match components can raise VarTypeError instead of returning a boolean. Their match_cases contain tuples with lists of Vars. This helper handles the lists but falls back to Python equality for the tuples, which tries to use a Var comparison as a boolean. Compare tuples recursively too.

        if isinstance(a, (list, tuple)) and isinstance(b, type(a)):
            return len(a) == len(b) and all(
                _field_values_equal(x, y) for x, y in zip(a, b, strict=False)
            )
    
  • P1 Padding duplicated in both root style and & textarea selector packages/reflex-components-radix/src/reflex_components_radix/themes/components/text_area.py:118 ▶

    Before this PR, add_style called self.style.pop("padding") - removing padding from the instance style so it wouldn't be re-merged by _add_style_recursive. Now that components are immutable, add_style only reads padding via .get() and leaves it in self.style. Consequently, _add_style_recursive merges self.style into new_style unconditionally (new_style.update(self.style)), so a component created with padding="1rem" ends up with padding: 1rem in both the root container CSS and inside & textarea { padding: 1rem }. The padding prop is applied twice, producing incorrect layout for any TextArea that sets an explicit padding.

  • P2 The docstring still says "suitable for compile-time mutation", but the returned copy is frozen because vars self contains frozen=True which is propagated . Any caller that reads this docstring and expects a mutable copy will receive an AttributeError on first write. packages/reflex-base/src/reflex_base/components/component.py:386 ▶

    The docstring still says "suitable for compile-time mutation", but the returned copy is frozen (because vars(self) contains _frozen=True which is propagated). Any caller that reads this docstring and expects a mutable copy will receive an AttributeError on first write.

        def __copy__(self) -> BaseComponent:
            """Return a frozen shallow copy with render-path caches cleared.
    
            Bypasses ``copy.copy``'s generic ``__reduce_ex__`` dispatch. Nested
            mutable containers (``children``, ``style``, ``event_triggers``) are
            shared with the original. Render-path caches populated on the original
            are dropped so the clone recomputes against its (potentially rebound)
            fields. The copy retains the same frozen state as the original; use
            ``copy_with()`` for modified copies.
    
            Returns:
                A new instance of the same class with ``__dict__`` shallow-copied.
            """
    

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread reflex/compiler/utils.py
)
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():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
var_data = self.contents._var_data
var_data = self.contents._get_all_var_data()

Comment thread tests/integration/test_data_editor.py Resolved
head = HeadContainer.create(content=script)
result = utils._without_static_id_refs(head)

assert not result._get_all_hooks()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
assert not result._get_all_hooks()
assert not result._get_all_refs()

Comment thread reflex/compiler/compiler.py Resolved
Comment on lines +66 to +67
Their hook bodies are equal, so the compiler's hook dedupe collapses them to a
single function declaration rather than emitting a duplicate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@masenf masenf added the breaking Public API facing change considered for minor release bump pre-v1.0 label Sep 30, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@masenf masenf added the roadmap https://github.com/reflex-dev/reflex/issues/2727 label Oct 23, 2026
@FarhanAliRaza FarhanAliRaza added the enhancement Anything you want improved label Nov 12, 2026 — with ChatGPT Codex Connector
@FarhanAliRaza FarhanAliRaza added the on deck PRs lined up to review / merge next label Nov 30, 2026
@FarhanAliRaza FarhanAliRaza added the priority: P2 Medium: valid edge-case bug, reasonable feature, or docs fix label Nov 30, 2026 — with Claude
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.
@FarhanAliRaza
FarhanAliRaza requested a review from Alek99 as a code owner December 1, 2026 18:36
Comment thread reflex/compiler/utils.py
Comment on lines +835 to +839
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Nested head refs remain

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:

Comment on lines +115 to +117
padding = self.style.pop("padding", None)
if padding is not None and "& textarea" not in self.style:
self.style["& textarea"] = {"padding": padding}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Text area padding disappears

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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Suggested change
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Comment on lines +133 to +134
referenced = re.findall(r"getCellContent:(getData_[a-z]+)\b", web_sources)
declared = re.findall(r"const (getData_[a-z]+) = useCallback\(", web_sources)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Public API facing change considered for minor release bump pre-v1.0 enhancement Anything you want improved on deck PRs lined up to review / merge next priority: P2 Medium: valid edge-case bug, reasonable feature, or docs fix roadmap https://github.com/reflex-dev/reflex/issues/2727

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single-pass compiler: Make Component effectively immutable

2 participants