Skip to content

Conversation

abeatrix
Copy link
Contributor

@abeatrix abeatrix commented Jul 26, 2025

Related Issue

Issue: #4700

Description

Fix webview visibility detection to check both visible and active states before taking focus. If a panel is visible but not active (focused), it should not steals editor focus.

Also removes unused import & add type imports

Test Procedure

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • ♻️ Refactor Changes
  • 💅 Cosmetic Changes
  • 📚 Documentation update
  • 🏃 Workflow Changes

Pre-flight Checklist

  • Changes are limited to a single feature, bugfix or chore (split larger changes into separate PRs)
  • Tests are passing (npm test) and code is formatted and linted (npm run format && npm run lint)
  • I have created a changeset using npm run changeset (required for user-facing changes)
  • I have reviewed contributor guidelines

Screenshots

Same tab group - keeps focus when switching between tabs:

Screen.Recording.2025-07-26.at.11.22.21.AM.mov

Side by side mode:

Screen.Recording.2025-07-26.at.11.29.15.AM.mov

Before

Focus keeps being stole from cline panel in side by side mode because this.webview.visible will always be true

Screen.Recording.2025-07-26.at.11.35.29.AM.mov

Additional Notes


Important

Fixes focus issue in VscodeWebviewProvider by checking both visibility and active states before focusing, preventing webview from stealing focus when not active.

  • Behavior:
    • Fixes focus issue in VscodeWebviewProvider by checking both visible and active states before focusing.
    • Ensures webview does not steal focus if not active.
  • Imports:
    • Removes unused Uri import from vscode.
    • Reorganizes import statements for clarity.

This description was created by Ellipsis for 29759a0. You can customize this summary. It will automatically update as commits are pushed.

abeatrix added 2 commits July 26, 2025 11:06
Fix webview visibility detection to check both visible and active states before taking focus. If a panel is visible but not active (focused), it should not steals editor focus.

Also removes unused import & add type imports
@Copilot Copilot AI review requested due to automatic review settings July 26, 2025 18:38
Copy link

changeset-bot bot commented Jul 26, 2025

🦋 Changeset detected

Latest commit: 38e7050

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
claude-dev Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a focus management issue where the Cline webview panel would steal focus from the editor in side-by-side mode. The fix ensures that focus is only taken when the panel is both visible and active (focused), preventing unwanted focus stealing when the panel is visible but not the active tab.

Key changes:

  • Updated webview visibility detection logic to check both visible and active states
  • Cleaned up imports by converting some to type-only imports and removing unused code

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/hosts/vscode/VscodeWebviewProvider.ts Fixed focus stealing by checking both visible and active states, cleaned up imports and removed unused code
.changeset/sweet-days-whisper.md Added changeset entry documenting the focus management fix

Copy link
Contributor

Coverage Report

Extension Coverage

Base branch: 46%

PR branch: 47%

✅ Coverage increased or remained the same

Webview Coverage

Base branch: 17%

PR branch: 17%

✅ Coverage increased or remained the same

Overall Assessment

Test coverage has been maintained or improved

Last updated: 2025-07-26T19:58:14.158588

Copy link
Contributor

@arafatkatze arafatkatze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving this PR because the code makes sense.

Full disclosure: despite my repeated attempts I could not replicate the case in #4700

And the before case mentioned in this PR description. That being said since Bee replicated it I will take her word for it and approve because the code is good.

@arafatkatze arafatkatze merged commit a91878e into main Jul 28, 2025
13 checks passed
@abeatrix abeatrix deleted the bee/fix-focus-panel branch July 28, 2025 18:03
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.

2 participants