Repository navigation
fix(desktop): crash dialog restarts or quits, quit no longer hangs - #5537
Conversation
…nstall dialogs fit the failure When GAIA's backend died, the crash dialog's "Quit" did nothing, left the app running with no backend, and its log tail showed raw colour codes. Its replacement offers Restart GAIA / Save diagnostics / Quit, and each one ends in a restart or a quit. - Quit after a backend crash used to hang for good: with nothing left to stop, cleanup resolved in the same tick as the prevented will-quit, and Electron dropped the re-quit. The re-quit now waits a task. - The install-failure dialog offers "Install uv (auto)" only when uv is what failed; every other failure defaults to Retry. - The "Lemonade Server found" question is modal to the progress window and brought to the front, so it can't open hidden while the install waits at 70%. - A chat export's Save dialog is titled "Save from GAIA", not after a blob: URL.
- Restart after a crash relaunches the AppImage file itself; its temporary mount is gone once the app exits, so relaunching process.execPath would only quit. - The crash dialog shows the last 8 log lines, so it fits on screen. - "Install uv" is offered only for the ensure-uv stage, the one that exists.
|
Verdict: Approve with suggestions Every button in the desktop crash dialog now does something: Restart GAIA, Save diagnostics, or Quit. Quit no longer hangs when there is nothing left to clean up. The install-failure dialog only offers "Install uv" when uv is what failed, and the Lemonade question opens in front of the progress window. The logic is right and each fix has a focused unit test. Nothing blocks the merge. Two small things to look at:
Real-world evidenceN/A here: no evidence bundle was produced for this run. The verdict rests on reading the code and on the author's evidence. The PR description embeds screenshots of the new crash dialog and the install-failure dialog, and its test plan records manual runs of crash → Restart/Quit, a missing-wheel install failure, and quit with no backend left. The Linux AppImage relaunch is unit-tested only and is still unchecked in the test plan. 🔍 Technical detailsIssues found 🟢 The Also add a line about this change to the PR description, since it's a separate user-visible behaviour. 🟢 The crash dialog has no parent window ( Strengths
|
The backend-crash dialog had no owner window, so it could open behind other apps. It is now modal to the main window and brings it forward. The Save-dialog title for exports is registered once on the default session instead of on every window reopen, which piled up listeners on macOS.
|
Both suggestions are in: the crash dialog now opens in front of GAIA's window, and the export Save-dialog title is set up once instead of on every window reopen. The description now mentions the Save-dialog title change. The red macOS unit-test job is a timing flake in an unrelated file-lock test, not this PR. 🔍 Technical details
|
…5610) Four timing-sensitive unit tests failed 8 unrelated PRs this week (#5537, #5539, #5562, #5563, #5564, #5565, #5566, #5568) and one of main's last 11 completed runs. Each still guards the same bug, but no longer races the clock on a busy runner. Every rewritten test was checked by breaking the code: it fails on the real bug and passes 50/50 runs, including under full CPU load. The PR also keeps three tests out of the developer's real `~/.gaia`. ## Test plan - [x] `pytest tests/unit/mcp/client/test_stdio_hung_server.py tests/unit/test_file_lock.py tests/unit/test_mcp_bridge_concurrency.py tests/unit/chat/ui/test_agent_model_override.py tests/integration/test_folder_indexing.py -n 4`: 316 passed, 3 skipped - [x] The four de-flaked tests, run 50x each: 250/250 serial, and 250/250 under xdist (32 workers) with all 32 cores also running busy loops. Main's versions in that same loaded run: redaction failed 10/50. - [x] Each test fails when its bug is put back in the code (see details) - [x] `tests/integration/test_folder_indexing.py -n 4`, 5 runs: all pass. Main's version fails 7 to 9 tests per run. - [x] Test 841 passes with `GAIA_HOME` set to a temp dir. Main's version fails. - [x] Electron `npx jest`: 1098 passed. The one failure, `test_electron_chat_installer.js` (component size 103,725 > 102,400), also fails on main and is unrelated. - [ ] CI green on Linux, macOS and Windows unit lanes <details> <summary>🔍 Technical details</summary> **`test_redaction_stays_fast_on_dense_escapes`** (Linux, 2.01 to 2.03 s against a 2 s limit) - Cause: an absolute 2 s bound. Locally the worst text takes 0.19 s. On a 4-worker, coverage-traced runner it took about 10x that. - Fix: time one 1M-char text against eight 125K texts with the same total length, on the same machine. Linear code scores about 1.0 and a quadratic scan scores 8, so the test asserts < 3. It takes the best of up to three paired runs, and uses the lower of the wall-clock and CPU (`thread_time`) ratios. Contention inflates wall time, and Windows samples CPU time on ticks. The test also fails if the 1M text takes more than 15 s of CPU, which catches a per-position rescan: that is linear but takes minutes. - Break checks: a quadratic prefix copy in `_candidate_windows` (`len(text[:start].rstrip("\\"))`) gives a ratio of 5.9x and the test fails. Main's 2 s test passed that same regression locally (1.57 s). A per-anchor rescan without merging takes 56 s and hits the 15 s ceiling. **`test_children_of_an_exited_server_are_still_stopped`** (Linux) - Cause: the test slept a fixed 2 s for the child watcher. The watcher backs off (0.5, 1, 2, 4 s…), so on a slow start its next scan came after the launcher had exited and the child was never recorded. - Fix: poll until `child_pid in transport._children`, with a deadline of 3 × `_CHILD_SCAN_MAX_S`. - Break checks: never recording children fails with "never recorded". Clearing `_children` before stopping fails with "kept running". Delaying the watcher's first scan by 2.5 s reproduces the CI failure on main's test, and the new test passes. - Note for the product side: a launcher that spawns a child and exits inside a backoff window still orphans that child. Real `npx`/`uvx` launchers outlive the window. **`test_the_next_waiter_takes_the_lock_within_milliseconds`** (macOS, median 6.5 to 8.1 ms against 5 ms) - Cause: macOS stretches `sleep(0.001)` under load, and the 5 ms median left no headroom. - Fix: the test wraps `_poll_interval`, which records each interval and signals the moment the waiter starts a poll's sleep. The lock is released right then, so the whole interval stands between the waiter and the lock. - Assertions: every interval the front waiter asks for is ≤ 2 ms, and the median hand-off is < 15 ms. A 20 ms poll always waits at least 20 ms, so it fails the median even with the bound widened. - Break checks: `_NEXT_POLL_SECONDS = 0.02` or `0.1` fails the interval assertion. Sleeping `_POLL_SECONDS` directly, so `_poll_interval` is bypassed, fails the median (20.8 ms). **`test_a_dropped_idle_connection_is_logged[True]`** (Linux) - Cause: the test asserted that `"Traceback"` was absent from the stderr captured by `capsys`. The traceback in that run came from a fake Lemonade server that `test_lemonade_shared_server.py` left running on the same xdist worker (`BrokenPipeError`). - Fix: the `serve` fixture records the bridge server's own `handle_error` calls, and the test asserts that list is empty. socketserver calls `handle_error` before it closes the connection, so the check doesn't race. A plugin that writes a traceback to stderr during the test fails main's version and passes the new one. - Break check: making `log_error` also call the base `log_error`, and reverting `str(args[0])`, raises `TypeError` in the handler, and the test fails. **Isolation fixes** - `test_folder_indexing.py`: `temp_folder` now lives in `isolated_gaia_home`, a per-test fake home, so `ensure_within_home` still admits it. Parallel workers no longer share or delete `~/.gaia/test_temp`. - `test_issue_841…`: the test now sets `GAIA_HOME` itself, so an inherited value can't override the patched `Path.home`. - `tests/electron/setup.js`: `os.homedir()` points at a per-file temp dir. It is assigned rather than spied, so `jest.restoreAllMocks()` can't undo it. Setting `HOME` would not work, because Jest's sandboxed `process.env` never reaches `os.homedir()`. - The "Ignoring invalid agents section in …\.gaia\tray-config.json" log came from `crash-loop-notification.test.cjs`, which mocks `fs` with a config the validator rejects. The real file was never read, but the path now names the temp home. </details>
When GAIA's background service crashed, the dialog's Quit only closed the dialog and left a dead window, and its log tail was full of colour-code junk. Quitting with nothing left to clean up could hang, and a failed install offered "Install uv" for failures that had nothing to do with uv. Now every crash-dialog choice ends somewhere (Restart GAIA, Save diagnostics, Quit), quit always exits, install-failure dialogs offer only actions that fit the failure, and the crash and Lemonade-choice dialogs open in front of GAIA's window instead of behind it. Exporting a file also opens a Save dialog titled "Save from GAIA" instead of one named after an internal
blob:URL.Test plan
cd tests/electron && npx jest --ci: 1113 passed. The one failure is the ChatView size check on a CRLF checkout (101,751 bytes with LF; this PR doesn't touch ChatView).relaunchOptions; not run on Linux).🔍 Technical details
app.quit()issued in the same tick as thewill-quitthat started cleanup; the re-quit now waits onesetImmediate.services/backend-crash-dialog.cjsso it can be tested without Electron; the log tail is the last 8 lines, ANSI stripped.execPath: $APPIMAGE; its own mount is gone once the app exits.ensure-uv.parent: mainWindow(restored and focused first); with no live window it shows unowned. Thewill-downloadtitle handler is registered once onsession.defaultSession, sincecreateWindowreruns on every macOS reopen.