mirror of
https://github.com/wu736139669/hapi.git
synced 2026-12-04 06:57:55 +00:00
feat(ios): search message content and jump to the matched message
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>
This commit is contained in:
@@ -353,6 +353,43 @@ public enum MessageWindowLogic {
|
||||
return next
|
||||
}
|
||||
|
||||
/// Replace the window with the bounded context page centered on one
|
||||
/// message (content search / jump-to-match). Unlike a latest page this
|
||||
/// enters history mode, so the UI anchors at the target while older and
|
||||
/// newer pages stay reachable. In-flight tail syncs are invalidated so
|
||||
/// they cannot overwrite the context replace; optimistic queued rows are
|
||||
/// preserved by identity.
|
||||
public static func applyContextWindow(
|
||||
_ previous: MessageWindowState,
|
||||
messages: [WindowMessage],
|
||||
page: MessageContextPage
|
||||
) -> MessageWindowState {
|
||||
let retained = messages.filter { shouldRetainWindowMessage($0) }
|
||||
let optimistic = previous.messages.filter { $0.isOptimistic }
|
||||
let merged = MessageMerge.mergeMessages(optimistic, retained)
|
||||
var next = settingMessages(previous, merged)
|
||||
next.epoch = page.epoch
|
||||
next.hasMore = page.hasMore
|
||||
next.oldestPosition = pagePosition(at: page.nextBeforeAt, seq: page.nextBeforeSeq)
|
||||
?? derivePosition(retained, .oldest)
|
||||
next.newestPosition = pagePosition(at: page.snapshotHeadAt, seq: page.snapshotHeadSeq)
|
||||
?? derivePosition(retained, .newest)
|
||||
next.viewMode = .history
|
||||
next.warning = nil
|
||||
// The context page is not the live tail: a normal tail sync must not
|
||||
// claim it is. "Back to latest" runs an allowingHistoryReset sync,
|
||||
// which fetches and replaces this window with the current page.
|
||||
next.requiresLatestReset = true
|
||||
next.isSyncingTail = false
|
||||
next.isLoadingMore = false
|
||||
next.historyVersion = previous.historyVersion + 1
|
||||
next.tailRevision = previous.tailRevision + 1
|
||||
// Cancel responses from requests that started against the old window.
|
||||
next.syncGeneration = previous.syncGeneration + 1
|
||||
next.olderGeneration = previous.olderGeneration + 1
|
||||
return next
|
||||
}
|
||||
|
||||
// MARK: - Tail sync
|
||||
|
||||
/// Web `beginTailSync`: claim a new sync generation. The older generation
|
||||
|
||||
Reference in New Issue
Block a user