Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 7, 2026

Related GitHub Issue

Closes: #10492

Roo Code Task Context (Optional)

This PR was created with assistance from Roo Code.

Description

This PR attempts to address Issue #10492 by gating the auto-focus behavior behind the existing preventFocusDisruption experiment flag.

Changes made:

  • ChatTextArea.tsx: Changed autoFocus={true} to autoFocus={!experiments?.preventFocusDisruption} so the textarea only auto-focuses when the experiment is disabled (default behavior)
  • ChatView.tsx: Added gating to the didBecomeVisible action handler so it only focuses when the experiment is disabled
  • ChatView.tsx: Added gating to the useDebounceEffect hook that auto-focuses the textarea, also adding the experiment flag to the dependency array

The fix reuses the existing preventFocusDisruption experiment flag which was previously only used for diff view operations. Users can enable this via Settings > Experimental > Prevent Focus Disruption to prevent focus stealing during initial load.

Test Procedure

  1. Enable the preventFocusDisruption experiment in Settings > Experimental
  2. Reload the VSCode window
  3. While Roo Code is loading, start typing in the integrated terminal
  4. Verify that focus remains in the terminal and is not stolen by the Roo Code input box
  5. Disable the experiment to verify default behavior is preserved

Automated tests:

  • Type checking: cd webview-ui && npx tsc --noEmit - passed
  • Linting: cd webview-ui && npx eslint src/components/chat/ChatView.tsx src/components/chat/ChatTextArea.tsx --max-warnings=0 - passed
  • Unit tests: cd webview-ui && npx vitest run src/components/chat - 298 tests passed

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: Existing tests pass, no new tests required as this is a configuration flag gate.
  • Documentation Impact: No documentation updates required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A - This is a behavior change (focus management) rather than a visual change.

Documentation Updates

  • No documentation updates are required.

Additional Notes

Feedback and guidance are welcome. This implementation follows the plan outlined in the original issue comment.

Get in Touch

Please mention @roomote in the PR comments for questions.


Important

Conditionally gates auto-focus behavior in ChatTextArea.tsx and ChatView.tsx using the preventFocusDisruption experiment flag.

  • Behavior:
    • ChatTextArea.tsx: Changes autoFocus={true} to autoFocus={!experiments?.preventFocusDisruption} to conditionally auto-focus the textarea.
    • ChatView.tsx: Adds gating to didBecomeVisible action handler and useDebounceEffect hook to conditionally focus the textarea based on the experiment flag.
  • Experiment Flag:
    • Reuses preventFocusDisruption experiment flag, previously used for diff view operations, to control focus behavior.
  • Testing:
    • Manual testing steps provided to verify focus behavior with and without the experiment enabled.
    • Automated tests for type checking, linting, and unit tests passed.

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

This addresses the focus-stealing behavior on initial load that violates
WCAG 3.2.1 and 3.2.2 accessibility criteria.

Changes:
- ChatTextArea.tsx: autoFocus now respects preventFocusDisruption flag
- ChatView.tsx: didBecomeVisible focus call gated by flag
- ChatView.tsx: useDebounceEffect focus call gated by flag

The fix uses the existing preventFocusDisruption experiment flag which
users can enable in Settings > Experimental to prevent focus disruption.

Closes #10492
@roomote
Copy link
Contributor Author

roomote bot commented Jan 7, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The implementation correctly gates auto-focus behavior behind the existing preventFocusDisruption experiment flag at all three locations where focus is programmatically set. The changes are minimal, type-safe, and preserve backward compatibility.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jan 7, 2026
@hannesrudolph hannesrudolph moved this from Triage to PR [Draft / In Progress] in Roo Code Roadmap Jan 8, 2026
@hannesrudolph hannesrudolph added PR - Draft / In Progress and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jan 8, 2026
Copy link

@lemiesz lemiesz left a comment

Choose a reason for hiding this comment

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

Tested locally this appears to fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: PR [Draft / In Progress]

Development

Successfully merging this pull request may close these issues.

[BUG][A11Y] Roo-Code steals focus on load when using VSCode over SSH (WCAG 3.2.1, 3.2.2 violation)

4 participants