Restore root state metadata after the shared-state telemetry test

MU
10h ago
+17-2

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

  • Bug fix (non-breaking change which fixes an issue)

What

test_collect_features_used_counts_shared_state_subclasses in tests/units/utils/test_telemetry_accounting.py defines two rx.SharedState subclasses. SharedState.__init_subclass__ adds SharedStateBaseInternal to State._always_dirty_substates and changes the _reflex_internal_links field default, and the test never restores them.

Any tests/units/test_state.py test that runs later in the same process then fails:

uv run pytest tests/units/utils/test_telemetry_accounting.py::test_collect_features_used_counts_shared_state_subclasses tests/units/test_state.py
# main: 5 failed (test_potentially_dirty_states AssertionError; test_shared_storage_name_* KeyError at reflex/istate/delta.py)

The default suite order runs test_state.py before utils/, so CI doesn't hit it, but any reordering does (running tests/units/utils first, splitting the suite, pytest-randomly).

How

Restore both pieces of root metadata with monkeypatch, exactly as the shared-state tests in test_state.py already do. Test-only change, so no news fragment (skip-changelog).

Testing

  • The command above: 5 failed before, 322 passed after.
  • uv run pytest tests/units/utils tests/units/test_state.py: 1176 passed, 15 skipped.
  • uv run pytest tests/units/utils/test_telemetry_accounting.py: 25 passed.
  • ruff check, ruff format --check, pyright on the file: clean.

AI disclosure: Claude Code (an AI coding agent) found and fixed this and ran the checks above, operating my account. A separate AI review pass checked it. I haven't reviewed the diff line by line myself.

🤖 Generated with Claude Code