Repository navigation
search: add experimental ahp-search channel - #629
Merged
Connor Peet (connor4312) merged 5 commits intoNov 25, 2026
Merged
Conversation
Adds a channel that searches file names, file text, session titles, and chat messages and streams scored, highlighted results into SearchState. Clients start a search with createSearch, change the query with the client-dispatched search/queryChanged (old results stay visible while the lifecycle is pending), and cancel by unsubscribing. Hosts append or replace results with search/resultsChanged and report progress with search/lifecycleChanged. Registers the channel in every generator and client reducer, adds shared reducer and round-trip fixtures, and documents the channel. Also types CompletionItem.rangeStart/rangeEnd as integers in the JSON Schema. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A host may keep a search after the connection closes so a client can resume it, and any subscriber to the channel URI is treated as continuing the same search. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sessions targets may match any session content, not just titles; drop the note that only clients dispatch search/queryChanged (the host echoes every action) and the unsubscribe-before-subscribe aside. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve generator conflicts with deferred turns (#620), renumber search reducer fixtures to 340-346, bump the stability marker count, and use deferred-turn wording in the chat-message target. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Lets clients signal a quick-find context where precise matching isn't expected; hosts may then match loosely and ignore isRegex and wholeWord. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
roblourens
approved these changes
Nov 25, 2026
Dirk Bäumer (dbaeumer)
approved these changes
Nov 25, 2026
Connor Peet (connor4312)
deleted the
agents/search-streaming-cancelable-results
branch
November 25, 2026 17:52
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.
Adds an experimental
ahp-search:/<id>channel (stability 1.0). A client can search file names, file text, session titles, and chat messages in one query. Results stream into channel state, the client can change the query without opening a new channel, and unsubscribing cancels the search.How it works
InitializeResult.search: { targets }. The client callscreateSearchwith a URI it chooses and aSearchQuery, then subscribes. The query hastext,matchCase,wholeWord,isRegex,maxResults, and a list of targets:fileNamesandfileTexttakeroots,includes,excludes, andincludeIgnored. The host decides how to match file names.sessionssearches session titles, the same sessionslistSessionsreturns.chatMessagessearches thechatsit lists.SearchStateis{ query, results, lifecycle }. Each result is one match: aresource, amatch(textplushighlightsas[rangeStart, rangeEnd)UTF-16 ranges, likeCompletionItem), and an optionalscorewhere higher is better. Each result kind adds its own fields:fileText:range, the match location as aTextRange.session:title.chatMessage:titleandturnId;resourceis the chat URI.search/queryChanged(client only) keeps the current results and sets the lifecycle topending, so the list doesn't flash empty.search/resultsChangedappends results. Withreplace: trueit replaces them and movespendingtorunning. This follows thereplaceflag on*/configChanged.search/lifecycleChangedsets one ofpending,running,completed(with a reason) orfailed(with an error). The types follow the terminal channel:SearchLifecycleStateandSearchLifecycleStatus.resultsChangedbefore any other search action. If the query is invalid, the host replaces the results with an empty list and sets the lifecycle tofailed. A host that watches the searched data may keep changing the results of a completed search.Start with the spec.
Reviewers should know
lifecycle. Search state is now checked first, byqueryplusresults, so search snapshots are no longer read as session snapshots. No other state has aqueryfield.@preserveUnknownMembersis only onSearchQueryand its target variants, which clients send back insearch/queryChanged. Results, matches and lifecycle states only go from host to client.{ items }wrappers. Inline wrappers become raw JSON in the generated clients.CompletionItem.rangeStartandrangeEndas integers (minimums 0 and 1) in the JSON Schema. Generated client types don't change.Validation:
npm run generateandnpm testpass (676 tests). These client suites also pass, including the shared reducer fixtures 330–336 and round-trip fixtures 110–117:go testcargo test,fmtandclippyswift testdotnet formatNo live host or VS Code run was performed.