Skip to content

Make AppHarness dependencies installable - #7008

Merged
masenf merged 3 commits into
reflex-dev:mainfrom
harsh21234i:fix/6974-testing-deps
Sep 4, 2026
Merged

Make AppHarness dependencies installable#7008
masenf merged 3 commits into
reflex-dev:mainfrom
harsh21234i:fix/6974-testing-deps

Conversation

@harsh21234i

@harsh21234i harsh21234i commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes issue #6974 by making reflex.testing usable from a clean published Reflex installation.

Changes

  • Removed the top-level uvicorn import from reflex.testing.

  • Added lazy imports with actionable installation messages.

  • Added a reflex[testing] extra containing:

    • uvicorn
    • psutil
    • selenium
  • Updated uv.lock.

  • Added a regression test for importing reflex.testing without test dependencies.

  • Added a changelog fragment.

Testing

  • AppHarness unit tests: 5 passed, 1 skipped
  • Verified reflex.testing imports without uvicorn and psutil.
  • Ruff formatting and lint checks passed.

Review in cubic

@harsh21234i
harsh21234i requested a review from a team as a code owner August 31, 2026 05:32
@greptile-apps

greptile-apps Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes reflex.testing importable without eagerly requiring AppHarness runtime dependencies.

  • Adds a testing package extra for psutil, Selenium, and uvicorn.
  • Lazily imports uvicorn at every backend and production frontend startup path, with actionable installation errors.
  • Adds equivalent missing-dependency guidance for psutil cleanup.
  • Adds an import regression test, lockfile update, and changelog fragment.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
reflex/testing.py Replaces the eager uvicorn import with guarded lazy imports across all runtime uses, resolving the previously reported production harness NameError.
pyproject.toml Adds the testing extra containing the three optional AppHarness dependencies.
tests/units/test_testing.py Adds regression coverage confirming that importing reflex.testing does not bind uvicorn at module load.
uv.lock Synchronizes the package lock metadata with the new testing extra.

Reviews (3): Last reviewed commit: "Merge branch 'main' into fix/6974-testin..." | Re-trigger 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 5 files

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

Re-trigger cubic

Comment thread reflex/testing.py
@codspeed-hq

codspeed-hq Bot commented Aug 31, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 32 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing harsh21234i:fix/6974-testing-deps (65263ee) with main (9a26753)

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.

@masenf
masenf merged commit fb04aa1 into reflex-dev:main Sep 4, 2026
111 checks passed
adhami3310 added a commit that referenced this pull request Sep 4, 2026
Two unrelated things the same pre-commit run wanted.

`ruff-format` also formats python blocks inside docs, and the sample I
added in the previous commit was missing the blank line before its
decorator. That is why the docs commit before it passed and this branch
then went red on a change that touched one markdown file.

The lock is stale against `pyproject.toml`, which has declared a
`testing` extra since #7008 while `uv.lock` still says
`provides-extras = ["db", "pydantic"]` and carries no `extra ==
'testing'` entries at all. Nothing in this branch can affect dependency
resolution -- it is two docs files -- so this is main's drift surfacing
once `uv` began writing the field. Relocked rather than left, since
every branch cut from here hits it.
masenf added a commit that referenced this pull request Sep 4, 2026
PR #7008 added the testing optional-dependency group but left uv.lock
without the corresponding requires-dist entries and provides-extras
entry, so every uv command rewrote the lock file. Regenerated with
`uv lock`; only the reflex package metadata changed, no dependency
versions were bumped.


Claude-Session: https://claude.ai/code/session_01KpSPsdMoxxXp3xqsDUpvVS

Co-authored-by: Claude <noreply@anthropic.com>
adhami3310 added a commit that referenced this pull request Sep 5, 2026
* docs: add a User Authentication page for brokered app sign-in

Documents letting people sign in to a generated app with their Reflex
account: adding it, choosing who is admitted, the user list and export,
blocking somebody, the sign-in page's presentation, and removing it.

Four things the page is careful about, because each is a support ticket
if it is left implicit:

* **On Free, an app admits anyone with a Reflex account.** Adding
  sign-in makes an app know who somebody is, not private. Narrowing the
  audience is the Pro control, so that is said in the plan callout and
  again as a warning rather than left to be discovered.
* **Narrowing signs everyone out**, not only the people it excludes.
* **A session lasts at most 7 days** whatever the token lifetimes
  suggest, because the client stores its renewal credential in a cookie
  with that ceiling. "30 day refresh token" would be a promise we do not
  keep.
* **A block takes up to 30 minutes** to reach a session already running,
  since the app re-checks identity on a schedule.

The security note tells people to decide what somebody may do in
backend code: the frontend can hide a page but cannot keep data out of
reach, which is the mistake an agent-built app is most likely to make.

Screenshots are captured from the real panel against seeded data.

* docs: use the real current-user API, not the authz check's argument

`auth_user.email` and friends are not a public surface. `auth_user` is
the name of the argument an *authorization check* callable receives, and
I lifted it out of an internal docstring and presented it as the way an
app reads its signed-in user. Apps generated from that would fail on
attribute access.

The supported interface, per `docs/enterprise/auth/example-app.md` and
`reflex_enterprise/auth/user_state.py` (where `User = AuthUserState`):

* `User.name` / `.email` / `.sub` / `.picture` are Vars, for rendering.
* `await User.current()` returns the claims dict inside an event
  handler, or `None` when anonymous.

Both are shown, split by what the reader is doing rather than listed as
one set, since which of the two is correct depends on where the code
runs. Anything beyond the common claims wants a computed var on an
`AuthUserState` subclass, so the page points at the Authentication guide
rather than restating it.

* docs: format the handler sample, and relock for the testing extra

Two unrelated things the same pre-commit run wanted.

`ruff-format` also formats python blocks inside docs, and the sample I
added in the previous commit was missing the blank line before its
decorator. That is why the docs commit before it passed and this branch
then went red on a change that touched one markdown file.

The lock is stale against `pyproject.toml`, which has declared a
`testing` extra since #7008 while `uv.lock` still says
`provides-extras = ["db", "pydantic"]` and carries no `extra ==
'testing'` entries at all. Nothing in this branch can affect dependency
resolution -- it is two docs files -- so this is main's drift surfacing
once `uv` began writing the field. Relocked rather than left, since
every branch cut from here hits it.

* docs: make both identity samples runnable as written

The handler sample called `@rxe.event` without importing
`reflex_enterprise as rxe`, so copying it raises `NameError` at import,
before the handler could run.

The component sample above it had the same flaw and was not reported:
`rx.hstack`, `rx.avatar` and `rx.text` with no `import reflex as rx`.
Fixed both, since a reader copies whichever one matches what they are
doing and neither would have worked.

The page's own `python exec` block imports rx for the screenshot calls,
which is what hid this: the samples render fine on the page while being
incomplete for anyone pasting them into an app.

* docs: state the block's availability plainly

Per review. "Available on every plan, because being unable to revoke
access is worse than being unable to configure it" imported the
reasoning behind the decision into a page whose reader only needs the
decision. Now just says blocking is available on every plan.

Trimmed the same tic from the sign-out paragraph, which explained why
the behaviour is what people expect rather than saying what it does.

---------

Co-authored-by: Masen Furer <m_github@0x26.net>
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.

2 participants