Skip to content

feat(cli): /search greps the current session for a substring#212

Merged
emal-avala merged 1 commit intomainfrom
feat/search-command
Apr 23, 2026
Merged

feat(cli): /search greps the current session for a substring#212
emal-avala merged 1 commit intomainfrom
feat/search-command

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

Adds `/search ` (alias `/find`) — case-insensitive substring match across every message in the session, with a context snippet and role tag on each hit.

```

5 [user] …what does `fn main` do in Rust?…

7 [asst] …a `fn main` is the entry point of the binary…

12 [tool] …Searched src/ for fn main and found…

3 match(es) for "fn main".
```

Searches all text-bearing content: text blocks, tool-result bodies, tool_use names + JSON args, and thinking blocks. Caps at 20 hits so a stray common word (`the`, `error`) doesn't flood the scrollback.

Why

`/scroll` has search but only while inside the viewer. `/history` only shows your prompts. Neither helps you find "where did the agent mention the error string" or "which tool call read that config file". `/search` covers that gap from the main REPL.

Test plan

  • `cargo fmt --all`
  • `cargo clippy -p agent-code --all-targets -- -D warnings`
  • `cargo test -p agent-code --bin agent` (114 passed)
  • New tests:
    • `snippet_around_match_includes_ellipses_when_trimmed`
    • `snippet_around_match_is_case_insensitive`
    • `snippet_around_match_returns_none_for_absent_needle`
    • `snippet_around_match_handles_multibyte_boundaries` — guards against byte/char boundary bugs with emoji + accents
    • `snippet_around_match_empty_needle_yields_none`
    • `message_searchable_text_covers_tool_use_and_result`
    • `message_tag_labels_each_variant`

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Case-insensitive substring match across every message in the
current session — text blocks, tool-result bodies, tool_use names +
JSON args, and thinking blocks. Returns numbered rows with a
role tag (user/asst/tool/sys) and a ~80-char context snippet
around the first hit per message.

  /search error
  /search "fn main"
  /search Bash ls

Caps at 20 hits to avoid flooding the scrollback. Character-
boundary-aware snippet slicing so multi-byte content (emoji, CJK)
doesn't panic on mid-glyph cuts.
@emal-avala emal-avala force-pushed the feat/search-command branch from b11f6f7 to 69d1174 Compare April 23, 2026 16:30
@emal-avala emal-avala merged commit 5ac5dc9 into main Apr 23, 2026
14 checks passed
@emal-avala emal-avala deleted the feat/search-command branch April 23, 2026 16:58
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