Skip to content

fix: address frontend template, visibility, and storage error follow-ups (#7869) - #8012

Open
MilindChatrabhuji wants to merge 5 commits into
reflex-dev:mainfrom
MilindChatrabhuji:fix/frontend-template-followups-7869
Open

MilindChatrabhuji wants to merge 5 commits into
reflex-dev:mainfrom
MilindChatrabhuji:fix/frontend-template-followups-7869

Conversation

@MilindChatrabhuji

@MilindChatrabhuji MilindChatrabhuji commented Nov 26, 2026 •

Copy link
Copy Markdown

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)

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?

Summary

Fixes #7869 (follow-ups from #7794):

  1. Prefer packages/reflex-frontend/src in a source checkout (reflex_base/constants/base.py, packages/reflex-base/hatch_build.py)

    • Updated _web_template_dir(root_dir) to prefer packages/reflex-frontend/src when utils/state.js exists there, and to require utils/state.js inside .templates/web before treating it as an embedded copy (so leftover directories such as .templates/web/.DS_Store or stale files in a checkout never shadow the frontend package).
    • Updated FrontendBuildHook in packages/reflex-base/hatch_build.py to also require utils/state.js when checking for an sdist's embedded copy.
    • Updated tests/units/reflex_base/constants/test_base.py and added regression tests in test_base.py and tests/units/test_build_config.py.
  2. Remove dead visibility branch and keep cleanup next to the socket ref (packages/reflex-frontend/src/utils/state.js)

    • Removed the unreachable if (!socket.current) self-removal branch from checkVisibility.
    • Stopped mutating socket.current.stopWatchingVisibility onto the socket.io-client Socket instance: connect() now attaches the visibilitychange listener only if socket.current is still the active socket after await socket.current.reconnect() and returns the cleanup callback, which useEventLoop stores in a stopWatchingVisibility ref alongside the socket ref and invokes before clearing socket.current.
    • Updated packages/reflex-frontend/tests/state_connection.test.js and added a regression test for unmounting mid-connect.
  3. Surface a clear browser-storage-blocked connection error (packages/reflex-base/src/reflex_base/constants/event.py, packages/reflex-frontend/src/utils/state.js, packages/reflex-components-core/src/reflex_components_core/core/banner.py)

    • Added ClientErrorType.STORAGE_BLOCKED = storage_blocked and matching ERROR_TYPE_STORAGE_BLOCKED in state.js.
    • Wrapped sessionStorage / localStorage access in getToken, setToken (SecurityError), and hydrateClientStorage to throw a storage_blocked-coded Error (preserving the underlying cause) telling the user that site storage is blocked by the browser and to allow cookies/site data and reload; guarded optional localStorage refresh-hint accesses in reconnect and session_token error handling, and reported new_token storage errors via setConnectErrors instead of rejecting.
    • Added has_storage_blocked_error in banner.py, handled it immediately (before the 2-error threshold, without claiming the server is unreachable) in ConnectionToaster, and handled both has_storage_blocked_error and has_hydration_payload_error in default_connection_error() / ConnectionModal.
    • Added/updated unit tests in tests/units/components/core/test_banner.py, tests/units/test_app.py, tests/units/compiler/state_js.test.mjs, packages/reflex-frontend/tests/state.test.js, and packages/reflex-frontend/tests/state_connection.test.js.

Local Verification

  • Frontend (packages/reflex-frontend): npm run check (biome lint, tsc -p tsconfig.json, tsc -p tsconfig.node.json, vitest run: 10 files / 219 passed), biome format, npm run build (npm pack)
  • Python targeted suites: pytest tests/units/reflex_base/constants/ tests/units/components/core/test_banner.py tests/units/compiler/test_state_js_template.py tests/units/test_build_config.py tests/units/test_app.py (497 passed, 2 skipped) and broader pytest tests/units/reflex_base/ tests/units/components/ tests/units/compiler/ tests/units/test_app.py (8718 passed, 38 skipped)
  • Linters & type checks: ruff check ., ruff format --check ., codespell, make_pyi.py --check, pyright --pythonplatform Linux (touched packages & tests), ty check --python-version 3.14 tests/type_checking, pyright --pythonversion 3.11/3.14 tests/type_checking, reflex-release sync --check, reflex-release changelog-check, reflex-release check-headings

View guided diff

@MilindChatrabhuji
MilindChatrabhuji requested a review from a team as a code owner November 26, 2026 00:55
@FarhanAliRaza FarhanAliRaza added the bug Something isn't working label Nov 26, 2026 — with ChatGPT Codex Connector

@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 15 files

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

View guided diff | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The reviewed changes appear safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

The PR fixes frontend template selection, cleans up visibility listeners, and shows clear errors when browser storage is blocked.

  • Source checkouts use the live frontend template.
  • Socket cleanup removes its visibility listener after a connection finishes.
  • Blocked browser storage gets its own connection error.

Reviews (5) · Last reviewed commit: "fix(components): keep custom modal child..." · Reviewed by Greptile

@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 6 files (changes from recent commits).

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

View guided diff | Re-trigger cubic

Comment thread tests/units/test_app.py Resolved

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

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-ups from #7794: stale web template in a checkout, dead visibility branch, connect error message

2 participants