Skip to content

perf(terminal): append output without replaying retained history - #308

Merged
rynfar merged 6 commits into
pylonfrom
upstream/2026-09-06-terminal-streaming
Sep 6, 2026
Merged

perf(terminal): append output without replaying retained history#308
rynfar merged 6 commits into
pylonfrom
upstream/2026-09-06-terminal-streaming

Conversation

@rynfar

@rynfar rynfar commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Long terminal sessions repeatedly rebuilt retained history, replayed whole buffers when retention rolled over, and allocated temporary buffers for snapshots.

Port five upstream terminal fixes (#9663, #9703, #9707, #9748, and #7680). Server history now appends incrementally and retains at most 5,000 lines or 8 MiB. Client output uses chunked storage and an append cursor, Ghostty reuses snapshot buffers safely across WebAssembly memory growth, and PTYs advertise truecolor when COLORTERM is unset. Preserve Pylon’s terminal command ordering and adapt mobile’s existing string-buffer boundary without changing its native ABI.

Validation: 111 focused tests passed across server terminal management, both PTY adapters, shared terminal state, real Ghostty WebAssembly, and mobile terminal menus. Typechecks passed for server, client-runtime, web, and mobile; changed-file lint passed.

Integrated Chromium verification used a real server PTY and Ghostty renderer with 5,300 output lines. Both baseline and candidate retained the latest 5,000-line tail (524,264 characters in this fixture); the candidate reported COLORTERM=truecolor where the baseline was unset. This verifies retained output, rendering, and truecolor behavior; it is not a measured performance benchmark or native mobile run.

Client verification evidence

terminal-before.png

terminal-after.png

terminal-after.webm

Model: GPT-6 Astra. Harness: Codex.

t3dotgg and others added 6 commits September 6, 2026 09:11
(cherry picked from commit cccd7e3c885065e925f559c5708378cdb3b51eb3)
Append terminal history incrementally and materialize text for snapshots and coalesced disk writes.
Clear evicted line references without changing retained output.

Continues [#9357](pingdotgg/t3code#9357). The original contribution and author credit are preserved.
The current line limit and wire format stay unchanged. A strict byte limit remains separate work.

Created with GPT-6 Astra (preview) in Codex.

Co-authored-by: will <will@moondiner.com>
(cherry picked from commit 3bbbc1d9fd8b3d649c60ba0137c7dae93a6aab3f)
Keep bounded, byte-counted terminal chunks and append only unread output. Use UTF-16 cursors so compaction preserves live terminal replies. Reset on lifecycle changes or a real retained-data gap.

Keep the existing wire protocol, native buffer interface, and client retention limit. Native streaming and strict server replay byte bounds remain separate.

Continue the client helpers from pingdotgg/t3code#9027 at source head 9391da2b48439d1d7a2b01d169e785682bf8abb8.

Created with GPT-6 Astra (preview) in Codex.

Co-Authored-By: Wout Stiens <71498452+StiensWout@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit da7e46d08e85bcb07ecd78721a40f7b612fac2f2)
Keep at most 5,000 lines and 8 MiB of retained UTF-8 terminal history. Discard the oldest text at either limit while preserving complete live output.

Track bytes and newlines in small chunks. Join split surrogates before eviction. Restore only the needed file tail, handle short reads, and close the file before rewriting current or legacy history.

Created with GPT-6 Astra (preview) in Codex.

Co-authored-by: will <will@moondiner.com>
(cherry picked from commit cf9729d5ee9660c08556e823080d3bb19648ed28)
Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com>
(cherry picked from commit 89ee69e4430b21ee14565abf5c34dae43f38c1d8)
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XL labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.6 KiB 13.6 KiB −19 B (−0.1%) 15.1 KiB
Codex Thread snapshot wire 7.1 KiB 7.1 KiB −14 B (−0.2%) 7.3 KiB
Codex Live turn WebSocket wire 6.6 KiB 6.5 KiB −5 B (−0.1%) 7.8 KiB
Codex Live turn WebSocket decoded 56.5 KiB 56.5 KiB 0 B (0.0%) 66.4 KiB
Codex Live turn messages 8 8 0 (0.0%) 21
Claude Total thread wire 13.8 KiB 13.6 KiB −129 B (−0.9%) 15.1 KiB
Claude Thread snapshot wire 7.1 KiB 7.1 KiB +8 B (+0.1%) 7.3 KiB
Claude Live turn WebSocket wire 6.7 KiB 6.6 KiB −137 B (−2.0%) 7.8 KiB
Claude Live turn WebSocket decoded 58.1 KiB 57.3 KiB −840 B (−1.4%) 66.4 KiB
Claude Live turn messages 8 8 0 (0.0%) 21

Baseline: c966815 · PR result: 311e7c5 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 111.2 KiB
  • Claude decoded thread snapshot: 111.9 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@rynfar
rynfar marked this pull request as ready for review September 6, 2026 18:12
@rynfar
rynfar merged commit e4d21cc into pylon Sep 6, 2026
17 checks passed
@rynfar
rynfar deleted the upstream/2026-09-06-terminal-streaming branch September 6, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants