Skip to content

fix(lemonade): ignore a dead embedded server's leftover state file - #4284

Closed
github-actions[bot] wants to merge 2 commits into
mainfrom
autofix/issue-4281
Closed

github-actions[bot] wants to merge 2 commits into
mainfrom
autofix/issue-4281

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

A gaia lemonade embedded server that was killed, crashed, or lost to a reboot left
behind a state file naming the port it once held — and every GAIA client read that file
ahead of the default. From then on gaia llm, the Agent SDK, and the API server all
dialled a port with nothing on it and reported Lemonade as down, while a perfectly
healthy server answered on 13305. The only cure was knowing to delete a file most users
have never heard of. Now that file is only honoured while the process it records is
actually alive; otherwise GAIA falls back to the normal endpoint and says so in a
warning that names the leftover file. This also unsticks the Windows Agent SDK CI lane,
which has been failing on three unrelated branches because a stale embedded port on the
persistent runner outvoted the server the setup step had just readied.

Closes #4281

Test plan

  • python -m pytest tests/unit/ -x passes
  • python util/lint.py --all passes
  • With no embedded server running, write ~/.gaia/lemonade/state.json containing
    {"pid": 999999, "port": 59939, "api_key": "x"}, then run gaia llm "hello" —
    it must reach the real server (13305 / LEMONADE_BASE_URL), not 59939, and log a
    warning naming the file.
  • Start a real embedded server (gaia lemonade embedded start) and confirm
    gaia llm "hello" still reaches its chosen port with its own API key — the gate
    must not cost a genuinely running instance.
  • On actions-runner-01, re-run Test Agent SDK on Windows (Lemonade Integration)
    without deleting C:\Users\Administrator\.gaia\lemonade\state.json and confirm
    the tests now dial the port the setup step readied.

⚠️ Needs manual validation — the checks here prove no Python regression and cover
the resolution logic, but they cannot exercise a real lemond daemon or the Windows
self-hosted runner. A maintainer should run the last three boxes above before merging.

🔍 Technical details

Root cause. _read_embedded_lemonade_state() (src/gaia/llm/lemonade_client.py)
validated only that port was an int in 1..65535 — no pid check, no health probe, no
timestamp — and _get_lemonade_config() preferred its result over
DEFAULT_LEMONADE_URL whenever LEMONADE_BASE_URL was unset. The asymmetry was the
bug: state.json already records a pid, and EmbeddedLemonade.status() does the full
job (health probe → _daemon_alive(pid) → _clear_state()), but the client-side reader
bypassed all of it. The manager cannot fix this from its own side — a SIGKILL or a
reboot gives it no chance to clear the file — so the reader-side check is the one that
closes the hole.

The fix. _read_embedded_lemonade_state() now requires
_embedded_lemonade_alive(state["pid"]) before returning the state. That single gate
covers both consumers — _embedded_lemonade_url() and _embedded_lemonade_api_key() —
so a dead instance stops donating its port and stops donating its credential
(credentials naming a dead port are worse than none: the next process to grab that port
inherits the trust). The reader does not delete the file; status() still owns clearing.

Why a second liveness implementation. _embedded_lemonade_alive() repeats
EmbeddedLemonade._daemon_alive's rule — match the image name, not mere existence, so a
recycled pid is never mistaken for the daemon — but on psutil (already a module-level
import here) rather than ps/tasklist. This runs on the base-URL resolution path,
which every client construction and UI health poll crosses; a subprocess spawn per
request would be a real cost, on Windows especially. It fails closed: an unidentifiable
pid counts as gone, so an unverifiable state file loses to the documented default. The
docstring records the intentional divergence.

Verified that the recorded pid really is a lemond image and not a wrapper — start()
Popens self.daemon_path (dist/<version>/lemond[.exe]) directly and stores
process.pid, so psutil.Process(pid).name() is lemond/lemond.exe. status() only
consults _daemon_alive after a health probe, so it would have masked a wrong image
name; this path would not, which is why it was checked explicitly.

Verification. Both directions were exercised against real processes, not mocks: a
reaped pid and a live non-lemond pid (a recycled-pid stand-in) both fall back to
http://localhost:13305/api/v1 with no key; a real process whose image name is lemond
is still honoured on its own port with its own key. tests/unit/test_lemonade_client_api_key.py
gains TestStaleEmbeddedState for the gate itself, the warn-once behaviour, and the
fail-closed pid validation. Three existing tests wrote state files with no pid (or a
placeholder pid: 1) and asserted the embedded endpoint wins; they now record a pid and
stub liveness, since no test can produce a real lemond.

Scope note. The issue also suggested a workflow-level assertion or exporting
LEMONADE_BASE_URL in CI. Both were interim unblocks for the stale file; with the reader
fixed, the runner no longer needs hand-cleaning, so the workflows are left alone.

docs/guides/ai-providers.mdx is updated too: its credential-resolution paragraph
promised the state file applied to "the matching local HTTP server and port" with no
liveness caveat, which this change narrows.

A killed or crashed `gaia lemonade embedded` cannot clear
~/.gaia/lemonade/state.json, and every client read that file ahead of the
default — so `gaia llm`, the Agent SDK and the API server all dialled the
port it once held and reported Lemonade as down while a healthy server
answered on 13305. The only cure was deleting a file users have never heard
of; on the persistent Windows runner it failed the Agent SDK lane on three
unrelated branches.

The state file is now honoured only while the pid it records is still a live
lemond. Gating inside the reader covers the credential path too, so a dead
instance stops donating its API key as well as its port, and the fallback
warns once naming the file instead of failing silently.

Liveness is checked with psutil rather than reusing
EmbeddedLemonade._daemon_alive: this sits on the base-URL resolution path
that every client construction and UI health poll crosses, where ps and
tasklist would mean a subprocess per request. It keeps the same image-name
rule, so a recycled pid never passes, and fails closed.

Closes #4281

@kovtcharov-amd kovtcharov-amd 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.

The fix is correct — I verified it end-to-end against real processes, not mocks. But the regression tests don't actually catch the bug: I reintroduced #4281 in one line and the whole suite stayed green.

The four tests that prove "a stale file no longer hijacks the endpoint" all replace the liveness check with a lambda, so they only prove the resolver calls something. The two tests that run the real check feed it type-garbage and this test process's own pid. Nothing anywhere feeds it a pid that is genuinely gone — which is the one condition #4281 is about. Revert the fix and the tests go red, but only because the mocked symbol disappears; ship a fix that gets dead pids wrong and they stay green.

One unmocked test closes it — code below, it costs about a second and needs no fixture changes.

🔍 Technical details

The mutation. With this one change to _embedded_lemonade_alive — the exact #4281 behaviour, a dead daemon's state file honoured:

    try:
        return "lemond" in psutil.Process(pid).name().lower()
    except psutil.NoSuchProcess:
        return True          # <- bug reintroduced
    except (psutil.Error, OSError, ValueError):
        return False

pytest tests/unit/test_lemonade_client_api_key.py tests/unit/test_base_agent_lemonade_api_key.py tests/unit/test_lemonade_asr.py → 157 passed (the single failure is TestRealServer::test_real_transcription_round_trip, a pre-existing 401 on my box against a running Lemonade — unrelated).

Reverting lemonade_client.py to base instead gives 16 failures / 54 errors, but every one is AttributeError: module 'gaia.llm.lemonade_client' has no attribute '_embedded_lemonade_alive' from the monkeypatch.setattr in the fixtures — a missing-symbol error, not a behavioural failure.

The missing test. Spawns a process, waits for it, and uses the pid it just vacated, so the real psutil path runs against a pid that is genuinely gone:

def reaped_pid() -> int:
    """A pid that really is gone: spawned, waited on, and exited.

    Beats a made-up number — the liveness check runs for real against it, so
    the dead-state path is exercised end to end rather than mocked past.
    """
    process = subprocess.Popen(
        [sys.executable, "-c", "pass"],
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL,
    )
    process.wait(timeout=60)
    return process.pid


def closed_port() -> int:
    """A port nothing is listening on — the stale file's recorded port."""
    with socket.socket() as sock:
        sock.bind(("127.0.0.1", 0))
        return sock.getsockname()[1]


def test_a_dead_daemon_does_not_hijack_the_endpoint(self, tmp_path, monkeypatch, caplog):
    """Regression: a stale file made a healthy server on 13305 invisible.

    No stub on the liveness check — a fix that gets real dead pids wrong
    has to fail here.
    """
    monkeypatch.delenv("GAIA_HOME", raising=False)
    monkeypatch.delenv("LEMONADE_BASE_URL", raising=False)
    monkeypatch.delenv("LEMONADE_API_KEY", raising=False)
    monkeypatch.setattr(lc, "_WARNED_STALE_EMBEDDED_STATE", set())
    dead, port = reaped_pid(), closed_port()
    path = tmp_path / "state.json"
    path.write_text(
        json.dumps({"pid": dead, "port": port, "api_key": "stale-key"}),
        encoding="utf-8",
    )
    monkeypatch.setattr(lc, "EMBEDDED_LEMONADE_STATE", path)

    caplog.set_level(logging.WARNING, logger="gaia.llm.lemonade_client")
    assert lc.resolve_lemonade_base_url() == lc.DEFAULT_LEMONADE_URL
    assert lc._get_lemonade_config()[1] == lc.DEFAULT_PORT
    assert lc.resolve_lemonade_api_key() is None

    warning = "\n".join(
        r.getMessage() for r in caplog.records if r.levelno >= logging.WARNING
    )
    assert str(path) in warning and str(port) in warning and str(dead) in warning

Fails on the mutated build above; passes on this branch. It also subsumes test_dead_pid_does_not_change_the_base_url, test_dead_pid_does_not_hand_out_its_key and test_the_fallback_names_the_leftover_file — those three could keep their stubs or go, either way.

What I checked and found fine, running against this branch with real processes rather than stubs:

behaviour result
real reaped pid + closed port falls back to DEFAULT_LEMONADE_URL, key None
pid reuse — recorded pid now an unrelated live process falls back (image-name match, not mere existence)
state file with no pid key at all falls back, warns with pid None — fail-closed, and deliberate
LEMONADE_BASE_URL set alongside a stale file env still wins unconditionally
warning names path, port and pid, once per (path, pid)

psutil over importing EmbeddedLemonade._daemon_alive is the right call on the resolution path, and the docstring already says why — no import cycle either way, since lemonade_embedded only pulls gaia.logger and gaia.version.

Scope. The three existing test files and the ai-providers.mdx paragraph all had to move: the test files write state fixtures that would now read as stale, and the doc states the credential-resolution order this changes. Not scope creep.

One inverse failure mode, not a blocker. The client now decides liveness by pid alone, whereas EmbeddedLemonade.status() health-probes first and treats the process check as a second opinion. If psutil.Process(pid).name() ever raises AccessDenied — a lemond started elevated or under another user while the client is not — a live embedded server fails closed and every request silently moves to 13305. psutil's Windows name() has a snapshot fallback that usually avoids this, so it may never fire in practice; the warning at least names the file when it does.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Follow-up to my review above, with two things about CI.

The Windows job that reproduces this bug has never run on this PR. It skips drafts, so the only checks here are CodeQL and friends — a fix for a CI failure whose own CI never exercised it. Worth fixing before merge.

A manual run of that job on this branch did prove the fix, though — and more convincingly than a plain green tick would. The runner still had the poisoned state file on it, and the log shows the new warning firing against it: port 59939, the exact port from the #4281 report. The tests then ran on 13305 and passed. So this is not "no stale file happened to exist that day" — the stale path was genuinely taken and the fix stepped over it. That warning line is what makes the run readable; without it a pass would have been ambiguous.

One caveat on getting the job to run here: the ready_for_ci label alone won't do it on this workflow — it doesn't listen for labeled events, so the label only counts when a push or Ready for review fires. Pushing the extra test from my review above would be enough on its own.

🔍 Technical details

The gate — .github/workflows/test_agent_sdk.yml:47:

if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')

and its triggers on line 23:

    types: [opened, synchronize, reopened, ready_for_review]

labeled is absent, so adding ready_for_ci to an already-open draft triggers no new evaluation — the label is only read when one of those four events fires. workflow_dispatch runs do not attach to a PR's check list either, which is why this PR still shows no Agent SDK job despite the label being on it now.

The dispatched run — 36092298740, job 107937084883, workflow_dispatch on autofix/issue-4281, conclusion success:

test_basic_chat_sdk_functionality ...
WARNING | gaia.llm.lemonade_client._warn_stale_embedded_state | lemonade_client.py:148 |
Ignoring C:\Users\Administrator\.gaia\lemonade\state.json: embedded Lemonade is recorded
on port 59939 under pid 12372, which is not a running lemonade process. Falling back to
LEMONADE_BASE_URL or http://localhost:13305/api/v1. ...
🔄 Loading model: Gemma-4-E4B-it-GGUF...
✅ Model loaded
...
Ran 8 tests in 36.212s
OK

Every endpoint in the log is localhost:13305; no WinError 10061 anywhere. Against the failing run on #4186 (36086997346) which dialled 58491 and refused about a hundred times, the 1m2s vs 2m2s duration gap is just connection retries.

The runner is persistent, so C:\Users\Administrator\.gaia\lemonade\state.json is still sitting there with pid 12372 in it. It will keep being read — and keep being correctly discarded — on every future run until someone deletes it. That is the fix working as designed, but it also means the next run on that box is a repeat of the same proof rather than an independent one.

Still the gap from my earlier review: this run proves the shipped implementation behaves, not that the tests would catch it breaking. Reintroducing #4281 as a one-line change to _embedded_lemonade_alive leaves the whole suite green, because every endpoint-level test stubs that function out. The unmocked reaped-pid test above closes it.

@github-actions

Copy link
Copy Markdown
Contributor Author

Verdict: Approve

A leftover state file from a dead embedded Lemonade no longer redirects every client to a port nothing is listening on — the file is only trusted while the process it names is still a live lemond, and when it isn't, GAIA falls back to the normal endpoint and logs a warning that names the file and how to clear it. The gate sits in the one place both the port and the credential are read from, so a dead instance stops donating either, and a genuinely running one is unaffected.

Two things I looked at specifically and found sound: the state file has recorded a pid since the embedded server shipped, so there's no older-install shape that now gets ignored; and the recorded pid really is the daemon binary, not a wrapper, so matching on the image name holds. The one behaviour worth knowing: any pid the check can't positively identify counts as gone, so an unverifiable file loses to the default port rather than hijacking traffic — the right default here, and the reason the fix is safe to ship.

Nothing blocking. The manual boxes in the test plan (a real lemond lifecycle and the Windows self-hosted runner) still deserve a maintainer's pass before merge, as the description says.

Real-world evidence

evidence-bundle.md exercised both directions on this runner with real processes, not mocks — a listener actually bound to the recorded port, and a real process whose image name is lemond.

Stale file (dead pid recorded) — the recorded port saw zero requests, and the warning names the file:

$ GAIA_HOME=/tmp/ev/home gaia llm "ping"
WARNING | gaia.llm.lemonade_client._warn_stale_embedded_state |
  Ignoring /tmp/ev/home/lemonade/state.json: embedded Lemonade is recorded on port 59939
  under pid 59939, which is not a running lemonade process. Falling back to
  LEMONADE_BASE_URL or http://localhost:13305/api/v1. ...
# requests the listener on 59939 saw during that run:
(count: 0)

Same file naming a live lemond — still honoured:

$ GAIA_HOME=/tmp/ev/home gaia llm "ping"
# requests the listener on 59939 saw during that run:
      1 GET /api/v1/health

The HTTP API showed the same split on /api/system/status (200 both ways, route shape unchanged): the stale run withheld the state file's key (authorization=absent), the live run sent it. A spot check of three adjacent operations was clean, including gaia lemonade embedded status, which agrees with the new gate.

Deferred: the rendered Agent UI screenshot — pending strix-halo lane (no real inference on this runner). I could not run pytest in this environment (not installed), so the new unit tests rest on CI; the CLI and API behaviour above is observed, not inferred.

🔍 Technical details

Strengths

  • The gate lands in the single chokepoint (_read_embedded_lemonade_state, src/gaia/llm/lemonade_client.py:106), so both consumers — _embedded_lemonade_url and _embedded_lemonade_api_key — are covered without a second policy to keep in sync. Withholding the credential alongside the port is the right call: a key naming a recycled port is worse than no key.
  • Fail-loudly rather than a silent fallback: _warn_stale_embedded_state names the path, the port, the pid and the two ways out, and warns once because this is a per-request path. TestStaleEmbeddedState covers both directions, the warn-once behaviour, the fail-closed pid table, and — usefully — that the test's own live pid is not mistaken for lemond, which is the assertion that proves the check is identity-based and not existence-based.
  • Blast radius on existing tests was handled rather than worked around: the three tests that asserted "embedded endpoint wins" now record a pid and stub liveness, with a comment saying why a test can't produce a real lemond.
  • psutil was already a module-level import here, so no new dependency, and the docstring records why this doesn't reuse EmbeddedLemonade._daemon_alive.

🟢 Minor

  • One rule, two implementations (lemonade_client.py:83 and lemonade_embedded.py:706). The docstrings acknowledge the divergence and the perf reason is real, but the manager's ps/tasklist path is the one that can now drift — and it pays a subprocess with a 15s timeout for the same answer. Worth a follow-up making _daemon_alive delegate to the psutil helper (it's already a dependency there) so the image-name rule lives in one place; not for this PR.
  • An unidentifiable pid counts as gone, which also covers a daemon whose name the calling user can't read, or a pid from a different namespace (a container sharing ~/.gaia with a host-run server). Both fall back to the default port instead of the recorded one. That's the correct default, but the docstring's "cannot be identified" wording reads as "malformed pid" — a couple of words on the permission/namespace case would save a future reader the trace.

The existing regression tests replaced `_embedded_lemonade_alive` with a
lambda, so they pinned the wiring but not the check itself. Reintroducing
#4281 as a one-line change — `except psutil.NoSuchProcess: return True` —
left the whole suite green, which means a fix that got dead pids wrong
would have shipped unnoticed.

This test spawns a process, waits for it, and writes the pid it just
vacated into the state file, so the real psutil check runs against a pid
that is genuinely gone. Against the mutated build it is the only failure;
the other thirteen still pass.
@kovtcharov-amd
kovtcharov-amd marked this pull request as ready for review September 25, 2026 04:28
@github-actions github-actions Bot added documentation Documentation changes llm LLM backend changes tests Test changes performance Performance-critical changes labels Sep 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

Verdict: Approve

A killed or crashed embedded Lemonade used to leave behind a file that quietly redirected every GAIA client to a port with nothing on it — so gaia llm, the SDK and the API server all reported Lemonade as down while a healthy server answered next door. This PR only trusts that file while the process it names is genuinely running, and when it isn't, it says so in a warning that names the file and the command that fixes it. That's the right layer for the fix: a SIGKILL or a reboot never gives the server a chance to clean up after itself, so the reader has to be the one that checks.

Nothing blocking. Two small things worth a look: the "is this really the Lemonade daemon?" rule now exists in three places in the tree and will drift unless one of them becomes the owner, and the new warning also fires for people who deliberately point GAIA at a different server, where its advice ("start the embedded server") doesn't fit what they're doing.

One caveat the author already flagged and I agree with: this lane can't run a real lemond or the Windows self-hosted runner, so the last test-plan box — re-running the Windows Agent SDK lane without hand-deleting the leftover file — still needs a maintainer.

Real-world evidence

evidence-bundle.md exercised the CLI, the resolver, and the Agent UI backend on a no-inference runner, with fixtures built from real OS state (a spawned-and-reaped pid, a bound-then-closed port, and a real process named lemond). The before/after comparison against the pre-fix commit, on the same state file, is the convincing part:

$ GAIA_HOME=/tmp/ev/home PYTHONPATH=/tmp/ev/base/src python -c "..."   # BEFORE
base_url  : http://localhost:58125/api/v1     ← dead port
api_key   : stale-key                          ← credential for a port with nothing on it

$ GAIA_HOME=/tmp/ev/home PYTHONPATH=/home/runner/work/gaia/gaia/src python -c "..."   # AFTER
WARNING | ... | Ignoring /tmp/ev/home/lemonade/state.json: ... port 58125 under pid 10863 ...
base_url  : http://localhost:13305/api/v1
api_key   : None

The real gaia llm run shows the same warning and the fallback, and a state file naming a genuinely running lemond still keeps its port and its key — the gate doesn't cost a live instance. The bundle marks the Agent UI screenshot pending strix-halo lane and MCP/eval as N/A, which matches the diff; the underlying route and CLI evidence this lane could produce is present, so that's adequate for merge-time CI.

I also ran the affected suites locally: tests/unit/test_lemonade_client_api_key.py, test_lemonade_asr.py, test_base_agent_lemonade_api_key.py → 158 passed, 1 skipped.

The bundle's own observation — that the warning fires even when LEMONADE_BASE_URL wins the resolution — is real, and is the second nit below.

🔍 Technical details

Issues

🟢 The "is this pid our daemon?" rule now lives in three places (src/gaia/llm/lemonade_client.py:83)

_embedded_lemonade_alive() re-implements EmbeddedLemonade._daemon_alive (src/gaia/llm/lemonade_embedded.py:706), and src/gaia/ports.py:17 documents itself as making "the same identity check". The performance argument for psutil over ps/tasklist on the resolution path is sound and well documented — but it applies to the other copy too: _daemon_alive pays a subprocess with a 15s timeout for the identical answer, and lemonade_embedded has no import of lemonade_client, so the dependency direction is free. Worth a follow-up that puts the psutil check in lemonade_embedded and has both callers use it, so the rule has one home instead of three that must be kept in step.

🟢 The warning also fires for users who aren't using the embedded server (src/gaia/llm/lemonade_client.py:148)

With LEMONADE_BASE_URL set, _get_lemonade_config() short-circuits before _embedded_lemonade_url() — but resolve_lemonade_api_key() still calls _embedded_lemonade_api_key(), which reads the state and warns. So someone pointing GAIA at a remote or hand-started Lemonade, with an old state.json lying around, gets told to run gaia lemonade embedded start for a server they don't want. The message is accurate about what was ignored; only the remedy is off. Either skip the warning when the configured URL already wins, or soften the second half to make deleting the file the lead suggestion.

Strengths

  • The credential half matters as much as the port half. Gating _read_embedded_lemonade_state() rather than just _embedded_lemonade_url() means a dead instance stops donating its API key too — otherwise the next local process to grab that port inherits GAIA's trust. Good instinct to close both with one gate.
  • test_a_dead_daemon_does_not_hijack_the_endpoint is the test that actually protects this. The sibling tests stub _embedded_lemonade_alive and would stay green against a liveness check that calls dead pids alive; this one hands the real check a spawned-and-reaped pid and asserts the warning names the file, the port and the pid. The docstring says exactly that, which is the right thing to record.
  • Fail-closed is the correct default and is documented as a deliberate choice, along with the parametrized unusable-pid cases and the "this test process is not lemond" check — existence alone doesn't pass, so a recycled pid can't resurrect a dead instance.
  • The repr(pid) dedup key quietly handles a malformed state file holding an unhashable pid, with a one-line comment saying why.

kovtcharov pushed a commit to kovtcharov/gaia that referenced this pull request Sep 26, 2026
…md#4186)

The website, the Agent UI, and the terminal each carried their own
palette, so GAIA's copper appeared as three near-but-unequal golds and
the same assistant looked like three products. All three now implement
one set of colour roles from one set of literals, and each surface has a
test that fails when a component writes a hex inline instead of asking
for a role. `docs/spec/gaia-design-language.mdx` is the source of truth
for what the roles are, what contrast each owes the reader, and why the
light copper is not a darkening of the dark one.

Implements milestone 0 of the redesign plan in amd#3803, plus the theming
half of milestone 5. The shell simplification (milestone 2) stacks on
top of this in a follow-up.

## What it looks like

The welcome headline used to keep a cursor blinking at a sentence
nothing was writing to — the first thing every new user saw. The chat
transcript had the same defect. Both now go quiet the moment the text
stops.

| Before | After |
| --- | --- |
| ![Welcome headline with a cursor still blinking after the subtitle
finished](https://raw.githubusercontent.com/amd/gaia/7aeb753343094ff46dfaf4fa7140336b558dbad3/evidence/02_agentui_light.png)
| ![Same headline, settled, no
cursor](https://raw.githubusercontent.com/amd/gaia/kalin/ui-design-language-evidence/evidence/02_agentui_light.png)
|
| ![Chat answer ending in a blinking cursor after the turn
completed](https://raw.githubusercontent.com/amd/gaia/kalin/ui-design-language-evidence/evidence/03a_chat_light_before.png)
| ![Same answer, settled, no
cursor](https://raw.githubusercontent.com/amd/gaia/kalin/ui-design-language-evidence/evidence/03_chat_light.png)
|

Dark mode on the same palette — copper is the only accent; green and
amber appear solely as status, never decoration:

![Agent UI welcome screen in dark
mode](https://raw.githubusercontent.com/amd/gaia/kalin/ui-design-language-evidence/evidence/01_agentui_dark.png)

![Dark chat transcript with tool-call
results](https://raw.githubusercontent.com/amd/gaia/kalin/ui-design-language-evidence/evidence/04_chat_dark.png)

The agent-picker grid under the headline is the surface milestone 2
removes — the shell is being rebuilt around the flagship agent, not a
hub of them.

## The other threads

- **The website now offers both downloads.** It advertised the desktop
app only, so the terminal build — which ships six platform targets to
the desktop's three — was invisible to anyone who did not already know
it existed. Both are presented side by side, and asymmetric platform
coverage raises an actionable error instead of rendering an empty card.
- **Three controls had no visible keyboard focus at all**, light-theme
status badges read below 4.5:1, and picking an agent then clicking a
welcome chip quietly opened a session on a different one. All three
shipped green because the guards meant to catch them each matched
exactly one spelling of the mistake.

## Two design calls worth a second opinion

Both change what users see, so please push back if you disagree rather
than let them ride in:

- **Tools in the activity list no longer have their own colours.**
Green, amber, red, and blue carry status meaning, so they are not
available for decoration — keeping the per-tool table meant a green tool
badge sitting directly beside a red failure icon in the same row. Tools
are now told apart by their icon.
- **The animated starfield and constellation backgrounds on the website
are gone.** The design language rules out decorative motion; nothing
else referenced them.
- **Inline code keeps the accent in the terminal renderer.** A code span
is a different kind of token rather than a louder one, and the accent is
what makes it findable — but a paragraph with six `` `flags` `` in it
does speckle, so it is worth a second read.

## What catches the next regression

Guards, each written because a real defect got past the previous one:
token contrast per surface in both themes, no colour literal outside the
token file, and call-site pairing — the fg/bg pair a component actually
ships is measured, not just the pairing the tokens intended. That last
one matters most: token-level assertions rated a hover state fine that
shipped at 4.15:1.

**Two of these guards were green while broken**, and neither was found
by reading them. A focus-ring regex backtracked to zero width, so
`outline: none` counted as "paints an outline"; an Electron assertion
matched a type annotation instead of the default it was pinning. Every
guard here is now mutation-proven — the mistake it exists to reject is
re-injected and observed to fail it. That is the argument for the
mutation step, not a footnote to it.

## Known non-conformance

`--accent` on `--bg-active` reads 4.15:1 against a 4.5 floor, and is
excluded deliberately. The copper is pinned across all three surfaces,
and lightening the active surface enough to clear the floor pushes it
past `--bg-hover`, inverting the depth ramp. It needs a cross-surface
accent decision, which is larger than this PR.

## Test plan

- [x] `cd src/gaia/apps/webui && npx vitest run` — 637 pass, 59 files
- [x] `cd src/gaia/apps/webui && npx tsc --noEmit` — clean
- [x] `cd src/gaia/apps/webui && npm run build` — clean
- [x] `cd tests/electron && npx jest test_electron_chat_app.js` — 196
pass
- [x] `cd website && npx vitest run` — 213 pass
- [x] `cd website && npx astro check` — 0 errors, 0 warnings
- [x] `cd website && HUB_CATALOG_URL=https://hub.amd-gaia.ai npm run
build` — completes (needs network; the build has no fixture fallback by
design. Behind a TLS-inspecting proxy add
`NODE_OPTIONS=--use-system-ca`.)
- [x] `cd tui && go vet ./... && go test -count=1 ./internal/ui/...` —
clean, all packages pass
- [x] `python util/check_doc_links.py` — 2496 links, 0 broken
- [x] Toggle light/dark in the Agent UI and on the website; confirm code
panels stay dark in both and the `>` prompt, focus ring, and primary
button are the only coloured things on screen
- [x] Tab through the file browser, activity filters, and update chip in
both themes; every control shows a ring

`Test Agent SDK on Windows (Lemonade Integration)` is red here for
amd#4281, a self-hosted-runner bug unrelated to this PR — a leftover state
file points the tests at a dead port. It fails the same way on unrelated
branches and is fixed by amd#4284.

---------

Co-authored-by: f <f@f>
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Closing as superseded — main already carries an equivalent, and slightly more robust, fix for this exact bug: _embedded_lemonade_alive() in src/gaia/llm/lemonade_client.py checks the state file's recorded pid is actually a running lemond process (by image name, not just pid existence, so a recycled pid belonging to an unrelated process doesn't false-positive), falls back to the default endpoint when it isn't, and warns once via _warn_stale_embedded_state naming the leftover file — the same behavior this PR describes. No action needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation 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

Development

Successfully merging this pull request may close these issues.

A dead embedded Lemonade's leftover state file hijacks every client to a port with nothing on it

1 participant