Skip to content

fix(widget): use welcomeBubbleDefault locale string when text is omitted - #630

Merged
anurag629 merged 2 commits into
codercops:devfrom
bhushan4work:610
Nov 20, 2026
Merged

anurag629 merged 2 commits into
codercops:devfrom
bhushan4work:610

Conversation

@bhushan4work

Copy link
Copy Markdown
Collaborator

What does this change?

Makes WidgetConfig.welcomeBubble.text optional, defaulting to the chat's welcomeBubbleDefault locale string ("Need help? Chat with us!" in English, or the active translation).

  • packages/widget/src/widget.ts: Made text optional in WidgetConfig.welcomeBubble. In createBubble(), fallback to this.locale.welcomeBubbleDefault when text is not provided (welcomeBubble: {} and welcomeBubble: { delay: 5000 } now display default text).
  • packages/widget/src/script-config.ts: Changed data-welcome-bubble attribute check so an empty attribute (data-welcome-bubble="" or bare data-welcome-bubble) enables the welcome bubble with default text, while a tag without the attribute still shows no bubble. The loader gzip size remains within budget (4.95 kB / 5 kB budget), so no script-tag work needed to be dropped.
  • website/src/content/docs/widget/configuration.mdx: Updated documentation for welcomeBubble to show text is optional defaulting to welcomeBubbleDefault, corrected "hover bubble" comment to "bubble", and updated the data-welcome-bubble row to reflect that an empty value enables the bubble with default text.
  • api/widget.api.md & api/react.api.md: Updated API snapshots via pnpm api.
  • Added minor changeset for @chatcops/widget noting the empty attribute behavior.

Tests added

  • packages/widget/tests/widget.test.ts: Added test initializing with welcomeBubble: {}, advancing past 3000 ms, and asserting .cc-bubble-trigger displays "Need help? Chat with us!" as well as the translated string when strings overrides are passed, plus verification for welcomeBubble: { delay: 5000 }.
  • packages/widget/tests/script-config.test.ts: Added test verifying data-welcome-bubble="" enables the bubble with default text, and tags without the attribute show no bubble.
  • packages/widget/tests/loader.test.ts: Added test verifying createLoader with loadLocale resolving { default: { welcomeBubbleDefault: 'Brauchen Sie Hilfe?' } } passes it through strings to the widget when the bubble is due.

Closes #610

How I tested this

Ran the required checks, all passing:

  • pnpm vitest run --project @chatcops/widget
  • pnpm test:coverage
  • pnpm lint
  • pnpm size (chatcops.min.js at 4.95 kB gzipped <= 5 kB limit)
  • pnpm docs:check

AI assistance

None

Checklist

  • This PR targets dev
  • I was assigned the linked issue
  • pnpm -r build, pnpm test and pnpm -r typecheck pass locally
  • Tests added or updated where it makes sense
  • For a bug fix: the new test fails without my change
  • Changeset added (pnpm changeset) if this changes core, widget or server
  • pnpm api run and api/ committed if an exported type or option changed
  • Docs updated if behavior or options changed

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @bhushan4work. welcomeBubble: {} and { delay: 5000 } now fall back to this.locale.welcomeBubbleDefault (packages/widget/src/widget.ts:334), and the loader needed no change: current.welcomeBubble at loader.ts:236 is true for {}, and the new loader test shows the German string coming through strings. An empty or bare data-welcome-bubble turns the bubble on, and a tag without it still doesn't. The loader is at 4.96 of 5 kB. All checks pass, including e2e.

@anurag629
anurag629 merged commit 660bcee into codercops:dev Nov 20, 2026
5 checks passed
@anurag629

Copy link
Copy Markdown
Member

Merged, thanks @bhushan4work.

@github-actions github-actions Bot added the codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com) label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show the translated welcomeBubbleDefault when welcomeBubble has no text

2 participants