Skip to content

Avoid root dirty delta for shared state events - #6841

Open
harsh21234i wants to merge 3 commits into
reflex-dev:mainfrom
harsh21234i:fix/shared-state-root-dirty-6392
Open

Avoid root dirty delta for shared state events#6841
harsh21234i wants to merge 3 commits into
reflex-dev:mainfrom
harsh21234i:fix/shared-state-root-dirty-6392

Conversation

@harsh21234i

@harsh21234i harsh21234i commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Tests

  • uv run --frozen pytest tests/units/test_state.py::test_linked_state_event_does_not_dirty_root_state -q
  • uv run --frozen pytest tests/units/test_state.py::test_linked_state_event_does_not_dirty_root_state tests/units/test_state.py::test_router_var_dep tests/units/test_state.py::test_computed_var_depends_on_parent_non_cached tests/units/test_state.py::test_async_computed_var_get_state -q
  • uv run --frozen pytest tests/units/test_state.py -q
  • uv run --frozen pre-commit run --files reflex/istate/shared.py tests/units/test_state.py news/6392.bugfix.md

Closes #6392

Review in cubic

@harsh21234i
harsh21234i requested a review from a team as a code owner August 4, 2026 11:06
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@codspeed-hq

codspeed-hq Bot commented Aug 4, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing harsh21234i:fix/shared-state-root-dirty-6392 (c19e5a2) with main (a348aea)

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.

@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR prevents temporary router dirtiness used during linked/shared-state patching from leaking into regular event deltas and now restores that dirtiness when resolution raises.

  • Snapshots and restores root dirty variables and substates for non-full linked-state patches.
  • Adds regression coverage for normal linked-state events and exceptional delta resolution.
  • Corrects the changelog category for an earlier entry.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported exceptional-resolution leak is addressed by nested finally blocks that restore both dirty state and patched tree links, with regression coverage for the error path.

Important Files Changed

Filename Overview
reflex/istate/shared.py Preserves root dirty-state snapshots around temporary router-dependent delta resolution and restores them in a finally block for regular linked-state events.
tests/units/test_state.py Adds focused regression tests covering clean regular-event deltas and dirty-state/tree-link restoration after resolution errors.
news/6841.bugfix.md Documents the linked/shared-state temporary router-dirtiness fix.
news/6836.misc.md Reclassifies an existing changelog entry from chore to misc.

Reviews (3): Last reviewed commit: "Use valid news fragment type for Pillow ..." | Re-trigger Greptile

Comment thread reflex/istate/shared.py Outdated

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread reflex/istate/shared.py Outdated
Comment thread reflex/istate/shared.py
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.

Events against SharedState should not mark root state dirty all the time

1 participant