Repository navigation
Studio: realtime option for speed and context stats, shorter Chat defaults - #16888
Conversation
Settings > Chat > Speed and context stats picks between When done (the default, today's behaviour) and Realtime, where the header context meter counts the prompt and reply as they stream and the live tok/s line shows without Generation details. Realtime reads the live figures through a 200 ms leading and trailing throttle, and the settled path keeps its existing subscriptions.
Auto-compact, keep running after the tab closes, scroll while generating and reply notifications move from Chat defaults to Conversations. Speed and context stats moves from Display to Chat defaults and also shows under System > Live monitor; both rows edit the same preference.
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0070cc734d
ℹ️ 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".
| const tracker = useRef<ReturnType<typeof createPassSettledTracker> | null>( | ||
| null, | ||
| ); | ||
| tracker.current ??= createPassSettledTracker(); |
There was a problem hiding this comment.
Reset the settled tracker when the live thread changes
With Realtime enabled, switching directly between two chats that are both decoding preserves this ref but changes the settled snapshot. createPassSettledTracker interprets the destination chat's snapshot as the previous pass having settled, so liveContextUsage returns null and the destination meter stops updating for the rest of that pass. The hook guards against displaying another thread's live figures, but the tracker needs the same thread isolation: reset or key it by liveThreadKey.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 46a92aa: the realtime meter is keyed by thread, so a chat switch mid-pass starts a fresh settled tracker.
| if (!decoding || !seeded) { | ||
| baseline = snapshot; | ||
| seeded = true; | ||
| return false; |
There was a problem hiding this comment.
Honor settled usage for passes without a decode frame
For a short tool-call pass that finishes before the server's 250 ms decode-frame interval, live.decode remains null even after its exact context_usage arrives. This branch continually replaces the baseline and returns false, so the realtime meter keeps displaying the prefill count with zero completion tokens instead of the settled count. The adapter only clears live generation on tool_end, so the incorrect count persists throughout tool execution or while waiting for approval. Track settlement for prefill-only passes as well, rather than requiring an observed decode frame.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 46a92aa: settlement is tracked from the start of each pass, so a pass that ends before any decode frame shows its exact context_usage.
- Chat defaults keeps the everyday rows: send shortcut, follow-up, scroll while generating, condense long pastes, speed and context stats. - New Replies and Thinking and tools sections; Memory moves above Conversations; plain text composer, rich text paste and context window usage move to Display. - Speed and context stats moves to System > Floating window. - Model memory is renamed Model loading, including the backend message that points to it. - Generation details is renamed Detailed speed and loading info with a description that says what it adds. - Chat menu, Shortcuts, download folder, model cache folder and chat template resets use the Appearance reset style; the Chat menu and Shortcuts resets get its ruled footer and grey out at the defaults.
… note Speed and context stats is no longer repeated under System > Floating window. The System tab's no-GPU note no longer says CPU-only, since on unified memory machines a built-in GPU shares the RAM shown above.
The tooltip says what each mode refreshes and that Realtime may cause lag or slower performance on older or busy machines.
…d short passes Key the realtime meter by thread, so switching between two chats that are both decoding starts a fresh settled tracker instead of reading the other chat's snapshot as this pass settling. Track settlement from the start of each pass, not its first decode frame, so a short tool-call pass that ends before any decode frame shows its exact context_usage. [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 80e91fe193
ℹ️ 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".
| const newPass = decoded && !decoding; | ||
| decoded = active && decoding; | ||
| if (!active || !seeded || newPass) { | ||
| baseline = snapshot; |
There was a problem hiding this comment.
Preserve pass boundaries across throttled live updates
In Realtime mode, when a tool-call pass settles without a decode frame and its tool finishes quickly, tool_end can clear live progress and the next prefill can arrive within the same 200 ms throttle window. useThrottledLiveGeneration then exposes only the new prefill, so this tracker never observes active === false; since the preceding pass never decoded, newPass is also false. The baseline remains the snapshot from before the completed pass, making the entire next pass appear already settled and disabling its realtime context updates. Track pass boundaries before throttling, or carry a pass identifier through the throttled snapshot rather than inferring boundaries solely from sampled booleans.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c1884d8: passes are numbered on every store change inside the throttled hook, and the settled tracker keys on that number, so a boundary inside one throttle window is kept.
A pass boundary inferred from throttled samples is lost when a tool pass with no decode frame ends and the next prefill arrives inside one 200 ms window, which made the next pass look already settled. Count passes on every store change in the throttled hook and key the settled tracker on that number. [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1884d8d49
ℹ️ 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".
| if (pass !== seenPass) { | ||
| baseline = snapshot; | ||
| seenPass = pass; | ||
| return false; |
There was a problem hiding this comment.
Preserve settlement when mounting during tool execution
When switching back to a chat after its context_usage has arrived but while its tool is still running or awaiting approval, the thread-keyed remount creates a fresh tracker and treats that already-settled snapshot as the baseline. It consequently returns false and replaces the exact context count with the older live figures until tool_end clears them. The new keyed remount exposes this separate initialization case even though switching between actively decoding chats is now isolated correctly. Persist settlement alongside the pass in the runtime store, or otherwise initialize the tracker with whether the current pass has already settled, rather than assuming its first observed snapshot predates settlement.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 15718f8: settlement now lives on the thread's live progress in the store (set when the adapter publishes that pass's context_usage, cleared by the next prefill), so a remount during tool execution keeps it; the component tracker is gone.
The realtime meter inferred settlement in component state from the settled snapshot changing, which broke on a chat switch, on a pass with no decode frame, on a boundary inside one throttle window, and on a remount while a tool runs. The adapter now marks the thread's live progress settled when it publishes that pass's own context_usage, the next pass's prefill clears it, and the meter reads the flag. The tracker, pass numbering and keyed remount are gone.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
The Chat settings regroup moved the plain text, rich paste and context window rows out of ComposerSettings, so the composer smoke page (Playwright on every engine and native Safari) no longer had the switches it drives. [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Resolve composer-settings against unslothai#16888, which moved Plain text, Rich text paste and Context window usage to Display; Share drafts across chats stays in Chat defaults, and the pinned Chat defaults row list includes it.
Related to unslothai#16055. ## Problem Studio knows where a loaded GGUF's weights are, but the only lasting readout is the "Weight placement" row in Run settings (unslothai#14909), and it sits behind a switch that is off by default. In a [Reddit thread](https://www.reddit.com/r/unsloth/comments/1xra6ua/inference_speed_cratered_after_recent_update/) about slow generation, people could not tell whether the model had spilled to the CPU. They tried to read it from the memory estimate, which is a forecast. ## Fix - The "Weight placement" row always shows for the loaded GGUF, in the same grey text for every placement. - The switch that used to gate it now only controls the live speed lines, so "Detailed speed and loading info" becomes "Detailed speed info" in all 25 locales. That label is from unslothai#16888, so please say if you prefer another name. - The "partly on CPU" and "none of the layers fit" warnings now end with the weight amounts, for example "Model weights: 1.9 GiB on the GPU, 2.8 GiB on the CPU." These are totals, and they count the weights only. This is the idea from unslothai#16064 (thanks @debojyoti-dev), worded so it is also correct with unified memory. - A MoE load with expert weights in RAM, which llama.cpp counts as fully on the GPU, now says so on its success toast. - A load that llama.cpp logs as fully offloaded while every buffer is in system memory, on a machine with a GPU, now gets the existing "llama.cpp could not use it" warning. There are no backend changes, and which loads get a warning is otherwise the same. ## Before and after Main (`011129b355`) vs this PR (`7e9fd96cc5`), with the same real load on both sides. A model that is fully on the GPU: <img width="3504" height="1072" alt="placement_01_fully_on_gpu" src="https://raw.githubusercontent.com/oobabooga/unsloth/pr-media/pr/studio-gguf-placement-visible/placement_01_fully_on_gpu-b3ed33f4ace9.png" /> 14 of 37 layers on the GPU: <img width="3504" height="1124" alt="placement_02_partly_on_cpu" src="https://raw.githubusercontent.com/oobabooga/unsloth/pr-media/pr/studio-gguf-placement-visible/placement_02_partly_on_cpu-a21ce5ab7fd0.png" /> A MoE model with the expert weights of 24 layers in RAM: <img width="3504" height="1124" alt="placement_03_moe_expert_weights_in_ram" src="https://raw.githubusercontent.com/oobabooga/unsloth/pr-media/pr/studio-gguf-placement-visible/placement_03_moe_expert_weights_in_ram-94f22098f15b.png" /> ## Testing - Live in Studio on Linux with an RTX 3090: the three loads above, and the row after a page reload. A small tool makes the card report less free VRAM than it has, so a model that would fit lands partly on the CPU. - 7 new frontend tests. The failed GPU backend case is covered by these tests only. - `typecheck`, `i18n:check:strict` and the frontend and `tests/studio` tests that cover these files pass. - Not tested on Windows or macOS. ## Before and after, separate installs Merge base `011129b355` vs this PR `dbd790c8ed`, each built from its own tree, "Detailed speed info" left at its default (off). Run settings with gemma-3-270m GGUF loaded on an NVIDIA L4. Main shows no placement; this PR shows all 19 layers on the GPU and the weight split: <img width="620" alt="pr17449_gpu_l4" src="https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/17449/pr17449_gpu_l4_crop-95099eb1a905.png" /> Run settings with Qwen3-0.6B GGUF loaded on a CPU-only Linux machine. This PR says all 29 layers are on the CPU, with 0.5 GiB in RAM: <img width="660" alt="pr17449_cpu_only" src="https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/17449/pr17449_run_settings_crop-4524523ed93c.png" />
Adds a Speed and context stats setting, in Settings > Chat > Chat defaults, with two options:
tokens · tok/sline shows under a streaming reply even with Detailed speed and loading info off.The row's info tooltip explains both modes and notes that Realtime may cause lag or slower performance on older or busy machines.
How it works
generationStatsUpdates: "settled" | "realtime"in the chat preferences store, persisted like the other preferences. Anything other than"realtime"(missing, old records, unknown values) normalises to"settled".generation_progressfigures throughuseThrottledLiveGeneration, which subscribes to the runtime store outside React and re-renders at most once per 200 ms (leading and trailing, so the first and the last frame always land). The server already sends decode frames at most every 250 ms, so this only guards against bursts.LiveContextUsageBar. In settled mode it renders the existingContextUsageBarand subscribes to no live figures, so the chat header never re-renders mid-stream. In realtime mode only the small wrapper re-renders, notChatPage.context_usageframe lands, the meter switches back to that exact count instead of the last (trailing) decode frame. This is keyed on the snapshot object, not its numbers, so a regenerate with the same prompt still counts live.Verification
npm run typecheck,npm test(15014 tests, 0 failures),npm run build,npm run i18n:check:strictpass.biome linton the changed files adds no new errors (the remaining ones are on untouched lines;npm run biome:checkis red repo-wide on main as well).tests/realtime-generation-stats.test.tspins the default and persistence, the throttle (fake clock: a 1,000 frame/s burst renders once per interval and the last frame lands), the live context arithmetic, the settled-snapshot handover, and that settled mode keeps the old code paths.timings_per_token) moved decode speed by under 1% and 15k-token prefill by noise on the same model.New strings are translated in all 25 locales.
Settings cleanup
tests/chat-settings-sections.test.tspins which rows each section holds, the section order and the reset footers.Not tested here
Studio UI regression check
Base
06766f791vs head4676652cb. Functional: NO_REGRESSION, UI coverage 85%, 5 visual change(s), 1 text-only change(s). Only steps whose screenshots differ are shown.settings/s04_tab_system: masks cover 9% of the shot | reproduced on confirm (VISUAL_DIFF)

settings/s05_tab_chat: | reproduced on confirm (VISUAL_DIFF)

settings/s13_tab_shortcuts: | reproduced on confirm (VISUAL_DIFF)

settings/s20_toggle_persist: | reproduced on confirm (VISUAL_DIFF)

settings/s21_reload_persisted: | reproduced on confirm (VISUAL_DIFF)

settings/s06_tab_api