Skip to content

docs: document Sidekick Experimentation panel setup for v2#61

Closed
keepthebyte wants to merge 1 commit into
adobe:v2from
keepthebyte:docs/sidekick-experimentation-mfe-setup
Closed

docs: document Sidekick Experimentation panel setup for v2#61
keepthebyte wants to merge 1 commit into
adobe:v2from
keepthebyte:docs/sidekick-experimentation-mfe-setup

Conversation

@keepthebyte

@keepthebyte keepthebyte commented Jul 22, 2026

Copy link
Copy Markdown

Summary

v2 moved the experiment/audience/campaign simulation UI out of the plugin's own injected overlay and into a hosted MFE panel loaded by the AEM Sidekick browser extension, but I couldn't find any documentation describing how to actually wire that up in a project. setupCommunicationLayer in src/index.js implements the postMessage handshake side of it, but a consuming project still needs to register a Sidekick plugin and load a page-side listener script for the toolbar button to do anything.

I worked this out first-hand while instrumenting a real (non-Xwalk) project against v2, including two non-obvious gotchas that cost real debugging time:

  • For a project already migrated to AEM's unified ("helix5") config format (e.g. via Experience Workspace), Sidekick reads its plugin list from the persisted admin config, not a live read of tools/sidekick/config.json off the code bus — so just committing that file isn't enough.
  • That same admin config API has its PUT/POST verbs inverted from typical REST conventions: PUT only creates a config and fails with config already exists if one is already there; POST is what updates it.
  • If the page-side listener script is never loaded (nothing wires it up automatically — it's a classic, non-module script), clicking the Sidekick button silently does nothing: the button correctly dispatches its custom event, there's just nobody listening, so there's no console error either.

Changes

  • New "Enabling the Sidekick Experimentation panel" section in README.md covering all three setup steps, plus the config-propagation and PUT/POST gotchas above.
  • documentation/sidekick/config.json and documentation/sidekick/aem-experimentation.js as copy-pasteable reference files matching what's inlined in the README.
  • A correction to documentation/experiments.md's "Simulation" section, which still described the v1 in-page overlay as automatic, and referenced the wrong query parameter name (audience instead of experiment) for forcing a variant.

Test plan

  • Verified documentation/sidekick/config.json is valid JSON and documentation/sidekick/aem-experimentation.js has valid JS syntax.
  • All of this was validated against a live project: registered the plugin, hit the exact config already exists / PUT-vs-POST issue and confirmed the POST workaround, and confirmed the Sidekick button was a silent no-op until the listener script was actually loaded from head.html.
  • Would appreciate a maintainer sanity-check on whether the MFE URL / panel behavior described matches current internal expectations, since I only have external visibility into the hosted panel itself.

Opening as a draft since I'm an external contributor working from a downstream project, not an AEM Engineering team member — happy to adjust scope, tone, or wording to match your preferred docs style.

🤖 Generated with Claude Code

v2 replaced the plugin's own in-page overlay with a hosted MFE panel
that the AEM Sidekick browser extension loads on demand, but nothing
in the README or experiments.md documented how to actually enable it
in a project. This adds:

- A new "Enabling the Sidekick Experimentation panel" section in the
  README covering the three required pieces: registering the plugin
  in tools/sidekick/config.json, adding the page-side listener script
  that responds to the toolbar click, and loading that script from
  head.html (easy to miss since it's the one piece nothing else wires
  up automatically).
- A callout for projects already migrated to the unified ("helix5")
  config format (e.g. via Experience Workspace), where Sidekick reads
  plugins from the persisted admin config rather than a live read of
  tools/sidekick/config.json off the code bus, and where the admin
  config API's PUT/POST verbs are inverted from typical REST
  conventions (PUT creates-only, POST updates).
- documentation/sidekick/config.json and
  documentation/sidekick/aem-experimentation.js as copy-pasteable
  reference files matching what's inlined in the README.
- A correction to documentation/experiments.md's Simulation section,
  which still described the v1 in-page overlay as automatic and
  referenced the wrong query parameter name (audience instead of
  experiment).

All of this was worked out first-hand instrumenting a real project
against the v2 branch, including the config propagation and PUT/POST
gotchas, which cost real debugging time without any of this being
documented anywhere.
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ramboz

ramboz commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Thanks for this @keepthebyte — the reference implementation and the write-up of the helix5 / PUT-vs-POST gotchas were exactly what was needed to pin down the problem.

We opted to fix this in the plugin itself rather than as project-side docs: #62 moves the listener/MFE-loading logic into the plugin's loadLazy(), so consuming projects no longer copy aem-experimentation.js into tools/sidekick/ or add a <script> to head.html (which also removes the CSP-nonce and silent-no-op traps you documented). It keeps the genuinely project-side parts of your PR — the Sidekick config.json registration and the helix5 admin-config note — in the README, and adds a simulationUI option to distinguish the EDS + Sidekick surface from the Universal Editor.

Given that, I'd suggest we close this one in favor of #62 once it lands, but I've kept your documentation/experiments.md fixes and config reference there so nothing is lost. Credited you in the PR description. 🙏

@ramboz ramboz closed this Jul 22, 2026
ramboz added a commit that referenced this pull request Jul 23, 2026
## Summary

In v2 the experiment/audience/campaign simulation UI was moved out of
the plugin's own injected overlay and into a hosted MFE that the [AEM
Sidekick
extension](https://chromewebstore.google.com/detail/aem-sidekick/igkmdomcgoebiipaifhmpfjhbjccggml)
opens. But nothing on the page ever loaded it: `loadLazy()` in
`src/index.js` was an empty placeholder, so the Sidekick
"Experimentation" button dispatched its custom event to nobody — a
silent no-op with no console error. This is the issue reported in
[SITES-48456](https://jira.corp.adobe.com/browse/SITES-48456).

This makes the plugin own that wiring in its lazy phase, so a consuming
project no longer copies a listener script into `tools/sidekick/` or
adds anything to `head.html`.

## Changes

- **`loadLazy(document, options)`** now:
- binds the Sidekick toolbar button
(`custom:aem-experimentation-sidekick`) to the panel, falling back to
the `sidekick-ready` event since the extension injects its element
asynchronously;
- lazy-loads the hosted MFE `client.js` on first use and toggles the
panel thereafter;
- opens the panel automatically on a `?experiment=<id>/<variant>`
simulation deep-link;
- restores the panel after a variant-switch triggers a full-page reload.
- It is gated to preview/dev only (`setDebugMode`) and **never runs in
production**.
- **New `simulationUI` option** — `'auto'` (default) | `'sidekick'` |
`'universal-editor'` | `false` — provides a clean way to distinguish the
**EDS + Sidekick** surface from the **Universal Editor**, where the
panel is delivered as a UE extension instead. `'auto'` only activates on
the Sidekick path, so a UE context naturally gets nothing.
- `setupCommunicationLayer` is now **idempotent**, so the eager and lazy
phases can both ensure the `postMessage` handshake exists (the panel now
works even on preview pages with no experiment configured yet). Its
reload handler also preserves the panel's open state across the reload.
- **Docs**: README gains `runExperimentationLazy` in the loader, the
`loadLazy()` wiring, the `simulationUI` option, and an **"Enabling the
simulation panel (AEM Sidekick)"** section. That section keeps the
still-necessary Sidekick plugin registration (`config.json`) and the
helix5 persisted-config / PUT-vs-POST gotcha, and drops the obsolete
copy-script / `head.html` steps. `documentation/experiments.md`'s
Simulation section is corrected (v1 overlay → v2 panel, `audience` →
`experiment` query param). Adds `documentation/sidekick/config.json` as
a reference.

## Relationship to #61

This supersedes the fragile half of #61: the ~167-line copy-paste
`aem-experimentation.js` listener is no longer needed because the plugin
owns it (versioned, no CSP-nonce trap, no silent no-op). The genuinely
project-side parts of #61 — the Sidekick `config.json` registration and
the helix5 admin-config gotcha — are preserved here in the README.
Thanks to @keepthebyte for working out the reference implementation and
documenting the gotchas first-hand.

## Test plan

- [x] `npm run lint:js` clean
- [x] `npx playwright test` — 88 passed
- [ ] Maintainer verification of the live Sidekick panel behavior
against a real v2 project (MFE URL / handshake).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Dereje Dilnesaw <dilnesaw@adobe.com>
github-actions Bot pushed a commit that referenced this pull request Jul 23, 2026
# [1.2.0](v1.1.0...v1.2.0) (2026-07-23)

### Features

* load simulation panel UI in loadLazy (AEM Sidekick) ([#62](#62)) ([44828b6](44828b6)), closes [#61](#61) [#61](#61) [#61](#61)
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