Skip to content

fix(tui): stop the AI provider screen reporting faults that aren't there - #4505

Merged
kovtcharov-amd merged 2 commits into
amd:mainfrom
kovtcharov:fix/tui-provider-screen-4503
Oct 1, 2026
Merged

kovtcharov-amd merged 2 commits into
amd:mainfrom
kovtcharov:fix/tui-provider-screen-4503

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Three things on the AI provider screen told users something untrue. On a new machine, pressing p before setup installed Lemonade showed "Lemonade did not respond… Start it", a fault for a step they hadn't reached. A Fireworks key Lemonade already held (LEMONADE_FIREWORKS_API_KEY) still showed "Paste API key", though Enter connected. And the setup text said keys are lost when Lemonade restarts, which stopped being true with #4485. Now the picker names the setup step that installs Lemonade and waits for it, the key field says "A key is already set — Enter connects", and the text says the key is kept in the OS credential store.

Past setup, an unreachable Lemonade still reports the fault as before.

Closes #4503

🔍 Technical details
  • Lemonade lists a provider in /system-info, and so reports env_var_set, only after POST /install registers it. That's why the env key was invisible. Opening Fireworks setup now registers it with the same fixed settings Connect sends (no key), re-runs the kept-key restore, then re-reads providers. I confirmed this against a real lemond 2026.39.1: providers: [] before, env_var_set: true after.
  • lemonade.ErrUnreachable is now a sentinel. Root passes Report.LemonadeStep() into the panel via WithSetupStep, so the wording follows the real step number.
  • A failed provider read no longer wipes the known key states. This came out of review.
  • tui/README.md and docs/guides/ai-providers.mdx are updated to match.

Test plan

  • cd tui && go build ./... && go vet ./... && go test ./... — all pass; gofmt -l clean after CRLF strip
  • New frame tests in tui/internal/ui/providers/setup_state_test.go: step message before setup, fault after setup, "A key is already set" against a fake Lemonade that lists Fireworks only once registered, credential-store wording at both panel heights
  • Fresh GAIA_HOME first run, driven over the control API, p on the setup gate: before shows "Lemonade did not respond"; after shows "Lemonade isn't installed yet — setup step 1 installs it" and Enter does nothing
  • Real lemond started with LEMONADE_FIREWORKS_API_KEY, /provider → Fireworks: before shows "Paste API key" plus "Keys stay in Lemonade memory until it restarts"; after shows "A key is already set — Enter connects" plus the credential-store line

On a new machine, opening the provider picker before setup installed
Lemonade said "Lemonade did not respond", a fault for a step the user had
not reached. It now names the setup step that installs Lemonade and waits
for it. A Fireworks key Lemonade already held (LEMONADE_FIREWORKS_API_KEY)
still showed "Paste API key", because Lemonade reports a provider's key
only once the provider is registered. Opening Fireworks setup now
registers it (no key sent), restores any kept key, and says "A key is
already set — Enter connects". The setup text no longer claims keys are
lost when Lemonade restarts.

Closes amd#4503
@github-actions github-actions Bot added documentation Documentation changes tui Go terminal UI (gaia-tui) labels Sep 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

The AI provider screen stops showing faults that aren't real. On a new machine it names the setup step that installs Lemonade, where before it said "Lemonade did not respond". A Fireworks key that Lemonade already holds now shows as set, not "Paste API key". The setup text now says pasted keys go to the OS credential store, not that they're lost on restart. The logic is sound and well tested, and a real unreachable Lemonade after setup still reports the fault. Nothing blocks the merge.

Two small things worth knowing:

  • Just opening Fireworks setup registers Fireworks on the shared Lemonade server, even if the user presses Esc without connecting. The docs say so, and no key is sent, but it's a write from a screen that looks read-only.
  • If the user presses Enter very quickly, a provider read started when the panel opened can land after the registration. That would briefly put "Paste API key" back.

Real-world evidence

N/A — no evidence bundle for this run; the change is a Go TUI surface. The PR description reports two manual runs driven over the TUI control API: a fresh GAIA_HOME first run, and a real lemond 2026.39.1 started with LEMONADE_FIREWORKS_API_KEY. Each has before/after wording, but only as text, with no screenshots. I re-ran the Go tests for the changed packages here and they pass:

ok  	github.com/amd/gaia/tui/internal/ui/providers	0.022s
ok  	github.com/amd/gaia/tui/internal/ui/preflight	8.851s
ok  	github.com/amd/gaia/tui/internal/lemonade	0.017s

Apart from those tests, the verdict rests on static review; I did not drive the TUI myself.

🔍 Technical details

Issues found

🟢 Opening setup writes to a shared server (tui/internal/ui/providers/model.go:166, called from the enter branch at :273)
register() sends POST /install for Fireworks as soon as the setup stage opens. If the user then presses Esc, Fireworks stays registered for every client of that Lemonade. This is harmless (no key, the same fixed settings Connect sends) and ai-providers.mdx documents it. If you'd rather not write on view, you could register only when the user reaches the key field with nothing typed. Otherwise fine as is.

🟢 Possible stale-read race (tui/internal/ui/providers/model.go:208-238)
The loadedMsg handler takes whichever provider read arrives last. Suppose the panel's Init() read (served before /install) arrives after register()'s read. It then overwrites m.providers with [] and puts the placeholder back to "Paste API key". This needs Enter pressed before the first read returns, so it's unlikely. Tagging register's message, or ignoring reads older than the latest request, would close it.

🟢 Restore result discarded (tui/internal/ui/providers/model.go:173)
restoreKey(p.Name) throws its result away (persist.go:49-52 uses _, _ =). That pattern already existed, but this PR adds a new caller. If the restore fails, the user only sees "Paste API key", with no reason.

Checked and fine

  • LemonadeStep() is non-zero only when the Lemonade row is FirstRun. That flag is set only when nothing is installed (preflight/local.go:366-368). So the "isn't installed yet" wording can't show up for an installed Lemonade that is just stopped or failing.
  • The panel says "press enter to start it", which matches the preflight key binding (preflight/model.go:569, where Enter starts a FirstRun step).
  • Keeping the known providers when a read fails (v.err == nil || v.providers != nil) fixes the old behavior, where one failed read forgot every key. TestFailedRegistrationKeepsKnownProviders covers it.

Strengths

  • Making ErrUnreachable a sentinel checked with errors.Is is the right way to branch on "not set up yet" versus "down". It keeps the wording decision out of the HTTP client.
  • registeringLemonade models the real Lemonade quirk: a provider is listed only after /install. The test also asserts that opening setup never calls /cloud/auth, so it checks the shape of the call, not just that a call was made.
  • The docs (tui/README.md, docs/guides/ai-providers.mdx) and the in-panel text were updated together, with tests guarding both panel heights against the old "until restart" wording.

A provider read sent when the panel opened could land after the read that
followed registering Fireworks, putting "Paste API key" back for a key
Lemonade holds. Each read now carries when it was sent, and an older one
is dropped.
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 1, 2026
Merged via the queue into amd:main with commit b350a99 Oct 1, 2026
46 of 48 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the fix/tui-provider-screen-4503 branch October 1, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation changes tui Go terminal UI (gaia-tui)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(tui): the provider screen misleads new users — 'did not respond', 'paste a key', 'until it restarts'

2 participants