Normalize whitespace in grid get_process_output to save tokens

Grid snapshots pad every row to the full terminal width and leave the
bottom of the screen blank, so MCP grid reads carried a lot of dead
whitespace. Add normalizeGridText (CRLF/lone-CR to LF, right-trim each
line, collapse blank runs to a single blank, drop leading/trailing
blanks) and apply it to the grid branch of GetProcessOutput only.
Stream output, raw output, and WaitForPattern matching are untouched.

Resolves the terminal-read newline/token-waste TODO item.
This commit is contained in:
2026-05-25 12:33:59 +01:00
parent 50fd7be70d
commit 53f06b604f
4 changed files with 72 additions and 2 deletions

View File

@@ -1,4 +1,3 @@
- [ ] We should deduplicate /r/n newlines or /n newlines to save tokens on mcp responses for terminal reads.
- [ ] Codex idle detection seems to trigger too soon, see below [CODEX IDLE]
- [ ] Issue with mcp timing out [MCP TIMEOUT]
- [ ] When opening a codex sub agent, the message gets input to the field, but the message is never submitted.