Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Oct 30, 2025

Problem
Random focus loss to the editor occurs due to a timing race introduced by sending action: focusInput immediately after switching views via the plus button path. VS Code’s panel reveal/focus and the webview’s own focus compete.

Changes

  • Remove eager focusInput right after chatButtonClicked in the plus button path plusButtonClicked.
  • Make focus symmetric: after focusPanel completes, send action: focusInput for both sidebar and tab panels focusInput.
  • Defer webview focus to the next frame for stability on both didBecomeVisible and focusInput handlers ChatView.tsx, ChatView.tsx.

Impact

  • Eliminates focus races during view transitions; input reliably keeps focus.
  • “Add to Context” remains unaffected: it still inserts text and explicitly posts action: focusInput from provider ClineProvider.handleCodeAction().

Tests

  • Webview: 1108 passed, 6 skipped
  • Extension: 3958 passed, 48 skipped

Important

Stabilizes focus handling across sidebar and tab panels by deferring focus actions and ensuring symmetric focus behavior in registerCommands.ts and ChatView.tsx.

  • Behavior:
    • Removes immediate focusInput action after chatButtonClicked in plusButtonClicked in registerCommands.ts.
    • Makes focus handling symmetric by sending focusInput after focusPanel completes for both sidebar and tab panels in registerCommands.ts.
    • Defers webview focus to the next frame using requestAnimationFrame in didBecomeVisible and focusInput handlers in ChatView.tsx.
  • Impact:
    • Resolves focus races during view transitions, ensuring input retains focus.
    • "Add to Context" functionality remains unchanged, still posting focusInput from ClineProvider.handleCodeAction().
  • Tests:
    • Webview: 1108 passed, 6 skipped
    • Extension: 3958 passed, 48 skipped

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

@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners October 30, 2025 21:24
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Oct 30, 2025
@roomote
Copy link

roomote bot commented Oct 30, 2025

Review Complete

No issues found. The changes effectively address the focus race condition without introducing new bugs.

Summary:

  • ✅ Removes eager focusInput from plus button path to prevent race condition
  • ✅ Makes focus symmetric for both sidebar and tab panels
  • ✅ Uses proper deferral mechanisms (setTimeout + requestAnimationFrame)
  • ✅ All tests passing (1108 webview, 3958 extension)
  • ✅ No breaking changes or side effects detected

Follow Along on Roo Code Cloud

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Oct 30, 2025
@mrubens
Copy link
Collaborator

mrubens commented Oct 30, 2025

I'm struggling to see the connection between the changes to the code action in #8877 and a broader impact on focus when you're not using code actions. Is there a piece I'm not seeing?

@daniel-lxs daniel-lxs closed this Oct 31, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Oct 31, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Needs Review size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants