Skip to content

Wire scrollback search UI to the FTS5 index#30

Merged
buggerman merged 1 commit intomainfrom
scrollback-search-ui
Apr 25, 2026
Merged

Wire scrollback search UI to the FTS5 index#30
buggerman merged 1 commit intomainfrom
scrollback-search-ui

Conversation

@buggerman
Copy link
Copy Markdown
Owner

Summary

  • Final piece of scrollback search: Cmd+Shift+F now queries the FTS5 index from Add SQLite FTS5 scrollback index (no UI yet) #29 instead of doing an in-memory substring scan over currently-loaded messages. Searches every persisted message, not just what happens to be in @Observable model state right now.
  • Adds a segmented scope picker (All servers / This server / This channel) so a user investigating one channel doesn't drown in cross-network noise.
  • Surfaces FTS5's full query syntax — phrase ("foo bar"), prefix (bar*), boolean (term1 AND term2 NOT term3), column-scoped (sender:alice) — by passing the input through verbatim. The text-field placeholder advertises the syntax so users discover it without docs.

Changes

  • Sources/Brygga/Views/ContentView.swiftGlobalFindSheet rewritten end-to-end:
    • Removes the GlobalFindMatch substring-scan plumbing. Holds @State private var hits: [SearchHit] instead, populated via .task(id:) that re-runs on every query or scope change with a 120ms debounce.
    • New ScopeUI enum + segmented Picker. The This server / This channel segments are disabled when there's no matching selection, so the picker can't silently downgrade behavior.
    • New SearchHitRow (private) replaces GlobalFindMatchRow. Renders serverName / target · timestamp and a 2-line hit.content excerpt.
    • open(_:) resolves (serverID, target) back to a channel for navigation, with sensible fallbacks: server-console hits land on the server row; hits whose target was closed since indexing land on the parent server row rather than no-op'ing.
    • Title changed from "Find in All Channels" to "Search Scrollback" — accurate now that scope is configurable and depth includes channels not currently open.

Test plan

  • swift build — passes
  • swift test — 131 tests pass (no test changes; UI is exercised by build + manual)
  • swiftformat --lint . — clean
  • Manual:
    • Cmd+Shift+F opens the new sheet. Default scope is "All servers".
    • Type a single word; results appear within ~120ms across every persisted server/channel.
    • Switch scope to "This server" — results now filter. Switch to "This channel" — further filter. Confirm segments are disabled when no matching selection exists.
    • Try "foo bar" (phrase), connect* (prefix), term1 AND term2 NOT term3 (boolean), sender:alice (column-scoped) — all work as documented.
    • Click a result; the sidebar selection jumps to the right channel and the sheet dismisses. For a server-console hit, the server row is selected.
    • Search for content in a previously-closed PM — confirm it doesn't appear (was cleared from the index when the PM was closed in Add SQLite FTS5 scrollback index (no UI yet) #29's closePrivateMessage).
    • Search for content in a channel from a different network — confirm it appears under "All servers" but not "This server".

Risk / rollback

  • View-layer-only change. No model or persistence schema changes; index from Add SQLite FTS5 scrollback index (no UI yet) #29 is unchanged.
  • Behavioral change: previous Find scanned only the in-memory channel.messages array (typically the last 500 lines after rehydrate). New search hits the full persisted index, so users will see more results — by design, but worth flagging for muscle-memory.
  • Known scope-out: clicking a hit jumps to the channel but does not scroll the message buffer to the matched line. The hit row already shows timestamp + content, so the user has the context — adding scroll-to-message requires a programmatic API on MessageBufferView (NSTextView-backed) and is a separate PR.
  • Revert: this single commit. The FTS5 index keeps being populated either way.

@buggerman buggerman merged commit ed6d275 into main Apr 25, 2026
1 check passed
@buggerman buggerman deleted the scrollback-search-ui branch April 25, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant