Skip to content

Conversation

@mikescamell
Copy link
Contributor

@mikescamell mikescamell commented Nov 4, 2025

Task/Issue URL: https://app.asana.com/1/137249556945/project/1207908166761516/task/1211756086814103?focus=true

Description

Added support for sending subscription events to ContentScopeScripts. This enables real-time updates to the SERP settings when DuckChat settings change. The implementation includes:

  • Created a new ContentScopeScriptsSubscriptionEventPlugin interface to allow features to provide subscription event data
  • Added a plugin point for subscription event plugins
  • Implemented a DuckChat-specific plugin that sends the enabled state to Content Scope Scripts
  • Added subscription event channels and flows in both BrowserTabViewModel and SettingsWebViewViewModel
  • Set up observers in BrowserTabFragment and SettingsWebViewActivity to send events to Content Scope Scripts

Steps to test this PR

DuckChat Settings Sync from Browser

  • Enable serpSettingsSync​ feature toggle
  • Do a search e.g. "FPL"
  • Open Settings -> AI Features
  • Disable/enable Duck.AI
  • Navigate back to SERP
  • Verify that the subscription event is sent to Content Scope Scripts (check logs for "SERP-Settings: Sending subscription event data") with the correct state
  • Open Settings -> AI Features
  • Disable/enable Duck.AI
  • Verify that the subscription event is sent to Content Scope Scripts (check logs for "SERP-Settings: Sending subscription event data") with the correct state

DuckChat Settings Sync from SettingsWebView

  • Enable serpSettingsSync​ feature toggle
  • Open Settings -> AI Features
  • Note the current state of Duck.AI
  • Click "Search Assist Settings"
  • Press back
  • Verify that the subscription event is sent to Content Scope Scripts (check logs for "SERP-Settings: Sending subscription event data") with the correct state
  • Disable/enable Duck.AI
  • Click "Search Assist Settings"
  • Press back
  • Verify that the subscription event is sent to Content Scope Scripts (check logs for "SERP-Settings: Sending subscription event data") with the correct state

UI changes

N/A

@mikescamell mikescamell force-pushed the feature/mike/serp-settings-sync/add-nativeDuckAiSettingChanged-subscription branch 4 times, most recently from e58b586 to 31ad0bd Compare November 5, 2025 18:14
@mikescamell mikescamell changed the title [WIP] SERP Settings Sync: Add event when Duck Ai setting changed SERP Settings Sync: Add event when Duck Ai setting changed Nov 5, 2025
@mikescamell mikescamell marked this pull request as ready for review November 5, 2025 18:21
Copy link
Contributor

@marcosholgado marcosholgado left a comment

Choose a reason for hiding this comment

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

LGTM and pre-approving. Two things before merging:

  1. Needs tests
  2. The events are sent even if the serp settings sync feature flag is disabled which I guess is wrong?

@mikescamell mikescamell force-pushed the feature/mike/serp-settings-sync/add-nativeDuckAiSettingChanged-subscription branch from 31ad0bd to c85fcc2 Compare November 6, 2025 10:46
@mikescamell
Copy link
Contributor Author

LGTM and pre-approving. Two things before merging:

  1. Needs tests
  2. The events are sent even if the serp settings sync feature flag is disabled which I guess is wrong?
  1. Tests added
  2. Feature flag added to stop sending events

Tested and works as expected.

@mikescamell mikescamell force-pushed the feature/mike/serp-settings-sync/add-nativeDuckAiSettingChanged-subscription branch from c85fcc2 to b9538f5 Compare November 6, 2025 11:12
@mikescamell mikescamell force-pushed the feature/mike/serp-settings-sync/add-nativeDuckAiSettingChanged-subscription branch from b9538f5 to 62f1e89 Compare November 6, 2025 11:40
@mikescamell mikescamell requested a review from Copilot November 6, 2025 12:06
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 introduces a plugin system for sending subscription events from content scope scripts to web views in both the Settings and Browser contexts. The implementation enables SERP settings synchronization through a feature-flagged subscription event mechanism.

Key changes:

  • New plugin interface (ContentScopeScriptsSubscriptionEventPlugin) for providing subscription event data
  • Integration in both SettingsWebViewViewModel and BrowserTabViewModel to process and emit subscription events
  • DuckChat implementation providing enabled state through the new plugin system

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
ContentScopeScriptsSubscriptionEventPlugin.kt Defines plugin interface for subscription events
ContentScopeScriptsSubscriptionEventPluginPoint.kt Plugin point for subscription event plugins
DuckChatContentScopeJsMessageHandler.kt Implements plugin to provide DuckChat enabled state
SettingsWebViewViewModel.kt Processes plugins and emits subscription events on resume
SettingsWebViewActivity.kt Observes subscription events and sends to content scope scripts
BrowserTabViewModel.kt Similar subscription event processing in browser context
BrowserTabFragment.kt Observes and forwards subscription events in browser
SettingsWebViewViewModelTest.kt Test coverage for settings subscription events
BrowserTabViewModelTest.kt Test coverage for browser subscription events
BrowserViewModel.kt Removed unused DuckChat dependency
BrowserViewModelTest.kt Removed unused DuckChat mock

@mikescamell mikescamell force-pushed the feature/mike/serp-settings-sync/add-nativeDuckAiSettingChanged-subscription branch from 187cef7 to 146e33c Compare November 6, 2025 12:17
@mikescamell mikescamell merged commit da235e2 into develop Nov 6, 2025
6 checks passed
@mikescamell mikescamell deleted the feature/mike/serp-settings-sync/add-nativeDuckAiSettingChanged-subscription branch November 6, 2025 13:03
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.

2 participants