Skip to content

feat: add experimental setting to prevent editor focus disruption #6093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

roomote[bot]
Copy link

@roomote roomote bot commented Jul 23, 2025

This PR implements an experimental setting to prevent file edits from stealing focus, addressing the issue where diff views disrupt the user's workflow.

Summary

When Roo Code edits files, it opens diff views that steal focus from whatever the user is currently working on. This creates a frustrating experience that makes it nearly impossible to work alongside Roo. This PR adds an experimental setting experimentalPreventFocusDisruption that, when enabled, prevents file edits from stealing focus.

Changes

  • Added new configuration property roo-cline.experimentalPreventFocusDisruption (default: false)
  • Updated DiffViewProvider to respect the new setting when:
    • Opening diff editors
    • Saving changes
    • Reverting changes
  • Added localization entry for the new setting description
  • Added comprehensive tests to verify the functionality

Testing

  • All existing tests pass
  • Added new test suite specifically for the experimental setting
  • Verified that preserveFocus is correctly set based on the configuration value

User Experience

When the setting is disabled (default):

  • Current behavior is maintained
  • Diff views will steal focus as before

When the setting is enabled:

  • File edits happen in the background
  • User's current focus remains unchanged
  • User can continue typing without interruption
  • Files are still edited successfully

Fixes #4784


Important

Adds an experimental setting experimentalPreventFocusDisruption to prevent focus changes during file edits, updating DiffViewProvider and adding tests and localization support.

  • Behavior:
    • Adds experimentalPreventFocusDisruption setting to prevent focus change during file edits.
    • Updates DiffViewProvider to respect this setting when opening, saving, and reverting changes.
  • Configuration:
    • Adds roo-cline.experimentalPreventFocusDisruption configuration property (default: false).
  • Localization:
    • Adds localization entries for the new setting description in multiple language files.
  • Testing:
    • Adds tests to verify preserveFocus behavior based on the new setting in DiffViewProvider.spec.ts.
    • Ensures all existing tests pass.

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

- Add experimentalPreventFocusDisruption setting to package.json
- Update DiffViewProvider to respect the new setting when opening diff views
- Add localization entry for the new setting
- Add comprehensive tests for the new functionality

Fixes #4784
@roomote roomote bot requested review from mrubens, cte and jr as code owners July 23, 2025 05:57
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jul 23, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 23, 2025
@hannesrudolph
Copy link
Collaborator

@roomote-agent experimental settings are not vscode settings, they are in the settings pane of the plugin.

Copy link
Author

roomote bot commented Jul 23, 2025

Thanks for the clarification @hannesrudolph! I understand now - experimental settings should be in the plugin's settings pane rather than VSCode settings. I'll update the implementation to move this setting to the proper location. Working on it now.

- Remove experimentalPreventFocusDisruption from VSCode settings
- Add PREVENT_FOCUS_DISRUPTION to experiments system
- Update DiffViewProvider to use experiments instead of VSCode config
- Update Task.ts to pass experiments to DiffViewProvider
- Add localization entries for the new experiment
- Update tests to use the experiments system

This change moves the experimental setting from VSCode configuration to the plugin's experimental settings system as requested.
@@ -198,7 +214,15 @@ export class DiffViewProvider {
await updatedDocument.save()
}

await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), { preview: false, preserveFocus: true })
// Check if the experimental setting is enabled
const preventFocusDisruption = this.experiments
Copy link

Choose a reason for hiding this comment

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

Good use of the experimental flag: using Experiments.isEnabled to set preserveFocus ensures that file edits won’t steal focus when the experiment is enabled. Consider extracting this flag lookup into a helper function if similar checks occur elsewhere to reduce duplication.

- Added placeholder translations for all locales
- Uses English text as placeholder until proper translations are provided
- Fixes failing translation check in CI
@@ -618,6 +618,10 @@
"MULTI_FILE_APPLY_DIFF": {
"name": "啟用並行檔案編輯",
"description": "啟用後 Roo 可在單個請求中編輯多個檔案。停用後 Roo 必須逐個編輯檔案。停用此功能有助於使用能力較弱的模型或需要更精確控制檔案修改時。"
},
"PREVENT_FOCUS_DISRUPTION": {
Copy link

Choose a reason for hiding this comment

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

The new 'PREVENT_FOCUS_DISRUPTION' entry still uses English text for both its name and description. For consistency with other localized entries, please provide proper Traditional Chinese translations.

This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.

Copy link
Author

roomote bot commented Jul 23, 2025

Thanks for the feedback @hannesrudolph! I've successfully refactored the experimentalPreventFocusDisruption setting to use the plugin's experimental settings system instead of VSCode configuration.

Changes made:

  • ✅ Removed the setting from package.json VSCode configuration
  • ✅ Added PREVENT_FOCUS_DISRUPTION to the experiments system in experiments.ts
  • ✅ Updated DiffViewProvider to use the experiments system instead of VSCode config
  • ✅ Modified Task.ts to pass experiments to DiffViewProvider
  • ✅ Removed the localization entry from package.nls.json
  • ✅ Added localization entries for the new experiment in the webview UI
  • ✅ Updated all tests to use the experiments system
  • ✅ Added placeholder translations for all locales (proper translations can be added later)

All CI checks are now passing. The setting will now appear in the plugin's experimental settings pane instead of VSCode's settings.

@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jul 23, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PR - Needs Preliminary Review size:L This PR changes 100-499 lines, ignoring generated files.
Projects
Status: PR [Needs Prelim Review]
Development

Successfully merging this pull request may close these issues.

Feature Proposal: Option to Prevent Editor Focus Disruption During File Edits
2 participants