feat(chat): Implemented reactive adoptRootStyles with dedicated controller#2093
Merged
damyanpetev merged 2 commits intomasterfrom Feb 13, 2026
Merged
Conversation
…oller Added a new AdoptedStylesController that enables chat components to dynamically adopt document-level styles into Shadow DOM with proper lifecycle management. Changes: - Created src/components/common/controllers/adopt-styles.ts * Reactive controller for managing document style adoption * Implements WeakMap-based caching per document for performance * Provides cache invalidation for theme changes * Handles cross-origin stylesheet restrictions gracefully * Automatic cleanup on component disconnection - Updated chat-input.ts and chat-message.ts * Migrated from inline controller to shared adopt-styles controller * Added reactive _shouldAdoptRootStyles state property * Implemented proper update() lifecycle to respond to option changes * Added cache invalidation on theme changes via _adoptPageStyles() - Enhanced chat.spec.ts * Added ResizeObserver loop error suppression for test stability * Added tests for dynamic adoptRootStyles toggling (false→true, true→false) * Added test for multiple toggle cycles * Added test for theme change interaction with adoptRootStyles - Updated types.ts * Removed outdated warning about runtime changes not working - Refactored chat/utils.ts * Removed duplicate AdoptedStylesController implementation * Controller moved to shared controllers directory Benefits: - adoptRootStyles now works reactively at runtime (no longer one-time shot) - Consistent controller implementation across all components - Improved performance through stylesheet caching - Better memory management with automatic cleanup - Proper theme change handling with cache invalidation - Comprehensive test coverage for all scenarios
damyanpetev
approved these changes
Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added a new AdoptedStylesController that enables chat components to dynamically adopt document-level styles into Shadow DOM with proper lifecycle management.
Changes:
Created src/components/common/controllers/adopt-styles.ts
Updated chat-input.ts and chat-message.ts
Enhanced chat.spec.ts
Updated types.ts
Refactored chat/utils.ts
Benefits:
Type of Change
Testing
Checklist