Skip to content
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

#9105: POC of mod variable sync #9106

Closed
wants to merge 7 commits into from

Conversation

twschiller
Copy link
Contributor

@twschiller twschiller commented Sep 6, 2024

What does this PR do?

Approach

  • Adds a variables.schema section to Mod Definition (as required)
  • Adds a variables.schema section to Activated Mod Component (as required)
  • Adds to Page Editor form state so policy isn't lost when editing a mod in the page editor
  • Adds a registerModVariables method to platform.state protocol
  • State controller uses chrome.storage.session for variables declared with a sync policy.
    • Background sets storage policy to allow content script to access session storage directly
    • Session storage used to subscribe to storage changes from other tabs
    • State controller emits existing JS event for starter brick, etc. to listen to

Not Implemented

  • Persisted slice migrations
  • Tab-only sync policy (vs. all frames)

Demo

For more information on our expectations for the PR process, see the
code review principles doc

@twschiller twschiller self-assigned this Sep 6, 2024
Copy link

github-actions bot commented Sep 6, 2024

Playwright test results

failed  6 failed
passed  5 passed
flaky  1 flaky
skipped  120 skipped

Details

report  Open report ↗︎
stats  132 tests across 44 suites
duration  3 minutes, 8 seconds
commit  ab7ab2f
info  For more information on how to debug and view this report, see our readme

Failed tests

chrome-setup › setup/affiliated.setup.ts › authenticate with affiliated user
msedge-setup › setup/affiliated.setup.ts › authenticate with affiliated user
chrome-setup › setup/affiliated.setup.ts › authenticate with affiliated user
msedge-setup › setup/affiliated.setup.ts › authenticate with affiliated user
chrome-setup › setup/affiliated.setup.ts › authenticate with affiliated user
msedge-setup › setup/affiliated.setup.ts › authenticate with affiliated user

Flaky tests

chrome-setup › setup/unaffiliated.setup.ts › authenticate with unaffiliated user

Skipped tests

chrome › tests/bricks/sidebarEffects.spec.ts › sidebar effect bricks › toggle sidebar brick
msedge › tests/bricks/sidebarEffects.spec.ts › sidebar effect bricks › toggle sidebar brick
chrome › tests/deployments/deploymentActivation.spec.ts › activate a deployed mod in the extension console
msedge › tests/deployments/deploymentActivation.spec.ts › activate a deployed mod in the extension console
chrome › tests/extensionConsole/activation.spec.ts › can activate a mod with no config options
chrome › tests/extensionConsole/activation.spec.ts › can activate a mod with built-in integration
chrome › tests/extensionConsole/activation.spec.ts › validates activating a mod with required integrations
chrome › tests/extensionConsole/activation.spec.ts › can activate a mod with a database
chrome › tests/extensionConsole/activation.spec.ts › activating a mod when the quickbar shortcut is not configured
chrome › tests/extensionConsole/activation.spec.ts › can activate a mod via url
msedge › tests/extensionConsole/activation.spec.ts › can activate a mod with no config options
msedge › tests/extensionConsole/activation.spec.ts › can activate a mod with built-in integration
msedge › tests/extensionConsole/activation.spec.ts › validates activating a mod with required integrations
msedge › tests/extensionConsole/activation.spec.ts › can activate a mod with a database
msedge › tests/extensionConsole/activation.spec.ts › activating a mod when the quickbar shortcut is not configured
msedge › tests/extensionConsole/activation.spec.ts › can activate a mod via url
chrome › tests/extensionConsole/modsPage.spec.ts › can open mod in the workshop
msedge › tests/extensionConsole/modsPage.spec.ts › can open mod in the workshop
chrome › tests/extensionConsole/zapierModal.spec.ts › Zapier Integration Modal › can copy Zapier key and close modal
msedge › tests/extensionConsole/zapierModal.spec.ts › Zapier Integration Modal › can copy Zapier key and close modal
chrome › tests/modLifecycle.spec.ts › create, run, package, and update mod
msedge › tests/modLifecycle.spec.ts › create, run, package, and update mod
chrome › tests/pageEditor/addStarterBrick.spec.ts › Add new starter brick
chrome › tests/pageEditor/addStarterBrick.spec.ts › Add starter brick to mod
msedge › tests/pageEditor/addStarterBrick.spec.ts › Add new starter brick
msedge › tests/pageEditor/addStarterBrick.spec.ts › Add starter brick to mod
chrome › tests/pageEditor/brickActions.spec.ts › brick actions panel behavior
msedge › tests/pageEditor/brickActions.spec.ts › brick actions panel behavior
chrome › tests/pageEditor/brickConfiguration.spec.ts › brick configuration
msedge › tests/pageEditor/brickConfiguration.spec.ts › brick configuration
chrome › tests/pageEditor/copyMod.spec.ts › copying a mod that uses the PixieBrix API is copied correctly
chrome › tests/pageEditor/copyMod.spec.ts › run a copied mod with a built-in integration
msedge › tests/pageEditor/copyMod.spec.ts › copying a mod that uses the PixieBrix API is copied correctly
msedge › tests/pageEditor/copyMod.spec.ts › run a copied mod with a built-in integration
chrome › tests/pageEditor/liveEditing.spec.ts › live editing behavior
msedge › tests/pageEditor/liveEditing.spec.ts › live editing behavior
chrome › tests/pageEditor/logsPane.spec.ts › can view error logs
msedge › tests/pageEditor/logsPane.spec.ts › can view error logs
chrome › tests/pageEditor/modEditorPane.spec.ts › mod editor pane behavior
msedge › tests/pageEditor/modEditorPane.spec.ts › mod editor pane behavior
chrome › tests/pageEditor/saveMod.spec.ts › can save a standalone trigger mod
chrome › tests/pageEditor/saveMod.spec.ts › shows error notification when updating a public mod without incrementing the version
msedge › tests/pageEditor/saveMod.spec.ts › can save a standalone trigger mod
msedge › tests/pageEditor/saveMod.spec.ts › shows error notification when updating a public mod without incrementing the version
chrome › tests/pageEditor/specialPages.spec.ts › Restricted browser page
chrome › tests/pageEditor/specialPages.spec.ts › Unavailable mod
chrome › tests/pageEditor/specialPages.spec.ts › Page Editor reload
msedge › tests/pageEditor/specialPages.spec.ts › Restricted browser page
msedge › tests/pageEditor/specialPages.spec.ts › Unavailable mod
msedge › tests/pageEditor/specialPages.spec.ts › Page Editor reload
chrome › tests/regressions/doNotCloseSidebarOnPageEditorSave.spec.ts › #8104: Do not automatically close the sidebar when saving in the Page Editor
msedge › tests/regressions/doNotCloseSidebarOnPageEditorSave.spec.ts › #8104: Do not automatically close the sidebar when saving in the Page Editor
chrome › tests/regressions/formFlicker.spec.ts › forms flickering due to components unexpectedly unmounting/remounting › #8320: Search field loses focus while typing on snippet mod
msedge › tests/regressions/formFlicker.spec.ts › forms flickering due to components unexpectedly unmounting/remounting › #8320: Search field loses focus while typing on snippet mod
chrome › tests/regressions/hideModalsOnPageEditorRefresh.spec.ts › should hide add brick modal when Page Editor refreshes
msedge › tests/regressions/hideModalsOnPageEditorRefresh.spec.ts › should hide add brick modal when Page Editor refreshes
chrome › tests/regressions/sandboxBrickErrors.spec.ts › #8821: ensure Javascript script errors are thrown during brick runtime
msedge › tests/regressions/sandboxBrickErrors.spec.ts › #8821: ensure Javascript script errors are thrown during brick runtime
chrome › tests/regressions/sidebarLinks.spec.ts › #8206: clicking links from the sidebar doesn't crash browser
msedge › tests/regressions/sidebarLinks.spec.ts › #8206: clicking links from the sidebar doesn't crash browser
chrome › tests/regressions/welcomeStarterBricks.spec.ts › #8740: can view the starter mods on the pixiebrix.com/welcome page
msedge › tests/regressions/welcomeStarterBricks.spec.ts › #8740: can view the starter mods on the pixiebrix.com/welcome page
chrome › tests/runtime/allFrames.spec.ts › 8527: availability allFrames declaration
msedge › tests/runtime/allFrames.spec.ts › 8527: availability allFrames declaration
chrome › tests/runtime/customEvents.spec.ts › custom event brick functionality
msedge › tests/runtime/customEvents.spec.ts › custom event brick functionality
chrome › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options
msedge › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options
chrome › tests/runtime/insertAtCursor.spec.ts › Insert at Cursor › 8157: can insert at cursor from side bar
chrome › tests/runtime/insertAtCursor.spec.ts › Insert at Cursor › 8154: can insert at cursor after opening sidebar from selection menu
msedge › tests/runtime/insertAtCursor.spec.ts › Insert at Cursor › 8157: can insert at cursor from side bar
msedge › tests/runtime/insertAtCursor.spec.ts › Insert at Cursor › 8154: can insert at cursor after opening sidebar from selection menu
chrome › tests/runtime/localIntegrations.spec.ts › Local Integrations Page › can create a new integration
chrome › tests/runtime/localIntegrations.spec.ts › Local Integrations Page › #8067: blank numeric text integration configuration field validated on save
msedge › tests/runtime/localIntegrations.spec.ts › Local Integrations Page › can create a new integration
msedge › tests/runtime/localIntegrations.spec.ts › Local Integrations Page › #8067: blank numeric text integration configuration field validated on save
chrome › tests/runtime/screenshotTab.spec.ts › screenshot tab brick functionality
msedge › tests/runtime/screenshotTab.spec.ts › screenshot tab brick functionality
chrome › tests/runtime/setInputValue.spec.ts › can set input value
msedge › tests/runtime/setInputValue.spec.ts › can set input value
chrome › tests/runtime/sidebar/sidebarActivation.spec.ts › initiates sidebar mod activation from activate url click
chrome › tests/runtime/sidebar/sidebarActivation.spec.ts › does not redirect to non-pixiebrix domain
msedge › tests/runtime/sidebar/sidebarActivation.spec.ts › initiates sidebar mod activation from activate url click
msedge › tests/runtime/sidebar/sidebarActivation.spec.ts › does not redirect to non-pixiebrix domain
chrome › tests/runtime/sidebar/sidebarAuth.spec.ts › Connect action in partner auth sidebar takes user to the Extension Console
msedge › tests/runtime/sidebar/sidebarAuth.spec.ts › Connect action in partner auth sidebar takes user to the Extension Console
chrome › tests/runtime/sidebar/sidebarController.spec.ts › sidebar controller › can open sidebar immediately from iframe without focus dialog
chrome › tests/runtime/sidebar/sidebarController.spec.ts › sidebar controller › shows focus dialog in top-level frame
chrome › tests/runtime/sidebar/sidebarController.spec.ts › sidebar controller › prevents host page styles from leaking into dialog
msedge › tests/runtime/sidebar/sidebarController.spec.ts › sidebar controller › can open sidebar immediately from iframe without focus dialog
msedge › tests/runtime/sidebar/sidebarController.spec.ts › sidebar controller › shows focus dialog in top-level frame
msedge › tests/runtime/sidebar/sidebarController.spec.ts › sidebar controller › prevents host page styles from leaking into dialog
chrome › tests/runtime/sidebar/sidebarNavigation.spec.ts › sidebar mod panels are persistent during navigation
chrome › tests/runtime/sidebar/sidebarNavigation.spec.ts › sidebar form and temporary panels are unavailable after navigation
msedge › tests/runtime/sidebar/sidebarNavigation.spec.ts › sidebar mod panels are persistent during navigation
msedge › tests/runtime/sidebar/sidebarNavigation.spec.ts › sidebar form and temporary panels are unavailable after navigation
chrome › tests/runtime/sidebar/sidebarPanelTheme.spec.ts › custom sidebar theme css file is applied to all levels of sidebar document
msedge › tests/runtime/sidebar/sidebarPanelTheme.spec.ts › custom sidebar theme css file is applied to all levels of sidebar document
chrome › tests/runtime/srcdocFrames.spec.ts › 8143: mods can run in srcdoc iframes
msedge › tests/runtime/srcdocFrames.spec.ts › 8143: mods can run in srcdoc iframes
chrome › tests/runtime/textSnippets.spec.ts › text snippet shortcut functionality
msedge › tests/runtime/textSnippets.spec.ts › text snippet shortcut functionality
chrome › tests/smoke/floatingActionButton.spec.ts › sidebar page smoke test › can toggle the sidebar from the floating action button and view the related mod's sidebar panel
chrome › tests/smoke/floatingActionButton.spec.ts › sidebar page smoke test › can hide the floating action button
msedge › tests/smoke/floatingActionButton.spec.ts › sidebar page smoke test › can toggle the sidebar from the floating action button and view the related mod's sidebar panel
msedge › tests/smoke/floatingActionButton.spec.ts › sidebar page smoke test › can hide the floating action button
chrome › tests/smoke/modsPage.spec.ts › extension console mods page smoke test › can view available mods
msedge › tests/smoke/modsPage.spec.ts › extension console mods page smoke test › can view available mods
chrome › tests/smoke/pageEditor.spec.ts › page editor smoke test › can open the page editor and connect to an open tab
msedge › tests/smoke/pageEditor.spec.ts › page editor smoke test › can open the page editor and connect to an open tab
chrome › tests/smoke/sidebar.spec.ts › sidebar page smoke test › can open the sidebar from selection menu action and view the related mod's sidebar panel
msedge › tests/smoke/sidebar.spec.ts › sidebar page smoke test › can open the sidebar from selection menu action and view the related mod's sidebar panel
chrome › tests/smoke/workshopPage.spec.ts › extension console workshop smoke test › can navigate to workshop page without a username
msedge › tests/smoke/workshopPage.spec.ts › extension console workshop smoke test › can navigate to workshop page without a username
chrome › tests/telemetry/errors.spec.ts › can report errors to telemetry service
chrome › tests/telemetry/errors.spec.ts › can report a service worker error to telemetry service
msedge › tests/telemetry/errors.spec.ts › can report errors to telemetry service
msedge › tests/telemetry/errors.spec.ts › can report a service worker error to telemetry service
chrome › tests/workshop/createMod.spec.ts › can create a new mod from a yaml definition and update it
msedge › tests/workshop/createMod.spec.ts › can create a new mod from a yaml definition and update it

Copy link

codecov bot commented Sep 8, 2024

Codecov Report

Attention: Patch coverage is 55.05618% with 40 lines in your changes missing coverage. Please review.

Project coverage is 74.65%. Comparing base (8318d74) to head (ab7ab2f).
Report is 274 commits behind head on main.

Files with missing lines Patch % Lines
src/contentScript/stateController.ts 46.37% 37 Missing ⚠️
src/background/background.ts 0.00% 1 Missing ⚠️
src/pageEditor/starterBricks/base.ts 66.66% 1 Missing ⚠️
src/starterBricks/types.ts 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9106      +/-   ##
==========================================
+ Coverage   74.24%   74.65%   +0.41%     
==========================================
  Files        1332     1345      +13     
  Lines       40817    41731     +914     
  Branches     7634     7781     +147     
==========================================
+ Hits        30306    31156     +850     
- Misses      10511    10575      +64     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -54,6 +54,12 @@ import { initApiClient } from "@/data/service/apiClient";
// In the future, it might also run other background tasks from mods (e.g., background intervals)
setPlatform(backgroundPlatform);

// Allows the content script to directly access the session storage for mod variables. Without this, we'd need to
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change required to allow content script to directly access session storage. Otherwise, we'd need to use messenger to broadcast state to tabs

const privateState = new Map<UUID, JsonObject>();
const keyPrefix = "#modVariables/";

const SCHEMA_POLICY_PROP = "x-sync-policy";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The JSON Schema prop name for controlling the policy

@twschiller twschiller changed the title #9105: [WIP]: POC of mod variable sync #9105: POC of mod variable sync Sep 9, 2024
@twschiller twschiller added the do not merge Merging of this PR is blocked by another one label Sep 9, 2024
@twschiller
Copy link
Contributor Author

@twschiller twschiller closed this Sep 10, 2024
@twschiller twschiller deleted the feature/9105-mod-variable-sync branch November 14, 2024 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Merging of this PR is blocked by another one spike
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Spike] POC of mod variable syncing
1 participant