Skip to content

Implement Ctrl+F find widget support for chat panes and editors - #330340

Merged
Osvaldo Ortega (osortega) merged 3 commits into
mainfrom
osortega/agents/ctrl-f-find-widget-support
Aug 12, 2026
Merged

Osvaldo Ortega (osortega) merged 3 commits into
mainfrom
osortega/agents/ctrl-f-find-widget-support

Conversation

@osortega

Copy link
Copy Markdown
Contributor

This pull request implements the Ctrl+F find widget functionality for the chat pane, chat editors, and the Agents Window in VSCode. The changes include:

  • Shared Find Controller: A unified implementation for the chat find functionality that serves both the core chat pane and the Agents Window.
  • Transcript Search: The search now indexes the full logical transcript, including off-screen and collapsed content, ensuring comprehensive search results.
  • UI Enhancements: Adjustments to the find widget's input box width to match the editor's find widget, including setting initialWidth: 419 and enabling a draggable sash for user flexibility.
  • Bug Fixes: Resolved issues related to focus-based commands and incorrect highlighting of search results, ensuring a smoother user experience.

The implementation has been validated with 79 targeted tests passing, and the code has been reviewed for compliance with the approved behavior.

Copilot AI balanced review requested due to automatic review settings August 11, 2026 20:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds shared transcript Find support across chat panes, chat editors, and the Agents Window.

Changes:

  • Adds transcript indexing, navigation, highlighting, and find commands.
  • Integrates Find with chat hosts, accessibility help, context keys, and themes.
  • Adds targeted unit tests and Agents Window documentation.
Show a summary per file
File Description
chatFindWidget.test.ts Tests DOM matching and disclosure behavior.
chatFindModel.test.ts Tests transcript search modeling.
chatFindHighlights.test.ts Tests highlight registry composition.
chatFindActions.test.ts Tests routing and keybindings.
chatAccessibilityHelp.test.ts Tests Find help availability.
chatColors.ts Adds Find highlight colors.
annotations.ts Tracks source indexes through annotation.
chatContextKeys.ts Adds Find context keys.
chatViewPane.ts Enables Find in chat panes.
chatEditor.ts Enables Find in chat editors.
chatWidget.ts Hosts the shared Find controller.
chatFindWidget.ts Implements Find UI and highlighting.
chatFindWidget.css Styles transcript highlights.
chatFindModel.ts Indexes logical transcript matches.
chatFindHighlights.ts Manages CSS highlights.
chatFindCommandIds.ts Defines Find command IDs.
chatFindAccessibilityHelp.ts Adds Find-specific accessibility help.
chat.ts Exposes Find options and controller API.
chat.shared.contribution.ts Registers Find contributions.
chatFindActions.ts Implements Find commands and routing.
chatAccessibilityHelp.ts Documents transcript Find commands.
chatResponseAccessibleView.ts Shares response plaintext extraction.
SESSIONS.md Documents Agents Window Find behavior.
sessionsChatAccessibilityHelp.ts Documents Find for Agents Window users.
chatView.ts Enables Find in Agents Window chats.
accessibleView.ts Adds the Chat Find help provider ID.

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 26/26 changed files
  • Comments generated: 6
  • Review effort level: Balanced

Fix three bounded-work bugs found in review:

- Enforce the global match cap per segment, so two large segments can no
  longer expose roughly twice MAX_FIND_MATCHES.
- Count code-block matches toward the highlight cap; previously an
  all-code result set left both range arrays empty and rescanned every
  match on each repaint.
- Repaint after the debounced recompute. The row rerender lands before
  the 200ms pass, so streamed matches were counted but not highlighted.

Scope Find down to content it can actually reveal. Reasoning bodies are
built lazily by ChatCollapsibleContentPart on first expansion and are not
<details> elements, so a match inside collapsed reasoning could be counted
but never revealed. Reasoning is now excluded from the index and the help
text, Find help dialog and SESSIONS.md no longer promise it. The remaining
gaps (a typed expansion API, and extraction for warning/info/confirmation
and other rendered kinds) are documented for a follow-up.

Co-authored-by: Copilot <[email protected]>
@osortega
Osvaldo Ortega (osortega) force-pushed the osortega/agents/ctrl-f-find-widget-support branch from d4d4537 to 7d1ff5b Compare August 11, 2026 23:09
@osortega
Osvaldo Ortega (osortega) marked this pull request as ready for review August 11, 2026 23:09
@osortega
Osvaldo Ortega (osortega) enabled auto-merge (squash) August 11, 2026 23:10

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review: Consolidated inline findings.

let match: RegExpExecArray | null;
// Guard against catastrophic/zero-length-match regexes looping forever.
let safety = 0;
while ((match = regex.exec(segment.text))) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review: MAX_FIND_MATCHES cannot bound a single RegExp.exec call. A pathological expression can catastrophically backtrack on one transcript segment before this loop can apply the cap, blocking the renderer UI. Please constrain regex execution or complexity so one user-supplied expression cannot run unbounded; the result-count cap alone does not provide the protection described above.

break;
}
case 'markdownContent': {
const text = renderAsPlaintext(part.content, { includeCodeBlocksFences: true, useLinkFormatter: true });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review: This makes transcript Find index the literal code-fence markers, but rendered chat shows the code in an embedded editor without those markers. Searching for ``` therefore reports results that _locateMatch cannot reveal or highlight. The accessible view can preserve fences if needed, but the Find index needs text that matches its rendered target.

if (URI.isUri(ref)) {
const name = part.name || basename(ref);
const path = ref.scheme === 'file' ? ref.path : ref.toString(true);
text = name !== path ? `${name} (${path})` : path;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review: The annotation renderer displays only the inline reference label, while this extractor indexes name (path) (and locations include a line number). Searching for the hidden path or line therefore counts a match that cannot be located or highlighted. Please keep accessibility prose separate from the text used by transcript Find, or otherwise align the indexed and rendered strings.

.filter(codeBlock => root.contains(codeBlock.element))
.sort((first, second) => first.element.compareDocumentPosition(second.element) & 4 ? -1 : 1);

findMatchRangesInDom(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review: Repainting calls _locateMatch once per model match, and each call rescans the same DOM root through occurrenceIndex + 1. For many matches in one visible part this is quadratic work, repeated again while responses stream. Please scan each mounted root once per repaint and map its ranges back to model matches rather than restarting from the root for every occurrence.

}

private _onMatchesChanged(): void {
void this.updateResultCount();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review: Model changes fire synchronously from _onInputChanged, so this announces the result count, and SimpleFindWidget then calls updateResultCount() again from its input/change handlers. Navigation duplicates it too because find() calls model.next/previous() (which fires this event) and then explicitly updates the count. This produces repeated aria.status announcements; please give result-count updates a single owner.

// Counts code-block matches too: they are painted as editor decorations rather than DOM
// ranges, so bounding only the ranges would let an all-code result set rescan every match.
let locatedCount = 0;
for (let index = 0; index < this._model.matches.length && locatedCount < MAX_VISIBLE_HIGHLIGHTS; index++) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review: Once 500 earlier matches have been located, this loop never visits an active match at index 500 or above. Navigation still reveals that occurrence, but it receives neither the current DOM highlight nor a code decoration. Please always include the active match in the painted set even when the non-active highlight cap has been reached.

}
});

StartFindAction.addImplementation(100, (accessor: ServicesAccessor, codeEditor: ICodeEditor) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AI Review: This priority-100 implementation claims every Monaco editor below a chat widget, including non-simple code or diff editors that own their own Find controller. The chat keybinding precondition does not protect this dispatch path. Please restrict the StartFindAction override to codeEditor.isSimpleWidget, matching the composer/embedded-editor behavior documented for this feature.

roblourens
roblourens previously approved these changes Aug 12, 2026
The hygiene stylelint check validates every `var(--vscode-*)` reference
against build/lib/stylelint/vscode-known-variables.json. The two colors
added for Find match highlighting were registered in chatColors.ts but not
added to that list, so Compile & Hygiene failed with four unknown-variable
errors.

Co-authored-by: Copilot <[email protected]>
@osortega
Osvaldo Ortega (osortega) merged commit f5929d2 into main Aug 12, 2026
45 of 46 checks passed
@osortega
Osvaldo Ortega (osortega) deleted the osortega/agents/ctrl-f-find-widget-support branch August 12, 2026 04:39
@vs-code-engineering vs-code-engineering Bot added this to the 1.134.0 milestone Aug 12, 2026
@yCodeTech

Copy link
Copy Markdown

Fixes #259374

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants