Skip to content

Commit 32e78a0

Browse files
committed
Merge branch 'main' into release/reflex-0.8.5
2 parents c1c0f54 + a1432bc commit 32e78a0

File tree

6 files changed

+29
-190
lines changed

6 files changed

+29
-190
lines changed

MCP_README

Lines changed: 0 additions & 97 deletions
This file was deleted.

MCP_README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Reflex MCP Server
2+
3+
The Reflex MCP Server provides comprehensive access to Reflex framework documentation and component information through the Model Context Protocol (MCP). This server is deployed and ready to use with your MCP-compatible AI tools.
4+
5+
Check the documentation at https://reflex.dev/docs/ai-builder/integrations/mcp-overview

reflex/compiler/utils.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
from reflex.istate.storage import Cookie, LocalStorage, SessionStorage
2424
from reflex.state import BaseState, _resolve_delta
2525
from reflex.style import Style
26-
from reflex.utils import console, format, imports, path_ops
27-
from reflex.utils.exec import is_in_app_harness
26+
from reflex.utils import format, imports, path_ops
2827
from reflex.utils.imports import ImportVar, ParsedImportDict
2928
from reflex.utils.prerequisites import get_web_dir
3029
from reflex.vars.base import Field, Var
@@ -201,16 +200,11 @@ def compile_state(state: type[BaseState]) -> dict:
201200
except RuntimeError:
202201
pass
203202
else:
204-
if is_in_app_harness():
205-
# Playwright tests already have an event loop running, so we can't use asyncio.run.
206-
with concurrent.futures.ThreadPoolExecutor() as pool:
207-
resolved_initial_state = pool.submit(
208-
asyncio.run, _resolve_delta(initial_state)
209-
).result()
210-
console.warn(
211-
f"Had to get initial state in a thread 🤮 {resolved_initial_state}",
212-
)
213-
return _sorted_keys(resolved_initial_state)
203+
with concurrent.futures.ThreadPoolExecutor() as pool:
204+
resolved_initial_state = pool.submit(
205+
asyncio.run, _resolve_delta(initial_state)
206+
).result()
207+
return _sorted_keys(resolved_initial_state)
214208

215209
# Normally the compile runs before any event loop starts, we asyncio.run is available for calling.
216210
return _sorted_keys(asyncio.run(_resolve_delta(initial_state)))

reflex/components/core/auto_scroll.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,27 @@ def add_hooks(self) -> list[str | Var]:
5252
The hooks required for the component.
5353
"""
5454
ref_name = self.get_ref()
55+
unique_id = ref_name
5556
return [
56-
"const wasNearBottom = useRef(false);",
57-
"const hadScrollbar = useRef(false);",
57+
f"const wasNearBottom_{unique_id} = useRef(false);",
58+
f"const hadScrollbar_{unique_id} = useRef(false);",
5859
f"""
59-
const checkIfNearBottom = () => {{
60+
const checkIfNearBottom_{unique_id} = () => {{
6061
if (!{ref_name}.current) return;
6162
6263
const container = {ref_name}.current;
6364
const nearBottomThreshold = 50; // pixels from bottom to trigger auto-scroll
6465
6566
const distanceFromBottom = container.scrollHeight - container.scrollTop - container.clientHeight;
6667
67-
wasNearBottom.current = distanceFromBottom <= nearBottomThreshold;
68+
wasNearBottom_{unique_id}.current = distanceFromBottom <= nearBottomThreshold;
6869
6970
// Track if container had a scrollbar
70-
hadScrollbar.current = container.scrollHeight > container.clientHeight;
71+
hadScrollbar_{unique_id}.current = container.scrollHeight > container.clientHeight;
7172
}};
7273
""",
7374
f"""
74-
const scrollToBottomIfNeeded = () => {{
75+
const scrollToBottomIfNeeded_{unique_id} = () => {{
7576
if (!{ref_name}.current) return;
7677
7778
const container = {ref_name}.current;
@@ -80,37 +81,37 @@ def add_hooks(self) -> list[str | Var]:
8081
// Scroll if:
8182
// 1. User was near bottom, OR
8283
// 2. Container didn't have scrollbar before but does now
83-
if (wasNearBottom.current || (!hadScrollbar.current && hasScrollbarNow)) {{
84+
if (wasNearBottom_{unique_id}.current || (!hadScrollbar_{unique_id}.current && hasScrollbarNow)) {{
8485
container.scrollTop = container.scrollHeight;
8586
}}
8687
8788
// Update scrollbar state for next check
88-
hadScrollbar.current = hasScrollbarNow;
89+
hadScrollbar_{unique_id}.current = hasScrollbarNow;
8990
}};
9091
""",
9192
f"""
9293
useEffect(() => {{
9394
const container = {ref_name}.current;
9495
if (!container) return;
9596
96-
scrollToBottomIfNeeded();
97+
scrollToBottomIfNeeded_{unique_id}();
9798
9899
// Create ResizeObserver to detect height changes
99100
const resizeObserver = new ResizeObserver(() => {{
100-
scrollToBottomIfNeeded();
101+
scrollToBottomIfNeeded_{unique_id}();
101102
}});
102103
103104
// Track scroll position before height changes
104-
container.addEventListener('scroll', checkIfNearBottom);
105+
container.addEventListener('scroll', checkIfNearBottom_{unique_id});
105106
106107
// Initial check
107-
checkIfNearBottom();
108+
checkIfNearBottom_{unique_id}();
108109
109110
// Observe container for size changes
110111
resizeObserver.observe(container);
111112
112113
return () => {{
113-
container.removeEventListener('scroll', checkIfNearBottom);
114+
container.removeEventListener('scroll', checkIfNearBottom_{unique_id});
114115
resizeObserver.disconnect();
115116
}};
116117
}});

reflex/constants/base.py

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
from platformdirs import PlatformDirs
1313

14-
from .utils import classproperty
15-
1614
IS_WINDOWS = platform.system() == "Windows"
1715
IS_MACOS = platform.system() == "Darwin"
1816
IS_LINUX = platform.system() == "Linux"
@@ -119,9 +117,6 @@ class ReflexHostingCLI(SimpleNamespace):
119117
class Templates(SimpleNamespace):
120118
"""Constants related to Templates."""
121119

122-
# The route on Reflex backend to query which templates are available and their URLs.
123-
APP_TEMPLATES_ROUTE = "/app-templates"
124-
125120
# The default template
126121
DEFAULT = "blank"
127122

@@ -132,58 +127,12 @@ class Templates(SimpleNamespace):
132127
CHOOSE_TEMPLATES = "choose-templates"
133128

134129
# The URL to find reflex templates.
135-
REFLEX_TEMPLATES_URL = "https://reflex.dev/templates"
136-
137-
# Demo url for the default template.
138-
DEFAULT_TEMPLATE_URL = "https://blank-template.reflex.run"
130+
REFLEX_TEMPLATES_URL = (
131+
"https://reflex.dev/docs/getting-started/open-source-templates/"
132+
)
139133

140134
# The reflex.build frontend host
141-
REFLEX_BUILD_FRONTEND = "https://reflex.build"
142-
143-
# The reflex.build backend host
144-
REFLEX_BUILD_BACKEND = "https://flexgen-prod-flexgen.fly.dev"
145-
146-
@classproperty
147-
@classmethod
148-
def REFLEX_BUILD_URL(cls):
149-
"""The URL to redirect to reflex.build.
150-
151-
Returns:
152-
The URL to redirect to reflex.build.
153-
"""
154-
from reflex.environment import environment
155-
156-
return (
157-
environment.REFLEX_BUILD_FRONTEND.get()
158-
+ "/gen?reflex_init_token={reflex_init_token}"
159-
)
160-
161-
@classproperty
162-
@classmethod
163-
def REFLEX_BUILD_POLL_URL(cls):
164-
"""The URL to poll waiting for the user to select a generation.
165-
166-
Returns:
167-
The URL to poll waiting for the user to select a generation.
168-
"""
169-
from reflex.environment import environment
170-
171-
return environment.REFLEX_BUILD_BACKEND.get() + "/api/init/{reflex_init_token}"
172-
173-
@classproperty
174-
@classmethod
175-
def REFLEX_BUILD_CODE_URL(cls):
176-
"""The URL to fetch the generation's reflex code.
177-
178-
Returns:
179-
The URL to fetch the generation's reflex code.
180-
"""
181-
from reflex.environment import environment
182-
183-
return (
184-
environment.REFLEX_BUILD_BACKEND.get()
185-
+ "/api/gen/{generation_hash}/refactored"
186-
)
135+
REFLEX_BUILD_FRONTEND = "https://build.reflex.dev"
187136

188137
class Dirs(SimpleNamespace):
189138
"""Folders used by the template system of Reflex."""
@@ -204,9 +153,6 @@ class Javascript(SimpleNamespace):
204153
# The node modules directory.
205154
NODE_MODULES = "node_modules"
206155

207-
# The package lock file.
208-
PACKAGE_LOCK = "package-lock.json"
209-
210156

211157
class ReactRouter(Javascript):
212158
"""Constants related to React Router."""

reflex/environment.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -563,16 +563,6 @@ class EnvironmentVariables:
563563
# Whether to skip purging the web directory in dev mode.
564564
REFLEX_PERSIST_WEB_DIR: EnvVar[bool] = env_var(False)
565565

566-
# The reflex.build frontend host.
567-
REFLEX_BUILD_FRONTEND: EnvVar[str] = env_var(
568-
constants.Templates.REFLEX_BUILD_FRONTEND
569-
)
570-
571-
# The reflex.build backend host.
572-
REFLEX_BUILD_BACKEND: EnvVar[str] = env_var(
573-
constants.Templates.REFLEX_BUILD_BACKEND
574-
)
575-
576566
# This env var stores the execution mode of the app
577567
REFLEX_ENV_MODE: EnvVar[constants.Env] = env_var(constants.Env.DEV)
578568

0 commit comments

Comments
 (0)