mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-10 01:09:43 +02:00
GET /api/sessions/:id/terminal?full=1 captured the whole tmux history (capture-pane -S -<history limit>, 100,000 lines by default) and cut it to `tail` only afterwards, all of it synchronous on the server's event loop. A grid tile keeps TILE_SCROLLBACK lines plus its screen, so the rest was captured to be thrown away, once per tile on every grid open, restore and deploy reconnect. The route now takes an optional `lines=<n>` (an integer of at least 1, clamped to the configured history limit) and passes it as the capture's history bound (the existing historyLimitLines, so -S -<n>); absent or malformed, the limit itself, so every existing caller gets the same capture as before. Only full captures read it: the visible-frame path (a shell tile's `tail=` load) reads no history and is untouched. The capture still ends with its RELATIVE cursor move back to the caret, still counts as a full capture (isFullCapture: the line-deleting transforms stay off) and still reports captureCols/captureRows. Grid tiles (boundedLoad) send lines=<scrollback + rows> on every full capture of theirs: a TUI load and a shell history pull. The split's Pane B asks for everything, as before. Measured: - A real haiku Claude pane on tileperf (about 3k lines of history): bounded captures (lines=50, 500, 2000, 100000) against the unbounded one, 4 PASS 0 FAIL: each a line-aligned suffix of it, ending in the same relative cursor move (ESC[4A CR ESC[2C), same source (mux-full-history) and capture geometry. Capture time there 72 ms both ways, that history being shorter than the tile's bound. As a grid tile (it sent lines=10047) its screen matched the pane row for row, 47 of 47 at the pane's own 77x47, caret on the composer. - Six tiles restoring with Claude-style loads (full=1&tail=1MiB forced on shells with about 19k lines of tmux history each, above the tile's bound; n=3+3 interleaved, load 4.2 to 7.2): capture per tile med 219 ms [194 to 294] -> 155 ms [127 to 211]; server event-loop delay in the capture window, max med 262 -> 201 ms; all painted 4.5 -> 3.6 s. At checkpoint 1 a 30k-line history cost 713 ms per capture (event loop blocked up to 765 ms each); the bound caps that at the tile's size. Tests: the route passes lines= through, clamps it, ignores every malformed form and leaves the visible-frame capture exactly as it was; a bounded capture keeps its rows and ends in the cursor restore; grid tiles send it on full captures and the split's Pane B does not. Mutation-checked six ways (lines ignored, no clamp, a lenient parse, lines on the visible path, the tile sending none, Pane B sending it). Documented in docs/api-reference.md (/api/v1 is public). Scope: PR 2 (the grid's loads; server route plus terminal-tile.js). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>