Skip to content

feat(ui): session panel — environment, outputs and changes per chat - #5326

Merged
kovtcharov-amd merged 26 commits into
amd:mainfrom
kovtcharov:kalin/ui-owned-fixes
Oct 20, 2026
Merged

kovtcharov-amd merged 26 commits into
amd:mainfrom
kovtcharov:kalin/ui-owned-fixes

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Before, a chat didn't show where it ran, what it could touch, or what it changed on disk, and its folder and internet settings weren't enforced. Now each chat has a session panel with this answer's sources, where the chat runs, the folders it may use, an internet switch, everything it produced, and every file it changed, plus a whole-chat diff, Undo all, and a git Commit or PR that runs only after you confirm. Removed folders and internet-off are enforced by the agent itself, before any approval prompt. Only true loopback addresses count as "this PC", and a commit never stages files git ignores.

It also carries fixes found testing the merged UI: Retry with… lists friendly model names, names update once they load, local models get their own still-waiting hint, New chat focuses the message box and its task cards come back on their own, the panel's resize edge is easier to grab, and a web call that internet-off refused no longer shows as a failed lookup or as a site GAIA contacted.

This PR now replaces #5283 (closed). It was rebuilt on main so it carries only what isn't merged yet.

Test plan

  • npx tsc --noEmit, npx vitest run (1465 passed) and npm run build in src/gaia/apps/webui
  • npx jest in tests/electron: all pass on Linux line endings; ChatView is 101.6 KB of the 102.4 KB limit
  • pytest tests/unit/agents tests/unit/chat/ui plus the security and shell suites; the only failures also fail on main on this machine (a background thread trying to start the daemon, and test_step_timing)
  • python util/lint.py --black --isort
  • Agent UI on a fresh GAIA home with a local model: a turn edits two files in a git folder, the panel shows them under Outputs and Changes, Review changes shows the diff, Commit commits only those files, and Undo all restores them (screenshots in the evidence comment)
  • Agent UI with internet off: web search and a page fetch are refused before running, the message box says the chat is offline, and the panel doesn't claim a failed lookup or a contacted site
  • Flagship eval at the next RC: the agent loop now refuses calls up front when internet is off or a folder was removed
🔍 Technical details

@github-actions github-actions Bot added documentation Documentation changes chat Chat SDK changes mcp MCP integration changes llm LLM backend changes cli CLI changes tests Test changes electron Electron app changes security Security-sensitive changes performance Performance-critical changes agents labels Oct 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

The fixes are sound. The main one matters: before this PR, every Retry with… crashed with a generic server error because it waited on a lock that no longer exists. It now takes its turn in the queue like a normal chat. The friendly model names, the hint for slow local models, the new-chat cards that come back on their own, New chat focusing the message box, and the wider resize edge all look correct and come with tests.

Two things to fix before merge:

  • One Test plan item doesn't match the code. It says a retry "waits its turn instead of erroring" while another chat is busy. The server still refuses with "GAIA is answering in another chat", and the new test checks for exactly that. What now waits is the reverse case: a chat sent during a retry queues behind it instead of unloading the model. Reword the item so a reviewer tests the right thing.
  • The Agent UI changes have no real-world proof yet. All three Agent UI items in the Test plan are unchecked, and the PR has no screenshots. Add before/after screenshots of the Retry with… menu, the new-chat cards coming back, and the resize edge. Or say where they're posted.

Real-world evidence

N/A: no evidence bundle was produced for this run, and the changes are Agent UI rendering, which is deferred to the strix-halo lane. This verdict rests on static review alone. The server fix is covered by unit tests that now use the real turn queue instead of a stand-in, but no live retry was run.

🔍 Technical details

Reviewed the commits after 3dff6cd0 Merge main into the session panel branch, as the description asks. The rest of the 40k-line diff belongs to #5283 and its stacked PRs.

🟡 Test plan contradicts the 409 path

routers/chat.py:772 still returns 409 when turn_queue.locked(), and test_retry_waits_while_another_chat_is_answering asserts that 409. The waiting behaviour that was added is the inverse: test_a_retry_holds_the_model_slot_and_gives_it_back covers it, and a normal turn's turn_queue.acquire queues behind the retry's slot. Suggested wording for the item: "Retry with… works (no 'Server error'), and a message sent in another chat while it runs waits its turn."

🟡 Missing Agent UI evidence

Per the rubric, a change to an Agent UI surface needs a Playwright run against gaia chat --ui with before→after screenshots embedded in the description. At minimum this covers the Retry with… menu with friendly names, the new-chat cards recovering after start-up, and the resize line on hover.

🟢 Retry slot is released while the worker thread may still be running (routers/chat.py:782-793)

If the client disconnects during await asyncio.to_thread(answer_retry.answer_with, ...), the coroutine is cancelled and finally: turn_queue.release() runs. The thread keeps loading and answering on the other model, so the next queued turn can evict it mid-answer. The old semaphore behaved the same way, so this is not a regression. Worth a follow-up if retries on big models are common.

🟢 New-chat retry polls for as long as the error is up (NewChat.tsx:99-102)

A permanent skills_error, such as a broken skill rather than a slow start, re-fetches /start-screen every 15 s for as long as New chat stays open. It is visibility-gated and cheap, so this is fine as-is. Note it if the start-screen call ever becomes expensive.

Strengths

  • test_answer_retry.py dropped the fake chat_semaphore attribute from _http() and now exercises the process-wide turn_queue. That closes the exact gap that let the crash ship, which is the CLAUDE.md "mocks prove we called it, not that the call is valid" lesson applied.
  • useModelNames() paired with displayModelName() is a small, consistent way to make every naming surface re-render when names arrive, instead of each component fetching names itself.
  • setVisibleInterval is a tidy shared helper with its own tests, and stays byte-identical to the copy in fix: Agent UI and agent bugs found in an end-to-end UI test #5311 so the two won't conflict.

A chat's folders and internet switch are now enforced by the agent itself,
not just shown: a removed folder is refused by every file and shell tool
(even under full access, inside a wider grant, or as the shell's starting
folder) and is never offered as an approval, and internet-off refuses web,
browser, connector and online shell calls before they can ask.

- PathValidator.withhold_path / release_path / withheld_root
- Agent.internet_off checked in _policy_refusal via agents/base/offline.py
The undo store can now answer for a whole chat: every file it changed, from
before its first turn to after its last, with line totals, and put all of
them back at once. Undo all is all or nothing like undoing one turn: copies
are checked first, a file changed outside GAIA is a conflict unless forced,
and a failure part-way restores every file.

restore_turn's apply/rollback is factored into _Step/_apply, shared by both.
Endpoints behind the session panel's Environment, Outputs and Changes:

- environment: folders the chat may touch (add/remove) and its internet
  switch, stored per chat, applied before every turn and to a running agent
  at once; relayed sidecar agents are reported as not enforced
- outputs: everything a chat produced (files, exports, images, indexed
  documents, memories, schedules), newest first, tied to its turn and marked
  undone after Undo; turn summaries now record non-file outputs
- changes: whole-chat totals and diff, Undo all, and git Commit / Create PR
  that run only with confirmed=true, stage only the chat's files (literal
  pathspecs), never force-push, and refuse a PR while internet is off
- tunnel status names the device behind the latest authenticated request
Each chat gets a docked, resizable session panel that keeps the facts that
build trust in view: this answer's sources, where the chat runs and what it
may touch, what fills the context, what it produced, and what it changed.

- One panel, not two: the per-answer side rail becomes its first section,
  so the transcript loses one column, not two
- Resizable (drag or keyboard) with remembered width, collapsible panel and
  sections with remembered state, overlay below 1100 px
- Reads on open, expand and turn end only; nothing polls, and a closed panel
  or collapsed section reads nothing
- Environment mirrors the composer's permission mode and drives phone
  access through the app's existing flow; internet-off shows in the composer
- Built on the existing tokens and components so the redesign can restyle it
The menu and the comparison headings showed Gemma-4-E4B-it-GGUF where the model chip says Gemma 4 E4B.

(cherry picked from commit a0ba8684567dd091d728cec58827d5c6454a525e)
It said "Loading Gemma-4-E4B-it-GGUF on your GPU" beside a chip reading Gemma 4 E4B.

(cherry picked from commit 99575036aaf58bd1dc6e634fba78ba00ca4206f8)
Friendly names were known only after opening the model chip or Settings, so the rail, warm-up line and Retry with… comparison showed raw ids on a fresh load.

(cherry picked from commit 12e7c66a8badb4942f307ff5b12ae2a4f84d2aaa)
ChatView.queue: each answer refetches history 300 ms later and the mock history is empty, so a slow run wiped the turns before they were checked. MemoryDashboard: the knowledge mock now forgets a deleted item, so a refresh can't bring it back mid-test.

(cherry picked from commit 24791b64cfc5a1a758600f3714e5b379bff1d331)
Ctrl+Shift+O from the new-chat screen left focus wherever it was, e.g. in chat search.

(cherry picked from commit 32bcc086d703f4f7fac436fafcbec9f28b8d3d77)
A slow local prompt said a hosted model would be retried, which never happens on this PC.

(cherry picked from commit 62c607277d3c664470665be81fd90c7daec9e606)
The rail said Gemma-4-E4B-it-GGUF while the model chip said Gemma 4 E4B.

(cherry picked from commit 4f627e23613c1045d610bf6b366dc6b3f153e3de)
displayModelName reads the store without subscribing, so a view rendered before the names loaded kept the raw id; those views now subscribe through useModelNames.

(cherry picked from commit 5b2afa05e0dc9fd3af02569355608b6e6e2f3e7f)
…nt starts

On a cold start the cards said "GAIA's assistant didn't start" and stayed that way until Try again was clicked. While that reason is showing, the screen now asks again every 15 s, keeping the reason up until there is an answer.

(cherry picked from commit cdde89229e68be78791e2a03da1ce2056c20f11e)
It advanced the clock before React had started the retry interval, and its leftover mock answers then failed the next test.

(cherry picked from commit ab35fece0380aafbe88b70af785ba97646bcbc71)
The handle was a 6px strip with no cue until hovered. It is now 8px wide with a thin accent line on hover and keyboard focus.
… files

Turning the internet off for a chat now checks every command on a shell
line on its own, and treats a destination as this PC only when it is
localhost exactly or a loopback IP (127.0.0.0/8, ::1). Hosts are parsed
whole, so look-alike names, userinfo, numeric IP forms and proxy or
resolver options no longer count as local. Only a plain curl, wget or
Invoke-WebRequest whose every destination is this PC is let through; a
connector tool or an online command is refused even if a local URL rides
along in its arguments.

Commit from the session panel no longer fails when the chat touched a
gitignored file: those files are left out of what is staged, listed as
"ignored" by the API, and named in the commit dialog. A tracked file that
matches an ignore pattern is still committed.
Keeps ChatView under the 100 KB component budget with room to spare.
…ontacted site

With the chat's internet off, a refused search showed "Couldn't get live data"
and a refused page fetch listed its host under the websites GAIA contacted,
though nothing left the PC. Calls that never ran (refused before running, or
denied by the user) now count toward neither.
…host pages fetchable

The web tools refuse private addresses on their own, so the guide's
'pages served from this PC stay reachable' overpromised.
@kovtcharov-amd kovtcharov-amd changed the title fix(ui): Retry with, model names and new-chat fixes on the session panel stack feat(ui): session panel — environment, outputs and changes per chat Oct 20, 2026
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

The session panel works end to end in the real Agent UI with a local model: it shows a turn's file edits, their diff, a scoped commit and Undo all, and it enforces internet-off.

After a turn that edited two files: This answer, Environment and the panel
Outputs and Changes: 2 files changed, +2 −1, with Commit in the git folder
Review changes: one diff per file across the chat
Commit dialog: only the chat's two files, message drafted from the request
Internet off: the switch, the Offline tag and the message-box notice
Offline turns: search and page fetch refused before running; no false "couldn't get live data"
Undo all: both files restored, outputs marked Undone

🔍 Technical details
  • Setup: Agent UI built and served from this branch with an empty GAIA home (GAIA_HOME, GAIA_CONFIG_DIR, GAIA_MEMORY_DB, GAIA_DAEMON_HOME and USERPROFILE all pointed at a temp dir), started from a throwaway git repo. Inference on an existing Lemonade 11.8.1, Gemma-4-E4B on the Radeon 8060S GPU (Vulkan). Driven with headless Playwright (Edge).
  • The edit turn wrote Field code: violet-otter-92 to notes.md and changed greet in app.py. The files on disk matched the Review changes diff. Commit made cce8faf with exactly those two files, and Undo all put both back.
  • This run found two bugs, both fixed in this PR with tests. With internet off, a refused search showed Couldn't get live data, and a refused page fetch would have listed its host as a site GAIA contacted. The guide also promised localhost pages stay fetchable offline, but the web tools refuse private addresses on their own, so the guide now describes local commands instead.
  • These screenshots come from the rebuilt branch before its last rebase onto the feat(ui): context and performance panel (what fills the window, where the time goes) #5275 merge. The only change since is feat(ui): context and performance panel (what fills the window, where the time goes) #5275's own per-section error handling in the context details.

@kovtcharov-amd kovtcharov-amd added the ready_for_ci Run CI workflows on draft PR without requesting review label Oct 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This PR gives each chat a session panel. It shows where the chat runs, which folders it can use, an internet switch, what it produced, and what it changed, with Undo all and a confirmed git Commit or PR. The enforcement is real: removed folders and internet-off are checked on every tool call before any approval prompt. That covers shell commands that name a removed folder even in Full access, which I traced through the code. I found nothing that blocks merge.

Two small things worth fixing:

  • The guide oversells internet-off a little. The check reads what a command names: URLs, curl, git push, pip install. A script that goes online by itself (python fetch.py, node app.js) still runs. A sentence saying so keeps users from treating the switch as a network block.
  • Commit can include a file from a folder the user removed, as long as that folder sits inside the repo. Only the repo root is checked against removed folders, not each file. The confirm dialog lists the files, so the user still decides, but the panel's own rule should hold here too.

Real-world evidence

N/A: no evidence bundle was produced for this run. The PR says Agent UI screenshots (edit, Review changes, Commit, Undo all, internet-off) are in a separate evidence comment, which I didn't relay here. My verdict rests on static review of the backend and docs. The shell probe I tried couldn't run because this runner has no GAIA dependencies installed.

🔍 Technical details

Issues

🟢 Guide overstates internet-off (docs/guides/agent-ui.mdx, "Internet" bullet). offline_refusal (src/gaia/agents/base/offline.py) matches command text (_ONLINE_COMMAND_RE, URLs via effects_of_call). A program that opens a connection without naming a host on the command line isn't caught. The SDK page words this precisely ("any call whose arguments or shell command reach a host"), but the guide says GAIA "won't … run commands that go online". Suggested addition after the localhost sentence:

    such as `curl http://localhost:3000`, still run. The check reads what a
    command names, so a script that connects to the internet by itself (for
    example `python fetch.py`) can still reach it.

🟢 Commit ignores removed subfolders inside the repo (src/gaia/ui/session_git.py, _check_repo). Only within(root, withheld) is checked. Files under a withheld folder inside root stay in files and get staged. Filter them like the root:

    files = [
        f
        for f in _changed_by_chat(session_id)
        if session_environment.within(f, root)
        and not any(session_environment.within(f, w) for w in env["withheld"])
    ]

🟢 describe in session_git.py lists files from removed folders in the Commit draft for the same reason. The same filter applied in describe's loop over _changed_by_chat would keep the dialog consistent.

Eval note: Agent._policy_refusal now refuses calls up front when internet is off. The PR already names the flagship eval at the next RC. The categories to watch are the web/live-data and shell ones.

Strengths

  • Enforcement is in the right layer. withhold_path beats every grant in PathValidator (is_path_allowed, validate_read, _unaskable_reason). The shell's argument scan (_path_traversal_refusal → _path_allowed) runs under Full access too. The new cwd check covers the one hole the argument scan couldn't, and it's tested.
  • offline.py fails closed. It refuses on substitutions, assignments, proxy/resolve/config flags, xargs/find -exec, and nesting deeper than 3. It counts only true loopback as "this PC", and look-alike hosts and userinfo tricks have tests.
  • The git actions are careful. They need confirmed, use GIT_LITERAL_PATHSPECS, never force, commit -- <paths> so other staged work is left alone, drop ignored files, and refuse PRs while offline. restore_session reuses the per-turn all-or-nothing _apply with rollback.

A removed folder inside the repository still had its changed files staged and
listed in the drafted message; only a repository root inside a removed folder
was refused. The guide also now says internet-off reads what a command names,
so a script that connects on its own can still go online.
@kovtcharov-amd kovtcharov-amd added ready_for_ci Run CI workflows on draft PR without requesting review and removed ready_for_ci Run CI workflows on draft PR without requesting review labels Oct 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This PR gives every chat a session panel showing its sources, the folders it may use, an internet switch, everything it produced, and every file it changed, with Undo all and a confirmed git Commit/PR. Removed folders and internet-off are enforced in the agent before any approval prompt. The enforcement is careful: removed folders win over every grant including full access, the offline check accepts only true loopback addresses, and the commit path stages only the chat's own files with literal pathspecs. The docs honestly say a script that connects by itself can still go online.

One thing to fix before or soon after merge:

  • Changes breaks on a brand-new git repo. If the chat's files sit in a folder that was just git init-ed and has no commits yet, a common "start me a new project" flow, the panel's git section fails with a server error. The user then can't commit the chat's work from the panel. Treat "no commits yet" as a normal state, and add a test that starts from an empty repo. Every current test begins from a repo that already has a commit, which is why this slipped through.

Real-world evidence

N/A: this run produced no evidence bundle. The PR description says Agent UI screenshots and the internet-off run are in a separate evidence comment, which I couldn't see from here. The verdict rests on static review, plus a local check that confirmed the empty-repo failure.

🔍 Technical details

🟡 describe() / create_pr() raise on an unborn branch (src/gaia/ui/session_git.py:7712 in diff, _repo_state)
git rev-parse --abbrev-ref HEAD exits 128 in a repo with no commits (verified locally: prints HEAD plus fatal: ambiguous argument 'HEAD'). _run raises GitActionError, and git_state in routers/changes.py turns that into an HTTP 500 for the whole repo list. git commit -- <paths> itself works on an unborn branch, so only the state probe is in the way. git symbolic-ref --short HEAD returns the branch name with or without commits:

    branch = _run([git, "symbolic-ref", "--short", "-q", "HEAD"], root, ok_codes=(0, 1)) or "HEAD"

The existing "HEAD" check in pr_blocked then still covers a detached HEAD. Add a fixture variant in tests/unit/chat/ui/test_session_git.py that skips the initial commit (today's repo fixture always commits at line 64).

🟢 Release doesn't restore narrower grants (src/gaia/security.py, withhold_path)
withhold_path drops every allowed path inside the withheld root, but release_path only removes the withhold. If you remove a parent and then add back a different folder inside it, the cached agent won't get earlier approvals under that parent back until a new agent is built. It fails closed, so it's not blocking, but it may surprise users mid-chat.

🟢 Internet-off refusals land in the per-turn denied-effects ledger (agent.py, the _policy_refusal caller)
A shell command refused for internet-off is recorded with kinds={NETWORK, PATH}. If the user turns internet back on mid-turn, the next call to that host gets the "you declined this" re-ask instead of just running. It lasts only for the turn, so this is a nit.

Strengths

  • offline_refusal runs before the confirmation prompt and fails closed. Substitutions, VAR= prefixes, proxy/resolve flags, nested shells and xargs/find -exec all count as "goes online", and test_offline_loopback.py pins look-alike hosts and userinfo tricks.
  • restore_turn and the new restore_session share one all-or-nothing _apply, so Undo all gets the same checksum check, conflict detection and rollback as single-turn undo.
  • The commit path uses GIT_LITERAL_PATHSPECS, check-ignore --stdin -z, commit -- <paths> so the user's own staged work stays out, and a server-side confirmed flag. Each of these has a test.

In a folder that was just `git init`-ed, reading the branch failed and the
panel's git section returned a server error, so the chat's first files could
not be committed from it. The branch now reads through `symbolic-ref`, which
names it before the first commit and still reports a detached HEAD as HEAD.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Fixed: Changes now works in a folder that was just git init-ed. The two smaller notes stay as they are, because in both cases GAIA asks again rather than acting on a stale permission.

🔍 Technical details
  • Unborn branch: _repo_state reads the branch with git symbolic-ref --short -q HEAD, and a detached HEAD still reports HEAD. New tests start from a repo with no commits: it is listed, and Commit makes the first commit with only the chat's files. Another test checks a detached HEAD still reads as HEAD.
  • From the earlier round: Commit and its drafted message leave out files in a folder removed from the chat, even inside the repo. Tests cover that, a folder sharing a name prefix that must not be filtered, and a repo whose only changes are in a removed folder. The guide also says internet-off reads what a command names.
  • release_path not restoring narrower grants: re-adding a subfolder after removing its parent means the next access under the old grant is asked about again. That fails closed. Restoring grants would mean tracking what each withhold removed, which isn't worth it for a one-prompt cost.
  • Internet-off refusals in the denied-effects ledger: if the internet comes back on mid-turn, the next call to that host gets one re-ask, and only for the rest of that turn. A re-ask is the safe result.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 20, 2026
Merged via the queue into amd:main with commit 2680bc4 Oct 20, 2026
53 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/ui-owned-fixes branch October 20, 2026 01:54
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Oct 23, 2026
…leted (amd#5443)

Undo all left empty folders behind when a chat created a file inside new
folders and later deleted it. Across the whole chat that file counts as
unchanged, so Undo all skipped it, along with the folders made for it.
Undo all now removes those folders as well. It keeps any folder that
holds other files and names it, the same way undoing one turn does.

This was the remaining low-severity finding from the bot review of
amd#5283. Its other findings landed with amd#5326.

## Test plan
- [x] `pytest tests/unit/agents/test_session_snapshots.py
tests/unit/agents/test_file_snapshots.py
tests/unit/chat/ui/test_changes_router.py`: 79 passed. Both new tests
fail without the fix.
- [x] `python util/lint.py --black --isort --pylint --flake8` is clean.

---------

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

agents chat Chat SDK changes cli CLI changes documentation Documentation changes electron Electron app changes llm LLM backend changes mcp MCP integration changes performance Performance-critical changes ready_for_ci Run CI workflows on draft PR without requesting review security Security-sensitive changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants