Skip to content

fix(cc-widgets): restore bundler compatibility for wellness media - #751

Open
bhabalan wants to merge 1 commit into
webex:nextfrom
bhabalan:codex/wellness-media-portability
Open

bhabalan wants to merge 1 commit into
webex:nextfrom
bhabalan:codex/wellness-media-portability

Conversation

@bhabalan

@bhabalan bhabalan commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

COMPLETES

Fixes the Vite compatibility regression reported after @webex/cc-widgets was upgraded from 1.28.0-next.58 to 1.28.0-next.61.

Related change: #741 — Agent Wellness Break (WXCC-12423). No separate defect issue was supplied.

This pull request addresses

The published AI Assistant media loader contains the Webpack request !!./emit-wellness-asset.cjs!./WellnessBreakSound.mp3 and require.ensure(). Vite cannot resolve these requests. Importing the widgets can therefore fail even when the consumer does not use wellness breaks.

Full Vite consumer checks also found that UI logging was always built in development mode. Its exports were inside eval() modules, which prevented Vite 8 from reading withMetrics during browser startup.

by making the following changes

  • Generate JavaScript modules for the MP3 data URL and both animation objects during the AI Assistant package build.
  • Use standard dynamic imports for these modules and lottie-web. Accept both a default export and a direct CommonJS Lottie export.
  • Remove the inline Webpack asset loader. Retain the approved MP3 and animation JSON in the package.
  • Track source media files so watch builds regenerate the modules after a change.
  • Route the source React sample to the generated media modules from the package build.
  • Let UI logging use the root build mode, so production packages expose normal JavaScript exports.
  • Add packaging regression tests and an assertion that wellnessAudioUrl bypasses the default sound import.
  • Update the AI Assistant, UI logging, and wellness intake documentation, including the local compatibility record.

Compatibility and CSP

BREAKING CHANGE: The default wellness audio now uses a data URL. CSP must permit data: in media-src. Consumers whose policy permits only hosted media must set the existing wellnessAudioUrl prop to an allowed MP3 URL. The encoded sound module is about 3.5 MB before compression; the original MP3 is 2,603,884 bytes.

The existing recoverable MEDIA_UNAVAILABLE path handles media failures. Automatic retry and a hosted default fallback URL remain a follow-up that needs a published media endpoint.

Rollback: revert this PR.

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

  • The testing is done with the amplify link
  • yarn build:dev and yarn build:prod; React and Web Component sample production builds.
  • Full unit tests and repository lint through the pre-commit hook, without bypassing the hook: 1,796 test executions passed across 92 suite executions, with seven existing skips. The root script runs the meetings suite twice. Lint passed with zero errors and six warnings in the unchanged Web Component sample.
  • Packaging regression tests cover emitted modules, unchanged raw bytes, standard import requests, watch dependencies, and regeneration. The media emitter has 100% line and branch coverage.
  • AI Assistant and UI logging unit tests; the host audio override skips the packaged sound import.
  • Actual packed packages in local Webpack, Vite, Rollup, esbuild, and Parcel consumers, with no MP3 loader, wellness JSON loader, or raw media copy step.
  • React entry imports, direct AI Assistant import, and Web Component registration below /app/nested/.
  • Browser MP3 decoding and playback, both Lottie themes, delayed production sound loading, and development checks.
  • CSP media-src 'self' blocks the data audio and permits the original MP3 served from the same origin.
  • Fresh production archives for all nine Contact Center packages match the tested archive SHA-256 hashes.
  • Staged secret-pattern scan and git diff --check.
  • AWS Amplify preview build passed. Hosted preview functionality has not been tested with a live agent.
Consumer Version Production imports and playback Development
Webpack 5.111.1 Passed Passed
Vite 8.3.4 Passed Passed
Rollup 4.64.5 Passed Passed
esbuild 0.28.2 Passed Passed
Parcel 2.16.4 Passed Passed

Browser: Chromium 156.0.8078.4, Playwright 1.64.0. Local consumers use the required UI peers and normal CSS/SCSS support; Parcel package exports are enabled. Browser import checks supply the existing host globals without starting an authenticated SDK session. These checks cover the listed versions. The Amplify preview build passed; hosted preview functionality and a live Contact Center agent session have not been tested.

The first full unit run with production fixtures stopped after a Jest worker was terminated. An isolated run reached Node's 4 GB heap limit. After yarn build:dev, the store suite and the complete pre-commit hook passed.

GitHub CI requires a code owner to add the validated label for a fork PR. The initial validation run stopped at this label gate, before the title check and CI tests.

Testing record: ai-docs/features/agent-wellness-break-intake.md.

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
    • GAI Coding Policy and Copyright Annotation Best Practices: OpenAI Codex generated the code and tests, original approved media bytes and existing copyright notices are retained. Human review is required before merge.
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - OpenAI Codex
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

Checklist before merging

  • I have not skipped any automated checks
  • All existing and new tests passed locally
  • I have updated the testing document
  • I have tested the functionality with amplify link

Make sure to have followed the contributing guidelines before submitting.

Generate lazy JavaScript media modules, preserve the approved raw assets, and let production UI logging use normal exports. Add package regression tests and update the sample and module specs.

BREAKING CHANGE: Default wellness audio is a data URL. CSP must permit media-src data: or the host must supply an allowed wellnessAudioUrl.
@aws-amplify-us-east-2

Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-751.d1b38q61t1z947.amplifyapp.com

@bhabalan
bhabalan marked this pull request as ready for review October 13, 2026 16:46
@bhabalan
bhabalan requested a review from a team as a code owner October 13, 2026 16:46
@bhabalan
bhabalan requested a review from akulakum October 13, 2026 16:46
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T16:52:33.365738Z 645707f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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.

1 participant