feat(app): search history by workspace, agent, and branch (#2995)
History was a date-grouped list you scrolled. Finding a session from last week meant eyeballing every row. This adds a search field to the existing filter rail, next to the host picker. Search runs on the daemon, not the client. The daemon already holds every persisted agent in memory, so it ranks the whole history and the client never has to warn that it only looked at the pages it had loaded. A searched response is one ranked page with no cursor. The global top K is always contained in the union of each host's own top K, so merging per-host pages and slicing back to the limit is the exact global answer — no k-way merge, and no offset into a ranking that is recomputed per request, which would duplicate and skip rows as history changes underneath it. Past result 200 of a relevance order the answer is a narrower query, so the footer says that instead of offering a "Load more" that cannot deliver. Matching is the app's existing picker matcher, moved to the protocol package so app and daemon share one implementation instead of drifting into two "why didn't this show up?" rule sets. Typo tolerance is opt-in, so the comboboxes keep exact narrowing; the budget is per token, and four-character tokens get transpositions only, because at that length a free substitution turns "main" into "mail", "maid" and "rain". Ranked rows carry the spans they matched on, so results can mark them. The subsequence and typo tiers match characters the eye would never find unaided, and an unexplained row reads as a bug. The ranker computes the spans anyway; sending them keeps the client from deriving a second opinion that could disagree with the ranking it is explaining. Hosts that fail or are offline are now named above the list. Without that, "No sessions match" is a claim the app has no basis for. Gated on server_info.features.agentHistorySearch, checked once against the connected hosts. Reachability is reported by the banner instead, so one offline host in the registry no longer hides the field.
This commit is contained in:
@@ -1138,6 +1138,10 @@ export const FetchAgentHistoryRequestMessageSchema = z.object({
|
||||
type: z.literal("fetch_agent_history_request"),
|
||||
requestId: z.string(),
|
||||
filter: AgentDirectoryFilterSchema.optional(),
|
||||
// A ranked free-text query over agent title, workspace name, branch, and
|
||||
// project name. Present only on history: agent subscriptions filter on
|
||||
// structure, not on relevance. Ranking replaces `sort` when it is set.
|
||||
search: z.string().optional(),
|
||||
sort: z
|
||||
.array(
|
||||
z.object({
|
||||
@@ -2880,6 +2884,8 @@ export const ServerInfoStatusPayloadSchema = z
|
||||
rewind: z.boolean().optional(),
|
||||
// COMPAT(agentTimelinePromptIndex): added in v0.2.X, drop the gate when floor >= v0.2.X.
|
||||
agentTimelinePromptIndex: z.boolean().optional(),
|
||||
// COMPAT(agentHistorySearch): added in v0.3.0, remove gate after 2027-02-07.
|
||||
agentHistorySearch: z.boolean().optional(),
|
||||
// COMPAT(checkoutRefresh): added in v0.1.86, remove gate after 2026-11-29.
|
||||
checkoutRefresh: z.boolean().optional(),
|
||||
// COMPAT(workspaceMultiplicity): added in v0.1.97, drop the gate when floor >= v0.1.97
|
||||
@@ -3307,9 +3313,31 @@ export const AgentListMessageSchema = z.object({
|
||||
}),
|
||||
});
|
||||
|
||||
export const AgentSearchMatchFieldSchema = z.enum(["workspace", "title", "branch", "project"]);
|
||||
|
||||
export const AgentSearchMatchSchema = z.object({
|
||||
field: AgentSearchMatchFieldSchema,
|
||||
ranges: z.array(
|
||||
z.object({
|
||||
start: z.number().int().nonnegative(),
|
||||
length: z.number().int().positive(),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
export type AgentSearchMatch = z.infer<typeof AgentSearchMatchSchema>;
|
||||
|
||||
const AgentDirectoryResponseEntrySchema = z.object({
|
||||
agent: AgentSnapshotPayloadSchema,
|
||||
project: ProjectPlacementPayloadSchema,
|
||||
// Relevance of this entry to the request's `search`, lower being better.
|
||||
// Set only when the request carried a query; a client merging results from
|
||||
// several hosts needs it to interleave their separately ranked pages.
|
||||
searchScore: z.number().optional(),
|
||||
// Where the query matched, so the row can mark it. The ranker computes this
|
||||
// anyway; sending it keeps the client from re-deriving a second opinion that
|
||||
// could disagree with the ranking it is explaining.
|
||||
searchMatches: z.array(AgentSearchMatchSchema).optional(),
|
||||
});
|
||||
|
||||
const AgentDirectoryPageInfoSchema = z.object({
|
||||
@@ -3334,6 +3362,10 @@ export const FetchAgentHistoryResponseMessageSchema = z.object({
|
||||
requestId: z.string(),
|
||||
entries: z.array(AgentDirectoryResponseEntrySchema),
|
||||
pageInfo: AgentDirectoryPageInfoSchema,
|
||||
// More sessions matched the request's `search` than the page could hold.
|
||||
// Distinct from `pageInfo.hasMore`, which promises a fetchable next page —
|
||||
// a ranked result set has none, and the way on is a narrower query.
|
||||
searchTruncated: z.boolean().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user