mirror of
https://github.com/wu736139669/hapi.git
synced 2026-12-04 06:57:55 +00:00
Port the H5 content-search scope to the native session list: - The search field gains a Sessions/Content scope menu. Content mode debounces the hub's POST /sessions/content-search over the sessions visible under the current machine/status/unread filters, discards stale responses by generation, and surfaces loading, failure, and potentially-incomplete result states. - Result rows keep the two-line contract: the matched snippet (plus a truncation mark) replaces the project line, while server relevance order is preserved. - Tapping a hit passes its message id to the chat. A row already in the loaded transcript scrolls directly; otherwise the window controller loads the hub's bounded message-context page, enters history mode, and the chat scrolls/flashes the target. "Back to latest" still resets to the live tail because a context window is explicitly not the tail. Adds content-search wire models, endpoint coverage, context-window transition tests, and session-list model tests for scoping and rendering. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run> Co-Authored-By: Claude Code <noreply@anthropic.com>
58 lines
1.8 KiB
Swift
58 lines
1.8 KiB
Swift
import Foundation
|
|
|
|
/// One message hit from the hub's opt-in content search
|
|
/// (`SessionContentMatch`, `shared/src/apiTypes.ts`).
|
|
public struct SessionContentMatch: Codable, Equatable, Sendable {
|
|
public var messageId: String
|
|
/// `user` or `assistant`.
|
|
public var role: String
|
|
public var seq: Int
|
|
public var createdAt: Int
|
|
/// Hub-composed surrounding text (markup stripped, bounded).
|
|
public var snippet: String
|
|
/// The indexed message exceeded the search index budget.
|
|
public var truncated: Bool
|
|
|
|
public init(
|
|
messageId: String,
|
|
role: String,
|
|
seq: Int,
|
|
createdAt: Int,
|
|
snippet: String,
|
|
truncated: Bool
|
|
) {
|
|
self.messageId = messageId
|
|
self.role = role
|
|
self.seq = seq
|
|
self.createdAt = createdAt
|
|
self.snippet = snippet
|
|
self.truncated = truncated
|
|
}
|
|
}
|
|
|
|
public struct SessionContentSearchResult: Codable, Equatable, Sendable {
|
|
public var session: SessionSummary
|
|
public var match: SessionContentMatch
|
|
|
|
public init(session: SessionSummary, match: SessionContentMatch) {
|
|
self.session = session
|
|
self.match = match
|
|
}
|
|
}
|
|
|
|
/// `POST /api/sessions/content-search` (`SessionContentSearchResponse`).
|
|
public struct SessionContentSearchResponse: Codable, Equatable, Sendable {
|
|
public var results: [SessionContentSearchResult]
|
|
/// True when the query may miss content omitted by an indexing
|
|
/// optimization (the list surfaces a hint rather than hiding results).
|
|
public var hasPotentiallyIncompleteResults: Bool
|
|
|
|
public init(
|
|
results: [SessionContentSearchResult],
|
|
hasPotentiallyIncompleteResults: Bool
|
|
) {
|
|
self.results = results
|
|
self.hasPotentiallyIncompleteResults = hasPotentiallyIncompleteResults
|
|
}
|
|
}
|