Windows: file links in webview chat are not clickable (px() regex breaks on drive letter colon)
Bug Report
Environment
- OS: Windows 11 Pro
- IDE: Cursor (also affects VS Code)
- Extension version: claude-code 2.1.119
- Installation path:
C:/Users/<user>/.cursor/extensions/anthropic.claude-code-2.1.119-win32-x64
Description
Markdown links to local files in the Claude Code webview chat panel are not clickable on Windows. Web links (http/https) work correctly.
When Claude outputs markdown like:
[settings.json](C:/Users/shmid/.claude/settings.json)
Clicking the link does nothing. The link appears in the UI but is not interactive.
Root Cause
The webview's custom anchor click handler in webview/index.js uses a regex to parse file paths:
function px($) {
let Z = /^([^:#]+?)(?:[:#]L?(\d+)(?:-L?(\d+))?)?$/;
// ...
}
The character class [^:#] excludes colons from the captured file path. This is intended to separate the filename from a line number suffix (e.g. file.ts:42). However, on Windows, absolute paths start with a drive letter followed by a colon (e.g. C:/Users/...), so the regex fails to match:
C:/Users/shmid/.claude/settings.json— fails at the:afterCsettings.jsonorsrc/file.ts(relative paths without a drive letter) — may also fail depending on how react-markdown resolves the href before it reachespx()
When px() does not match, the click falls through to the default <a> anchor behavior (target="_blank"), which cannot open local file paths in a webview.
Meanwhile, https://... links work because they pass through the standard target="_blank" browser navigation, bypassing px() entirely.
Expected Behavior
File links with Windows absolute paths (e.g. C:/Users/...) should be clickable and open the file in the editor via fileOpener.open().
Suggested Fix
Update the px() regex to handle Windows drive letter prefixes. For example:
// Match optional Windows drive letter (e.g. C:) at the start
let Z = /^([A-Za-z]:[^#]*?|[A-Za-z]:|[^:#]+?)(?:[:#]L?(\d+)(?:-L?(\d+))?)?$/;
Or split the logic: first detect a Windows drive letter prefix, then apply line-number parsing to the remainder.
Workaround
No user-side workaround available. Users must manually copy file paths and open them via Ctrl+P (Quick Open) in the editor.
Additional Context
The react-markdown URL transform also plays a role — it strips file://, vscode://, and command: scheme URLs from hrefs. Only paths without a scheme survive, making the px() regex the sole mechanism for file-link click handling. Both issues compound on Windows.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗