Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Record why the permission pill is missing after a reload, and reload once more only if the app never booted (#12456)

Daniel Han245e77603409
diff --git a/tests/studio/playwright_chat_ui.py b/tests/studio/playwright_chat_ui.py
index 4bbc72ad893..0b6caf1172c 100644
--- a/tests/studio/playwright_chat_ui.py
+++ b/tests/studio/playwright_chat_ui.py
@@ -320,9 +320,41 @@ def exercise_permission_mode_controls(page, shoot):
# went out as Cache-Control: no-store (#12148): its own 30s timeout never fired, and the step sat
# there until the 180s watchdog killed the job (Chat UI Tests (chat) on main at 1dddc1437). The
# pill is the one thing the next assertion needs, and waiting for it is bounded.
+ #
+ # One more reload, only when the app never booted. Seen once on the Windows msedge permissions lane
+ # (#12438's run 36881445186): after the reload the server served /chat and the three boot scripts and
+ # then no /api request at all, the page stayed on "Loading...", and the pill never mounted. That is
+ # the app shell failing to start, not this step's assertion, so it gets one retry with the evidence
+ # logged; a page that booted and still lacks the pill fails at once, and so does a second boot failure.
+ def _boot_state():
+ try:
+ return page.evaluate(
+ """() => ({
+ url: location.href,
+ readyState: document.readyState,
+ composer: !!document.querySelector('textarea[aria-label="Message input"]'),
+ root: (document.getElementById("root")?.innerText || "").trim().slice(0, 80),
+ })"""
+ )
+ except Exception as exc:
+ return {"evaluate_failed": repr(exc)}
+
def reload_and_wait_for_pill():
page.reload(wait_until = "load")
+ try:
+ expect(pill).to_be_visible(timeout = 30_000)
+ return
+ except AssertionError:
+ state = _boot_state()
+ shoot("04-permission-pill-missing")
+ info(f"WARN permission pill missing 30s after reload; page state {state}")
+ if state.get("composer") or state.get("evaluate_failed"):
+ raise
+ page.reload(wait_until = "load")
expect(pill).to_be_visible(timeout = 30_000)
+ info(
+ "WARN the app did not boot on the first reload and did on the second; see the state above"
+ )
# choose() only drives THIS tab.
# The mirror to /api/chat/settings is a 400ms trailing-edge debounce (SETTINGS_DEBOUNCE_MS, chat-runtime-store.ts)
diff --git a/tests/studio/test_chat_ui_permission_reload_wait.py b/tests/studio/test_chat_ui_permission_reload_wait.py
index 4eee9c0f325..b4cfd691d06 100644
--- a/tests/studio/test_chat_ui_permission_reload_wait.py
+++ b/tests/studio/test_chat_ui_permission_reload_wait.py
@@ -72,3 +72,19 @@ def test_the_permission_reload_settles_on_a_bounded_pill_wait():
assert isinstance(timeout, ast.Constant) and 0 < timeout.value <= 60_000, ast.unparse(
visible[0]
)
+
+
+def test_a_reload_that_booted_the_app_gets_no_second_chance():
+ """The one extra reload is for an app shell that never started (no composer, no /api calls).
+ A page that booted and still has no pill is the regression this step exists to catch."""
+ source = (Path(__file__).resolve().parent / "playwright_chat_ui.py").read_text(encoding = "utf-8")
+ start = source.index("def reload_and_wait_for_pill():")
+ body = source[start : source.index("\n # choose()", start)]
+ assert body.count("page.reload(") == 2, "the step reloads more than once extra"
+ guard = body.index('if state.get("composer")')
+ assert (
+ body[guard : body.index("\n", body.index("raise", guard))].rstrip().endswith("raise")
+ ), "a booted page without the pill must fail, not retry"
+ assert (
+ body.index("_boot_state()") < body.index('shoot("04-permission-pill-missing")') < guard
+ ), "record the page state and a screenshot before deciding"