* `rx.color_mode.icon`, `rx.color_mode.button` and `rx.color_mode.switch` should not require a backend`
* remove print statement
* unit tests and precommit fix
* add unit tests
* change logic to check if event handlers actually contain state. Also delay websocket object check in state.js so server side events can get executed for stateless apps
* make sure events are not queued for server side events particularly ones that call queueEvents(clear_local_storage, clear_cookies, remove_local_storage, remove_cookies) when the app is stateless(no ws)
* fix unit tests
* fix broken unit tests in test_app
* modify socket check in processEvent to only return if socket exists and theres any event in the queue that requires state
* Apply suggestions from code review
make queueEvent call async
Co-authored-by: Masen Furer <m_github@0x26.net>
* await queueEventIfSocketExists
* Revert "await queueEventIfSocketExists"
This reverts commit 9ef8070b87.
---------
Co-authored-by: Masen Furer <m_github@0x26.net>
* Improve import times
* add lazy loading to rx.el
* add lazy loading to reflex core components
* minor refactor
* Get imports working with reflex web
* get imports to work with all reflex examples
* refactor to define imports only in the root.
* lint
* deadcode remove
* update poetry deps
* unit tests fix
* app_harness fix
* app_harness fix
* pyi file generate
* pyi file generate
* sort pyi order
* fix pyi
* fix docker ci
* rework pyi-generator
* generate pyi for __init__ files
* test pyright
* test pyright ci
* partial pyright fix
* more pyright fix
* pyright fix
* fix pyi_generator
* add rx.serializer and others
* add future annotation import which fixes container CI, then also load recharts lazily
* add new pyi files
* pyright fix
* minor fixes for reflex-web and flexdown
* forward references for py38
* ruff fix
* pyi fix
* unit tests fix
* reduce coverage to 68%
* reduce coverage to 67%
* reduce coverage to 66%as a workaround to coverage's rounding issue
* reduce coverage to 66%as a workaround to coverage's rounding issue
* exclude lazy_loader dependency review checks.
* its lazy-loader
* Add docstrings and regenerate pyi files
* add link
* address Pr comments
* CI fix
* partially address PR comments.
* edit docstrings and fix integration tests
* fix typo in docstring
* pyi fix
* add more tests
* add tests to raise coverage
* more tests, bump coverage to 73
* fix up icon_button test
* fix darglint for app.py
* fix utcnow usage warning
* set threshold to 72
* fix timestamp
* fix unit tests for linux-redis
* removed commented code and put a TODO
* Remove upper bounds of most dependencies.
Also adds a import try except block for pydantic.v1 and relocks.
Keep black and ruff to not mess to much with current formatting
Make pyright see the right import as long as constraint still lock pydantiv v1
Down pin pytest-asyncio again due to known issue
Fix upload handler with latest versions of fastapi
Change comment
* Add changed lockfile
* Set max versions for deps
* Revert app.pyi
---------
Co-authored-by: Malte Klemm <malte.klemm@blueyonder.com>
Co-authored-by: Nikhil Rao <nikhil@reflex.dev>
* [REF-2158] Enable state when `on_load` or event_triggers are set.
Basically all events in a reflex app require the backend to be up, even the
built-in server side events round trip to the backend and require "state" even
if no user-defined state classes are declared.
test_app_state_determination: checking that state is enabled at the right time
* Clear out DECORATED_PAGES when initializing a new app
* rebase
* pass include_children kwarg in radix FormRoot
* respect include_children
* ruff fixes
* readd statemanager init, run pyi gen
* minor performance imporovements, fix for state changes
* fix pyi and pyright
* pass include_children for chakra
* remove old state detection
* add test for unused states in stateless app
---------
Co-authored-by: Masen Furer <m_github@0x26.net>
* WiP get_state
* Refactor get_state fast path
Rudimentary protection for state instance access from a background task
(StateProxy)
* retain dirty substate marking per `_mark_dirty` call to avoid test changes
* Find common ancestor by part instead of by character
Fix StateProxy for substates and parent_state attributes (have to handle in
__getattr__, not property)
Fix type annotation for `get_state`
* test_state: workflow test for `get_state` functionality
* Do not reset _always_dirty_substates when adding vars
Reset the substate tracking only when the class is instantiated.
* test_state_tree: test substate access in a larger state tree
Ensure that `get_state` returns the proper "branch" of the state tree depending
on what substate is requested.
* test_format: fixup broken tests from adding substates of TestState
* Fix flaky integration tests with more polling
* AppHarness: reset _always_dirty_substates on rx.State
* RuntimeError unless State is instantiated with _reflex_internal_init=True
Avoid user errors trying to directly instantiate State classes
* Helper functions for _substate_key and _split_substate_key
Unify the implementation of generating and decoding the token + state name
format used for redis state sharding.
* StateManagerRedis: use create_task in get_state and set_state
read and write substates concurrently (allow redis to shine)
* test_state_inheritance: use polling cuz life too short for flaky tests
kthnxbai ❤️
* Move _is_testing_env to reflex.utils.exec.is_testing_env
Reuse the code in app.py
* Break up `BaseState.get_state` and friends into separate methods
* Add test case for pre-fetching cached var dependency
* Move on_load_internal and update_vars_internal to substates
Avoid loading the entire state tree to process these common internal events. If
the state tree is very large, this allow page navigation to occur more quickly.
Pre-fetch substates that contain cached vars, as they may need to be recomputed
if certain vars change.
* Do not copy ROUTER_DATA into all substates.
This is a waste of time and memory, and can be handled via a special case in
__getattribute__
* Track whether State instance _was_touched
Avoid wasting time serializing states that have no modifications
* Do not persist states in `StateManagerRedis.get_state`
Wait until the state is actually modified, and then persist it as part of `set_state`.
Factor out common logic into helper methods for readability and to reduce
duplication of common logic.
To avoid having to recursively call `get_state`, which would require persisting
the instance and then getting it again, some of the initialization logic
regarding parent_state and substates is duplicated when creating a new
instance. This is for performance reasons.
* Remove stray print()
* context.js.jinja2: fix check for empty local storage / cookie vars
* Add comments for onLoadInternalEvent and initialEvents
* nit: typo
* split _get_was_touched into _update_was_touched
Improve clarity in cases where _get_was_touched was being called for its side
effects only.
* Remove extraneous information from incorrect State instantiation error
* Update missing redis exception message
* Move sharding internal to StateManager
Avoid leaking sharding implementation details all over the State class and
breaking the API
* WiP StateManager based sharding
* Copy the state __dict__ when serializing to avoid breaking the instance
* State tests need to pass the correct substate token for redis
* state: when getting parent_state, set top_level=False
ensure that we don't end up with a broken tree
* test_app: get tests passing with redis by passing the correct token
refactor upload tests to suck less
* test_client_storage: look up substate key
* state.py: pass static checks
* test_dynamic_routes: working with redis state shard
* Update the remaining AppHarness tests to pass {token}_{state.get_full_name()}
* test_app: pass all tokens with state suffix
* StateManagerRedis: clean up commentary
* use redis-py url syntax for redis_url
* port is optional
* Add StateManagerRedis.close method
The close helper method always calls `close_connection_pool=True` so that all
outstanding redis operations can be stopped before changing event loops.
---------
Co-authored-by: Masen Furer <m_github@0x26.net>
* test_client_storage: remove race conditions for cookie assignment
Poll for default timeout for cookies to appear in the controlled browser.
* Remove use of deprecated get_token and get_sid in core
Both reflex.app and reflex.state were still using deprecated methods, which
were throwing unsolvable warnings for end users.
* Remove deprecated router functions from integration tests
Mostly removing custom "token" var and replacing with
router.session.client_token.
Also replacing `get_query_params` and `get_current_page` usage as well.
* fix upload tests
Cannot pass substate as main app state, since it blocks us from accessing
"inherited vars"
* state: do NOT reset `router` to default
When calling `.reset` to reset state vars, do NOT reset the router data, as
that could mess up internal event processing.
* partly add some radix-ui/themes based components
* add @radix-ui/themes integration to top-level app
* WiP: compile _app_wrap based on which component library is used
TODO: working color mode
* WiP get color mode working with agnostic provider
still not perfect, as the RadixColorModeProvider seems to trip hydration errors
when using color_mode_cond component, but for now, this provides a nice balance
between the two libraries and allows them to interoperate.
* WiP template _app.js instead of making a separate wrap file
* WiP: use next-themes for consistent darkmode switching
* strict pin chakra deps
* Move ChakraColorModeProvider to separate js file
* move nasty radix themes js code into js files
* remove chakra from default imports
* chakra fixup import to use .js extension
* Add radix theme typography and layout components
* do NOT special case the radix theme...
avoid templating json and applying it, avoid non-customizable logic
just add the radix Theme component as an app wrap if the user specifies it to
rx.App, and any other app-wrap theme-like component could _also_ be used
without having to change the code.
this also allows different themes for different sections of the app by simply
placing elements inside a different rdxt.theme wrapper.
* Theme uses "radius" not "borderRadius"
* move next-themes to main packages.json
this is always used, regardless of the component library
* test_app: test cases for app_wrap interface
* Finish wrapping Button, Switch, and TextField components
* docstring, comments, static fixups
* debounce: use alias or tag when passing child Element
Fix REF-830
* test_app: ruin my beautiful indentation
* py38 compatibility
* Add event triggers for switch and TextField
* Add type hints for radix theme components
* radix themes fixups from writing the tests
* Add integration test for radix themes components
* test_app: mock out package installation
we only need the compile result, we're not actually trying to install packages
* avoid incompatible version of @emotion/react
* test_radix_themes: include theme_panel component
* next-themes default scheme: "light"
until all of our components look good in dark mode, need to keep the default as
light mode regardless of the system setting.