claude-code - 💡(How to fix) Fix [BUG] Claude Code opens a new editor window and changes focus, instead of staying in the chat window. [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46350Fetched 2026-04-11 06:22:35
View on GitHub
Comments
1
Participants
2
Timeline
8
Reactions
0
Timeline (top)
labeled ×6commented ×1renamed ×1

Error Message

Console error logged at the time of the switch:

Uncaught Error: Cannot read properties of undefined (reading 'toUrl') TypeError: Cannot read properties of undefined (reading 'toUrl') at Iv.toUri (index.js:22) at Iv.asBrowserUri (index.js:22) at iP.$loadForeignModule (index.js:36)

Code Example

Console error logged at the time of the switch:


Uncaught Error: Cannot read properties of undefined (reading 'toUrl')
TypeError: Cannot read properties of undefined (reading 'toUrl')
    at Iv.toUri (index.js:22)
    at Iv.asBrowserUri (index.js:22)
    at iP.$loadForeignModule (index.js:36)
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Bug: Before approving a file edit switches VS Code focus from chat panel to code editor (v2.1.100)

Extension version: 2.1.100 (win32-x64) Previous version where this did not occur: 2.1.98

Behavior: When approving a file edit in the Claude Code panel, VS Code switches window focus away from the chat panel to the code editor. This did not happen in v2.1.98.

What Should Happen?

Expected: Focus stays in the Claude Code panel after approving an edit.

Error Messages/Logs

Console error logged at the time of the switch:


Uncaught Error: Cannot read properties of undefined (reading 'toUrl')
TypeError: Cannot read properties of undefined (reading 'toUrl')
    at Iv.toUri (index.js:22)
    at Iv.asBrowserUri (index.js:22)
    at iP.$loadForeignModule (index.js:36)

Steps to Reproduce

Steps to reproduce:

Open Claude Code in the VS Code panel (not terminal) Ask Claude to make any file edit As it asks you to approve it will open a new editor VS Code focus switches to the code editor Expected: Focus stays in the Claude Code panel after approving an edit. Actual: VS Code switches focus to the edited file in the code editor.

Platform: Windows 10 Pro (10.0.19045)

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.98

Claude Code Version

2.1.100

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

No response

extent analysis

TL;DR

The issue can likely be mitigated by reverting to the previous version of Claude Code (2.1.98) where the focus stayed in the Claude Code panel after approving an edit.

Guidance

  • The error message Cannot read properties of undefined (reading 'toUrl') suggests a potential issue with the toUri function in index.js, which may be related to the focus switch.
  • To verify the issue, follow the provided steps to reproduce and check if the focus switches to the code editor after approving a file edit.
  • Reverting to version 2.1.98 may resolve the issue, as it is reported to have worked correctly in the past.
  • If reverting is not feasible, further investigation into the toUri function and its usage in the Claude Code extension may be necessary to identify the root cause.

Notes

The provided information suggests a regression in the Claude Code extension, and reverting to a previous version may be the most straightforward solution. However, this may not be a long-term fix, and further investigation may be necessary to resolve the underlying issue.

Recommendation

Apply workaround: Revert to version 2.1.98, as it is known to work correctly and the current version (2.1.100) introduces the focus switch issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING