Skip to content

Compare output: diff two runs of a command - #361

Draft
raiseCatError wants to merge 8 commits into
feature/copy-reportfrom
feature/compare-output
Draft

raiseCatError wants to merge 8 commits into
feature/copy-reportfrom
feature/compare-output

Conversation

@raiseCatError

@raiseCatError raiseCatError commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #360. Closes #352. Part of #359.

  • Entry points: Actions → Compare output…, /compare, /compare N, /compare N M.
  • Suggestion: previous run of the same command; any block can be chosen. Records are identified by object/startId from a snapshot, never by screen position.
  • Diff: bounded Myers line diff, computed lazily; changed/added/removed counts; hunks with context; unchanged regions collapsed; refuses honestly when outputs cannot be aligned.
  • View: side by side ≥140 columns, unified otherwise; n/N; explicit, labelled whitespace normalization; NO_COLOR/Safe glyph-safe text.
  • Copy: c unified diff; r comparison report through the shared report review (wrapped, redacted, exact text).
  • Honesty: records that lost output while detached carry outputIncomplete and comparisons say so.
  • delta: considered; not integrated in this slice. The native view needs no dependency, and delta's paging/TTY handoff would add a second presentation for little gain. Documented in docs/design/terminal-workflow.md.

Tests: tests/compareOutput.test.ts (randomized reconstruction, counts, hunks, headers, normalization, unaligned, 5000-line timing, panel keys and layouts, hostile text, report review), tests/compareOutputLive.test.ts (real PTY: /compare, copy diff, bare /compare, missing numbers).

Review gate

  • #363 check diff content sanitization, terminal escape/Markdown injection, report review vs direct diff copy, exact clipboard bytes and narrow rendering against current HEAD.
  • Re-run focused/full tests and real PTY; record manual QA and only then mark ready. Stacked on Copy as Report: reviewed Markdown/plain reports from command blocks #360 and remains draft; no merge/release without approval.

- Actions → Compare output… and /compare [N [M]] (numbers as /copy shows them). The previous run of
  exactly the same command is suggested; any other completed block can be chosen. Bare /compare goes
  straight to the latest output and its previous run.
- Faithful by default: a Myers line diff over the stored output, bounded (outputs too different to
  align are said to be so instead of shown as a misleading diff). Changed, added and removed lines,
  three lines of context, unchanged regions collapsed; A is always the older run.
- Side by side at 140 columns or wider, unified otherwise; n/N between changes; w ignores whitespace,
  labelled wherever the result is shown or copied; both sides named by command, time and exit code.
- c copies a unified diff (feedback inside the panel). r opens the comparison report in the same
  review as Copy as Report: wrapped, redacted, exactly the text Enter copies.
- Output a detached session could not keep is flagged on its record (outputIncomplete) and said in
  comparisons; missing output is said, never guessed.
…reviewed, safe text

The plain diff copy now strips control and invisible characters like a report does and says when it looks sensitive and is not redacted. The comparison report cleans the diff before sizing its fence (hidden characters and Unicode line separators could close it) and writes each side's label as safe inline code.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant