feat(webchat): add branding, avatars, and widget CSS hardening - #938
Merged
Conversation
- Auto-contrast foreground text against admin-chosen brandColor (getRelativeLuminance/readableForeground) instead of hardcoded white - Show workspace logo beside bot/agent bubbles in the guest widget, gated server-side on showLogo - Sanitize IntegrationWebchat.customCss against </style> injection before rendering via dangerouslySetInnerHTML; cap length at 20k - Require superAdmin permission in updateWebchatAction, not just workspace membership, since it can set customCss served to the public widget; expose workspaceMemberPermissions on action ctx - Trim embed snippet to only still-used options - Reload instead of toast+refresh after workspace deletion actions; minor account-rail plan label and add-channel-button anchor fixes
- Add subtle border to ahc-iframe-container to highlight the chat bubble - Increase message avatar size and adjust alignment - Increase crown icon size in upgrade plan button
viethung0o0
pushed a commit
that referenced
this pull request
Sep 7, 2026
* feat(webchat): add branding, avatars, and widget CSS hardening - Auto-contrast foreground text against admin-chosen brandColor (getRelativeLuminance/readableForeground) instead of hardcoded white - Show workspace logo beside bot/agent bubbles in the guest widget, gated server-side on showLogo - Sanitize IntegrationWebchat.customCss against </style> injection before rendering via dangerouslySetInnerHTML; cap length at 20k - Require superAdmin permission in updateWebchatAction, not just workspace membership, since it can set customCss served to the public widget; expose workspaceMemberPermissions on action ctx - Trim embed snippet to only still-used options - Reload instead of toast+refresh after workspace deletion actions; minor account-rail plan label and add-channel-button anchor fixes * fix(builder): polish webchat iframe border and icon sizing - Add subtle border to ahc-iframe-container to highlight the chat bubble - Increase message avatar size and adjust alignment - Increase crown icon size in upgrade plan button
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.
Summary
brandColorinstead of a hardcoded white, and show the workspace logo beside bot/agent bubbles (gated server-side onshowLogo).IntegrationWebchat.customCssagainst</style>injection before it's rendered viadangerouslySetInnerHTML, and cap its length at 20k characters.updateWebchatActiononly checked workspace membership, so any member (not just superAdmin, as the edit page requires) could setcustomCssserved to the public widget — now gated onsuperAdminvia a newworkspaceMemberPermissionsfield on the action ctx.router.refresh()after workspace deletion actions, an account-rail plan label/layout tweak, and anadd-channel-buttonanchor-instead-of-button fix.Changes
apps/builder/src/features/integration-webchat/lib/brand-color.ts(new) — WCAG relative luminance + readable foreground helpersapps/builder/src/features/integration-webchat/lib/widget-css.tsx(new) —sanitizeWidgetCss+CustomWidgetStyleserver componentapps/builder/src/features/integration-webchat/actions/update-webchat.action.ts,apps/builder/src/lib/safe-action.ts— superAdmin permission gate on the action,workspaceMemberPermissionsexposed on ctxapps/builder/src/features/integration-webchat/schema/mutation.ts—customCssmax lengthapps/builder/src/app/(no-sidebar)/webchat/page.tsx,webchat-wrapper.tsx,webchat-message-list.tsx,guest-session-provider.tsx,guest-sesssion-store.ts— wire brand color + workspace logo through to the guest widgetapps/builder/src/features/messages/components/message-item.tsx— optionalavatarUrlprop for agent/bot bubblesapps/builder/src/features/integration-webchat/dialogs/embed-code-dialog.tsx,components/authorized-domain-field.tsx— trim unused embed snippet options, add domain field placeholderapps/builder/src/features/workspaces/components/{account-rail,workspace-deletion-card}.tsx,apps/builder/src/features/inboxes/components/add-channel-button.tsx— unrelated small fixesapps/builder/messages/*.jsonlocalesapps/builder/__tests__/andapps/builder/src/features/workspaces/components/__tests__/Test plan
pnpm lintpnpm --filter builder check-types(required fixing an unrelated stale workspace link for@chatbotx.io/integration-instagram-facebookviaCI=true pnpm install --no-frozen-lockfile)brandColorand confirm header/button text stays readable; toggleshowLogoand confirm the avatar appears/disappears; attemptupdateWebchatActionas a non-superAdmin member and confirm it's rejected