Skip to content

fix(tui): check a cloud default model as cloud after Lemonade restarts - #5992

Merged
kovtcharov-amd merged 4 commits into
mainfrom
autofix/issue-5989
Oct 28, 2026
Merged

kovtcharov-amd merged 4 commits into
mainfrom
autofix/issue-5989

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

With an AMD LLM Gateway model saved as the default, launching the TUI after Lemonade had stopped showed the gateway model as "not downloaded — About 4 GB · f download it now", and re-check never cleared it. The launch check only recognised a cloud model when one was passed for this launch, so a cloud default fell into the local-download check. Now it is checked as a cloud model: the TUI hands the restarted Lemonade the saved gateway key, confirms the model is listed, and never describes it as a download.

Closes #5989

Test plan

  • cd tui && go test ./internal/ui/... passes, including a new test that reproduces the issue's exact "About 4 GB" row without the fix
  • python util/lint.py --all passes in CI (here only the two checks that need GAIA installed failed, on environment)
  • Manual: set an amd.* gateway model as default_model, stop Lemonade, launch gaia-tui. The model row should go green ("chat uses amd.…") with no download offer and no need to press p

⚠️ Needs manual validation: the automated checks cover the gate's logic with a stubbed daemon and Lemonade. Before merging, a maintainer should run the steps above on a machine with a saved gateway key.

🔍 Technical details
  • Root cause: the daemon-path check (tui/internal/ui/preflight/check.go, AI model section) branched to checkCloudModel only when cfg.Model was a cloud id. With a saved default_model the launch passes no model, the sidecar's /init reports amd.DeepSeek-V4.1-Flash with present:false (keyless Lemonade lists no amd.*), and the row fell through to the local FixPullModel / "About 4 GB" path.
  • Fix: when cfg.Model is empty and the sidecar's model id is a cloud id, use that id for the cloud check. The cloud check already replays the kept key through the daemon (replayKeptKey) before it calls the provider disconnected.
  • Removed Config.runsInCloud from local.go, since it no longer has callers.
  • New test TestDaemonGateTreatsACloudDefaultModelAsCloud in cloud_daemon_test.go. The existing TestDaemonGateStillRequiresTheLocalModelForALocalLaunch still confirms that a local default keeps its download gate.

With an AMD LLM Gateway model saved as default_model, a TUI launch after
Lemonade restarted offered the gateway model as a ~4 GB download, and
re-check never cleared it. The launch passes no model, so the gate only
looked for a cloud model in the launch's own model and fell through to
the local download check for the sidecar's (cloud) default. The gate now
treats a cloud sidecar default as cloud, so it hands Lemonade the kept
gateway key and confirms the model is listed.

Closes #5989
Covers the states around the fix: no kept key, a failed key replay and a
model the gateway does not list all ask for the provider instead of
offering a download; a launch's own cloud model outranks the saved
default; and a local model whose name only starts with amd or fireworks
keeps its download gate.
@kovtcharov-amd kovtcharov-amd added the ready_for_ci Run CI workflows on draft PR without requesting review label Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

Verdict: Approve with suggestions

This fixes a launch-check bug for people who saved an AMD LLM Gateway model as their default. After Lemonade restarted, the TUI showed that model as a ~4 GB download it couldn't fetch, and re-check never cleared it. The check now recognises a cloud default as a cloud model, gives the restarted Lemonade the saved key back, and confirms the model is listed. The fix is narrow and correct, local defaults keep their download check, and the new test reproduces the issue's exact row. Only a one-line comment tweak is suggested.

Real-world evidence

N/A: no evidence bundle was produced for this PR. The change is TUI preflight logic, and its real surface needs a saved gateway key and a stopped Lemonade, which this runner doesn't have. The verdict rests on static review plus go test ./internal/ui/preflight/, which I ran here and which passes. The PR's manual step (gateway default_model, stop Lemonade, launch gaia-tui) is still unchecked and should be run before merge, as the author notes.

🔍 Technical details

Issues found

🟢 Stale lead comment (tui/internal/ui/preflight/check.go:776). The block still opens with "The sidecar reports on its default LOCAL chat model", but the new line under it says the sidecar's model can be a cloud default. Folding them into one comment reads cleaner:

	// The sidecar reports on GAIA's default chat model, which a cloud launch never
	// loads, so ask whether the cloud model can answer. A cloud default_model
	// arrives as the sidecar's model, not cfg.Model.

Checked, no issue

  • body.Model.ID is only used when cfg.Model == "", so an explicit local --model still overrides a cloud default and goes through the local gate. TestDaemonGateStillRequiresTheLocalModelForALocalLaunch still covers the local-default case.
  • Removing Config.runsInCloud leaves no dangling callers. The non-daemon path in local.go:799 still uses lemonade.IsCloudID(l.opts.Model) directly.
  • go test ./internal/ui/preflight/ passes locally.

Strengths

  • The fix sits at the branch point where the bug starts and reuses checkCloudModel and its key replay, with no new path.
  • The new test asserts what the user actually saw (no FixPullModel, no "4 GB" detail) and that the key was replayed, not just that the row passed.

@github-actions github-actions Bot added the tui Go terminal UI (gaia-tui) label Oct 28, 2026
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

I checked this against the issue's exact state: on main, a gateway default with a keyless Lemonade shows the "About 4 GB" download row, and with this fix the saved key is handed back and the row goes green. The key never reaches the TUI. The daemon reads it from the credential store and replies with only authenticated: true/false. Nothing logs it, and no launch command changed.

I added tests that try to break it, and they pass. When there's no kept key, the replay fails, or the gateway doesn't list the model, the row asks you to connect the provider and never offers a download. A cloud model passed at launch still wins over the saved default. A local model whose name merely starts with amd or fireworks keeps its download prompt.

One gap I left out of this PR: if the saved default is a gateway model and you launch on a picked local model, the gate still reports the gateway model as "not downloaded, About 4 GB". That's a different launch setup from #5989, so it belongs in a follow-up.

🔍 Technical details
  • New tests in cloud_daemon_test.go: TestDaemonGateNeverOffersACloudDefaultAsADownload (3 subcases), TestDaemonGateChecksTheLaunchCloudModelOverACloudDefault, TestDaemonGateKeepsTheDownloadForALocalLookalikeDefault. The first one and the PR's own test fail with check.go/local.go reverted to main.
  • The follow-up gap: cfg.Model is a local id and body.Model.ID is amd.* with present:false, so the code falls into the !body.Model.Present branch, which sets FixPullModel. Picking a local model doesn't clear a gateway default_model, so users can reach this state.
  • I merged main in with no conflicts. go vet and go test ./... pass in tui/. On Windows, tui/test's two full-access flag tests timed out under the parallel run and pass on their own.
  • I didn't do a live run with a real gateway key. The replay reads the OS credential store, which a temp HOME doesn't isolate.

@kovtcharov-amd
kovtcharov-amd marked this pull request as ready for review October 28, 2026 23:35
@kovtcharov-amd
kovtcharov-amd self-requested a review as a code owner October 28, 2026 23:35
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit 4073add Oct 28, 2026
74 of 75 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the autofix/issue-5989 branch October 28, 2026 23:36
@github-actions

Copy link
Copy Markdown
Contributor Author

Verdict: Approve

When an AMD LLM Gateway model is saved as the default, the TUI's launch check now treats it as a cloud model. It no longer offers it as a "~4 GB download" after Lemonade restarts. The fix is small and targeted: a model passed for this launch still wins, and only a real provider-prefixed id counts as cloud. The new tests cover each of those cases, plus the three ways a cloud default can fail to connect. I found no blocking issues.

Real-world evidence

N/A: no evidence bundle was produced for this run. The verdict rests on static review and the package's Go tests, which I re-ran here and which pass (go test ./internal/ui/preflight/ → ok). The PR's manual check is still unticked: saved gateway key, Lemonade stopped, launch gaia-tui, and the model row goes green. Someone should run it on a machine that has a gateway key.

🔍 Technical details

Issues found

🟢 A local model passed at launch, with a cloud default, still gets a download row (tui/internal/ui/preflight/check.go:779-782). If cfg.Model is a local id while the sidecar reports a cloud default_model, chat stays local and the code drops into the !body.Model.Present branch. That branch prints amd.… not downloaded and "About 4 GB" for the cloud id. This isn't new, and it may not happen in practice if the sidecar's /init reflects the launch model. It's worth a follow-up test either way, because it's the same kind of mismatch #5989 hit.

Strengths

  • TestDaemonGateKeepsTheDownloadForALocalLookalikeDefault tests prefix-lookalike ids (amdgpu-…, AMD-…, fireworks-mini-…). That guards the obvious over-match regression.
  • The failure-mode table (no kept key / replay error / model not listed) checks the remedy text as well as the state, so a user who isn't connected is always told to press p and is never told to download.
  • runsInCloud was deleted once nothing called it, so no dead helper is left behind.

grtninja pushed a commit to grtninja/gaia that referenced this pull request Oct 29, 2026
…del (amd#6017)

With an AMD LLM Gateway model saved as the default, launching the TUI on
a picked local model listed the gateway model as "not downloaded — About
4 GB" and blocked the launch on a download it would never use. Now the
model row checks the local model you picked: it goes green when that
model is on disk, and if it isn't, the row names that model, not the
cloud one. This is the local-launch half of amd#5992, which covers
launching on the gateway model itself.

Closes amd#6016

## Test plan

- [x] `cd tui && go test ./internal/ui/...` passes, including a new test
that reproduces the issue's exact "amd.… not downloaded — About 4 GB"
row without the fix
- [ ] `python util/lint.py --all` passes in CI (here GAIA wasn't
installed, so the two checks that import it failed for that reason)
- [ ] Manual: set an `amd.*` gateway model as `default_model`, launch
`gaia-tui` on a downloaded local model (e.g. Gemma-4-E4B). The model row
should read "downloaded — chat uses Gemma-4-E4B-it-GGUF", with no
download offer

> ⚠️ **Needs manual validation:** the automated checks cover the gate's
logic with a stubbed daemon and Lemonade. Before merging, a maintainer
should run the manual step above on a machine with a saved gateway key.

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

- Root cause: the daemon-path model row in `probeInit`
(`tui/internal/ui/preflight/check.go`) reads `body.Model` from the
sidecar's `/init`, which names the saved `default_model`. With a cloud
default and a local `cfg.Model`, that cloud id came back
`present:false`, so the row fell through to the local `FixPullModel` /
"About 4 GB" branch.
- Fix: when `cfg.Model` is a local pick and the sidecar's model is a
cloud id, the row comes from `checkLocalModelDownloaded`, the existing
on-disk check pulled out of `localRunner.checkPickedModel` in
`local.go`.
- Scoped to a cloud sidecar model, so a local default under a local pick
behaves as before (context-window reporting included).
- Touches the same block as amd#5992, so whichever merges second needs a
small rebase. The two changes don't overlap in logic: amd#5992 handles an
empty `cfg.Model`, this one a local `cfg.Model`.
- New test: `TestDaemonGateChecksThePickedLocalModelOverACloudDefault`
in `cloud_daemon_test.go` covers both the downloaded and the missing
pick.
</details>

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Kalin Ovtcharov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready_for_ci Run CI workflows on draft PR without requesting review tui Go terminal UI (gaia-tui)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TUI says a gateway model needs a 4 GB download after Lemonade restarts

1 participant