@helpway/react 0.14.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2264,6 +2264,29 @@ function useConversations() {
2264
2264
  return { conversations, create, isCreating, setActiveConversation };
2265
2265
  }
2266
2266
 
2267
+ // src/hooks/use-header-identity.ts
2268
+ function useHeaderIdentity() {
2269
+ const activeConvSummary = useWidgetStore((s) => {
2270
+ const id = s.activeConversationId;
2271
+ return id ? s.conversations.find((c) => c.id === id) : null;
2272
+ });
2273
+ const agentConfigName = useWidgetStore((s) => s.agentConfig?.name);
2274
+ const websiteName = useWidgetStore((s) => s.website?.name);
2275
+ const teamSender = activeConvSummary?.lastMessageSenderType === "team" && activeConvSummary?.lastMessageSenderName ? activeConvSummary : null;
2276
+ const humanName = activeConvSummary?.assigneeName ?? teamSender?.lastMessageSenderName ?? null;
2277
+ const humanImage = activeConvSummary?.assigneeImage ?? teamSender?.lastMessageSenderImage ?? null;
2278
+ const companyName = agentConfigName ?? websiteName ?? "Support";
2279
+ return {
2280
+ humanName,
2281
+ humanImage,
2282
+ hasTeamAgent: !!humanName,
2283
+ /** Fallback identity when no human is on the thread — also how the AI signs its answers. */
2284
+ companyName,
2285
+ /** Exactly what the header prints. Compare per-bubble name labels against this. */
2286
+ headerName: humanName ?? companyName
2287
+ };
2288
+ }
2289
+
2267
2290
  // src/hooks/use-i18n.ts
2268
2291
  import { useEffect as useEffect4, useState as useState4 } from "react";
2269
2292
  function useI18n() {
@@ -4761,10 +4784,8 @@ function MessageList({
4761
4784
  const containerRef = useRef14(null);
4762
4785
  const prevItemCountRef = useRef14(items.length);
4763
4786
  const isInitialLoadRef = useRef14(true);
4764
- const agentName = useWidgetStore((s) => s.agentConfig?.name) ?? t("widget.helpway_ai");
4765
- const headerName = useWidgetStore(
4766
- (s) => s.conversations.find((c) => c.id === s.activeConversationId)?.assigneeName
4767
- ) ?? agentName;
4787
+ const { headerName, companyName } = useHeaderIdentity();
4788
+ const agentName = companyName;
4768
4789
  const client = useWidgetClient();
4769
4790
  const activeConversationId = useWidgetStore((s) => s.activeConversationId);
4770
4791
  const handleQuickReplyTap = React.useCallback(
@@ -5590,16 +5611,7 @@ function DefaultWidget({
5590
5611
  return () => win.removeEventListener("keydown", handleTab);
5591
5612
  }, [isOpen, hideLauncher, placement]);
5592
5613
  const showTabBar = subView === null;
5593
- const activeConvSummary = useWidgetStore((s) => {
5594
- const id = s.activeConversationId;
5595
- return id ? s.conversations.find((c) => c.id === id) : null;
5596
- });
5597
- const teamSender = activeConvSummary?.lastMessageSenderType === "team" && activeConvSummary?.lastMessageSenderName ? activeConvSummary : null;
5598
- const humanName = activeConvSummary?.assigneeName ?? teamSender?.lastMessageSenderName ?? null;
5599
- const humanImage = activeConvSummary?.assigneeImage ?? teamSender?.lastMessageSenderImage ?? null;
5600
- const hasTeamAgent = !!humanName;
5601
- const headerName = humanName ?? (agentConfig?.name ?? website?.name ?? "Support");
5602
- const companyName = agentConfig?.name ?? website?.name ?? "Support";
5614
+ const { humanImage, hasTeamAgent, companyName, headerName } = useHeaderIdentity();
5603
5615
  const subtitleMsg = agentConfig?.subtitleText;
5604
5616
  const subtitleIsFactoryDefault = !subtitleMsg || subtitleMsg === DEFAULT_EN_SUBTITLE;
5605
5617
  const subtitleText = subtitleMsg?.startsWith("widget.") ? t(subtitleMsg) : subtitleIsFactoryDefault ? t("widget.subtitle_text") : subtitleMsg;