Repository navigation
fix(webui): collapse long messages, code blocks and step outputs - #5566
Conversation
A 60,000-character pasted log filled 19 screens, a 300-line code block ran 7,500 px, and a long command output showed its raw truncation JSON at 2,500 px. Each now opens as a short preview with a fade and a Show all / Expand toggle; the full text stays one click away and Copy and Resend use all of it. - User messages over 15 lines or 1,500 characters show about 9 lines. - Code blocks over 25 lines show 20; while streaming they cap at 20 so the block never grows and then shrinks. - Step results that are a truncation envelope render the head and tail as plain text with a note on what was omitted; outputs over 25 lines or 2,500 characters are capped at 20 lines and no longer link every path. - The markdown components are module-level so a re-render keeps each code block's expand state.
|
Verdict: Approve with suggestions Long pasted messages, long code blocks and long tool outputs in the Agent UI now open as a short faded preview with an expand toggle, and Copy/Resend still use the full text. The logic is sound and well tested, including the code-block expand surviving streamed tokens (fixed by moving the markdown component map out of render). I found no correctness bugs that need fixing before merge.
Real-world evidenceN/A: no evidence bundle was produced for this run, and the Agent UI render is deferred to the strix-halo lane. The PR reports vitest, tsc, build and Electron jest passing, plus Chrome height measurements at 800 px, but embeds no screenshots. This verdict rests on static review of the diff and the new tests. 🔍 Technical detailsIssues 🟡 No rendered screenshot evidence for an Agent UI change. The rubric asks for a Playwright run against 🟢 (Side effects inside an updater also run twice under StrictMode. It's harmless here, but another reason to move the call out.) 🟢 Envelope note on cut-short JSON ( 🟢 Streaming threshold is message-wide. Strengths
|
The Show less scroll ran inside the state updater, before the body shrank, so it never moved the page. It now runs after the collapse commits. A step result whose JSON was cut short no longer reports fragment lengths that don't add up to the omitted count.
|
Both optional fixes are in: Show less now really scrolls the message back into view, and a cut-short tool output no longer shows character counts that don't add up. Before/after screenshots are in the PR description, and a live Agent UI check is in this comment. 🔍 Technical details
|
|
Checked live in the Agent UI: the 60,221-character pasted log now shows as a short preview with Show all, and a 300-line code block in an answer is capped with Expand (300 lines). 🔍 Technical detailsLive build with this branch merged; same chats as the original finding. Pasted-log bubble: 16,833 px → 285 px, toggle "Show all (60,221 characters)". Code block: 7,467 px → 528 px, toggles "Copy" and "Expand (300 lines)". Dark theme. |
…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>

A pasted 60,000-character log filled about 19 screens of the chat, a 300-line code block in an answer ran 7,500 px, and expanding a long "Ran command" step showed its raw truncation JSON (escaped
\n, every path a link) at 2,500 px. None of them could be collapsed. Now each opens as a short preview that fades out, with a "Show all (700 lines)" / "Expand (300 lines)" toggle under it. Nothing is cut: the full text is one click away, and Copy, Copy code and Resend always use all of it.At an 800 px window, measured in Chrome:
Test plan
npx vitest run: 145 files, 1,538 tests pass, including the newLongContent.test.tsxnpx tsc --noEmit -p .andnpm run buildpasstests/electron:npx jest --cipasses (38 suites)aria-expandeddir /s /b C:\Windows\System32\driversand expand the step: plain paths, one per line, under "Showing the first N and last M characters of …"🔍 Technical details
LongContent.tsx): a user message collapses past 15 lines or 1,500 characters and shows about 9 lines. A code block collapses past 25 lines and shows 20. A step result collapses past 25 lines or 2,500 characters and shows 20.componentsmap moved to module scope. Inline, it handed react-markdown new component functions on every render, which remounted eachCodeBlockand reset its toggle on every streamed token.mask-imageramp, so it needs no per-theme or per-surface colour. On the code surface the toggle is a full-width footer drawn in the code palette. Everywhere else it is the same quiet pill as "N steps · M tools".elide_textintool_output.py): the result is read as JSON. If a display cap cut the JSON short, the head, tail and counts are read field by field instead. Paths inside an envelope or a long output are no longer linked. A short result still links its paths, as before.ChatView.tsxis untouched (101,751 bytes with LF line endings).