Skip to content

Avoid root dirty delta for shared state events - #6841

Open
harsh21234i wants to merge 6 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 6 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 (4a76d69) with main (333b78b)

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

The PR prevents temporary router dirtiness used during linked/shared-state patching from leaking into regular event deltas and now restores dirty-state bookkeeping when delta resolution fails.

  • Snapshots root and descendant dirty-state sets before temporary router dependency resolution.
  • Restores descendant bookkeeping after exceptional resolution and root bookkeeping on every non-full-delta exit.
  • Adds regression tests for normal root cleanup and exceptional root/descendant cleanup.
  • Adds bug-fix release notes.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the current exception handler restores every pre-snapshotted descendant’s dirty sets, while the finally block restores the root dirty sets for failures and cancellations.

Important Files Changed

Filename Overview
reflex/istate/shared.py Preserves temporary dirty-state bookkeeping around linked-state delta resolution, including exception and cancellation paths.
tests/units/test_state.py Adds focused regression coverage for normal root cleanup and exceptional root/descendant cleanup.
news/6841.bugfix.md Documents the linked/shared-state dirty-delta fix.

Reviews (6): Last reviewed commit: "Restore descendant dirty state on linked..." | Re-trigger Greptile

Comment thread reflex/istate/shared.py Outdated

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

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