[PR #1450] [MERGED] perf(process): stop padding rendered terminal lines to full width #2895

Closed
opened 2026-10-17 21:11:31 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1450
Author: @kaoru0822-kitauji
Created: 10/10/2026
Status: ✅ Merged
Merged: 10/10/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: perf/process-trim-rendered-lines


📝 Commits (1)

  • 3b1bee8 perf(process): stop padding rendered terminal lines to full width

📊 Changes

5 files changed (+66 additions, -6 deletions)

View changed files

📝 docs/process-capture.md (+6 -0)
📝 src/domain/process/processScenario.ts (+1 -0)
➕ src/process/capture/TerminalRenderer.test.ts (+47 -0)
📝 src/process/capture/TerminalRenderer.ts (+11 -6)
📝 tests/boundary/process/processCaptureNormalization.test.ts (+1 -0)

📄 Description

Summary

Process capture padded every visible terminal row with trailing spaces to the terminal width (TerminalRenderer used padEnd(columns)). Each rendered frame repeats all rows, so blank and short rows cost a full row in every frame. The padding carried no information: each frame records columns, and serialized_state keeps the exact terminal state.

  • Rendered lines are now trimmed of trailing U+0020 after normalization. line.padEnd(frame.columns) restores the previous value exactly, so nothing is lost.
  • The comparison contract now commits rendered_line_format: "trailing-spaces-trimmed-v1". This follows the port_normalization_version precedent: comparing a capture with padded lines against a new capture reports an incompatible contract that names this field, instead of reporting terminal changes that are only whitespace.
  • rendered_terminal byte accounting counts the trimmed lines, so limits.output_bytes retains more frames before truncating.
  • docs/process-capture.md documents the line format.

No field was removed, and text/structured results are unchanged (#723).

Measurements

Real capture_process_scenario calls through stdio MCP on macOS arm64, comparing whole structuredContent bytes. "Before" means the same capture with its lines padded back to full width.

Command Rendered frames Before After Saved
#1250 sparse workload (65 lines over 1.3 s) 65 227,922 138,241 39%
git log --oneline -15 6 28,216 20,511 27%
echo hello 1 8,134 6,219 24%
ls -la /Applications 4 24,266 20,788 14%

MCP results carry the Evidence in both text and structured content, so a call saves twice these bytes.

Verification

  • New src/process/capture/TerminalRenderer.test.ts covers trimmed rows, preserved blank rows and inner spacing, padEnd(columns) restoration, byte accounting, and normalization still seeing the full-width row.
  • tests/boundary/process/processCaptureNormalization.test.ts pins the committed contract field.
  • npm run test:focused -- all of tests/boundary/process/*, src/domain/process/*, src/process/**, tests/boundary/mcp/toolResult.test.ts, src/application/ReconstructionObligationCandidates.test.ts: 52 files, 336 passed, 3 skipped (Linux-only).
  • tests/acceptance/tools/localToolContracts.test.ts passed. npm run check:changed, npm run typecheck and npm run docs:check pass.
  • Real PTY captures on macOS (table above). No Hopper or Ghidra is involved.

Refs #723, #1065.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1450 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/10/2026 **Status:** ✅ Merged **Merged:** 10/10/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `perf/process-trim-rendered-lines` --- ### 📝 Commits (1) - [`3b1bee8`](https://github.com/morluto/rea/commit/3b1bee877dc553cb86559aea54655cb3d72fbea9) perf(process): stop padding rendered terminal lines to full width ### 📊 Changes **5 files changed** (+66 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `docs/process-capture.md` (+6 -0) 📝 `src/domain/process/processScenario.ts` (+1 -0) ➕ `src/process/capture/TerminalRenderer.test.ts` (+47 -0) 📝 `src/process/capture/TerminalRenderer.ts` (+11 -6) 📝 `tests/boundary/process/processCaptureNormalization.test.ts` (+1 -0) </details> ### 📄 Description ## Summary Process capture padded every visible terminal row with trailing spaces to the terminal width (`TerminalRenderer` used `padEnd(columns)`). Each rendered frame repeats all rows, so blank and short rows cost a full row in every frame. The padding carried no information: each frame records `columns`, and `serialized_state` keeps the exact terminal state. - Rendered `lines` are now trimmed of trailing U+0020 **after** normalization. `line.padEnd(frame.columns)` restores the previous value exactly, so nothing is lost. - The comparison contract now commits `rendered_line_format: "trailing-spaces-trimmed-v1"`. This follows the `port_normalization_version` precedent: comparing a capture with padded lines against a new capture reports an incompatible contract that names this field, instead of reporting terminal changes that are only whitespace. - `rendered_terminal` byte accounting counts the trimmed lines, so `limits.output_bytes` retains more frames before truncating. - `docs/process-capture.md` documents the line format. No field was removed, and text/structured results are unchanged (#723). ## Measurements Real `capture_process_scenario` calls through stdio MCP on macOS arm64, comparing whole `structuredContent` bytes. "Before" means the same capture with its lines padded back to full width. | Command | Rendered frames | Before | After | Saved | |---|---|---|---|---| | #1250 sparse workload (65 lines over 1.3 s) | 65 | 227,922 | 138,241 | 39% | | `git log --oneline -15` | 6 | 28,216 | 20,511 | 27% | | `echo hello` | 1 | 8,134 | 6,219 | 24% | | `ls -la /Applications` | 4 | 24,266 | 20,788 | 14% | MCP results carry the Evidence in both text and structured content, so a call saves twice these bytes. ## Verification - New `src/process/capture/TerminalRenderer.test.ts` covers trimmed rows, preserved blank rows and inner spacing, `padEnd(columns)` restoration, byte accounting, and normalization still seeing the full-width row. - `tests/boundary/process/processCaptureNormalization.test.ts` pins the committed contract field. - `npm run test:focused --` all of `tests/boundary/process/*`, `src/domain/process/*`, `src/process/**`, `tests/boundary/mcp/toolResult.test.ts`, `src/application/ReconstructionObligationCandidates.test.ts`: 52 files, 336 passed, 3 skipped (Linux-only). - `tests/acceptance/tools/localToolContracts.test.ts` passed. `npm run check:changed`, `npm run typecheck` and `npm run docs:check` pass. - Real PTY captures on macOS (table above). No Hopper or Ghidra is involved. Refs #723, #1065. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:11:31 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2895
No description provided.