Skip to content

chat: index only content Find can reveal - #330585

Merged
Osvaldo Ortega (osortega) merged 2 commits into
mainfrom
osortega/agents/chat-find-reachable-matches
Aug 13, 2026
Merged

Osvaldo Ortega (osortega) merged 2 commits into
mainfrom
osortega/agents/chat-find-reachable-matches

Conversation

@osortega

Copy link
Copy Markdown
Contributor

Follow-up to #330340. Fixes Find reporting matches it cannot navigate to.

Symptoms

Searching a common word in a long transcript showed:

  • a match count that fell as rows rendered — one session went 9999 → 4013 → 3793, another 5949 → 705 → 240 → 123
  • Next moving the counter without moving the view
  • Find jumping back to the first result while navigating

Cause

The index reused getChatResponsePlaintextParts, the accessible view's extraction. That function describes a response to a screen reader rather than mirroring what is drawn, so it:

  • synthesizes text with no on-screen equivalent — Input:, Files:, Errored, MCP authentication prompts
  • includes tool result payloads, which live in a body that only exists once expanded

Matches in that text were counted, but the painter had nothing to highlight.

The count instability had a sharper cause: isAttachedToThinking is assigned by the renderer while drawing a row. A row that had not yet rendered looked un-grouped, so its tools were indexed; once drawn, they were excluded and those matches vanished. Navigating toward one meant targeting a match that ceased to exist.

Changes

New chatFindContent.ts — a Find-specific extraction covering markdown, inline reference labels, elicitations and error details.

Reasoning and tool invocations are deliberately not indexed. Where a tool renders is decided during rendering, and reasoning bodies are built on expansion; indexing either makes the count depend on how far the transcript has drawn. This is the "start small" position — broadening it needs a typed expansion API on ChatCollapsibleContentPart, tracked separately.

Repaint skips unrendered rows. One memoized row lookup before scanning parts. In a captured trace, 51,298 of 51,363 locate attempts were for rows that were not on screen.

Navigation advances past unlocatable matches (bounded at 50), so Next never appears to do nothing if a prediction is still wrong.

Tradeoff

Text inside a tool pill — including a terminal command header — is no longer searchable. Those matches were real and highlighted correctly, but keeping them requires reading render-time state, which is what produced the phantom results.

Testing

  • 47 targeted tests pass, including new cases for the extraction rule and a regression test that flips isAttachedToThinking after indexing and asserts the count is unchanged
  • typecheck-client, valid-layers-check, ESLint clean
  • Verified interactively against a long agent transcript: the count now holds steady and navigation moves

Diagnosed from console traces captured behind a temporary flag; the scaffolding is removed from this branch.

Find reported matches it could not navigate to. Searching a long transcript
showed a count that fell as rows rendered (9999 -> 4013 -> 3793 in one
session), navigation that moved the counter without moving the view, and
repaints that scanned thousands of matches to locate almost none.

The index reused the accessible view's extraction, which describes a
response to a screen reader rather than mirroring what is drawn. It
synthesizes text with no on-screen equivalent ("Input:", "Errored", MCP
authentication prompts) and includes tool result payloads, so the painter
had nothing to highlight for those matches.

Give Find its own extraction covering markdown, inline reference labels,
elicitations and error details. Reasoning and tool invocations are left
out: where a tool renders is decided while rendering (the renderer assigns
isAttachedToThinking), so indexing them made the count depend on how far
the transcript had drawn, and a row that had not yet been drawn contributed
matches that vanished once it was.

Also skip matches whose row is not rendered before scanning its parts, and
advance past any match the DOM cannot produce so navigation never appears
to do nothing.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings August 13, 2026 02:09

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

Introduces renderer-aligned chat Find indexing to reduce phantom matches and stabilize navigation.

Changes:

  • Adds Find-specific response text extraction.
  • Skips unrendered rows during repaint.
  • Advances past unlocatable matches and adds model regressions.
Show a summary per file
File Description
chatFindContent.ts Defines searchable response content.
chatFindModel.ts Uses the new extraction logic.
chatFindWidget.ts Optimizes repainting and navigation.
chatFindModel.test.ts Tests tool exclusion and stable counts.

Review details

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

Suppressed comments (3)

src/vs/workbench/contrib/chat/browser/widget/chatFind/chatFindContent.ts:57

  • renderAsPlaintext is still configured to synthesize text that the row never renders: includeCodeBlocksFences injects literal ``` delimiters, and useLinkFormatter invents a basename for an empty link (`markdownRenderer.ts:803-815`). Queries matching either value are therefore counted but cannot be located in the DOM/editor. Use the default plaintext renderer here so the indexed markdown mirrors visible text.
				const text = renderAsPlaintext(part.content, { includeCodeBlocksFences: true, useLinkFormatter: true });

src/vs/workbench/contrib/chat/browser/widget/chatFind/chatFindContent.ts:54

  • Filtered responses do not render any response.value parts (chatListRenderer.ts:1602-1612), but this loop still indexes their markdown, references, and elicitations. Those matches remain phantom results; return after collecting the visible error text when responseIsFiltered is set.
	item.response.value.forEach((part, partIndex) => {

src/vs/workbench/contrib/chat/browser/widget/chatFind/chatFindContent.ts:82

  • Hidden elicitations are indexed even though the renderer returns a no-content part for them (chatListRenderer.ts:3704-3707). This recreates an unlocatable match whenever either the live observable or serialized isHidden flag is true; apply the same visibility check before extracting the title/message.
			case 'elicitation2':
			case 'elicitationSerialized': {
				const title = isMarkdownString(part.title) ? renderAsPlaintext(part.title) : part.title;
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Address review feedback on the Find index.

Error details were indexed unconditionally, but the renderer omits the
error part for canceled or non-final responses and replaces the message
with fixed copy for the quota and anonymous rate-limit variants. Mirror
those conditions, and render the message as plaintext since it is drawn as
markdown.

Markdown was extracted with code fences and link formatting enabled. The
``` markers are consumed by the code block and an empty link renders as an
empty anchor, so both contributed text that was counted but absent from the
DOM.

Add regression coverage for the walk past unlocatable matches, proving it
keeps the requested direction, stops at the cap, and lands on a later
locatable match.

Co-authored-by: Copilot <[email protected]>
@osortega
Osvaldo Ortega (osortega) merged commit 97a71a0 into main Aug 13, 2026
60 of 63 checks passed
@osortega
Osvaldo Ortega (osortega) deleted the osortega/agents/chat-find-reachable-matches branch August 13, 2026 05:35
@vs-code-engineering vs-code-engineering Bot added this to the 1.134.0 milestone Aug 13, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Sep 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants