feat: add full-text session search via telescope grep picker#70
Open
ttak0422 wants to merge 1 commit into
Open
feat: add full-text session search via telescope grep picker#70ttak0422 wants to merge 1 commit into
ttak0422 wants to merge 1 commit into
Conversation
Add a `:Telescope pterm grep` picker that searches every session's contents line by line and opens the session containing the selected line. The existing `sessions` picker remains the title (name) search. The daemon previously exposed only the visible screen (snapshot-text), so full-text search needed a new query: - proto: FULL_TEXT message pair (client 0x08 / server 0x85) - daemon: build_full_text() renders scrollback + visible screen as plain text, re-joining wrapped rows so text spanning a wrap point stays searchable; skips scrollback while the alternate screen is active (same policy as history replay) - CLI: `pterm full-text <session>`; dump/snapshot-text/full-text now share one cmd_query() helper - lua: M.full_text(), with snapshot_text/dump refactored onto a shared run_text_command() helper Hardening found during review: - read_single_response() now enforces an overall deadline instead of a per-read timeout that reset on every frame: a pre-upgrade daemon that ignores FULL_TEXT but keeps streaming OUTPUT frames caused an unbounded hang (reproduced); now it fails within 3s - send_snapshot_to_client() skips diagnostic query clients: a RESIZE arriving while a dump/snapshot-text/full-text response was queued but unsent dropped the response permanently (reproduced; latent for the existing queries, far more exposed with full-text's larger payloads). Regression test added - wrap-rejoin test strengthened to cover wraps straddling a scrollback paging-window boundary and the scrollback->live-screen seam, the two paths where mutation testing showed regressions escaping the old test Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Adds a full-text search picker to the telescope extension, alongside the existing title (session-name) search:
Each non-empty line appears as
<session>: <line>;Enteropens that session. The preview pane reuses the existing screen-snapshot previewer.Implementation
The daemon only exposed the visible screen (
snapshot-text), so full-text search needed a new query end to end:FULL_TEXTmessage pair (client0x08/ server0x85)build_full_text()pages through the scrollback likebuild_history()and renders scrollback + visible screen as plain text. Wrapped rows are re-joined into one logical line so text spanning a wrap point stays searchable. Scrollback is skipped while the alternate screen is active (same policy as history replay); README documents this caveatpterm full-text <session>;dump/snapshot-text/full-textnow share onecmd_query()helperM.full_text(), withsnapshot_text/dumprefactored onto a sharedrun_text_command()helperHardening found during review
Multi-lens review with adversarial verification (each item below was reproduced, not just theorized):
read_single_response()used a per-read 3s timeout that reset on every frame, so an old daemon that ignoresFULL_TEXTbut keeps streamingOUTPUTframes hung the CLI forever. Now an overall deadline bounds it to 3ssend_snapshot_to_client(replace_send_buf=true)cleared a diagnostic client's queued-but-unsent response, so the CLI timed out and the session silently vanished from grep results. Latent fordump/snapshot-text, far more exposed with full-text's larger payloads. Fixed by skipping diagnostic clients; regression test addedpendinghandoff escaping the original test; it now covers wraps straddling a paging-window boundary and the scrollback→live-screen seamTesting
cargo test: 41 passed (3 new session tests + 1 new server regression test)full-textreturns every line exactly once with the wrap re-joined;snapshot-text/dumpunchangedfull-textfails in ~3.4s instead of hangingstylua --checkclean🤖 Generated with Claude Code