Skip to content

♻️(frontend) support legacy and new widget attribute#650

Merged
jbpenrath merged 1 commit into
mainfrom
deps/widget-upgrade
Apr 30, 2026
Merged

♻️(frontend) support legacy and new widget attribute#650
jbpenrath merged 1 commit into
mainfrom
deps/widget-upgrade

Conversation

@jbpenrath
Copy link
Copy Markdown
Contributor

@jbpenrath jbpenrath commented Apr 30, 2026

Purpose

The new widget loader consume window._lasuite_widget property to know which widget to load. The previous version was using window._stmsg_header. We refactor widget loading logic to support both version with ease.

Summary by CodeRabbit

  • Refactor
    • Consolidated widget initialization logic across feedback and Lagaufre components through a new centralized utility module, improving code maintainability and consistency in widget script loading and command handling.

The new widget loader consume `window._lasuite_widget` property to
know which widget to load. The previous version was using
`window._stmsg_header`. We refactor widget loading logic to support
both version with ease.
@jbpenrath jbpenrath force-pushed the deps/widget-upgrade branch from 5297af0 to 5870861 Compare April 30, 2026 13:54
@jbpenrath jbpenrath changed the title ♻️((frontend) support legacy and new widget attribute ♻️(frontend) support legacy and new widget attribute Apr 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

📝 Walkthrough

Walkthrough

The PR introduces a new WidgetHelper utility class that centralizes widget script loading and command queueing. Three widget components (feedback-button, feedback-widget, lagaufre) are refactored to delegate their window manipulation and script injection logic to this utility instead of handling it directly.

Changes

Cohort / File(s) Summary
Widget Component Refactoring
src/frontend/src/features/ui/components/feedback-button/index.tsx, src/frontend/src/features/ui/components/feedback-widget/index.tsx, src/frontend/src/features/ui/components/lagaufre/index.tsx
Components now use WidgetHelper.pushCommand and WidgetHelper.loadScript instead of directly manipulating window._lasuite_widget and manually creating/inserting script tags. Dependencies adjusted where needed.
WidgetHelper Utility
src/frontend/src/features/utils/widget-helper.ts
New utility class extending Window type with optional _lasuite_widget and _stmsg_widget queues. Provides pushCommand() to enqueue commands to both queues and loadScript() to load scripts with deduplication checks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title uses an emoji and incomplete phrasing ('support legacy and new widget attribute') that is vague about the actual refactoring work—delegating widget initialization to WidgetHelper. Consider a clearer title like 'Refactor widget loading to delegate initialization to WidgetHelper' that better describes the primary refactoring change.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/frontend/src/features/utils/widget-helper.ts`:
- Around line 24-35: loadScript currently early-returns when there is no
existing <script> tag (firstScript), causing widgets to never load on pages
without preexisting scripts; update loadScript (function loadScript, parameter
scriptUrl, local var firstScript) to append the created script to document.head
or document.body when firstScript is null instead of doing nothing—i.e., if
firstScript and firstScript.parentNode use insertBefore(script, firstScript),
otherwise appendChild to document.head || document.body so the script is always
added.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6cb12785-6e58-4f9c-97e3-402940b673e9

📥 Commits

Reviewing files that changed from the base of the PR and between 99caf32 and 5870861.

📒 Files selected for processing (4)
  • src/frontend/src/features/ui/components/feedback-button/index.tsx
  • src/frontend/src/features/ui/components/feedback-widget/index.tsx
  • src/frontend/src/features/ui/components/lagaufre/index.tsx
  • src/frontend/src/features/utils/widget-helper.ts

Comment thread src/frontend/src/features/utils/widget-helper.ts
@jbpenrath jbpenrath merged commit 44d455c into main Apr 30, 2026
13 checks passed
@jbpenrath jbpenrath deleted the deps/widget-upgrade branch April 30, 2026 14:18
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