Skip to content

Gate Simple Browser "Add element to chat" overlay on AI feature settings with immediate toggling#292679

Merged
jruales merged 6 commits intomainfrom
copilot/fix-add-element-chat-feature
Feb 3, 2026
Merged

Gate Simple Browser "Add element to chat" overlay on AI feature settings with immediate toggling#292679
jruales merged 6 commits intomainfrom
copilot/fix-add-element-chat-feature

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

The Simple Browser overlay ignored chat.disableAIFeatures and chat.sendElementsToChat.enabled settings, showing "Add element to chat" UI even when AI features or the specific feature were disabled. Changes required restart to take effect. Integrated Browser already had proper gating via ChatContextKeys.enabled in action preconditions.

Changes

SimpleBrowserOverlayController now reactively observes both AI feature settings:

  • Reactive observation: Uses observableContextKey for ChatContextKeys.enabled and observableConfigValue for chat.sendElementsToChat.enabled
  • Immediate toggling: Overlay appears/disappears instantly when either setting changes without requiring restart
  • No early exits: Controller always initializes to enable dynamic show/hide behavior
// Observe both settings reactively
const chatEnabledObs = observableContextKey<boolean>(ChatContextKeys.enabled.key, this.contextKeyService);
const sendElementsEnabledObs = observableConfigValue<boolean>('chat.sendElementsToChat.enabled', false, this.configurationService);

this._store.add(autorun(r => {
    const activeEditor = activeIdObs.read(r);
    const isChatEnabled = chatEnabledObs.read(r);
    const isSendElementsEnabled = sendElementsEnabledObs.read(r);
    
    // Hide if chat is not enabled, sendElementsToChat is not enabled, or no active editor
    if (!isChatEnabled || !isSendElementsEnabled || !activeEditor) {
        hide();
        return;
    }
    
    show({ webviewId: activeEditor.webviewId }, activeEditor.browserType);
}));

The controller always initializes, allowing the reactive autorun to handle all show/hide logic. This ensures the overlay responds to both chat.disableAIFeatures and chat.sendElementsToChat.enabled changes in real-time.

Testing

  • ✅ Overlay hides immediately when chat.disableAIFeatures: true
  • ✅ Overlay shows immediately when chat.disableAIFeatures: false
  • ✅ Overlay hides immediately when chat.sendElementsToChat.enabled: false
  • ✅ Overlay shows immediately when chat.sendElementsToChat.enabled: true
  • ✅ No restart required for any configuration changes

Aligns with chat feature gating guidelines in .github/instructions/chat.instructions.md.

Original prompt

This section details on the original issue you should resolve

<issue_title>Simple Browser's "Add element to chat" feature doesn't respect "chat.disableAIFeatures": true</issue_title>
<issue_description>The "Add element to chat" feature in simple browser doesn't respect the setting "chat.disableAIFeatures": true. It shouldn't show up when that flag is set.

Image</issue_description>

<agent_instructions>The Integrated Browser feature already removes that feature when the flag is set, but Simple Browser doesn't respect it</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 3, 2026 21:17
- Import ChatContextKeys and observableContextKey
- Add IContextKeyService injection to SimpleBrowserOverlayController
- Check ChatContextKeys.enabled in constructor (early exit if disabled)
- Observe chatEnabled state reactively in autorun to hide overlay when AI features are disabled
- Hide overlay when either chat is disabled or no active editor

Co-authored-by: jruales <1588988+jruales@users.noreply.github.com>
Co-authored-by: jruales <1588988+jruales@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix 'Add element to chat' feature to respect disableAIFeatures setting Gate Simple Browser "Add element to chat" overlay on ChatContextKeys.enabled Feb 3, 2026
Copilot AI requested a review from jruales February 3, 2026 21:20
@jruales
Copy link
Contributor

jruales commented Feb 3, 2026

@copilot currently this causes the "Add element to chat" widget to be hidden immediately when the user disables AI features, which is great. However, when the user re-enables AI features, the widget doesn't appear anymore until the user restarts VS Code. Can we fix that?

Remove early exit check for ChatContextKeys.enabled in constructor.
The reactive autorun already handles showing/hiding based on chat
enabled state, so the controller should always initialize to allow
dynamic toggling of AI features without requiring VS Code restart.

Co-authored-by: jruales <1588988+jruales@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 3, 2026

@copilot currently this causes the "Add element to chat" widget to be hidden immediately when the user disables AI features, which is great. However, when the user re-enables AI features, the widget d...

Fixed in 3d54ba0. Removed the early exit check for chat enabled state in the constructor - the reactive autorun now handles all show/hide logic dynamically. The overlay will now reappear immediately when AI features are re-enabled without requiring a restart.

@jruales
Copy link
Contributor

jruales commented Feb 3, 2026

@copilot can we make it so that chat.sendElementsToChat.enabled also works immediately here?

- Import observableConfigValue utility
- Remove early exit check for sendElementsToChat.enabled
- Create observable for chat.sendElementsToChat.enabled configuration
- Update autorun to also check isSendElementsEnabled
- Overlay now shows/hides immediately when toggling both chat.disableAIFeatures and chat.sendElementsToChat.enabled

Co-authored-by: jruales <1588988+jruales@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 3, 2026

@copilot can we make it so that chat.sendElementsToChat.enabled also works immediately here?

Fixed in 8697ec4. Now using observableConfigValue to reactively observe chat.sendElementsToChat.enabled. The overlay will show/hide immediately when toggling either chat.disableAIFeatures or chat.sendElementsToChat.enabled without requiring a restart.

Copilot AI changed the title Gate Simple Browser "Add element to chat" overlay on ChatContextKeys.enabled Gate Simple Browser "Add element to chat" overlay on AI feature settings with immediate toggling Feb 3, 2026
@jruales jruales marked this pull request as ready for review February 3, 2026 22:01
@jruales jruales requested review from Copilot and kycutler February 3, 2026 22:01
@jruales jruales enabled auto-merge (squash) February 3, 2026 22:01
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 3, 2026
Copy link
Contributor

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 ensures the Simple Browser “Add element to chat” overlay respects chat AI feature gating and can be toggled on/off immediately when related settings change.

Changes:

  • Adds reactive gating in SimpleBrowserOverlayController based on ChatContextKeys.enabled (covers chat.disableAIFeatures) and chat.sendElementsToChat.enabled.
  • Removes the constructor early-return so the controller always initializes and can dynamically show/hide the overlay without restart.

@jruales jruales merged commit 1296bc9 into main Feb 3, 2026
27 of 28 checks passed
@jruales jruales deleted the copilot/fix-add-element-chat-feature branch February 3, 2026 22:19
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.

Simple Browser's "Add element to chat" feature doesn't respect "chat.disableAIFeatures": true

3 participants