Repository navigation
feat: reach all terminal history and page thread search instead of capping it - #6
Merged
Merged
Conversation
Terminals kept only 5,000 lines or 8 MiB on the server, sent at most 512 KiB on attach with no way to reach anything older, held 10,000 rows in the client views, and forgot all but 128 exited sessions. Each persist also rewrote the whole history file, which would not scale to larger histories. The server now keeps up to 1,000,000 lines and 256 MiB per terminal by default (T3CODE_TERMINAL_HISTORY_MAX_LINES / _MAX_BYTES override them). History files grow by appends and are rewritten only when the history is cleared or the trimmed prefix outgrows the retained text, so total writes stay under about twice the output; existing files still load, and loading no longer rewrites them. Exited sessions are retained up to 4,096 and 4 GiB of history. An attach sends the newest 512 KiB plus its offset; the new terminal.history RPC returns the 512 KiB page before an offset. Clients prepend pages into the same buffer (now 8 MiB). Web and desktop load a page when the user scrolls to the top and keep the viewed rows in place; mobile gets a "Load earlier output" terminal menu action, since its native views own scrolling. Web, Android, and iOS views hold about 100,000 rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Message search read only the newest 2,000 hits, and of those at most the newest 10,000 index candidates or, without the index, the newest 20,000 messages. Anything older was silently missing from results. Search now pages newest-first by message rowid. Each page still reads at most 2,000 hits, passes over at most 10,000 index candidates (or scans 50,000 messages without the index) and returns up to `limit` ranked threads, so one request stays as fast as before. The result carries a cursor while older messages may hold more; the next request passes it back with the threads already returned, which later pages leave out. Every matching thread in a page's range is either returned or already excluded, so paging to the end misses none. The agent search tool keeps its single top-ranked page. Clients follow pages that found nothing on their own, and the web sidebar and mobile thread list searches show "Search older messages" while more remain. The command palettes keep showing only their best few message matches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ds it excludes Clients followed empty pages of message matches to the end of history on their own, which on a long history without matches could read for seconds per query. They now stop after three empty pages in a row and show "Search older messages", so the user decides whether to keep going. Without the index a page scans 20,000 messages again, as a single read did before paging. excludedThreadIds is capped at 2,000 threads; a search that reaches that many stops and says so in the web sidebar and mobile thread lists instead of dropping later matches silently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…indow Clients could page older output only until their 8 MiB buffer filled, so most of a large server history stayed unreachable and scrolling to the top silently did nothing. Reopening a terminal also processed its whole history synchronously, and history rewrites truncated the file in place. History offsets now count UTF-8 bytes, so they map onto the history file. Each terminal keeps its newest 16 MiB in memory (512 MiB across all terminals, 256 MiB for exited ones); older output stays only in the file, and `terminal.history` reads pages before or after any offset from memory or the file. Loading reads the file in blocks and keeps just the tail, and the alternate-screen scan on reopen looks at the last 4 MiB. Rewrites copy what is still needed into a temporary file and rename it over the old one, so a crash leaves one whole file; a failed append marks the file for such a rewrite. Output events carry the server's history end. A client holds a window of about 4 MiB and 25,000 lines: reading further back drops its newest output and pauses on earlier output, buffering live output aside; reading forward drops the oldest, and reaching the end follows the live output again. On web the view keeps the rows being read in place, asks for a page once per arrival at an edge, and shows "Jump to latest" while paused. Mobile gets "Load later output" and "Jump to latest output" menu actions. Views keep 60,000 rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the sliding window found several ways to lose older output or stall: - A live event over 16 KiB is split into chunks and only its last knows the server offset, so trimming an earlier one lost the window's start and "load older" stopped working. Trimming now drops through to that last chunk. - A paused view whose end the server had since trimmed ignored the next page, so "load later" did nothing. The page is accepted after a visible "Earlier output was removed" line; an older page past the server's start ends paging. - In narrow terminals 4 MiB of output can exceed the view's 60,000 rows, so a prepended page fell outside the view. The window now holds no more than fits the rows of the terminal's grid (a row per line plus one per column width of bytes), and the separate line budget is gone. - A page read chose its file range before taking the file lock, so a rewrite in between could make it read before the file's start. The range is re-clamped against the history and file start under the lock. - Memory pages now start at a character boundary. - Failed history writes, as on a full disk, back off from 1 s up to 60 s instead of trying a full rewrite every 250 ms; each failure is still logged, and closing a terminal still writes at once. - Rewrite directories a crash left behind are removed at startup, and history deletion takes the file lock so a rewrite cannot rename a file back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Second-review fixes in 73c62ba: large live events keep the window's start offset; a view paused past trimmed history shows a visible marker and rejoins live output; page reads re-clamp against the file start under the lock; leftover rewrite temp dirs removed at startup; backoff (1 s doubling to 60 s) after failed writes; deleteHistory takes the file lock; the client window is sized to the view's row capacity (narrow views hold less, documented); page starts aligned to UTF-8 boundaries.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Terminal scrollback kept 5,000 lines / 8 MiB per terminal and showed clients at most 512 KiB; thread search returned the newest 2,000 hits and scanned only the newest 20,000 messages without the index. Older output and older matches were silently unreachable.
Terminal history
T3CODE_TERMINAL_HISTORY_MAX_LINES,T3CODE_TERMINAL_HISTORY_MAX_BYTES). Persistence appends; rewrites go to a temp file, fsync, rename. Old history files load unchanged; loading streams the file and keeps only the newest part decoded.terminal.historyRPC pages before/after any byte offset. Clients keep a ~4 MiB / 25,000-line sliding window: scrolling to the top loads older output (dropping the newest), scrolling down loads newer, live output waits aside and resumes on "Jump to latest". Web keeps the reading position; mobile has "Load earlier/later output" and "Jump to latest" menu items. Scrollback 60,000 rows (iOS 60 MB).Search
Not done: native Android/iOS changes are not compiled (mobile needs a native rebuild); not yet tried in a running client; disk paging not benchmarked. Measured search on a 1M-message copy: no page over ~400 ms.
vp test run src/terminal src/orchestration-v2/ThreadSearch.test.ts src/provider/AgentContextBudget.test.ts(apps/server)vp test runterminalSession, terminal, threadSearch (client-runtime)vp test runThreadTerminalDrawer, terminal/ghostty (apps/web)vp test run src/features/terminal(apps/mobile)vp run check:changedClaude Opus 5.5 via Claude Code (T3 Code).