Skip to content

feat: add full-text session search via telescope grep picker#70

Open
ttak0422 wants to merge 1 commit into
mainfrom
feat/telescope-full-text-search
Open

feat: add full-text session search via telescope grep picker#70
ttak0422 wants to merge 1 commit into
mainfrom
feat/telescope-full-text-search

Conversation

@ttak0422

Copy link
Copy Markdown
Owner

Summary

Adds a full-text search picker to the telescope extension, alongside the existing title (session-name) search:

:Telescope pterm sessions   " title search (unchanged)
:Telescope pterm grep       " full-text search: scrollback + visible screen, all sessions

Each non-empty line appears as <session>: <line>; Enter opens 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:

  • proto: FULL_TEXT message pair (client 0x08 / server 0x85)
  • daemon: build_full_text() pages through the scrollback like build_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 caveat
  • 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

Multi-lens review with adversarial verification (each item below was reproduced, not just theorized):

  • Unbounded hang against a pre-upgrade daemon: read_single_response() used a per-read 3s timeout that reset on every frame, so an old daemon that ignores FULL_TEXT but keeps streaming OUTPUT frames hung the CLI forever. Now an overall deadline bounds it to 3s
  • RESIZE dropped queued query responses: send_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 for dump/snapshot-text, far more exposed with full-text's larger payloads. Fixed by skipping diagnostic clients; regression test added
  • Test-coverage gap: mutation testing showed regressions in the wrap-rejoin pending handoff escaping the original test; it now covers wraps straddling a paging-window boundary and the scrollback→live-screen seam

Testing

  • cargo test: 41 passed (3 new session tests + 1 new server regression test)
  • E2E: session with 100 scrolled-off lines + a wrapped marker line → full-text returns every line exactly once with the wrap re-joined; snapshot-text/dump unchanged
  • E2E: fake never-answering chatty daemon → full-text fails in ~3.4s instead of hanging
  • stylua --check clean

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant