Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

Fix false-positive linkification of terminal commands in chat responses - #5042

Draft
vijayupadya with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-terminal-command-linkify
Draft

Fix false-positive linkification of terminal commands in chat responses#5042
vijayupadya with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-terminal-command-linkify

Conversation

Copilot AI commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Terminal commands like `code-insiders --extensionDevelopmentPath=d:\src\test-byok-ext` were being incorrectly linkified, resolving to unrelated workspace files (e.g. src/common/spawnAsync.ts).

Two independent issues in the linkification pipeline:

  • FilePathLinkifier inline code regex too permissive — matched any text in backticks (`code-insiders`, `test-byok-ext`), unlike the plain text regex which already required a dot. Added a lookahead requiring at least one ., /, or \ in the content:

    # Before
    (?<!\[)`(?<inlineCodePath>[^`\s${}]+)`(?!\])
    
    # After — requires dot or path separator
    (?<!\[)`(?<inlineCodePath>(?=[^`\s${}]*[./\\])[^`\s${}]+)`(?!\])
    
  • ModelFilePathLinkifier.canLinkify unconditionally allowed "descriptive" text with anchors — when the LLM generated [command text](src/file.ts#L10), the non-filename text was treated as a valid description. Now rejects text containing =, \, /, or --flag patterns, which are characteristic of commands/paths rather than natural language descriptions.

Two changes to prevent false-positive linkification:

1. FilePathLinkifier: Require inline code paths to contain at least one dot
   or path separator (/ or \) to be considered a file path. This prevents
   command names like `code-insiders` or `test-byok-ext` from being matched.

2. ModelFilePathLinkifier: Reject "descriptive" link text that contains
   command-like patterns (=, \, /, --flag) when deciding whether to linkify
   markdown links with anchors. This prevents commands like
   `code-insiders --extensionDevelopmentPath=d:\src\test-byok-ext` from
   being incorrectly linked to workspace files.

Agent-Logs-Url: https://github.com/microsoft/vscode-copilot-chat/sessions/85ca9a0f-13b7-4d88-a9f7-bdbeaf84cc1c

Co-authored-by: vijayupadya <41652029+vijayupadya@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix terminal command linkification issue in documentation Fix false-positive linkification of terminal commands in chat responses Apr 8, 2026
Copilot AI requested a review from vijayupadya April 8, 2026 01:22
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.

terminal command was linkified

3 participants