Skip to content

feat(ui): model picker shows real device, fit and live status - #5244

Merged
kovtcharov-amd merged 20 commits into
amd:mainfrom
kovtcharov:claude/ui-model-picker-status-e6ffae
Oct 19, 2026
Merged

kovtcharov-amd merged 20 commits into
amd:mainfrom
kovtcharov:claude/ui-model-picker-status-e6ffae

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

The Agent UI's model picker offered a CPU/GPU/NPU switch no model can honour, went silently dead while GAIA was answering, named Gemma as the active model on PCs whose default is something else, and showed raw GGUF file names. Now each model shows where it really runs (Lemonade's report once loaded, with a plain warning if a GPU model fell back to the CPU), only models this PC can run are offered, a pick made mid-reply applies to the next message, and the chip names the model a new chat actually starts on. Settings › Model adds friendly names, a "Fits this PC" badge, download size and speed measured here, plus a Context size choice up to the most that fits. The sidebar's "Local · model" pill now opens a live status: loaded / warming / stopped, device, memory used vs free, context window, and Restart. Lands after v0.25.0.

Closes #5214
Closes #5209
Closes #5213
Closes #4823
Closes #5253

  • Context size is saved per model (context_sizes in ~/.gaia/config.json) and used on every load, including the reload after an idle unload. A saved size that no longer fits is refused at load, with how to fix it (GAIA_CTX_SIZE still overrides it). Changing it, like Restart, reloads through GAIA's normal load path with its free-memory check, and never under a reply that is still running. It replaces the 4K–32K presets in Settings › Advanced.
  • On a Lemonade you run yourself ("Use mine"), Restart asks before reloading your model and never starts your server, and a context-size change never reloads there (fix(ui): model status is inconsistent, and Restart reloads models on a server GAIA promised not to touch #5253). The chip says Local as soon as setup finishes, and the popover's used + free memory adds up to the pool setup reports.
  • Not in this PR: the TUI doesn't expose the context-size setting yet (feat(ui): choose the context size in Settings, up to what fits #5213 allows a follow-up issue for it), and the gateway is shown only once Lemonade has it registered, without probing whether the enterprise network can reach it.

Screenshots

From the running app on a Strix Halo (fresh GAIA home on an existing Lemonade, so no personal chats are shown).

Settings › Model Composer model picker
Status popover: Restart on your own Lemonade Status popover: server stopped Chip before the first chat

Test plan

  • python -m pytest tests/unit/test_model_device_and_context.py tests/unit/chat/ui/test_model_picker_routes.py tests/unit/chat/ui/test_providers_router.py
  • python -m pytest tests/unit/ (full suite)
  • npx vitest run and npx tsc --noEmit in src/gaia/apps/webui
  • python util/lint.py --all
  • Running app on a Strix Halo, with this branch's backend serving its own build: Settings › Model (device per model, fit, size, no device switch), the composer chip (friendly names, loaded dot / Ready / download, "Add your key" for Fireworks), and the sidebar popover loaded and stopped
  • Fresh GAIA home on an already-running Lemonade ("Use mine"): the chip says Local before the first chat, Restart shows the confirmation and reloads nothing until confirmed, memory reads 8.3 GB used · 55.7 GB free of 64 GB
  • Restart confirmed against a live Lemonade (covered by unit tests; not pressed live because another session was using the shared server)
  • On a PC without an NPU, FLM models appear under "Not available on this PC" (needs a PC without an NPU; covered by pytest from recorded /system-info bodies and by vitest)
  • Pick a model while GAIA is answering; the next message runs on it (covered by vitest, queue then apply on reply end; not run live, since a live reply would hold the Lemonade other test sessions share)
🔍 Technical details
  • Device: gaia.llm.model_device reads /health all_models_loaded[].device plus the llama-server path for a loaded model, and the recipe (llamacpp → GPU via the default or chosen backend, flm → NPU) before load. default_device no longer comes from the UI; the NPU context cap already follows the model (runs_on_npu).
  • Availability: recipe backends with no usable state in /system-info, or model_fit.check_fit against the model's size at its floor window. A loaded model is never hidden.
  • Context: gaia.llm.context_choice builds options from min_ctx_size to largest_context; resolve_ctx_size takes a saved size through _chosen_ctx_size and skips the free-memory shrink for it (the load's own free-memory check still refuses).
  • Speed: each turn's stored inference_stats now carries model; the list reports the median tokens/s over that model's last 20 turns.
  • New routes: GET/PUT /api/providers/local/context, GET /api/providers/local/status, POST /api/providers/local/restart. Builds on fix(ui): list chat models that are also labeled audio in the model picker #5140's _is_chat_model without touching it.

The Agent UI's model picker offered a CPU/GPU/NPU switch no model can
honour, went silently dead during a reply, named Gemma on PCs whose
default is another model, and showed raw GGUF ids. Each local model now
shows where it runs (Lemonade's report once loaded, its recipe's target
before, with a warning when they differ), only models this PC can run are
offered, a pick made mid-reply applies to the next message, and the chip
names the model a new chat starts on.

Settings > Model adds friendly names, a fits-this-PC badge, download size,
speed measured here, a "Not available on this PC" section, and a context
size choice up to the largest window that fits. The size is saved per
model in config.json and used on every load; one that stops fitting is
refused at load. The sidebar's "Local · model" pill opens a live status
popover with Restart.

Closes amd#5214, amd#5209, amd#5213, amd#4823.
@github-actions github-actions Bot added documentation Documentation changes llm LLM backend changes tests Test changes electron Electron app changes performance Performance-critical changes labels Oct 17, 2026
…nced

The source-text check still asserted Advanced's old 4K-32K presets, which
this branch replaced with a size chosen in Settings > Model up to what
fits.
test_cli_config reloads gaia.config, so a class imported at module load
is a different object from the one load() raises, and pytest.raises
missed it on CI's Linux and macOS runs.
With "Use mine", the status popover's Restart force-reloaded the model on
the user's own Lemonade, and could start that server, though setup says
GAIA never unloads their models. Restart now asks first and explains what
it interrupts, and never starts a server GAIA doesn't run; a context-size
change saves without reloading there.

Before the first chat the chip said GAIA couldn't tell where chats run.
The active-model view now carries the backend's answer for a new chat,
so the chip says Local as soon as setup finishes. The popover's free
memory no longer exceeds the pool setup reports: used plus free adds up.

Also from amd#5260: downloaded models say "on disk", user-registered model
ids read cleanly ("Qwen38 27B"), and the Settings nav focus follows the
tab you pick, so only one looks selected.

Fixes amd#5253
The status popover disabled Restart with "GAIA is answering with this
model" while only the new-chat warm-up was running. The status now says
why the model is busy, a warm-up or a request, and Restart's tooltip and
the route's refusal word each case; a request may come from another app
on the user's own Lemonade, so it no longer claims GAIA is answering.
Screen readers heard twenty buttons all called "Use" in Settings > Model.
…oud models

Each turn recorded its model as stats.model for the speed list, but a kept
"Retry with..." answer (amd#5241) uses that same key to name the model it was
kept from, so in a merged build every answer footer claimed a retry. The
speed sample is now stats.measured_model, which no other code reads.

Settings > Advanced's Model server panel showed a cloud chat model as its
raw routing id (fireworks.deepseek-v4p1-flash); it now shows the name, with
the id in the tooltip.
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Oct 17, 2026
Once turns record their model (amd#5244), the footer's "kept from Retry
with…" label would show on every answer. A kept retry now carries
retried: true and the footer keys on that.
Keeps both new Model server panel tests (cloud model names, and main's
embedding-model note) and regenerates api.gen.ts / api.schemas.json from
the merged backend models.
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This makes the model picker tell the truth: where a model actually runs, whether it fits this PC, and which model a new chat will start on. Picks made mid-reply now apply to the next message, and the context-size choice is checked against this PC's memory. The backend is careful about refusing on someone else's Lemonade, about busy models, and about saved sizes that no longer fit. Unit coverage is solid on both the Python and the UI side. I found no blocking bugs.

🟡 No screenshots on the PR for an Agent UI change. The description says the app was exercised on a Strix Halo, but no before→after images are embedded. That leaves the new Settings › Model rows, the chip and the sidebar status popover unseen by reviewers. Three test-plan items are also still open, including the headline "pick a model while GAIA is answering". Please embed Playwright screenshots of the picker and popover, and tick or explain the open items before merge.

🟢 Nits:

  • Saving a context size equal to the window already loaded (for example choosing Automatic when Automatic is the current size) still reloads the model. On the 35B model that is a long, pointless reload.
  • Restart refuses while GAIA is warming up a new chat, but a context-size change only checks whether the model is answering, so it can reload in the middle of a warm-up.
  • When GAIA can't read this PC's memory, a saved context size loads without the fit check (only a log line). That contradicts the docs' promise that a size which doesn't fit is refused.
🔍 Technical details
  • Redundant reload — routers/providers.py set_context: it reloads whenever view["loaded_ctx"] is set. Compare it to the size that will now be used (body.ctx_size or view["automatic"]) and skip _start_reload when they match.
  • Warm-up race — set_context checks only entry.get("is_busy"). restart_local uses _busy_reason(entry, _warming_up()). Reusing that would make the two routes agree.
  • Unchecked load — lemonade_client.py _chosen_ctx_size: on LemonadeClientError/ModelFitError from machine_capacity it returns tokens unchecked. Either raise with the remedy, or reword the context_choice.py module docstring and the guide so they don't promise a refusal.

…r loads unchecked

From review on amd#5244: picking the size a model is already loaded at
(including Automatic) no longer reloads it; a size change waits for the
new-chat warm-up as Restart does; and a saved size is refused, with the
fix, when this PC's memory can't be read, instead of loading unchecked.
@kovtcharov

Copy link
Copy Markdown
Contributor Author

All three nits are fixed in 2772c5f, and the description now has screenshots of Settings › Model, the picker and the status popover.

  • Needless reload: picking the size a model is already loaded at, Automatic included, no longer reloads it.
  • Warm-up: a context-size change now waits out the new-chat warm-up, the same way Restart does.
  • Unchecked load: when GAIA can't read this PC's memory, a saved context size is refused with how to fix it, rather than loaded without the fit check. That matches what the docs promise.
  • Open test-plan items: two still need conditions I can't set up safely here, a PC without an NPU and a live reply on a Lemonade other sessions share. Both are covered by unit tests, and each item now says so.
🔍 Technical details
  • set_context (routers/providers.py) compares loaded_ctx with chosen or automatic and returns reason: "already_loaded". It reuses _busy_reason(entry, _warming_up()) and returns reason: "warm_up" while the prefix warm-up runs.
  • _chosen_ctx_size (lemonade_client.py) raises LemonadeClientError naming Automatic and GAIA_CTX_SIZE as the ways out when machine_capacity fails. The context_choice.py docstring and the SDK doc now say so.
  • New tests: test_no_reload_when_the_model_is_already_at_that_size (with a size and with Automatic), test_a_size_change_waits_for_the_new_chat_warm_up, test_a_saved_size_is_not_loaded_unchecked_when_memory_is_unreadable, plus two vitest cases for the new notices.
  • Local runs: vitest 900, backend UI and model suites 1,817, tsc --noEmit and lint all pass.

kovtcharov-amd pushed a commit to kovtcharov/gaia that referenced this pull request Oct 19, 2026
The line under an answer showed developer stats ("1012ms TTFT · 68 → 510
tokens · 38.1 tok/s"), and permission prompts named internal tools
("Always allow `write_file on prompt-test.txt` in this chat", "ran
'write_file' without asking"). Now the footer reads "Answered in 40 s on
your GPU · first word in 1 s" (or "via Fireworks AI" for a cloud turn),
with the exact numbers one click away. Prompts read "Allow writing
file?" and "Always allow writing prompt-test.txt in this chat", and the
full-access notice says what ran: "Full access is on, so GAIA didn't ask
first. Writing file: prompt-test.txt".

Part of amd#5260. The suggestion-card item (cards wrapping 3 + 1) is
already fixed in amd#5240, which lays the cards out as a 2-column grid, so
this PR leaves it alone. On merges: this PR and amd#5241 both edit the
stats row under an answer, so expect a small conflict there. It also
touches the permission-request handling in the chat view next to code
that amd#5241, amd#5242, amd#5244 and amd#5245 change. It lands after v0.25.0.

## Screenshots
Footer (expanded by a click) and permission card, before → after:

| | Before | After |
|---|---|---|
| Light |
![](https://raw.githubusercontent.com/kovtcharov/gaia/efd1d2e456449ca32044b4bff748197a1353e1ce/before-light.jpg)
|
![](https://raw.githubusercontent.com/kovtcharov/gaia/efd1d2e456449ca32044b4bff748197a1353e1ce/after-light.jpg)
|
| Dark |
![](https://raw.githubusercontent.com/kovtcharov/gaia/efd1d2e456449ca32044b4bff748197a1353e1ce/before-dark.jpg)
|
![](https://raw.githubusercontent.com/kovtcharov/gaia/efd1d2e456449ca32044b4bff748197a1353e1ce/after-dark.jpg)
|

Footer before the click:
![](https://raw.githubusercontent.com/kovtcharov/gaia/efd1d2e456449ca32044b4bff748197a1353e1ce/after-dark-footer-collapsed.png)

## Test plan
- [x] `npx vitest run`: 860 passed. `npx tsc --noEmit` is clean
- [x] `pytest` on the Agent UI, permission, stdio, shell-prompt and
agent suites plus the flagship package tests: 6798 passed. The 3
failures are tool-count checks in `hub/agents/gaia` (87 tools found vs
95 declared). Optional dependencies are missing from the local venv, and
this PR doesn't touch tool registration
- [x] `python util/lint.py --black --isort --pylint` passes
- [x] Checked in the running app, in light and dark, before and after
(screenshots above). The footer shows plain words and expands on click,
and the permission card shows no tool ids
- [ ] Reviewer: run a turn on a local model and check that the footer
names the right device. Then run one on a cloud model and check that it
says "via …"

<details>
<summary>🔍 Technical details</summary>

- Each turn's stats gain `place`, set by `_turn_place`. For a cloud
model it is the provider's name. For a local model it is the `device`
that Lemonade's `/health` reports for that model. Older messages have no
`place`, so their footer makes no claim about where they ran. The cloud
provider is resolved from the model before any Lemonade call, so a cloud
turn names it even with Lemonade stopped.
- `permission_request` gains `tool_label` (from `tool_phrase`, built on
`derive_narration`) and `always_label` (from `grant_phrase`, which uses
the same `_VERB_FORMS`). `always_scope` is unchanged because
`agent_ui_control` matches it exactly. Shell scopes get no label because
they are already the command itself.
- `GrantScope` gains an optional `subject` (the file or skill), so the
label can be worded without parsing it.
- The MCP `turn_view` footer still returns the raw numbers. Only its
docstring and the guide line about it changed.
</details>
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 19, 2026
…ter (amd#5290)

The Agent UI looked developer-built: copper on cool blue-grey, 19 font
sizes, labels in spaced-out monospace capitals, and buttons in three
different shapes. This lands the foundation of the approved redesign
(amd#1001). It brings warm gray neutrals and muted brass for actions and
focus only. Inter replaces DM Sans and Space Mono. Controls are soft
tinted, rise slightly on hover and settle on press, and dialogs use calm
sentence-case titles. Every token keeps its name, so the open feature
PRs pick up the new look without edits. With no saved theme, the app now
follows the OS instead of defaulting to dark, so a light-mode user who
never picked a theme opens it in light.

**Decided: brass on both the Agent UI and the TUI.** This PR moves the
Agent UI first. The TUI keeps copper only until amd#5291 lands a
terminal-safe brass, because the light brass `#7A5A22` rounds to
`#875F00` on a 256-colour terminal, which is the TUI's Warning and
Selected entry. Until then the cross-surface test pins the TUI's copper
on its own, and amd#5291 restores the shared-accent assertion. The commit
marked `[decision pending]` predates the decision.

**Stacked on amd#5266.** This branch includes amd#5266's motion commit,
because its tokens are the motion base; review the commits after it.
Lands after v0.25.0.

| Before (`main`) | After |
|---|---|
|
![](https://raw.githubusercontent.com/kovtcharov/gaia/ui-redesign-1001-before/finished-answer-light-win32.png)
|
![](https://raw.githubusercontent.com/kovtcharov/gaia/5eb5f66b5ff11ed138c04b692443ee044caa5352/src/gaia/apps/webui/visual/__screenshots__/finished-answer-light-win32.png)
|
|
![](https://raw.githubusercontent.com/kovtcharov/gaia/ui-redesign-1001-before/scheduled-tasks-light-win32.png)
|
![](https://raw.githubusercontent.com/kovtcharov/gaia/5eb5f66b5ff11ed138c04b692443ee044caa5352/src/gaia/apps/webui/visual/__screenshots__/scheduled-tasks-light-win32.png)
|
|
![](https://raw.githubusercontent.com/kovtcharov/gaia/ui-redesign-1001-before/documents-dark-win32.png)
|
![](https://raw.githubusercontent.com/kovtcharov/gaia/5eb5f66b5ff11ed138c04b692443ee044caa5352/src/gaia/apps/webui/visual/__screenshots__/documents-dark-win32.png)
|
|
![](https://raw.githubusercontent.com/kovtcharov/gaia/ui-redesign-1001-before/new-chat-dark-win32.png)
|
![](https://raw.githubusercontent.com/kovtcharov/gaia/5eb5f66b5ff11ed138c04b692443ee044caa5352/src/gaia/apps/webui/visual/__screenshots__/new-chat-dark-win32.png)
|

**Defaulted, easy to change.** The four round-3 design questions went
unanswered, so the recommended answers stand: a green tick for a
finished step, neutral markers for the selected chat and current
chapter, a small dark dot for an unread answer, and an icon shadow that
falls only outside each shape. They apply in the follow-ups below, which
own those components.

## Test plan

- [ ] `npm test` in `src/gaia/apps/webui`: 899 pass, including new
contrast cases for the raw brass and the switch knob on it
- [ ] `npx tsc --noEmit -p .` and `npx tsc --noEmit -p visual` in
`src/gaia/apps/webui` are clean
- [ ] `npx vitest run` in `website/`: 236 pass
- [ ] `go test ./internal/ui/theme/...` in `tui/` passes against the
updated spec
- [ ] `npm run test:visual` in `src/gaia/apps/webui`: 12 snapshots, six
screens in light and dark, match on Windows (set `GAIA_VISUAL_CHROMIUM`
to a local Chromium if `npx playwright install chromium` can't download)
- [ ] `gaia chat --ui`: switch Light, Dark and Match system in Settings
› General. The composer shows a brass focus ring, buttons lift on hover,
the warning notice shows its icon, and Settings switches are brass when
on.

<details>
<summary>🔍 Technical details</summary>

**What moved**
- `index.css` tokens: warm-gray palette in both themes; brass `--accent`
(`#7A5A22` / `#D4B47E`); soft-tinted `--accent-fill`; new
`--accent-solid`, `--accent-ring`, `--shadow-press`, `--ease-spring`,
`--duration-spring`, `--duration-press` and `--fs-*`. The layered
`--shadow-sm/md/lg` carry a light top rim. None of them is a glow, and
the no-glow guard passes.
- Each place that used `--accent-fill` as a solid mark moved to a role
that stays visible on the new pale wash: switch tracks, native
checkboxes and progress bars, the suggested permission button, and the
count badges in `Sidebar.css` and `NotificationCenter.css`.
- `ScheduleManager.css` redefined `.btn-primary` and `.btn-secondary`
unscoped. Once its lazy chunk loaded, every button in the app changed
shape. Those rules are removed.
- Labels that were uppercase or monospace in stylesheets no other open
PR touches are now sentence-case Inter. Paths, keys and code stay
monospace.
- `--bg-active` rejoins the contrast matrix. The pinned copper used to
fail on it; the brass clears every floor.
- The Electron mirrors (`main.cjs`, the installer dialog), `index.html`
`theme-color` and `utils/theme.ts` follow the new canvas.

**Visual suite** (`src/gaia/apps/webui/visual/`): `vite preview` of the
production build, every `/api` call answered from fixtures, a frozen
clock, animations off, and at most 50 differing pixels. An API call
without a fixture fails the test by name. Baselines are Windows-only and
no CI job runs the suite yet; follow-up below.

**Follow-ups once these PRs merge** (each restyle goes through tokens;
no code here depends on them)
- amd#5242: sidebar rich rows (status, preview line, time), titles that
fade instead of truncating, borderless search.
- amd#5240: 28px greeting, raised suggestion cards that lift, first-run
stepper. `SetupScreen.css` gets a one-line change here, outside amd#5240's
hunks.
- amd#5243: Memory with neutral stat figures, brass switches instead of
green, and no per-tile hues.
- amd#5245: live checklist with each step's time, a shimmering live step,
and sans labels.
- amd#5269 / amd#5266: a raised user bubble, 15px answer prose, path chips and
the answer footer.
- amd#5244: AdvancedSettings headings in sentence case, and warning status
text with its icon.
- amd#5246, amd#5241, amd#5275, amd#5283, amd#5239: side rail, queue rows, context
panel, session panel and turn changes adopt the type and elevation
tokens.
- New behaviour, each its own PR: resizable panes, chapter bars (amd#5271),
the outer-only icon shadow wrapper, and Linux baselines plus a CI job
for `test:visual`.
- TUI: brass that survives 256-colour rounding, re-unifying the accent
(amd#5291).
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
github-merge-queue Bot pushed a commit that referenced this pull request Oct 19, 2026
… limit (#5270)

Choosing Fireworks AI or the AMD LLM Gateway said only "Usage may incur
charges", and you found out what a chat cost only after spending it. Now
setup and Settings › Model show each cloud model's list price per
million tokens before you pick it, from the same rate card the per-turn
cost estimate reads, and a model with no known price says "price
unknown", never $0. Settings › Model also shows this month's cloud
spending with an optional monthly limit: it warns near the limit, and
once it's reached GAIA stops before sending a chat to the cloud and says
how to go on. Lands after v0.25.0.

Closes #5258

- **Overlap:** #5244 also edits Settings › Model, the composer's model
chip and the providers router; expect small conflicts in those files,
nothing structural. #5246 estimates each turn's cost from the same
`gaia.eval.bench.metering` rate card, so the price before a pick and the
cost after a turn agree; this PR adds no second price table.
- **Limits of the estimate:** the total counts Agent UI chats at list
price without cache discounts, so it can read higher than the bill;
turns that fail or are stopped before a reply aren't counted, so it can
also read lower. Both are stated in Settings and the docs. The AMD LLM
Gateway's prices are set by the organization that runs it, so its turns
are counted apart rather than as $0; they are still stopped once the
limit is reached.

## Screenshots

From the running app (a throwaway GAIA home with a seeded $0.50 spend,
so nothing went to a cloud provider).

| Fireworks prices, before connecting | Gateway: price unknown, and why
|
|---|---|
| <img
src="https://raw.githubusercontent.com/kovtcharov/gaia/pr-5270-screenshots/prices-before-connecting.png"
width="460"> | <img
src="https://raw.githubusercontent.com/kovtcharov/gaia/pr-5270-screenshots/gateway-price-unknown.png"
width="460"> |

| Limit reached in Settings › Model | A cloud chat stopped at the limit
|
|---|---|
| <img
src="https://raw.githubusercontent.com/kovtcharov/gaia/pr-5270-screenshots/settings-limit-reached.png"
width="460"> | <img
src="https://raw.githubusercontent.com/kovtcharov/gaia/pr-5270-screenshots/chat-stopped-at-limit.png"
width="460"> |

## Test plan

- [x] `python -m pytest tests/unit/chat/ui` (1,581 passed, including the
new `test_spending.py`: prices from the shared rate card, unknown prices
never $0, the monthly total, the limit states, and both chat paths
stopping before a cloud turn)
- [x] `npx vitest run` and `npx tsc --noEmit` in `src/gaia/apps/webui`
(859 passed); Electron `npx jest` in `tests/electron` (847 passed)
- [x] `python util/lint.py --black --isort --flake8 --pylint`
- [x] Running app (fresh GAIA home, backend on 4305): Fireworks prices
shown before connecting; with $0.50 spent against a $0.50 limit, a chat
on a Fireworks model is answered with the stop message and nothing is
sent; Settings shows the total, the stopped state and "Allow more this
month"; the gateway tab says "Price unknown" and why
- [ ] A real paid Fireworks turn records its cost in the month's total
(not run; the recording path is unit-tested)
- [ ] Setup's cloud step shows prices before the key (covered by vitest;
the running app's setup check could not run in this test setup)

<details>
<summary>🔍 Technical details</summary>

- `src/gaia/ui/spending.py`: `price_card` / `price_list` read
`gaia.eval.bench.metering.rate_card`/`RATES`; `record_turn` writes a
`cloud_spend` row (new table in the chat DB, `usd` NULL when unpriced)
after each streamed turn; `limit_refusal` runs right after the turn's
model is resolved, in both `_stream_chat_impl` and `_get_chat_response`.
A refused streamed turn is saved as the assistant's reply and closes
with the normal `answer` and `done` events.
- Limit and the allowed month live in the Agent UI settings table; a
non-numeric saved limit is a 500 that names the fix.
- New routes: `GET /api/spending`, `PUT /api/spending/limit`, `POST
/api/spending/allow-month`, `GET /api/spending/prices/{provider}`. Cloud
models from `GET /api/providers/{provider}/models` carry `price`.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 19, 2026
…ing up (amd#5317)

Before: on a busy machine the Agent UI's 5 s status poll stacked a new
request behind every slow one, and the banner then said the model server
had stopped, or that the connection to GAIA was lost, when both were
only busy. After: one status request runs at a time and the poll backs
off while answers are slow. A backend that keeps answering late reads
"GAIA is slow to answer". A model server that is listening but slow
reads "not answering, may be busy", keeps the reason, and offers the
restart command only for if it stays that way. "Stopped responding" and
"Lost the connection" now mean nothing is listening. Check again shows
"Checking…" until it answers. Lands after v0.25.0.

Reproduced by `src/__tests__/App.statusPoll.test.tsx`: on main, 5 status
requests are in flight at once, 13 probes run in 60 s against a busy
server, and the busy wording never appears. All pass here.

## Test plan
- [x] `npx vitest run` in `src/gaia/apps/webui`: 872 passed; `npx tsc
--noEmit` clean
- [x] `App.statusPoll.test.tsx` (6), `ConnectionBanner.test.tsx` and
`statusPoll.test.ts`: three timeouts in a row read as slow, not lost; a
45 s answer is accepted; stopping the poll aborts the request in flight
and reports nothing; Check again shows progress
- [x] Live, Vite :5319 against a fake backend: with a busy model server
the probes ran at 0, 11 and 32 s, and the banner read "The model server
is not answering (Lemonade health query failed)... If it stays this way,
restart it: ...". With 45 s status answers there was never more than one
request in flight.

<details>
<summary>🔍 Technical details</summary>

- `services/statusPoll.ts`: single-flight `check()`, a `setTimeout`
chain, a 60 s `AbortSignal` per request (the status handler's sequential
probes, health 10 + models 10 + catalog 5 + stats 3 + system-info 3,
already exceed 30 s), backoff 5→10→20→30 s while slow. A generation
counter keeps a StrictMode double start from making two chains.
- "Unresponsive" is `lemonade_running: false` with `lemonade_error` set.
The backend sets that for a probe timeout as well as for a non-200
answer or an `httpx.ConnectTimeout`, so the banner keeps the remedy. A
backend field telling these apart, and a bound on the handler's total
time, are with the UI-backend reliability session.
- Outcomes: a refused request, or a 502 from a proxy or tunnel with
nothing behind it, is unreachable; a 500/503 is "answered with an
error"; a timeout or a gateway 504 is slow (five minutes of it is lost).
- Merge note: amd#5244 removes the `setDetectedDevices` line that moved
into `applyStatus`, a one-line conflict in App.tsx.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
The model picker's context-size and status routes push api.ts past the
50 KB ceiling shared with the store, types and App. It is the single client
for every backend route, so it gets 64 KB; the other three stay at 50 KB.
# Conflicts:
#	src/gaia/apps/webui/src/types/api.gen.ts
#	src/gaia/apps/webui/src/types/api.schemas.json
Saving a per-model context size now goes through the same locked, atomic
config write main adopted in amd#5388, so it can no longer clobber a key
another GAIA process saved at the same moment, or overwrite a corrupt
config.json. GaiaConfig.edit_doc does the locked read-modify-write and
validates the result before writing.
@kovtcharov-amd kovtcharov-amd added the ready_for_ci Run CI workflows on draft PR without requesting review label Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Request changes (one small fix)

This PR makes the model picker report where each model really runs, offers only models this PC can run, adds a per-model context-size choice, and turns the sidebar pill into a live status view with Restart. The design is careful: your own Lemonade is never started or reloaded without confirmation, and a saved context size that no longer fits is refused at load with a fix. One thing needs fixing before merge.

  • Restart can fail silently when the server is stopped. If GAIA can't start its own Lemonade, the popover just goes back to "stopped" with no error, so the user can't tell anything went wrong. That breaks the project's fail-loudly rule. Treat a failed start as an error so it shows up in the popover.

Real-world evidence

N/A here. No evidence bundle was produced for this run. The PR description includes rendered screenshots from a Strix Halo of Settings › Model, the composer picker, and the status popover (stopped, and the Restart confirmation on your own Lemonade), which covers the Agent UI surface. Two items are still unchecked: a confirmed Restart against a live server, and picking a model mid-reply. For those, this verdict rests on the unit tests and static review.

🔍 Technical details

🟡 Restart ignores a failed server start (src/gaia/ui/routers/providers.py, _restart_job)
LemonadeManager.ensure_ready() reports failure by returning False (for example after a DaemonError, a failed _autostart, or when the server is still not running after auto-start). It does not raise. _restart_job discards that return value, so _restart_error stays None. /local/status then reports stopped with no restart_error, and the user gets no explanation. Add a test for the server_up=False path where ensure_ready returns False.

        else:
            if not LemonadeManager.ensure_ready(quiet=True, model=model_id):
                raise RuntimeError(
                    "the model server did not start; see the GAIA log for why"
                )

🟢 "Automatic" can trigger a reload that changes nothing (set_context)
set_context compares loaded_ctx to view["automatic"], which is context_for_capacity. A real load also runs fit_ctx_to_free_memory, which can shrink the window. When memory is tight, the loaded window is smaller than automatic, so going back to Automatic reloads the model at the same size it already has. This is low impact, since the reload is guarded and runs in the background, but it stalls chat for nothing.

🟢 Cloud model passed to PUT /local/context saves before it is rejected
save_context_size(model, None, …) runs first. Only afterwards does _context_view raise 422 for a non-local model. Moving the provider_of(model_id) != LOCAL check to the top of set_context rejects the request before anything is written.

Strengths

  • Placement is honest: the device is labelled reported (from /health) versus expected (from the recipe), and a GPU→CPU fallback gets a plain warning. A loaded model is never hidden by the fit estimate.
  • A saved context size that no longer fits is refused at load with an actionable message, and GAIA_CTX_SIZE still wins as an escape hatch. Writes to config.json go through a locked, validated edit_doc.
  • The "not GAIA's server" rule is applied consistently in three places: Restart needs confirm, a stopped user server is never started, and a context change never reloads there. Unit tests cover these paths using recorded /system-info and /health bodies.

Resolving the load's context size now reads the saved per-model size,
and that read takes the config file lock, whose timeout clock consumed
the test's fake monotonic values. Stub the saved-size lookup so the
test measures only the load.
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

The model picker now shows where each model really runs, offers only models this PC can run, names the model a new chat actually starts on, and adds a saved per-model context size plus a live status popover with Restart. The backend is careful: a saved size that no longer fits is refused at load, not loaded into an out-of-memory crash, and GAIA never starts or silently reloads a Lemonade server the user runs themselves. Tests are thorough.

One edge case is worth fixing before merge:

  • Restart can race the new-chat warm-up while no model is loaded yet. Restart only counts as "busy" once Lemonade lists a loaded model. During a warm-up's first load, nothing is listed yet, so the popover enables Restart and the server starts a second, forced load of the same model next to the warm-up's load. The context-size change already avoids this; Restart should refuse the same way whenever a warm-up is running.

Real-world evidence

N/A: no evidence bundle was produced for this run. The PR description embeds screenshots from a running Strix Halo app: Settings › Model, the composer picker, the status popover in the stopped state and in the confirm-before-restart state on the user's own Lemonade, and the chip before the first chat. That covers the Agent UI surface. Three items are still unchecked in the test plan: a confirmed live Restart, the no-NPU PC, and a mid-reply model pick. For those, the verdict rests on static review and the unit and vitest coverage.

🔍 Technical details

🟡 Restart ignores a warm-up when no chat model is loaded yet (src/gaia/ui/routers/providers.py:1184)
busy_reason is computed only if entry. If the warm-up is mid-load and /health has no chat entry yet, the code falls through with model_id = active["model"] and starts _ensure_model_loaded(model_id, force=True) in parallel with the warm-up. The UI won't stop this. ModelStatusPill disables Restart on s.busy, and local_status sets that only when an entry exists, even though it reports state: "warming". set_context is safe because it only reloads when loaded_ctx is set.

        warming = _warming_up()
        busy_reason = _busy_reason(entry, warming) if entry else ("warm_up" if warming else None)

Add a test like test_warm_up_is_reported_as_getting_ready_not_answering but with lemonade.loaded = []. Consider also setting busy/busy_reason in local_status when entry is None and warming, so the button disables.

🟢 Corrupt config in the model list falls back quietly (providers.py, _suggested_local_models)
On GaiaConfigError, the list logs a warning and uses DEFAULT_MODEL_LADDER[-1]. /active does surface the error, so this isn't silent to the user. Still, /local/models already returns 500 for the same corrupt config through _preferred_backend, so this fallback only takes effect on cloud lists, where suggested isn't used anyway. It looks like dead code you could drop.

🟢 set_context saves before it re-reads (providers.py, set_context)
If _context_view fails after save_context_size succeeds (Lemonade drops between the calls), the client gets an error even though the size was persisted. This is minor: a retry is idempotent.

Strengths

  • _chosen_ctx_size refuses to load unchecked when memory can't be read, and lets GAIA_CTX_SIZE rescue a saved size that no longer fits. That is a clean application of the fail-loudly rule.
  • Where a model runs is reported, not assumed: Lemonade's /health for a loaded model, the recipe beforehand, and a plain warning when a GPU model fell back to the CPU. The tests are driven by recorded /system-info and /health bodies.
  • GaiaConfig.edit_doc is a locked read-modify-write that touches only the keys it changes, and gaia config set context_sizes is refused with a pointer to the UI. The docs (agent-ui.mdx guide and SDK, cli.mdx) are updated together and match the routes.

…start

Restart could race the new-chat warm-up while that first load had not
listed a model yet, starting a second forced load of the same model; it
now refuses the same way it does once the model is listed, and the
status popover disables the button then. A Restart whose server never
came up returned to "stopped" with no explanation; it now shows the
failure. A context-size change for a cloud model is refused before
anything is written to config.json.
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 19, 2026
Merged via the queue into amd:main with commit af653f0 Oct 19, 2026
52 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the claude/ui-model-picker-status-e6ffae branch October 19, 2026 20:02
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 19, 2026
…upport

Main's model picker (amd#5244) and default-ladder offers now sit alongside the
gpt-oss fit-filtered offers. The local list offers the ladder, the configured
default and the optional models that fit; an unregistered gpt-oss row carries
its recipe and size so the picker can show fit and download size; and
/api/providers/active stays a single /models read instead of also sizing
optional models.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation changes electron Electron app changes llm LLM backend changes performance Performance-critical changes ready_for_ci Run CI workflows on draft PR without requesting review tests Test changes

Projects

None yet

2 participants