Repository navigation
Implement Ctrl+F find widget support for chat panes and editors - #330340
Conversation
There was a problem hiding this comment.
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]>
d4d4537 to
7d1ff5b
Compare
Dmitriy Vasyura (dmitrivMS)
left a comment
There was a problem hiding this comment.
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))) { |
There was a problem hiding this comment.
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 }); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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++) { |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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.
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]>
|
Fixes #259374 |
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:
initialWidth: 419and enabling a draggable sash for user flexibility.The implementation has been validated with 79 targeted tests passing, and the code has been reviewed for compliance with the approved behavior.