Repository navigation
feat(sessions): add structured local history search - #1
ivanmilevtues wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 949f1a95b4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !source_filter.is_content_search_disabled() | ||
| && xai_grok_shell::session::storage::search::SessionQuery::parse(query).is_structured() | ||
| { | ||
| return vec![]; |
There was a problem hiding this comment.
Preserve foreign literal matches on the All page
When the picker is on SourceFilter::All, this early return suppresses foreign entries as well as native ones because is_content_search_disabled() is true only for External. For example, a Codex session titled title:rust notes previously matched title:rust on the All page but now disappears. Foreign histories are not FTS-indexed, so deep-search results cannot restore it. Apply structured-query suppression per entry to native sources while retaining literal matching for foreign entries.
Useful? React with 👍 / 👎.
| let plan = SessionQuery::parse(query); | ||
| let Some(primary) = plan.primary_match() else { |
There was a problem hiding this comment.
Check structured syntax before taking the session-ID shortcut
A negative-only hexadecimal query can return precisely the session it appears to exclude. For example, -deadbeef passes is_session_id_like() because that helper strips hyphens, and query_session_id() returns a session such as 12345678-1234-1234-1234-deadbeef0000 before this parser runs. This violates the new negative-only query contract through both CLI and ACP search. Parse before the ID shortcut and restrict that shortcut to unstructured queries.
Useful? React with 👍 / 👎.
Session history can now be narrowed with queries such as:
grok sessions search 'title:retry content:"rate limit" -title:archived'Previously, the local index stripped punctuation and searched word prefixes, so phrases, field constraints, and exclusions could not be expressed. This change extracts query parsing and match planning from SQLite into a shared
SessionQuerymodule. Plain keywords retain the existing AND-then-OR fallback; explicit syntax stays strict. BM25 ranking, snippets, workspace scoping, pagination, and session-ID lookup are preserved.The CLI automatically routes structured queries to the local index, adds
--localfor ordinary keywords, and skips authentication refresh for local searches. The native picker uses verified deep-search hits for structured queries so literal title matches cannot bypass content constraints. The ACP extension uses the same query engine.Useful paths to explore in CodeBoarding:
xai-grok-session-search/src/fts.rs→ newquery.rs: parsing and strict/relaxed match plans.xai-grok-shell/src/session/storage/search.rs→ shared query contract exported to consumers.xai-grok-pager/src/sessions_cmd.rs→ query-aware local/remote routing.xai-grok-pager/src/views/session_picker.rs→ structured-query result filtering.Includes parser tests, real SQLite coverage for phrases/scopes/exclusions and pagination, a cold-bootstrap async integration test, picker regressions, and user documentation.
This is a CodeBoarding architecture-diff demonstration PR, similar in scope to the Pi showcase, and is not intended to merge.
Validation:
cargo test -p xai-grok-session-search: 80 tests pass.cargo test -p xai-grok-pager --lib views::session_picker::tests::: 33 tests pass.cargo check -p xai-grok-pager --lib: passes.cargo clippy -p xai-grok-session-search --all-targets -- -D warnings: passes.The broader
cargo check -p xai-grok-pager --testsis blocked by the existingregistered_features_are_documentedintegration test: it includesdocs/internal/25-enterprise.mdanddocs/internal/22-environment-variables.md, neither of which is present in the baseline export. No placeholder documents or unrelated test changes were added.