Repository navigation
fix(ui): show an approved edit's diff in the Agent UI and the TUI - #6325
Conversation
Approving an edit_file changed the file but showed nothing of what
changed: the Agent-UI/TUI handler's print_diff was a no-op. It now attaches
a `diff` card ({title, unified}) to the edit's own tool_result, the canonical
translator forwards an event-level render key ahead of the tool map, and the
TUI draws the `diff` card instead of the unsupported fallback. Diffs over 400
lines are cut with a note so a huge edit cannot bloat the stream or the
persisted chat. A handler that draws nothing still returns success.
Fixes #3710
|
Verdict: Approve with suggestions An approved file edit now shows its diff in the Agent UI and the TUI, where before both showed nothing. The card attaches to the edit's own result, can't spill onto the next tool call, and huge diffs are capped. The wiring is sound and well tested. There is one thing to fix before users see this. Every changed line in the card comes out double-spaced: a blank line follows each Real-world evidenceThe evidence stage ran the real The stream event an edit now produces: The A payload missing 🔍 Technical details🟡 Important🟡 Diff card shows every changed line followed by a blank line ( diff = "\n".join(
difflib.unified_diff(
current_content.splitlines(),
updated_content.splitlines(),
fromfile=f"a/{os.path.basename(str(path))}",
tofile=f"b/{os.path.basename(str(path))}",
lineterm="",
)
)Add an assertion to 🟢 Minor🟢 TUI truncation line looks like an added line ( Update the 🟢 The 400-line cap doesn't bound size ( Strengths
|
Every changed line in the new diff card was followed by a blank line: the edit tool kept each line's ending and then joined lines with another newline. Each line is now terminated once (a line-ending-only edit still diffs), which also halves the line count the 400-line cap and the TUI's row budget were charging. One huge line, such as an edit to a minified file, is now capped at 64,000 characters, and the TUI's truncation line no longer starts with "+" where it reads as an added line.
|
I pushed fixes for the review's three points: the diff card is single-spaced now, one huge line can no longer bloat the stream, and the TUI's truncation line doesn't read as an added line. 🔍 Technical details
|
Skill audit
✅ All audited skills cleared the tier they claim. Per-finding detail is withheld here on purpose. Read it in the Security > Code scanning tab, or download the |
… answer An in-process agent's approved edit showed "Card failed to render" in the Agent UI, because its tool_result carried the diff under result_data while ChatView and step persistence read cards from data. The event now carries the card under data too. A diff card also made a turn that edited a file and then wrote nothing count as answered, so it saved as an empty success instead of "GAIA ran its tools but didn't write an answer." Diff cards no longer count as an answer, on the in-process and relay paths alike. The TUI diff card now expands tabs to 4-column stops instead of collapsing each tab to one space.
|
Fixed the two regressions the verifier found. An approved edit now draws its diff in the Agent UI when the agent runs in-process, instead of "Card failed to render". A turn that edits a file and then writes no answer is back to "GAIA ran its tools but didn't write an answer." The TUI diff card also keeps tab indentation now. 🔍 Technical details
|
Approving a file edit in the Agent UI or the TUI changed the file but never showed what changed — the CLI drew a diff, these two drew nothing. Now the edit's tool row carries a diff card in both: the Agent UI's existing
DiffCarddraws it, and the TUI gains a plain-textdiffcard instead of the "Unsupported card" fallback. The #3702 contract holds: a handler that can't draw a diff still reports the edit as a success.The card rides the edit's own
tool_result(one result per call, so it lands under the right row and is saved with the step; redrawing saved cards on reload is still #2109). Diffs over 400 lines are cut with a "Showing the first 400 of N" note so a huge edit can't bloat the stream or the saved message.Fixes #3710
Test plan
python -m pytest tests/unit/chat/ui/test_edit_diff_card.py -q— 13 passed: the realedit_filetool + real handler + real translator emitrender: "diff"with a schema-valid payload; no card on a no-op edit; a card never leaks to the next call (including a call whose result was skipped); a render-map card still wins; cap boundary at exactly N and N+1 lines; empty / non-stringrenderon an event is ignoredpython -m pytest tests/unit/chat/ui/ tests/unit/agents/test_write_display_contract.py tests/unit/agents/test_no_arg_tool_start.py hub/agents/email/python/tests/test_render_tool_to_lang_sync_2765.py tests/unit/test_email_sidecar_relay.py -q— 2966 passed, 14 skippedgo test ./...intui/— passes (newdiff_test.go: hunk drawn, badge/note, missing/wrong-typeunifiedis invalid, CRLF and ANSI escapes can't shear the card, long diff bounded with a count, narrow terminal)python util/lint.py --black --isort,gofmt -l,go vetcleangaia-tui