Repository navigation
fix(webui): persist agent settings across desktop app restarts - #4330
Conversation
…onfig If the desktop app couldn't reserve a free port it quietly started the backend on 4200, where another GAIA or any other process may already be listening, so the window could talk to the wrong server. It now stops with the startup error dialog instead. The tray settings handler crashed on a null payload, wrote any key the renderer sent into ~/.gaia/tray-config.json, and handed non-booleans to the OS login-item API; it now accepts only the three known settings and requires booleans. Fixes amd#4234
Agent settings saved from the desktop app's config dialog now survive a restart. The settings handler only stored the tray section, so the agents section was dropped, and nothing loaded agent settings back at startup. - tray:set-config validates and stores an `agents` section (merged by agent id, unknown keys dropped); a bad payload writes nothing. - A failed write now rejects instead of logging and reporting success, and the in-memory config only changes once the file is written. - The agent store loads saved settings when the agent manager mounts, and the dialog closes only after the save lands, showing the error otherwise. Fixes amd#4300
|
Verdict: Approve with suggestions This fixes a real, user-visible bug the right way: agent settings now actually reach the desktop app's settings file, get loaded back at startup, and the dialog stays open with a visible error when the write fails instead of pretending it worked. The port-failure and tray-payload hardening that rides along is the same spirit — fail loudly rather than quietly substitute a default. One thing worth fixing before merge: the settings file loader is strict on the way in but silent on the way out. If the Smaller items (details below): a couple of now-unused store actions that would silently reintroduce the old non-persisting behaviour if someone reached for them, an error banner shared with the agent list that can show a stale unrelated message when the dialog opens, and one settings key the type system advertises but the settings handler quietly drops. Real-world evidenceNo 🔍 Technical detailsIssues🟡 A single bad
_loadConfig() {
let loaded = null;
try {
if (fs.existsSync(CONFIG_PATH)) {
loaded = JSON.parse(fs.readFileSync(CONFIG_PATH, "utf8"));
}
} catch (err) {
console.warn("[tray] Could not load tray config:", err.message);
}
if (!isPlainObject(loaded)) return { ...DEFAULT_CONFIG, agents: {} };
let agents = {};
try {
agents = validateAgents(loaded.agents ?? {}, CONFIG_PATH);
} catch (err) {
console.error(
`[tray] Ignoring invalid agents section in ${CONFIG_PATH}: ${err.message}`
);
}
return {
...DEFAULT_CONFIG,
...loaded,
tray: { ...DEFAULT_CONFIG.tray, ...(loaded.tray || {}) },
agents,
};
}Worth a test alongside the existing 🟢 🟢 The dialog's error banner shows unrelated errors ( useEffect(() => {
useAgentStore.setState({ lastError: null });
}, []);🟢 🟢 Strengths
|
… registration (amd#4338) Several Electron IPC tests passed without ever calling the handler with bad input. They only checked that a channel was registered, or they mocked out the method under test. A broken check would still pass: the updater could accept a path-traversal release tag, or the agent manager could spawn a process for an unknown id, with no test failing. These tests now call each handler the way the renderer does, pass malformed input, and assert that the call is rejected and nothing else happens. The install progress window had no tests at all and now has coverage. This PR changes tests only. Temporarily loosening the updater's tag regex fails 7 of the new tests, and removing the agent-id and URL-encoding guards fails 11. Tray-manager `tray:set-config` validation is left to amd#4299 and amd#4330, which already add those tests. ## Test plan - [x] `cd tests/electron && npm ci && npx jest` (26 suites, 770 tests pass on Node 20) - [x] Weaken `TAG_RE` in `auto-updater.cjs` to `/^v\d+\.\d+\.\d+/`: 7 new tag tests fail - [x] Remove the agent-id guard and `encodeURIComponent` in `agent-process-manager.cjs`: 11 new IPC tests fail Part of amd#4258 Co-authored-by: Kalin Ovtcharov <[email protected]>
The agents validator ran inside the try that guards reading the settings file, so a single malformed agent entry threw all the way out and the loader returned bare defaults -- discarding minimize-to-tray, start-minimized and start-on-login along with it. The next save wrote those defaults back, so a user who never opened agent settings lost their tray preferences for good. Version skew was the likely trigger: the validator requires every key it knows about on every entry, so adding a required field would make existing settings files unloadable. Validation is now scoped to the section that failed. A bad agents section is dropped with an error naming the file and the reason; tray settings survive. A non-object tray section falls back the same way without touching agents.
|
Fixed the settings-reset bug from the review: one malformed agent entry no longer wipes the user's tray preferences. Validation is now scoped to the section that failed, so a bad Still stacked — #4299 has not merged. It is open with no merge commit, so the branch still carries its commit and the diff will only shrink once it lands. 🔍 Technical details
Two tests in
Tests: Not addressed, all 🟢 from the review: the dead |
# Conflicts: # src/gaia/apps/webui/services/tray-manager.cjs # tests/electron/tray-manager.test.cjs
…imports (amd#4360) About 6,700 lines of code had no caller. One file couldn't even be imported, yet CLAUDE.md still listed it as "Shell integration". The dead code kept stale behaviour looking alive, like `rag/demo.py` printing `gaia rag` commands that don't exist, and it cost reviewers time. This PR deletes six of the items from amd#4243. It also adds a test that imports every module under `src/gaia`, so an unimportable file now fails CI instead of lingering. The test fails on current `main`: it flags `shell/prompt.py` and the three uncollected mic scripts. Left for a maintainer decision: - `src/gaia/eval/model_comparison.py`: it has no caller, but amd#3741 merged it yesterday as a library building block, with CLI wiring planned as a follow-up. - `governance/`, `talk/app.py` (amd#4333) and the webui AgentManager panel (amd#4330) were excluded. `docs/plans/cpp-framework-parity.md` still calls the C++ plan resolver dead code to resolve. I left it alone because amd#3812 deletes that file. <details> <summary>🔍 Technical details</summary> - Deleted: `src/gaia/shell/`, `rag/demo.py`, `rag/app.py` + `rag_main` export, `audio/tests/*.py`, `eval/longthread_quality.py` + its test and fixture, `hub/agents/email/node/`, `Agent::resolvePlanParameters` (+ decl, + now-unused `<regex>` include). - Two `rag_app` tests in `test_rag_index_status.py` went with `rag/app.py`. The chat/talk/file-monitor index-status tests stay. - `thread_fold` keeps its own coverage in `hub/agents/email/python/tests/test_thread_fold*.py`. - The import test's allowlist is keyed on the *missing package* (`mcp`, `reportlab`), not the module. An allowlisted module still fails if it breaks another way, and a second test checks each allowlisted package is an optional extra in `setup.py`, not a base dependency. Loose `.py` files outside a package are loaded by path, so broken relative imports fail too. - A CI-equivalent venv (`.[api]` + the unit job's test deps) flags only `mcp` and `reportlab` today, and the sweep takes ~7 s cold. No module does an unguarded platform-only import at top level, so the Windows smoke lane should match. That lane is not verified locally. - No open PR modifies a deleted file. amd#4260 edits the chat agent's `app.py`, not `src/gaia/rag/app.py`. </details> ## Test plan - [x] `pytest tests/unit/test_import_all_modules.py`: fails on `origin/main` (shell/prompt.py + 3 mic scripts). It also fails with prompt_toolkit installed (broken relative import) and with an `__init__.py` added (`gaia.shell.commands` missing). Passes on this branch in both the full dev venv and a `.[api]`-only venv. - [x] `pytest tests/unit/test_rag_index_status.py tests/unit/test_packaging.py tests/unit/test_model_comparison.py tests/unit/email tests/unit/rag tests/test_rag.py`: 296 passed, 9 skipped - [x] `pytest tests/unit` (`.[api]` venv): 14422 passed. The 23 failures (`test_cli_smoke`, `test_uninstall_command`, `test_lemonade_asr`) also fail on `origin/main` in the same env. - [x] C++: `cmake -S cpp -G Ninja && cmake --build` builds clean, and `tests_mock` passes 1002/1002 - [x] black, isort, pylint (CI flags) on the changed Python files - [ ] Windows and macOS unit smoke lanes pass (CI) Part of amd#4243 Co-authored-by: Kalin Ovtcharov <[email protected]>
Stacked on #4299 — merge that first. This branch includes #4299's commit, so the diff will shrink to one commit once it lands.
Before: agent settings saved in the desktop app's config dialog looked saved but were gone after a restart. The settings handler dropped them, nothing loaded them back at startup, and a failed disk write still reported success. After: the settings file validates and stores per-agent settings, the agent store loads them on startup, and the dialog closes only once the save has landed. If the save fails, the dialog stays open and shows the error.
Note: the agent manager panel that hosts this dialog isn't mounted in the app yet, so there's no clickable golden path today. The fix is verified at the IPC, store, and component level.
Test plan
cd tests/electron && npx jest— 25 suites / 721 tests pass. The newagent config persistencecases (save → new TrayManager reads the file → same config, merge by id, validation, write failure) fail 10/10 without the fix.cd src/gaia/apps/webui && npx vitest run— 52 files / 403 tests pass. The newagentStore.config.test.tsfails 3/3 without the fix.npx tsc --noEmitandnpx vite buildpassFixes #4300