Skip to content

fix: render file tree tooltip path as literal text, not markdown#493

Draft
laileni-aws wants to merge 2 commits into
Amazon-Q-Developer:mainfrom
laileni-aws:fix/file-tree-tooltip-path-markdown
Draft

fix: render file tree tooltip path as literal text, not markdown#493
laileni-aws wants to merge 2 commits into
Amazon-Q-Developer:mainfrom
laileni-aws:fix/file-tree-tooltip-path-markdown

Conversation

@laileni-aws

Copy link
Copy Markdown
Contributor

Problem

File paths shown in the file-tree item tooltip are displayed incorrectly on Windows: the backslash before a dot is dropped. For example C:\Users\discr\.gradle\init.gradle is shown as C:\Users\discr.gradle\init.gradle, and ...\repo\project\.github\workflows\main.yml is shown as ...\repo\project.github\workflows\main.yml.

Root cause

In src/components/chat-item/chat-item-tree-file.ts, the tooltip built its content by running the file name and details.description (the full path) through parseMarkdown(...), and then rendered the result through CardBody, which parses markdown as well.

A file path is not markdown. Markdown treats a backslash before ASCII punctuation as an escape, so \. becomes . and the backslash is removed. Backslashes before letters (e.g. \U, \g) are preserved, which is why only the \. segments were affected — exactly matching the reported behavior.

Fix

Render the tooltip lines (file name and path) as literal text instead of markdown:

  • The mouseover handler now collects the file name / description into a string[] without parsing them as markdown.
  • showTooltip renders each line as a plain text div (text node), so the content — including backslashes in Windows paths — is shown verbatim.

The now-unused parseMarkdown and CardBody imports were removed from this file.

Testing

  • Extended src/components/__test__/chat-item/chat-item-tree-file.spec.ts with a test that hovers a tree file whose path is a Windows path and asserts the tooltip contains the path verbatim (backslashes preserved), and does not collapse discr\.gradle to discr.gradle.
  • The test was confirmed to fail against the previous markdown-based rendering and to pass with this change.
  • Full unit test suite passes (npx jest): 843 tests.
  • eslint and prettier --check pass; production build (npm run build) succeeds.

Additional change

  • ui-tests/__test__/flows/quick-action-commands-header.ts: coerced the result of a Playwright evaluate call to a boolean with Boolean(...) to satisfy @typescript-eslint/strict-boolean-expressions and keep the repo lint gate green.

The file tree item tooltip ran the file name and path through the
markdown parser. For Windows paths this dropped backslashes that
precede a period (e.g. C:\\Users\\me\\.gradle\\init.gradle was shown as
C:\\Users\\me.gradle\\init.gradle), because \. is a markdown escape.

File names and paths are literal text, so render each tooltip line as
plain text instead of markdown. Adds a test asserting a Windows path is
shown verbatim.
Keeps the repo lint gate green (strict-boolean-expressions).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant