Repository navigation
fix(ui): store uploads and managed documents under GAIA_HOME - #4348
Conversation
Nine test files no CI lane runs had been failing silently against APIs and contracts that changed underneath them. This brings them back to green against current main so the next change can put them in a lane. - test_sdk.py: assert the SDK surface that exists today (process_query via Agent.chat, the tool registry instead of the never-public execute_tool, openai_server's module-level app, Agent.STATE_* class constants, current RAGSDK/AudioClient/KokoroTTS methods, LLMClient as an ABC); drop the xfail DatabaseMixin block (it ships as gaia.database.mixin) and the placeholder docs-exist check. - test_multi_caller_equivalence.py: send the X-Gaia-UI header on mutating calls and read /api/connectors' "connectors" shape. - test_memory_integration.py: fresh installs are schema v4. - test_memory_api_integration.py: consolidation is 503 until a chat session registers a consolidator, and runs it once one has. - test_documents_router.py: two fixtures indexed for real and needed Lemonade. - test_tui_control_e2e.py: give the pty a size and a TERM like a terminal. - test_ui_email_scope_consent.py: the agent now declares microsoft_work too; drop three tests of the in-process /v1/email mount the UI no longer has. - test_lemonade_embedded_lifecycle.py: llamacpp:cpu has no macOS build. - test_email_mcp_stdio_parity.py: docstring said no Lemonade; triage uses it. - test_vlm_integration.py: deleted. A script that returned booleans instead of asserting, so it could not fail, and it called a removed constructor arg. Refs amd#4205
…blocking 43 test files ran in no CI lane, so they looked green on every PR whether they worked or not, and nothing stopped the count from growing. Now every test file is either run by a lane or listed with the reason CI can't run it, and lint fails the moment a new file is neither. - test_unit.yml gains an offline-integration job for the 23 files that need no Lemonade, live account or AMD hardware (with Go for the TUI e2e and the [mcp] extra for the SDK and MCP-server tests). - test_email_agent_unit.yml runs test_ui_email_scope_consent.py. - util/test_lane_allowlist.yml lists the 18 that need a live Lemonade Server, a real Gmail account, a self-hosted model runner, npm-fetched MCP servers, or are hand-run scripts, each with its reason. - util/lint.py runs check_test_lane_coverage.py as a blocking check (--test-lanes, and part of --all); lint.yml re-runs when the allowlist changes. Fixes amd#4205
The Agent UI wrote Document Library uploads and chat attachments to the real ~/.gaia even when GAIA_HOME pointed elsewhere, so the document and file router tests left files in the developer's GAIA home on every run. - The documents dir, the uploads dir and the static uploads mount now resolve GAIA_HOME at call time; the agent's writable scope follows the same dir. - A relocated documents dir is added as a document root so reindexing a dropped file still works when GAIA_HOME is outside the home directory. - A GAIA_HOME that is the home directory or above it is refused: the server deletes files in <GAIA_HOME>/documents as its own, and there that is the user's real Documents folder. - The router tests run under a fake home with GAIA_HOME set elsewhere, and fail if anything appears under <home>/.gaia. Fixes amd#4347
|
Verdict: Approve with suggestions The Agent UI now stores Document Library uploads and chat attachments under One thing worth resolving before merge: GAIA already refuses a Smaller follow-ups: the same test fixture is written twice (once for the integration tests, once for the unit tests) and could be shared; the document-root tests now quietly depend on whether the developer has Merge order: the author notes this needs #4343 first, which is still open. Real-world evidenceNo 🔍 Technical details🟡 ImportantDuplicate
The exception type is the practical problem. Suggested shape: move the structural check next to 🟢 MinorDuplicated fixture — Document-root tests now read the ambient Existing blob uploads become orphans under a relocated
Strengths
|
The file-search tests walked the real home directory, so on a developer machine one test ran past two minutes, and the results depended on what that user owned. Most assertions were hedged with "if found" because the fixture lived under ~/.gaia, which the search skips as hidden. The search tests now point HOME/USERPROFILE at a temp dir and write their files into its Documents folder, so each one asserts the exact result. The file runs in about 4 seconds with the real HOME set. Refs amd#4205
# Conflicts: # tests/test_vlm_integration.py
…free box Both files this PR repairs still failed in the offline lane, so the "534 passed" claim held only on the author's machine. The memory test built its URL by interpolating a local-timezone stamp. At a negative UTC offset the "-" is URL-safe and it passes; on a UTC runner the "+00:00" decodes to a space, fromisoformat rejects it, and the endpoint correctly 422s. Passing the stamp through the client's params lets it percent-encode, and a second pinned +00:00 case means the test now catches this from any timezone rather than only from UTC. The TUI test set TERM to get color, but termenv treats any environment with CI set as "not a TTY" before it looks at TERM or the pty, so lipgloss dropped to the Ascii profile and rendered no escapes at all for format=ansi to return. CLICOLOR_FORCE is the documented override, and NO_COLOR outranks it, so both it and CLICOLOR are cleared. Also resolves the merge with main: amd#4290 removed only one of this file's three fallback_model uses, and VLMClient no longer takes that argument, so the deletion stands.
…ew live-Lemonade suite tests/test_ui_email_scope_consent.py was added to the email lane's pytest command but not to its paths filters, so a PR editing only that file still ran it nowhere -- while the new checker counted it as covered, because the checker asks whether a lane names a file, not whether any trigger reaches that lane. Listed in both the push and pull_request blocks, next to the other individually-named tests/test_email_* entry. Merging main brought tests/integration/test_lemonade_predownload_checks.py, which the gate correctly flagged as run by no lane. It takes require_lemonade, so it is allowlisted rather than wired offline.
uploads_dir() runs inside create_app(), which is not a request context, so the new guard's HTTPException surfaced as a raw "fastapi.exceptions.HTTPException: 500: ..." out of `gaia chat --ui`. The user sees a stack trace for a mistake they could have fixed in one step. It now raises UnsafeGaiaHomeError, and both launch paths -- `gaia chat --ui` and `python -m gaia.ui.server` -- print the message and exit 64 (EX_USAGE, the code gaia uninstall already uses for the same misconfiguration). The structural test itself moves to gaia.config as unsafe_gaia_home_reason(), which uninstall_command now calls instead of keeping a second copy. Its messages, tiers and exit codes are unchanged; it keeps its own identity/marker check on top. The UI copy had also dropped the filesystem-root case, which it now inherits for free. UnsafeGaiaHomeError moves to gaia.config alongside it and stays importable from uninstall_command, where it was defined and is still imported from.
|
Fixed the guard's failure mode and folded the duplicate into one shared check. Also merged main. Pointing The structural "is this home safe to own files in" test now lives in one place that both the uninstaller and the UI call, rather than two copies drifting apart. The uninstaller keeps its own wording, exit codes and its extra marker check — nothing about it changes. The UI copy had quietly dropped the filesystem-root case, which it now gets for free. Confirmed the merge-order note in the description is real: the 3 reindex tests fail here for exactly the reason stated, so #4343 still needs to land first. 🔍 Technical detailsBefore, with After:
Tests:
— i.e. #4343's Not addressed (the review's 🟢 items, all still valid follow-ups): the duplicated |
…nc-4348 # Conflicts: # tests/integration/test_files_router.py
# Conflicts: # tests/integration/test_memory_integration.py
…2-4344 # Conflicts: # docs/reference/dev.mdx # util/lint.py
…blocking (amd#4344) 43 test files ran in no CI lane, so they looked green on every PR whether they worked or not. The checker from amd#4124 could see the gap but blocked nothing, so the count kept growing. After this PR, every test file either runs in a lane or is listed with the reason CI can't run it, and lint fails as soon as a new file is neither. Stacked on amd#4343 — merge that first. It repairs the files this PR starts running. - **23 files that need no Lemonade, live account, or AMD hardware** now run in a new `offline-integration` job in `test_unit.yml`. The job takes about 2 minutes of tests, in parallel with the unit job, so the unit job's 30-minute budget isn't touched. One more email file joins the email unit lane. - **18 files are allowlisted with a reason.** Most need a live Lemonade Server, a real Gmail account, or a self-hosted model runner; two are hand-run scripts. Two of them (`tests/mcp/test_mcp_cli_to_agent_workflow.py`, `test_mcp_sdk_integration.py`) fetch unpinned MCP servers from npm at test time **and are broken today**. Their entries say so, so a reviewer can decide whether to repair or delete them. - **The file-search tests no longer walk the real home directory.** On a developer Mac, `test_search_finds_file` ran past a 2-minute timeout, and most search assertions only checked results "if found". They now search a fake home and assert exact results; `test_files_router.py` takes about 4 s with the real `HOME` set. - **The check is now blocking** in `util/lint.py --all`, which CI already runs. Overlaps: amd#4348 makes the whole of `test_files_router.py` use a fake home, so it touches the same search tests. Whichever PR lands second resolves a small conflict. amd#4038 adds its own lint check in the same spots of `util/lint.py` and `docs/reference/dev.mdx`, so expect a trivial conflict there. amd#3669, amd#3721, and amd#3812 touch other parts of `test_unit.yml`. ## Test plan - [x] Before, on `origin/main`: `python util/check_test_lane_coverage.py` reports 43 files and exits 1 - [x] After: the checker exits 0 (850 files, 18 allowlisted), and `python util/lint.py --test-lanes` fails when a new unwired `tests/test_*.py` is added - [x] The new job's exact file list passes locally in a clean py3.12 venv matching its install step, with homes isolated and Lemonade unreachable: 534 passed, 12 skipped - [x] `test_search_finds_file` hangs past 130 s on this branch before the fix, with the real `HOME` set. After it, the whole of `test_files_router.py` passes in 4 s (75 passed, 1 skipped) - [x] The email lane's full command plus the added file passes: 4971 passed - [x] `actionlint` is clean on the three edited workflows, and `black`, `isort`, and `pylint --errors-only` are clean on `util/lint.py` - [ ] Watch this PR's `Offline Integration Tests` job go green on Linux. `test_backend_install_command_is_accepted` only runs there (it's skipped on macOS), so CI is its first real run Fixes amd#4205 --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
Searching files in the Agent UI could walk the entire home directory with no limit. On a real machine one search took minutes, and it never returned at all if one directory read blocked, for example on a cloud mount or a macOS privacy prompt. Now a search stops after 20,000 entries or about 10 seconds and returns what it found so far. The file browser says so when a search stopped early. ## Test plan - [x] `python -m pytest tests/integration/test_files_search_budget.py -q`: 5 passed. All 5 fail on `main`. - [x] `python -m pytest tests/integration/test_files_search_budget.py tests/integration/test_files_router.py tests/unit/chat/ui/test_models.py -q`: 111 passed, 1 skipped. On this Mac, `test_files_router.py`'s search tests hung past 10 minutes against the real home dir before this change; each now returns at the ~11 s cap. - [x] `cd src/gaia/apps/webui && npx vitest run`: 400 passed. The new truncation-note test fails without the component change. - [x] `cd src/gaia/apps/webui && npx tsc --noEmit`: clean - [x] black, isort, pylint clean on the changed Python files - [ ] Manual: Agent UI file browser, search a common name on a large home dir, and see the "Search stopped early" note - [ ] `gaia eval agent`: the Agent UI MCP server's `search_files` tool result gains a `truncated` field <details> <summary>🔍 Technical details</summary> - The walk now runs on a dedicated daemon thread instead of the default executor. A deadline checked between entries can't interrupt a blocked `opendir`, so the endpoint also stops waiting at budget + 1 s grace. A stuck thread exits once its read returns, and it never holds a shared executor slot. - The `$HOME` pass skips the four priority folders it already walked at greater depth. - `truncated` is true only when the entry cap or time budget cut the walk short, not when `max_results` was reached. - Overlaps: amd#4345 adds a generated-types drift check. If it merges first, `api.gen.ts` needs regenerating for `FileSearchResponse.truncated`. amd#4348 edits other parts of `routers/files.py` (the upload dir). New tests are in their own file to stay clear of amd#4344/amd#4348's edits to `test_files_router.py`. The docs edit is outside amd#4340's hunks. </details> Fixes amd#4352 Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
The Agent UI ignored
GAIA_HOMEand always saved Document Library uploads and chat attachments under the real~/.gaia. So a run of the document and file router tests left files in the developer's own GAIA home, and those files could change the next run's results. Both folders now live under$GAIA_HOME(default is still~/.gaia). The router tests run under a fake home and fail if anything lands in<home>/.gaia. AGAIA_HOMEset to your home directory or one of its parents is now rejected, because the server deletes files in<GAIA_HOME>/documentsas its own, and there that would be your real Documents folder.Merge #4343 first. It fixes three reindex tests in
test_documents_routerthat fail onmainright now because they call real RAG indexing without Lemonade. I checked this branch with #4343's changes applied: both router files pass (89 passed, 1 skipped). This PR edits different lines of that file, so the two won't conflict. It also adds nothing to the unit conftest that #4301 changes.Test plan
pytest tests/unit/chat/ui/test_gaia_home_storage.py: fails onmain(4 failed, 2 errors), passes here (6 passed)pytest tests/unit/chat/ui tests/integration/test_files_router.py tests/integration/test_documents_router.py: 1127 passed. The only failures are the 3 reindex tests that test: repair the unwired test files that drifted into failure #4343 fixesGAIA_HOMEunset and a fakeHOME: default~/.gaialayout unchangeddocuments.pyis already onmain)Fixes #4347