Skip to content

feat(app): find text inside a thread conversation (Cmd+F) - #317

Merged
opficdev merged 3 commits into
mainfrom
feat/thread-find
Dec 6, 2026
Merged

opficdev merged 3 commits into
mainfrom
feat/thread-find

Conversation

@opficdev

@opficdev opficdev commented Dec 6, 2026

Copy link
Copy Markdown
Member

Summary

Ports upstream's in-thread find (chat.find, Cmd+F) to tern so users can search across the open thread's conversation, step through matches, highlight every visible match with the active one emphasized, and jump straight to the matched message when opening a thread from a sidebar message-search hit.

What it searches

  • Searches thread row data directly (tern_conversation::find) rather than only drawn DOM/list rows, since tern_ui::scroller virtualizes off-screen rows.
  • Counts user messages (plain text with mentions named, or Markdown text around context chips), assistant answers, and proposed plans—including messages inside folded turns.
  • Mirrors upstream's threadFindText and THREAD_FIND_BLOCK_TAGS: matches do not cross block boundaries (paragraphs, headings, list items, table cells, lines of plain user text, or code blocks), inline formatting does not split phrases, links search their visible labels only, and images, chips, work-log steps, notices, and approvals are excluded.
  • Uses upstream's foldThreadSearchCase folding: case-insensitive, ς -> σ, curly apostrophes ‘/’ -> ', and Turkish İ without shifting byte offsets.

Older history pages

  • Upstream's server indexes the entire thread in SQLite; tern counts the rows loaded in memory and automatically requests older history pages one after another while a query is non-empty (or while waiting for a sidebar message-search target).
  • Until the last history page lands, the find bar displays N/… (or Searching… / 찾는 중… before any match is found) while keeping the selected match pinned across prepended pages.

Highlights, scrolling, and focus

  • Theme tokens in crates/ui/themes/tern.json (find_match, find_match_text, find_match_active, find_match_active_text) match upstream's light/dark search highlight palette (#ffde8b / #8c6c1f, active #eea52b).
  • Markdown rows and code blocks with matches render through keyed TextViewState range highlights (tern_conversation_view::find_marks) without shifting layout; plain user messages combine mention and find highlights with active text contrast.
  • Selecting a match opens any folded turn or folded/long user message containing it, scrolls its row 96px below the top (ScrollerState::scroll_to_item_below, clear of the 280x36px find bar), and reveals the active range inside long Markdown rows and code blocks.
  • Cmd+F is bound to chat.find (FindInThread), while Terminal and FilesPanel keep Cmd+F for themselves; with no thread open (or on settings/draft/archive), Cmd+F falls back to sidebar thread search (thread.find). Escape closes find from the find bar, composer, or conversation without stopping a running turn.
  • Opening a thread from a sidebar message-search match (Row::Found) opens find with query_for_snippet and scrolls to the matched message_id once loaded.
  • Documented in docs/ui.md.

Verification

  • cargo fmt --all --check
  • ./scripts/check-colors.sh
  • ./scripts/check-layers.py
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo test --workspace --locked (scratch HOME, TERN_KEYCHAIN=off)
  • 2x Retina light/dark screenshots and 1:1 crops captured via GPUI offscreen Metal rendering (showing the find bar, multiple matches across user bubbles, Markdown, and code blocks, and jumping far up a long thread).

@opficdev
opficdev merged commit 54eb738 into main Dec 6, 2026
11 checks passed
@opficdev
opficdev deleted the feat/thread-find branch December 6, 2026 09:37
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