Summarise large edit diffs and label the card with file and stat

The chat edit diff card rendered every line of an edit, so the >400-line
fallback flooded the transcript with thousands of Text nodes on a phone;
it also showed only the tool name, not the file, on the expanded panel.

- ChatFormat.toolEditDiff keeps the first MAX_RENDERED_DIFF_LINES (200)
  lines and puts the remainder in the new ToolDiff.omitted, while the
  +N/-M counts continue to describe the whole edit.
- DiffView prints "… N more changed lines not shown" first so the
  truncation is visible without scrolling.
- The expanded panel header now shows the edited file name and the shared
  green/red DiffStat, matching the collapsed chip.
- ChatFormatTest pins omitted = 0 for a small edit and the true counts,
  200-line cap and omitted = 300 for an oversized one.
- android/README.md records the change and its evidence.
This commit is contained in:
2026-10-16 15:15:35 +01:00
parent 291cec2bda
commit e2f306b8bd
4 changed files with 121 additions and 6 deletions
+53
View File
@@ -2664,3 +2664,56 @@ Evidence (macOS, Gradle 9.7.1, `ANDROID_HOME=/Users/alan/Library/Android/sdk`):
Not verified in this pass: the live brokered server (separate lane), streaming
against real OpenCode, and attachments — unchanged from the passes above.
## Edit diffs: file name, stat and large-edit summarisation (16 Oct 2026)
The edit diff card already derived its lines, but three things the task calls for
were missing or wrong. `android/` only; no new dependency (still just the declared
`material-icons-extended`), no Pipelines server/Go/installer/Docker file touched,
no run started from the app, and `emulator-5556` only (lane A's `emulator-5554`
was never addressed).
- **The file name and `+N -M` are on the card, not just the chip.** The expanded
panel header showed the tool name (`edit`); it now shows the edited file (as the
chip already did) and the shared green/red `DiffStat`, so the diff names its file
and its counts wherever it is read.
- **Very large edits are summarised, not flooded.** A diff longer than
`MAX_RENDERED_DIFF_LINES` (200) kept *every* line — the >400-line fallback
rendered `old + new` in full, thousands of `Text` nodes in a scrolling `Column`
on a phone. `ChatFormat.toolEditDiff` now keeps the first 200 lines and carries
the rest in the new `ToolDiff.omitted`; `DiffView` prints
`… N more changed lines not shown` **first**, so the truncation is visible
without scrolling. The `+N -M` counts still describe the whole edit, never the
rendered prefix.
Evidence (macOS, JDK 17, Gradle 9.7.1 `--offline`,
`ANDROID_HOME=/Users/alan/Library/Android/sdk`):
- `gradle :app:testDebugUnitTest :app:assembleDebug` → `BUILD SUCCESSFUL`; the
JUnit XML totals **254 tests, 0 failures, 0 errors, 0 skipped** (new
`toolEditDiffSummarisesAnOversizedEditInsteadOfRenderingEveryLine`, which
asserts the true `+250 -250` counts, the 200-line render cap and
`omitted = 300`; the small-edit test now also pins `omitted = 0`).
- The rebuilt debug APK was installed on `emulator-5556` only and driven against
`.diff_check/chat_stub_diff.py` (the `.tool_calls_check/chat_stub_tools.py`
`/connect` WebSocket double plus a 300-line edit whose intersection with the
cap must summarise; stdlib double, test scaffolding, not the app). Captures were
validated with `android/scripts/capture_png.sh -s emulator-5556`:
`03_diff_small.png` shows the small edit card — `src/layout.kt +2 -2 300ms`,
then red `- val gap = 4.dp` / `- val inset = 1.dp` and green
`+ val gap = 6.dp` / `+ val inset = 2.dp` in monospace — and
`05_diff_summarised.png` shows `src/big.kt +100 -100 150ms` over
`… 200 more changed lines not shown` and the interleaved context/`-`/`+` lines.
`uiautomator dump` confirms the same nodes; `adb -s emulator-5556 logcat -d`
held 0 `FATAL EXCEPTION` and 0 `E AndroidRuntime` during the sweep.
- **APK publish.** `app-debug.apk` (18,220,501 bytes, sha256
`7cfca9c40361d4f1871bc61da20aec8c918637f8e085b8eb534d134b3cb8fe00`) copied to
`~/.local/share/pipelines/data/artifacts/133/1/pipelines-debug-wip-291cec2.apk`;
`curl -I http://10.0.0.75:8080/artifacts/133/1/pipelines-debug-wip-291cec2.apk`
returned `HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
`Content-Length: 18220501`, and a streamed `GET | shasum -a 256` matched.
Not verified in this pass: the live brokered server (separate lane), streaming
against real OpenCode, and attachments — unchanged from the passes above.
`:app:lintDebug` still cannot run here (the Gradle JVM's `25.0.4.1` version
string is rejected by AGP 8.7.2 lint), unchanged from the slices above.