Skip to content

fix(ui): make the new-chat folder chip work on installed GAIA - #5961

Merged
kovtcharov-amd merged 4 commits into
amd:mainfrom
tylerbea:claude/folder-chip-sidecar
Oct 28, 2026
Merged

kovtcharov-amd merged 4 commits into
amd:mainfrom
tylerbea:claude/folder-chip-sidecar

Conversation

@tylerbea

@tylerbea tylerbea commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

#5826 turned the new-chat folder chip into a real picker, but only when the GAIA agent runs inside the app. When the agent runs as its own process, the chip went back to plain text, because that process had no way to receive the folder. Installed copies run the agent that way, so most people still couldn't use the picker. This PR closes that gap: the chip works whenever the agent can take a folder, and the picked folder actually reaches the agent on every message.

It also changes how you pick. In the desktop app, the chip and the session panel's Add folder now open the operating system's own folder picker. GAIA's popup stays for the browser version only, and it now hides dot folders behind a Show hidden checkbox, as the file browser already does since #5834.

  • Folders reach a background agent. Before, a background agent's turn got only the chat's documents as its allowed files. Added folders now go with every turn.
  • The agent knows which folder "this folder" is. Being allowed into a folder didn't tell the model it was the one meant, so "what are we working on in this folder?" sent it to the home folder, which is refused. Each message to the agent now starts with a short note naming the chat's folders. The chat still shows exactly what the user typed.
  • Older agents fail loudly. An agent too old to take folders keeps the chip as plain text. A chat that already has folders stops with "update GAIA" instead of quietly ignoring them.
Before (installed GAIA) After
before after

The Mac folder picker opened from the chip, then the picked folder on the chip:

native picker

picked

The agent reads a file in a folder outside the home folder, picked this way:

answer

Asked "what are we working on in this folder?" with a project folder picked, the agent goes straight to it:

this folder

The browser version's popup, with hidden folders tucked away:

web popup

Closes #5957

🔍 Technical details
  • session_environment.takes_folders(agent_type): in-process agents always can; a relayed one can when scope_supported(profile, handle.api_version) (contract 2.18+). A daemon start failure raises EnvironmentChangeError, never a silent False.
  • _dispatch_sidecar_query takes folders and merges them into allowed_paths through _effective_scope, so GAIA_ALLOWED_PATHS still narrows them. With folders and no scope support it emits agent_error.
  • Removing a folder and the internet switch stay refused for relayed chats: a withheld sub-path can't be expressed as an allowed-paths list, and internet-off isn't sent to the sidecar.
  • The session panel still shows a relayed chat's folders as read-only (enforced: False), so after the chat starts, folders are added from the chip only. Unlocking the panel's Add folder is left for a follow-up.
  • Native picker: dialog:pick-folder IPC in services/folder-dialog.cjs, exposed as gaiaAPI.dialog.pickFolder; useFolderPicker picks native vs popup in one place for both callers.
  • The folder note is added in the UI backend (with_folder_note), on both the relayed and in-process paths, so it works with already-installed agents and needs no contract change. Only the text sent to the agent changes; the stored message, title and attachment parsing keep the user's words.
  • The note also lands in what the agent's memory saves for that turn, and in-process stored history keeps it. Avoiding that needs a per-turn context field in the agent contract, left for later.
  • The before photo was taken in light mode, the rest in dark mode, because the Mac switched appearance between shots.

Evals to watch on the next RC (the folder note changes prompt text, only in chats with picked folders): gaia_files, gaia_resilience, gaia_tool_selection, tool_selection, gaia_code, gaia_git, gaia_shell.

Test plan

  • pytest tests/unit/chat/ui/test_environment_router.py tests/unit/chat/ui/test_start_screen.py tests/unit/chat/ui/test_relayed_scope.py tests/unit/test_relay_flagship_documents.py tests/unit/chat/ui/test_gaia_home_storage.py (85 passed), plus tests/unit/chat/ui/ with the folder-note tests (2499 passed)
  • npx tsc --noEmit -p . and npx vitest run in src/gaia/apps/webui (1920 passed)
  • npx jest in tests/electron (1256 passed)
  • python util/lint.py --black --isort and --flake8
  • Desktop app on macOS with the agent as its own process (contract 2.21): chip opens the Mac picker, picked folder shows on the chip, the agent reads a file in it
  • Desktop app: picked ~/Projects/Armada, asked "what are we working on in this folder?", the agent listed that folder
  • Browser version: chip opens GAIA's popup with dot folders hidden
  • Reviewer: repeat the desktop check on Windows

… own process

On an installed GAIA the new-chat folder chip was plain text, and folders
added to a chat never reached the agent, because GAIA runs its agent as a
daemon sidecar and every folder path refused sidecars outright.

- The chip, creating a chat with folders, and adding a folder now ask the
  running sidecar whether it takes a file scope (contract 2.18+). Only an
  older agent, or one that can't start, is refused, with a message that
  says what to do.
- Each relayed turn sends the chat's added folders with its scope, still
  narrowed by GAIA_ALLOWED_PATHS. A chat with folders on a sidecar too old
  to take them stops with an update message instead of dropping them.
- Removing a folder and the internet switch still refuse for a sidecar;
  their message no longer tells a GAIA chat to start a GAIA chat.

Closes amd#5957
The desktop app now opens the computer's own folder picker for a new chat's folder chip and the session panel's Add folder. The browser version keeps GAIA's popup, which now hides dot folders behind a Show hidden checkbox so a home folder opens on Documents and Downloads, not a wall of config folders.

- New dialog:pick-folder IPC channel (services/folder-dialog.cjs), exposed as gaiaAPI.dialog.pickFolder. It resolves the chosen path or null on cancel, and errors reach the UI.
- useFolderPicker holds the desktop-or-browser choice for both callers.
- A typed path still opens any folder, hidden ones included.
@github-actions github-actions Bot added documentation Documentation changes tests Test changes electron Electron app changes labels Oct 28, 2026
A folder picked with the new-chat folder chip was granted to the agent but never named to the model, so asking about "this folder" made it guess the home folder. Each turn's query to the chat's agent, relayed or in-process, now opens with a short note naming the chat's folders. The stored chat, title and turn summary keep what the user typed.
@tylerbea
tylerbea marked this pull request as ready for review October 28, 2026 01:47
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve

Picking a folder for a new chat now works when GAIA runs its agent as a separate process, which is how an installed GAIA runs it. The desktop app opens the computer's own folder picker, and the agent is told which folder "this folder" means, so it stops wandering off to the home folder. An agent too old to take folders now stops with an "update GAIA" message instead of quietly ignoring them. I found no blocking issues. Every chat path that sends a turn to a separate-process agent passes the folders along. The background-task path is the exception, but it has no chat and so no folders.

Two small things are worth knowing. Neither blocks the merge:

  • The folder note becomes part of the prompt on every turn of a chat that has folders, and it ends up in saved memory and in-process history. The PR already says this and names the eval categories to watch on the next RC, which is the right call.
  • The native picker has only been tried on macOS. The Windows check is still unticked in the test plan.

Real-world evidence

No evidence bundle was produced for this run. The PR description has its own: rendered before/after screenshots from the desktop app with the agent running as its own process (macOS, contract 2.21), the OS picker opening from the chip, the agent reading a file in the picked folder, the agent answering "what are we working on in this folder?" from the right folder, and the browser popup with hidden folders tucked away. That covers the Agent UI surface this PR changes. Windows hasn't been tried, and my verdict there rests on reading the code.

🔍 Technical details

Issues found

🟢 Folder note is re-added every turn and lands in memory and history (src/gaia/ui/session_environment.py:840, _chat_helpers.py:713, :743, :680). It is fine for budgeting, since _restore_model_history and _relayed_history only use query for token accounting. But it costs tokens on every turn and leaks into what memory saves. The PR body already defers this to a per-turn context field in the agent contract. A follow-up issue would keep that from getting lost.

🟢 add_folder still skips the capability check when the session row is missing (session_environment.py:944-947). This is unchanged from the old _require_enforceable behaviour and is harmless, because the router already 404s an unknown session first. Noting it only because grant_folder is now the unchecked entry point, and its docstring is the only thing keeping a future caller from skipping check_new_chat_folders.

Verified while reviewing

  • allowed_paths is always a list from _compute_allowed_paths on the streaming relay path, so sorted({*allowed_paths, *folders}) never silently drops folders when scope is supported.
  • The non-streaming relay branch (_chat_helpers.py:3342) still refuses with a 400, so it doesn't need folders. The scheduled relay (server.py:416) has no session and so no folders.
  • Both new daemon round-trips run off the event loop: create_session now uses asyncio.to_thread, the environment router already does, and new_chat_start is a sync def, so FastAPI runs it in a threadpool. list_skills already acquires the same handle, so takes_folders adds an attach, not a new spawn.
  • A daemon start failure in takes_folders raises EnvironmentChangeError. It never quietly returns False, which matches the fail-loudly rule.
  • The IPC handler validates defaultPath's type and refuses a sender with no window. Paths picked natively still go through the backend's check_folder.

Strengths

  • useFolderPicker puts the native-vs-popup choice in one place for both the chip and the session panel, and both get cancel and error tests.
  • The tests check the actual turn: test_folder_note.py asserts the agent receives the note on both streaming and non-streaming sends, and that the stored user message keeps the user's own words.
  • The docs (guide and SDK reference) are updated together for the new choosable and 400/409 semantics.

A chat made while the agent ran inside GAIA can have a sub-folder taken
away from a folder it was given. Once the same chat's agent runs as its own
process, the turn sent the folder as a whole, and the sidecar could read and
write the sub-folder the user removed. An allowed-paths list can't express a
removal, so such a chat now stops with a message to start a new chat.

Also pins that a relayed folder grants that folder and not its siblings, and
that GAIA_ALLOWED_PATHS still narrows it.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Thanks for this, @kurplunkin. Sending the chat's folders on every turn, and refusing loudly when the agent is too old to take them, are the right calls. The live-sidecar test that checks the folder reaches the real /query endpoint made this easy to verify.

I pushed one small fix. A chat can have a sub-folder taken away while its agent runs inside GAIA. If that same chat later runs on a relayed agent, for example after switching from a source install to an installed GAIA, the whole folder was sent, removed sub-folder included. A relayed turn can't express a removal, so that chat now stops and asks the user to start a new one. New chats on an installed GAIA can't reach that state, so the demo path is unaffected.

Because this widens what a relayed agent may read and write, it still needs a maintainer's sign-off on the permission scope before merge.

🔍 Technical details
  • _dispatch_sidecar_query takes withheld and emits agent_error (withheld_refusal()) when it's non-empty, before any scope is built. This also covers a removed default folder (cwd), which a relayed agent was already ignoring before this PR.
  • New tests in tests/unit/test_relay_flagship_documents.py: removed sub-folder and removed default folder both stop the turn (both fail without the fix); a picked folder is granted without its sibling or parent; GAIA_ALLOWED_PATHS still narrows a relayed folder.
  • Not changed, already true before this PR: a relayed chat's internet-off switch, if set while the agent ran in-process, isn't sent to the sidecar.
  • Local runs: tests/unit/chat/ui plus every test touching session_environment / _dispatch_sidecar_query, 2590 passed. The 3 test_confirmation_summary failures only happen under a temp HOME and pass on the real one. vitest 1920 passed, tsc clean, black/isort/flake8 clean.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 28, 2026
Merged via the queue into amd:main with commit 9b20685 Oct 28, 2026
55 checks passed
kovtcharov-amd added a commit to huong8373tt-beep/gaia that referenced this pull request Oct 28, 2026
Since amd#5961 the new-chat chip can show a folder the user picked, and the
agent is told "this chat is working in" that folder, but a bare
"notes.txt" still went to the process folder. The chat's first picked
folder is now the workspace, for in-process and relayed agents alike;
with none picked it stays the folder the chip shows by default.

Adds adversarial checks that the workspace base can't move a write out
of the chat's folders: a symlink inside it, a path on another drive
(C:foo style) and a drive-root path (\foo) on Windows all resolve
outside and are refused, and the approval prompt names the same path.
kovtcharov-amd added a commit to tylerbea/gaia that referenced this pull request Oct 28, 2026
main's amd#5966 took contract 2.22 for /query's reasoning field, and that
contract shipped in v0.25.2-rc5. internet_off and /sessions/{id}/internet
move to 2.23, so a 2.22 agent from rc5 is not mistaken for one that takes
the switch and sent a field it would 422.

From amd#5961, a relayed GAIA chat can now be given a folder; only taking one
away is still refused, and that refusal no longer mentions the internet.

The live-sidecar switch tests released the parked agent before the relay
had re-read the switch, so they raced the push they were checking. They now
wait for the relay to go live, as a real first tool call waits on a model
reply.
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 29, 2026
The new chat keeps main's folder picker under the message box (amd#5826,
amd#5961), and this branch's chip now shows only in an existing chat's
composer, where it opens the session panel's folders.

- Kept main's library documents, first-run setup notice, private chip,
  saved draft and typing-while-the-chat-is-created queue in the new chat;
  the task cards stay removed, so the agent-ui guide no longer offers them.
- setHole reuses its mask when the grid size is unchanged.
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 tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New-chat folder chip can't be clicked on installed GAIA

2 participants