Skip to content

Studio: keep Hub Run settings open on a first Chat visit - #13524

Merged
Lyxot merged 2 commits into
unslothai:mainfrom
oobabooga:studio-hub-run-first-chat-visit
Oct 13, 2026
Merged

Lyxot merged 2 commits into
unslothai:mainfrom
oobabooga:studio-hub-run-first-chat-visit

Conversation

@oobabooga

@oobabooga oobabooga commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

On a page loaded at /hub (a fresh tab, a reload, or opening Studio straight on the Hub), Run navigates to a new chat, the run settings flash open and close, and nothing loads. It works only if Chat was already visited in that tab. This affects any model: it showed up while testing Qwen3.8-27B on the AMD NPU and reproduces with a downloaded GGUF and no NPU.

Screenshots

Merge base vs this branch, each a separate build on an empty Studio home. Both pages were loaded at /hub with Qwen3.5-0.8B GGUF selected, Run was clicked, and the shot is taken 4 s later.

pr-hub-run-first-chat-visit-before-after

Root cause

ChatPage stays mounted once visited, so on a tab that never showed Chat, Run is what mounts it. The handoff opens the model picker's run settings, and then the newly mounted composer focuses itself (ComposerPrimitive.Input autofocus, which also fires on thread switch and scroll to bottom). Radix treats that as a focus outside the popover and dismisses it. Library runs and shared model links use the same handoff.

Fix

ChatComposerAutoFocusContext turns the composer's autofocus off while a Run handoff owns the picker, from the pending request until the picker closes. ChatPage sets the flag when it adopts the request and clears it during render once the picker is closed. An effect would run after the picker's own adoption effect on a first mount and clear the flag it had just set.

Behavior that stays as on main:

  • Escape from the model picker still returns focus to the picker button, and normal picker use does not change composer focus. Gating autofocus whenever the picker is open also fixed Hub Run, but it moved focus to the composer on Escape, so I scoped it to the handoff.
  • After Load from the handed-off settings, focus lands on the picker button, as it does on main when Chat was visited first.

Testing

Local A/B with Qwen3.5-0.8B GGUF and no NPU, main at 0f7bdbb against this branch, driven by Playwright:

Main This PR
Run from a page loaded at /hub, settings sampled every second for 8 s Visible 0 of 8, focus in the composer Visible 8 of 8
Run after visiting Chat first Visible 8 of 8 Visible 8 of 8
Escape from the picker Focus on the picker button Focus on the picker button
Run from /hub, Load, ask "What is 2+2?" Settings never shown Loads, answers 4

On the AMD NPU, Linux and Windows, with this change and #13525 applied together, the page reloaded on the Hub during an 18.1 GB Qwen3.8 download and Run then clicked: the settings stayed open 8 of 8 seconds on both OSes, against 0 of 8 on main (run).

  • tests/studio/playwright_model_config.py gains a step that loads /hub, selects the GGUF and clicks Run. Run locally against both builds, the full script passes on this branch and fails only on that step on main.
  • hub-runtime-boundary.test.ts also checks for the provider and the gated autoFocus.
  • npm run typecheck passed. npm test fails 5 files that fail the same way on main. ESLint adds one react-refresh/only-export-components hit for the new context, the same as ChatActiveContext beside it.

Not tested: the desktop app, macOS, and the Library and shared-link runs, which use the same handoff.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T08:30:19.191856Z 8c24ac5 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-13T04:19:35.818982Z 9868af5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@oobabooga

Copy link
Copy Markdown
Member Author

Reached Codex review convergence at oobabooga#362 (no issues found on 9868af5).

@Lyxot Lyxot self-assigned this Oct 13, 2026
…ofocus

Turning the composer's autoFocus back on is itself a focus request, so releasing the gate when the handed-off picker closed moved focus into the composer. It bounced through the composer on Escape and Load, and took focus from whatever dismissed the picker: Find in page opened over the run settings ended up typing into the chat draft.

Leave autoFocus alone and have the input ignore focus() while the handoff owns the picker, so its autofocus cannot dismiss the picker and releasing the gate focuses nothing. A click or tap on the composer still focuses it natively. The input is not made inert, which would swallow that press and make the Chat shortcuts treat the page as covered.

The handoff test only checked that the provider and the gated prop exist. Pin the provider's value, the flag being set on adoption and released on close, the consumer, and the override.
@Lyxot

Lyxot commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Reproduced the bug and the fix (merge base: run settings visible in 0 of 10 samples after Run from a page loaded at /hub; this branch: 10 of 10), and pushed one follow-up commit, 8c24ac5.

Why: gating the composer's autoFocus has a side effect when the gate lifts. In ComposerPrimitive.Input, turning autoFocus back on is itself a focus request, so when the handed-off picker closed the composer took focus:

  • On Escape and Load, focus went to the composer and then back to the picker button about 100 ms later (two focus events where main has one).
  • With the run settings open, Cmd/Ctrl+F dismissed the picker and the composer then took focus from Find in page, so typing went into the chat draft.

What changed:

  • autoFocus is !disabled again, as on main. While the handoff owns the picker, the composer input ignores focus() instead, and gets it back when the picker closes, so lifting the gate focuses nothing. A click or tap on the composer still focuses it natively. I tried inert first and dropped it: a touch tap no longer focused the composer, and isSurfaceBackgrounded(COMPOSER_INPUT_SELECTOR) reads [inert] as Chat being covered, which disabled the Chat shortcuts.
  • The context is renamed ChatComposerFocusableContext to match.
  • hub-runtime-boundary.test.ts now also pins the provider's value, the flag being set on adoption and released on close, the consumer, and the override. The Playwright step closes the settings and checks the composer accepts focus() again.

With the settings open, Escape, Load, click outside, Cmd/Ctrl+F, Ctrl+Shift+M, and a click or touch tap on the composer now all end where they do on main when Chat was visited first.

Known and left alone: with a multi-line draft present, a touch tap on the Expand composer toggle while the handed-off settings are open closes the picker but leaves focus on the page; one more tap on the input recovers.

@Lyxot

Lyxot commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 8c24ac5a93

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Lyxot

Lyxot commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Codex converged at 8c24ac5 in one round: #13524 (comment). There were no review threads to resolve.

CI: this repository's runs for that commit were still queued, so the same head was run against the same base on a staging PR, Lyxot#156: 42 passed, 4 failed.

  • Passing includes Frontend build + bundle sanity, Frontend unit tests (Windows), and all three Chat UI Tests jobs. The extra shard ran the new step:
[ui-modelcfg] STEP Hub Run opens run settings on a page loaded at /hub
[ui-modelcfg] OK Hub Run kept run settings open on a page loaded at /hub
[ui-modelcfg] OK composer takes focus again after the run settings close
  • The 4 failures are Python tests in code this PR does not touch, and the same tests failed on a staging run of an unrelated PR an hour earlier ([staging] #13390 Studio: make the first-token waiting limit configurable Lyxot/unsloth#155):
    • (Python 3.13, a-k): tests/test_diffusion_autoopt_parity.py (2 tests)
    • Repo tests (CPU, rest): tests/test_st_subfolder_weights_are_fetched.py
    • Core zoo (HF=4.57.6 + TRL<1) and Core zoo (HF=default + TRL=default): tests/test_block_checkpointing.py in unsloth-zoo

Changed in this pass: only the follow-up commit described in #13524 (comment). The branch was not merged with main (43 commits behind, no conflicts).

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced the bug on the merge base and the fix on this branch in a real browser; the handoff's exit paths match main. LGTM.

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