[BUG] Diff preview not showing for Edit tool on certain file types
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Affects: .js, .php files (and possibly others)
Works: .md, .txt, .css files, and Write tool (always shows diffs)
Error in DevTools: TypeError: Cannot read properties of undefined (reading 'toUrl') in toUri(e, t) function
Root cause: MonacoEnvironment.getWorker not configured in webview, causing globalThis._VSCODE_FILE_ROOT to be undefined in worker context
Console warning: "You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker"
Versions tested: 2.0.5, 2.0.60, 2.0.70, 2.0.74 - all affected
VS Code versions: 1.104.3, 1.107.1 - both affected
Platform: macOS (darwin-arm64)
What Should Happen?
The diff should show as a separate tab, but doesn't show as a separate tab and doesn't show in the Claude Code extension panel.
Error Messages/Logs
index.js:13 Uncaught Error: Cannot read properties of undefined (reading 'toUrl')
TypeError: Cannot read properties of undefined (reading 'toUrl')
at n.toUri (index.js:21:12347)
at n.asBrowserUri (index.js:21:11821)
at index.js:35:29767
at new Promise (<anonymous>)
at z1.$loadForeignModule (index.js:35:29658)
at index.js:631:4136
at async index.js:997:7864
at n.toUri (index.js:21:12347)
at n.asBrowserUri (index.js:21:11821)
at index.js:35:29767
at new Promise (<anonymous>)
at z1.$loadForeignModule (index.js:35:29658)
at index.js:631:4136
at async index.js:997:7864
at index.js:13:12
(anonymous) @ index.js:13
setTimeout
unexpectedErrorHandler @ index.js:11
onUnexpectedExternalError @ index.js:15
gi @ index.js:11
(anonymous) @ index.js:1007
Promise.then
(anonymous) @ index.js:1007
create @ index.js:1007
getOrCreate @ index.js:1007
(anonymous) @ index.js:1007
(anonymous) @ index.js:161
_runIfNeeded @ index.js:161
oI @ index.js:161
lg @ index.js:161
Eo @ index.js:161
gwe @ index.js:1007
_createInstance @ index.js:623
createInstance @ index.js:623
(anonymous) @ index.js:1007
(anonymous) @ index.js:674
(anonymous) @ index.js:161
_recomputeIfNeeded @ index.js:161
get @ index.js:161
reportChanges @ index.js:161
get @ index.js:161
reportChanges @ index.js:161
get @ index.js:161
reportChanges @ index.js:161
endUpdate @ index.js:161
endUpdate @ index.js:161
endUpdate @ index.js:161
endUpdate @ index.js:161
finish @ index.js:161
_endUpdate @ index.js:674
(anonymous) @ index.js:674
_deliver @ index.js:20
fire @ index.js:20
_endUpdate @ index.js:672
setModel @ index.js:672
(anonymous) @ index.js:674
e @ index.js:161
(anonymous) @ index.js:674
wi @ index.js:161
Ph @ index.js:161
setDiffModel @ index.js:674
setModel @ index.js:674
(anonymous) @ index.js:1082
P5 @ index.js:8
JS @ index.js:8
bXe @ index.js:8
Py @ index.js:8
_0e @ index.js:8
qv @ index.js:6
(anonymous) @ index.js:8
postMessage
(anonymous) @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1282
HostMessaging.channel.port1.onmessage @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:342
index.js:997 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'toUrl')
at n.toUri (index.js:21:12347)
at n.asBrowserUri (index.js:21:11821)
at index.js:35:29767
at new Promise (<anonymous>)
at z1.$loadForeignModule (index.js:35:29658)
at index.js:631:4136
at async index.js:997:7864
_doValidate @ index.js:997
await in _doValidate
l @ index.js:997
o @ index.js:997
(anonymous) @ index.js:997
_deliver @ index.js:20
_deliverQueue @ index.js:20
fire @ index.js:20
createModel @ index.js:603
W5e @ index.js:675
Uhe @ index.js:675
Slt @ index.js:675
(anonymous) @ index.js:1082
P5 @ index.js:8
JS @ index.js:8
bXe @ index.js:8
Py @ index.js:8
_0e @ index.js:8
qv @ index.js:6
(anonymous) @ index.js:8
postMessage
(anonymous) @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1282
HostMessaging.channel.port1.onmessage @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:342
index.js:997 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'toUrl')
at n.toUri (index.js:21:12347)
at n.asBrowserUri (index.js:21:11821)
at index.js:35:29767
at new Promise (<anonymous>)
at z1.$loadForeignModule (index.js:35:29658)
at index.js:631:4136
at async index.js:997:7864
_doValidate @ index.js:997
await in _doValidate
l @ index.js:997
o @ index.js:997
(anonymous) @ index.js:997
_deliver @ index.js:20
_deliverQueue @ index.js:20
fire @ index.js:20
createModel @ index.js:603
W5e @ index.js:675
Uhe @ index.js:675
Slt @ index.js:675
(anonymous) @ index.js:1082
P5 @ index.js:8
JS @ index.js:8
bXe @ index.js:8
Py @ index.js:8
_0e @ index.js:8
qv @ index.js:6
(anonymous) @ index.js:8
postMessage
(anonymous) @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1282
HostMessaging.channel.port1.onmessage @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:342
index.js:997 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'toUrl')
at n.toUri (index.js:21:12347)
at n.asBrowserUri (index.js:21:11821)
at index.js:35:29767
at new Promise (<anonymous>)
at z1.$loadForeignModule (index.js:35:29658)
at index.js:631:4136
at async index.js:997:7864
_doValidate @ index.js:997
await in _doValidate
l @ index.js:997
o @ index.js:997
(anonymous) @ index.js:997
_deliver @ index.js:20
_deliverQueue @ index.js:20
fire @ index.js:20
createModel @ index.js:603
W5e @ index.js:675
Uhe @ index.js:675
Slt @ index.js:675
(anonymous) @ index.js:1082
P5 @ index.js:8
JS @ index.js:8
bXe @ index.js:8
Py @ index.js:8
_0e @ index.js:8
qv @ index.js:6
(anonymous) @ index.js:8
postMessage
(anonymous) @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1282
HostMessaging.channel.port1.onmessage @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:342
index.js:1008 Uncaught (in promise) Error: String not found in file. Failed to apply edit.
at oQ.readMessages (index.js:1008:42173)
readMessages @ index.js:1008
postMessage
(anonymous) @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1282
HostMessaging.channel.port1.onmessage @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:342
index.js:13 Uncaught Error: Cannot read properties of undefined (reading 'toUrl')
TypeError: Cannot read properties of undefined (reading 'toUrl')
at n.toUri (index.js:21:12347)
at n.asBrowserUri (index.js:21:11821)
at index.js:35:29767
at new Promise (<anonymous>)
at z1.$loadForeignModule (index.js:35:29658)
at index.js:631:4136
at async index.js:997:7864
at n.toUri (index.js:21:12347)
at n.asBrowserUri (index.js:21:11821)
at index.js:35:29767
at new Promise (<anonymous>)
at z1.$loadForeignModule (index.js:35:29658)
at index.js:631:4136
at async index.js:997:7864
at index.js:13:12
(anonymous) @ index.js:13
setTimeout
unexpectedErrorHandler @ index.js:11
onUnexpectedExternalError @ index.js:15
gi @ index.js:11
(anonymous) @ index.js:1020
await in (anonymous)
(anonymous) @ index.js:1020
create @ index.js:1020
(anonymous) @ index.js:1020
doRun @ index.js:20
onTimeout @ index.js:20
setTimeout
schedule @ index.js:20
_update @ index.js:1020
G0 @ index.js:1020
_createInstance @ index.js:623
createInstance @ index.js:623
_instantiateById @ index.js:668
_instantiateSome @ index.js:668
(anonymous) @ index.js:668
requestIdleCallback
Yk @ index.js:20
v1 @ index.js:21
initialize @ index.js:668
Pw @ index.js:670
fj @ index.js:675
_createInstance @ index.js:623
createInstance @ index.js:623
_createInnerEditor @ index.js:675
(anonymous) @ index.js:674
_constructInnerEditor @ index.js:674
_createLeftHandSideEditor @ index.js:674
cj @ index.js:674
_createInstance @ index.js:623
createInstance @ index.js:623
Bf @ index.js:674
mj @ index.js:675
_createInstance @ index.js:623
createInstance @ index.js:623
vlt @ index.js:675
(anonymous) @ index.js:1082
P5 @ index.js:8
JS @ index.js:8
bXe @ index.js:8
Py @ index.js:8
_0e @ index.js:8
qv @ index.js:6
(anonymous) @ index.js:8
postMessage
(anonymous) @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1282
HostMessaging.channel.port1.onmessage @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:342
index.js:13 Uncaught Error: Cannot read properties of undefined (reading 'toUrl')
TypeError: Cannot read properties of undefined (reading 'toUrl')
at n.toUri (index.js:21:12347)
at n.asBrowserUri (index.js:21:11821)
at index.js:35:29767
at new Promise (<anonymous>)
at z1.$loadForeignModule (index.js:35:29658)
at index.js:631:4136
at async index.js:997:7864
at n.toUri (index.js:21:12347)
at n.asBrowserUri (index.js:21:11821)
at index.js:35:29767
at new Promise (<anonymous>)
at z1.$loadForeignModule (index.js:35:29658)
at index.js:631:4136
at async index.js:997:7864
at index.js:13:12
(anonymous) @ index.js:13
setTimeout
unexpectedErrorHandler @ index.js:11
onUnexpectedExternalError @ index.js:15
gi @ index.js:11
(anonymous) @ index.js:1020
await in (anonymous)
(anonymous) @ index.js:1020
create @ index.js:1020
(anonymous) @ index.js:1020
doRun @ index.js:20
onTimeout @ index.js:20
setTimeout
schedule @ index.js:20
_update @ index.js:1020
G0 @ index.js:1020
_createInstance @ index.js:623
createInstance @ index.js:623
_instantiateById @ index.js:668
_instantiateSome @ index.js:668
(anonymous) @ index.js:668
requestIdleCallback
Yk @ index.js:20
v1 @ index.js:21
initialize @ index.js:668
Pw @ index.js:670
fj @ index.js:675
_createInstance @ index.js:623
createInstance @ index.js:623
_createInnerEditor @ index.js:675
(anonymous) @ index.js:674
_constructInnerEditor @ index.js:674
_createRightHandSideEditor @ index.js:674
cj @ index.js:674
_createInstance @ index.js:623
createInstance @ index.js:623
Bf @ index.js:674
mj @ index.js:675
_createInstance @ index.js:623
createInstance @ index.js:623
vlt @ index.js:675
(anonymous) @ index.js:1082
P5 @ index.js:8
JS @ index.js:8
bXe @ index.js:8
Py @ index.js:8
_0e @ index.js:8
qv @ index.js:6
(anonymous) @ index.js:8
postMessage
(anonymous) @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:1282
HostMessaging.channel.port1.onmessage @ index.html?id=393ca8ad-55b6-4bf4-9679-b33b3f66fdbf&parentId=2&origin=2ca5af85-5fcb-4d14-a593-fa794414d5bb&swVersion=4&extensionId=Anthropic.claude-code&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app:342
index.js:13 Uncaught Error: Cannot read properties of undefined (reading 'toUrl')
TypeError: Cannot read properties of undefined (reading 'toUrl')
at n.toUri (index.js:21:12347)
at n.asBrowserUri (index.js:21:11821)
at index.js:35:29767
at new Promise (<anonymous>)
at z1.$loadForeignModule (index.js:35:29658)
at index.js:631:4136
at async index.js:997:7864
at n.toUri (index.js:21:12347)
at n.asBrowserUri (index.js:21:11821)
at index.js:35:29767
at new Promise (<anonymous>)
at z1.$loadForeignModule (index.js:35:29658)
at index.js:631:4136
at async index.js:997:7864
at index.js:13:12
Steps to Reproduce
Make sure you have the most recent version of VS Code (1.107.1) and the most recent version of the VS Code Claude Code extension (2.0.74 or 2.0.75... really I tested a few all the way back to 2.0.50 and they all have the same issue).
Have Claude create a .js file. This should work and show a diff.
Then have Claude Edit (using the Edit tool) the .js file. This will not show a diff.
The same will happen with a .php file. But NOT .txt or .md.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
I tried rolling back the Claude Code extension to 2.0.50 (3 weeks ago) and still had the issue.
Claude Code Version
2.0.65 (Claude Code) (but I'm not using regular Claude Code, I'm using the VS Code Extensions version 2.0.74)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
I've tried reinstalling VS Code, creating a different profile in VS Code, reinstalling the extension, rolling back the extension. Nothing fixed it.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗