fix: gate auto-focus behavior with preventFocusDisruption experiment #10529
+12
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
preventFocusDisruptionexperiment flag.Changes made:
autoFocus={true}toautoFocus={!experiments?.preventFocusDisruption}so the textarea only auto-focuses when the experiment is disabled (default behavior)didBecomeVisibleaction handler so it only focuses when the experiment is disableduseDebounceEffecthook that auto-focuses the textarea, also adding the experiment flag to the dependency arrayThe fix reuses the existing
preventFocusDisruptionexperiment 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
preventFocusDisruptionexperiment in Settings > ExperimentalAutomated tests:
cd webview-ui && npx tsc --noEmit- passedcd webview-ui && npx eslint src/components/chat/ChatView.tsx src/components/chat/ChatTextArea.tsx --max-warnings=0- passedcd webview-ui && npx vitest run src/components/chat- 298 tests passedPre-Submission Checklist
Screenshots / Videos
N/A - This is a behavior change (focus management) rather than a visual change.
Documentation Updates
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.tsxandChatView.tsxusing thepreventFocusDisruptionexperiment flag.ChatTextArea.tsx: ChangesautoFocus={true}toautoFocus={!experiments?.preventFocusDisruption}to conditionally auto-focus the textarea.ChatView.tsx: Adds gating todidBecomeVisibleaction handler anduseDebounceEffecthook to conditionally focus the textarea based on the experiment flag.preventFocusDisruptionexperiment flag, previously used for diff view operations, to control focus behavior.This description was created by
for 6a315cd. You can customize this summary. It will automatically update as commits are pushed.