Skip to content

Conversation

@dlab-anton
Copy link
Contributor

@dlab-anton dlab-anton commented May 3, 2025

Context

image

Tasks can get long, restore points are hard to find, if you lose your place in a long task you waste a lot of time trying to find it. All this takes away time, causes frustration. There are many possible solutions from minimaps to timeline panels, annotated scrollbars, etc. but the best solution is simple text search.

Search is a "need to have" fundamental usability feature for the chat interface.

Implementation

chat-search

Note I replaced the X button (since the + button has the same function) but we can also hide the icon and rely on keyboard shortcut, move the icon somewhere else.

This PR introduces a comprehensive search functionality within the chat view and resolves minor linting issues.

Key Features & Changes:

  1. In-Chat Search:

    • Adds a search bar accessible via a toggle button in the TaskHeader or using the Ctrl/Cmd + F keyboard shortcut.
    • Allows users to search across the entire chat history, including message content, titles, tool details (paths, diffs, modes, etc.), API request/response details, checkpoint titles, and followup suggestions.
    • Uses debouncing on the search input for performance.
    • Highlights all occurrences of the search term within the chat messages using <mark> tags.
    • Provides navigation controls (Next/Previous buttons, Enter/Shift+Enter keys) to jump between matches.
    • The currently active match is visually distinct with an outline style applied to its highlight.
    • Automatic scrolling
  2. Implementation Details:

    • Introduced a new hook useChatSearch to encapsulate search logic, state management, navigation, and the core highlighting function.
    • Integrated useChatSearch into ChatView, passing down necessary props (searchText, highlightText, itemIndex) to child components.
    • Implemented getSearchableTextForChatView in ChatView to extract rich, searchable text content from various message types and structures. This includes a lookahead mechanism to associate API response text with its corresponding request row for better searchability.
    • Modified ChatView's scrolling logic (handleRowHeightChange, useEffect on message length, toggleRowExpansion) to respect the search state (showSearch, isNavigatingRef) and prevent unwanted auto-scrolling.
    • Updated TaskHeader to include the search toggle button and manage its state.
    • Utilized Virtuoso's scrollIntoView API within the useChatSearch hook for efficient scrolling to matched items.
    • Highlighting is applied differently based on the component:
      • ChatRow, BrowserSessionRow, CheckpointSaved, FollowUpSuggest, CodeAccordian (header): Use the highlightText function prop directly.
      • MarkdownBlock: Uses a separate applyHighlighting utility function that traverses the React node tree generated by react-remark.
      • CodeBlock: Uses a custom Shiki transformer (createSearchHighlightTransformer) that operates on the code's AST during syntax highlighting.

@changeset-bot
Copy link

changeset-bot bot commented May 3, 2025

⚠️ No Changeset found

Latest commit: c46ce59

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. enhancement New feature or request labels May 3, 2025
@ellipsis-dev
Copy link
Contributor

ellipsis-dev bot commented May 3, 2025

The pull request introduces a comprehensive chat search feature with highlighting and navigation capabilities across multiple components. Given the cohesive nature of the changes, it seems appropriate to keep them within a single pull request. However, if there are any unrelated changes that could be split into separate pull requests, please consider doing so for better manageability and review efficiency. Thank you for your contributions!

@dlab-anton dlab-anton marked this pull request as draft May 3, 2025 10:14
messages,
virtuosoRef,
getSearchableText,
// disableAutoScrollRef, // Removed unused prop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The disableAutoScrollRef prop is defined in the interface but is commented out in the hook implementation; if it’s meant to control auto-scroll behavior during search, please integrate it properly or remove it from the interface.

This comment was generated because it violated a code review rule: mrule_aQsEnH8jWdOfHq2Z.

if (isCollapsing && isAtBottom) {
const timer = setTimeout(() => scrollToBottomAuto(), 0)
const timer = setTimeout(() => {
console.log(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several debug console.log statements in functions like toggleRowExpansion and handleRowHeightChange; consider removing or conditionally disabling these logs in production for cleaner output.

@KJ7LNW
Copy link
Contributor

KJ7LNW commented May 5, 2025

oh! Can / be the hotkey like vi?

@dlab-anton
Copy link
Contributor Author

dlab-anton commented May 5, 2025

oh! Can / be the hotkey like vi?

definitely can. one idea is we could handle keyboard shortcuts by a one-click link the vs code preferences>keyboardshortcuts>prefilled search term (tested working). Then it's easy for users to use vs code inherent keyboard shortcut handling.
image

@sachasayan
Copy link
Contributor

I like this, but I really do think the icon positioning doesn't work for me. I'd probably be up for making this a keyboard-only shortcut for now, but I'm hesitant to keep crowding the visual UI (for now).

@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 5, 2025
@hannesrudolph hannesrudolph moved this from PR [Pre Approval Review] to New in Roo Code Roadmap May 5, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 5, 2025
@KJ7LNW
Copy link
Contributor

KJ7LNW commented May 5, 2025

I like this, but I really do think the icon positioning doesn't work for me. I'd probably be up for making this a keyboard-only shortcut for now, but I'm hesitant to keep crowding the visual UI (for now).

I agree with that: It should be hidden until someone presses CTRL-F, and then it also needs to grab the focus.

@sachasayan sachasayan self-assigned this May 6, 2025
@sachasayan
Copy link
Contributor

Hey @hannesrudolph do we have a "needs changes" status yet?

@dlab-anton
Copy link
Contributor Author

I like this, but I really do think the icon positioning doesn't work for me. I'd probably be up for making this a keyboard-only shortcut for now, but I'm hesitant to keep crowding the visual UI (for now).

I agree keyboard only is best, no need to crowd. (I'd still remove the extra new task button if not replacing)

@hannesrudolph
Copy link
Collaborator

Hey @hannesrudolph do we have a "needs changes" status yet?

We do now @sachasayan !!

@hannesrudolph hannesrudolph moved this from PR [Pre Approval Review] to PR [Draft/WIP] in Roo Code Roadmap May 10, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Draft/WIP] in Roo Code Roadmap May 20, 2025
@hannesrudolph hannesrudolph moved this from PR [Draft / In Progress] to TEMP in Roo Code Roadmap May 26, 2025
@daniel-lxs
Copy link
Member

Hey @dlab-anton,
Thank you for your contribution, We noticed this PR is stale and will be closed. If you plan to revisit this, please create an issue first as required by our issue-first approach before opening a new PR.

@daniel-lxs daniel-lxs closed this May 26, 2025
@github-project-automation github-project-automation bot moved this from TEMP to Done in Roo Code Roadmap May 26, 2025
@github-project-automation github-project-automation bot moved this from PR [Draft/WIP] to Done in Roo Code Roadmap May 26, 2025
@dlab-anton dlab-anton mentioned this pull request May 27, 2025
4 tasks
@hannesrudolph hannesrudolph reopened this May 27, 2025
@github-project-automation github-project-automation bot moved this from Done to New in Roo Code Roadmap May 27, 2025
@github-project-automation github-project-automation bot moved this from Done to Triage in Roo Code Roadmap May 27, 2025
@hannesrudolph
Copy link
Collaborator

hannesrudolph commented May 27, 2025

@dlab-anton Sorry about the premature close. My fault! Let me see if we can get this approved.

@hannesrudolph hannesrudolph moved this from Triage to PR [Changes Requested] in Roo Code Roadmap May 27, 2025
@hannesrudolph hannesrudolph moved this from PR [Changes Requested] to PR [Needs Review] in Roo Code Roadmap May 28, 2025
@hannesrudolph
Copy link
Collaborator

@mrubens can you take a look at this feature and if its ok to move forwad with it I will ask @dlab-anton to rebase it and deal witht he conflicts. Otherwise there is no point.

@mrubens
Copy link
Collaborator

mrubens commented May 29, 2025

I like the idea of this feature, but I do think we need to find the right balance of code complexity and visual prominence to make it worth it.

I think if we launch it with no UI the people who need it won't find it. My instinct is to do something where we put it in the expanded view of the task header, maybe next to the "download" button, along with a keyboard shortcut.

Screenshot 2025-05-29 at 1 06 54 PM

That said, from a code review perspective this PR touches a ton of places in the code. Is there a way to do this more at the webview level so we wouldn't need to modify so many parts of the code?

@hannesrudolph hannesrudolph moved this from PR [Needs Review] to PR [Draft / In Progress] in Roo Code Roadmap May 29, 2025
@seedlord
Copy link
Contributor

Are there any updates regarding this?
I implemented TaskTimeline #5187 (cline/cline#3264 cline/cline#3333 cline/cline#3890) in this branch
Maybe it can be combined with the search function into a single PR?
Or should these functions stay separated?

@seedlord seedlord mentioned this pull request Jun 29, 2025
4 tasks
@KJ7LNW
Copy link
Contributor

KJ7LNW commented Jun 29, 2025

Or should these functions stay separated?

Generally speaking, one feature per pull request unless they are strongly related, or if separating them would create unnecessarily merge conflicts to break them apart.

Can they be cleanly separated or implemented as either independent, dependent, or follow-up pull requests?

@seedlord
Copy link
Contributor

I didnt really check 3144 yet, but TaskTimeline feature moves some codeblocks within ChatView that may be relevant when merging

@hannesrudolph
Copy link
Collaborator

stale

@github-project-automation github-project-automation bot moved this from PR [Draft / In Progress] to Done in Roo Code Roadmap Jul 7, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request PR - Draft / In Progress size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants