@paymanai/payman-ask-sdk 2.0.2 → 2.0.4

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
@@ -371,6 +371,7 @@ function UserMessageV2({
371
371
  "payman-v2-toast-inner",
372
372
  toast.tone === "success" ? "payman-v2-toast-success" : "payman-v2-toast-error"
373
373
  ),
374
+ style: { borderRadius: 9999 },
374
375
  children: [
375
376
  toast.tone === "success" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4", style: { color: "#059669" } }) : /* @__PURE__ */ jsxRuntime.jsx(
376
377
  lucideReact.AlertCircle,
@@ -1428,6 +1429,7 @@ function AssistantMessageV2({
1428
1429
  "payman-v2-toast-inner",
1429
1430
  toast.tone === "success" ? "payman-v2-toast-success" : "payman-v2-toast-error"
1430
1431
  ),
1432
+ style: { borderRadius: 9999 },
1431
1433
  children: [
1432
1434
  toast.tone === "success" ? /* @__PURE__ */ jsxRuntime.jsx(
1433
1435
  lucideReact.Check,
@@ -2106,6 +2108,7 @@ var ChatInputV2 = react.forwardRef(
2106
2108
  if (textareaRef.current) {
2107
2109
  textareaRef.current.style.height = "auto";
2108
2110
  textareaRef.current.focus();
2111
+ textareaRef.current.scrollIntoView({ block: "nearest", behavior: "smooth" });
2109
2112
  }
2110
2113
  });
2111
2114
  }, [value, disabled, onClearEditing, onSend]);
@@ -2193,6 +2196,7 @@ var ChatInputV2 = react.forwardRef(
2193
2196
  "textarea",
2194
2197
  {
2195
2198
  ref: textareaRef,
2199
+ autoFocus: true,
2196
2200
  value,
2197
2201
  onChange: (e) => {
2198
2202
  if (isRecording) return;
@@ -2519,9 +2523,9 @@ function ImageLightboxV2({ src, alt, onClose }) {
2519
2523
  document.body
2520
2524
  );
2521
2525
  }
2522
- var DEFAULT_WIDTH = 280;
2523
- var DEFAULT_MIN_WIDTH = 240;
2524
- var DEFAULT_MAX_WIDTH = 480;
2526
+ var DEFAULT_WIDTH = 260;
2527
+ var DEFAULT_MIN_WIDTH = 220;
2528
+ var DEFAULT_MAX_WIDTH = 440;
2525
2529
  var DEFAULT_PAGE_SIZE = 20;
2526
2530
  function getPersistKey(config, opts) {
2527
2531
  if (opts.persistKey) return opts.persistKey;
@@ -2740,10 +2744,11 @@ function SessionHistorySidebar({
2740
2744
  options,
2741
2745
  activeSessionId,
2742
2746
  loadingSessionId,
2743
- streamingSessionIds,
2744
2747
  recentlyCompletedSessionIds,
2745
2748
  optimisticActivity,
2746
2749
  onSelectSession,
2750
+ onNewSession,
2751
+ newSessionDisabled = false,
2747
2752
  mobileOpen,
2748
2753
  onMobileOpenChange
2749
2754
  }) {
@@ -2751,6 +2756,7 @@ function SessionHistorySidebar({
2751
2756
  const mobileThemeSourceRef = react.useRef(null);
2752
2757
  const [mobilePortalThemeStyle, setMobilePortalThemeStyle] = react.useState({});
2753
2758
  const history = useSessionHistory(config, options, optimisticActivity);
2759
+ const showNewSessionButton = options.showNewSessionButton === true;
2754
2760
  react.useEffect(() => {
2755
2761
  if (!isMobile) return;
2756
2762
  setMobilePortalThemeStyle(readPortalThemeStyle(mobileThemeSourceRef.current));
@@ -2777,8 +2783,10 @@ function SessionHistorySidebar({
2777
2783
  history,
2778
2784
  activeSessionId,
2779
2785
  loadingSessionId,
2780
- streamingSessionIds,
2781
2786
  recentlyCompletedSessionIds,
2787
+ showNewSessionButton,
2788
+ onNewSession,
2789
+ newSessionDisabled,
2782
2790
  onSelectSession: (s) => {
2783
2791
  onSelectSession(s);
2784
2792
  onMobileOpenChange(false);
@@ -2793,8 +2801,10 @@ function SessionHistorySidebar({
2793
2801
  history,
2794
2802
  activeSessionId,
2795
2803
  loadingSessionId,
2796
- streamingSessionIds,
2797
2804
  recentlyCompletedSessionIds,
2805
+ showNewSessionButton,
2806
+ onNewSession,
2807
+ newSessionDisabled,
2798
2808
  onSelectSession
2799
2809
  }
2800
2810
  );
@@ -2803,11 +2813,14 @@ function DesktopSidebar({
2803
2813
  history,
2804
2814
  activeSessionId,
2805
2815
  loadingSessionId,
2806
- streamingSessionIds,
2807
2816
  recentlyCompletedSessionIds,
2817
+ showNewSessionButton,
2818
+ onNewSession,
2819
+ newSessionDisabled,
2808
2820
  onSelectSession
2809
2821
  }) {
2810
2822
  const { width, setWidth, collapsed, setCollapsed, minWidth, maxWidth } = history;
2823
+ const reduceMotion = framerMotion.useReducedMotion();
2811
2824
  const dragStateRef = react.useRef(null);
2812
2825
  const [isDragging, setIsDragging] = react.useState(false);
2813
2826
  const [handleHover, setHandleHover] = react.useState(false);
@@ -2839,25 +2852,42 @@ function DesktopSidebar({
2839
2852
  window.removeEventListener("pointercancel", onEnd);
2840
2853
  };
2841
2854
  }, [isDragging, setWidth]);
2855
+ const handleActive = handleHover || isDragging;
2856
+ const sidebarEnter = reduceMotion ? { duration: 0.1, ease: "easeOut" } : { duration: 0.16, ease: [0.25, 0.46, 0.45, 0.94] };
2842
2857
  if (collapsed) {
2843
2858
  return /* @__PURE__ */ jsxRuntime.jsx(
2844
- CollapsedButton,
2859
+ framerMotion.motion.div,
2845
2860
  {
2846
- onExpand: () => setCollapsed(false),
2847
- history,
2848
- activeSessionId,
2849
- loadingSessionId,
2850
- streamingSessionIds,
2851
- recentlyCompletedSessionIds,
2852
- onSelectSession
2853
- }
2861
+ className: "payman-sidebar-collapsed-mount",
2862
+ initial: reduceMotion ? false : { opacity: 0, scale: 0.96 },
2863
+ animate: { opacity: 1, scale: 1 },
2864
+ transition: sidebarEnter,
2865
+ style: { alignSelf: "flex-start" },
2866
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2867
+ CollapsedButton,
2868
+ {
2869
+ onExpand: () => setCollapsed(false),
2870
+ history,
2871
+ activeSessionId,
2872
+ loadingSessionId,
2873
+ recentlyCompletedSessionIds,
2874
+ showNewSessionButton,
2875
+ onNewSession,
2876
+ newSessionDisabled,
2877
+ onSelectSession
2878
+ }
2879
+ )
2880
+ },
2881
+ "payman-sidebar-desktop-collapsed"
2854
2882
  );
2855
2883
  }
2856
- const handleActive = handleHover || isDragging;
2857
2884
  return /* @__PURE__ */ jsxRuntime.jsxs(
2858
- "aside",
2885
+ framerMotion.motion.aside,
2859
2886
  {
2860
2887
  className: "payman-sidebar payman-sidebar-desktop",
2888
+ initial: reduceMotion ? false : { opacity: 0 },
2889
+ animate: { opacity: 1 },
2890
+ transition: sidebarEnter,
2861
2891
  style: {
2862
2892
  width,
2863
2893
  minWidth,
@@ -2868,17 +2898,24 @@ function DesktopSidebar({
2868
2898
  display: "flex",
2869
2899
  flexDirection: "column",
2870
2900
  overflow: "hidden",
2871
- transition: isDragging ? "none" : "width 140ms ease"
2901
+ transition: isDragging ? "none" : "width 100ms ease"
2872
2902
  },
2873
2903
  children: [
2874
- /* @__PURE__ */ jsxRuntime.jsx(SidebarHeader, { onCollapse: () => setCollapsed(true) }),
2904
+ /* @__PURE__ */ jsxRuntime.jsx(
2905
+ SidebarTopBar,
2906
+ {
2907
+ onCollapse: () => setCollapsed(true),
2908
+ showNewSessionButton,
2909
+ onNewSession,
2910
+ newSessionDisabled
2911
+ }
2912
+ ),
2875
2913
  /* @__PURE__ */ jsxRuntime.jsx(
2876
2914
  SessionList,
2877
2915
  {
2878
2916
  history,
2879
2917
  activeSessionId,
2880
2918
  loadingSessionId,
2881
- streamingSessionIds,
2882
2919
  recentlyCompletedSessionIds,
2883
2920
  onSelectSession
2884
2921
  }
@@ -2916,26 +2953,30 @@ function DesktopSidebar({
2916
2953
  borderRadius: 999,
2917
2954
  background: handleActive ? "var(--payman-v2-text-3)" : "transparent",
2918
2955
  opacity: handleActive ? 1 : 0,
2919
- transition: "opacity 140ms ease, background 140ms ease"
2956
+ transition: "opacity 100ms ease, background 100ms ease"
2920
2957
  }
2921
2958
  }
2922
2959
  )
2923
2960
  }
2924
2961
  )
2925
2962
  ]
2926
- }
2963
+ },
2964
+ "payman-sidebar-desktop-expanded"
2927
2965
  );
2928
2966
  }
2929
- var POPOVER_LEAVE_DELAY_MS = 200;
2967
+ var POPOVER_LEAVE_DELAY_MS = 220;
2930
2968
  function CollapsedButton({
2931
2969
  onExpand,
2932
2970
  history,
2933
2971
  activeSessionId,
2934
2972
  loadingSessionId,
2935
- streamingSessionIds,
2936
2973
  recentlyCompletedSessionIds,
2974
+ showNewSessionButton,
2975
+ onNewSession,
2976
+ newSessionDisabled,
2937
2977
  onSelectSession
2938
2978
  }) {
2979
+ const reduceMotion = framerMotion.useReducedMotion();
2939
2980
  const [hoverOpen, setHoverOpen] = react.useState(false);
2940
2981
  const leaveTimerRef = react.useRef(null);
2941
2982
  const openPopover = () => {
@@ -2964,22 +3005,29 @@ function CollapsedButton({
2964
3005
  style: { position: "relative", alignSelf: "flex-start" },
2965
3006
  children: [
2966
3007
  /* @__PURE__ */ jsxRuntime.jsx(
2967
- "button",
3008
+ framerMotion.motion.button,
2968
3009
  {
2969
3010
  type: "button",
2970
3011
  "aria-label": "Expand sidebar",
2971
3012
  title: "Expand sidebar",
2972
3013
  onClick: onExpand,
2973
3014
  className: "payman-sidebar-collapsed-button",
3015
+ whileHover: reduceMotion ? void 0 : { scale: 1.04 },
3016
+ whileTap: reduceMotion ? void 0 : { scale: 0.97 },
3017
+ transition: { type: "spring", stiffness: 620, damping: 32 },
2974
3018
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelLeftOpen, { size: 16 })
2975
3019
  }
2976
3020
  ),
2977
- hoverOpen && /* @__PURE__ */ jsxRuntime.jsxs(
2978
- "div",
3021
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: hoverOpen && /* @__PURE__ */ jsxRuntime.jsxs(
3022
+ framerMotion.motion.div,
2979
3023
  {
2980
3024
  className: "payman-sidebar-popover",
2981
3025
  onMouseEnter: openPopover,
2982
3026
  onMouseLeave: schedulePopoverClose,
3027
+ initial: reduceMotion ? { opacity: 0 } : { opacity: 0, x: -6, scale: 0.98 },
3028
+ animate: reduceMotion ? { opacity: 1 } : { opacity: 1, x: 0, scale: 1 },
3029
+ exit: reduceMotion ? { opacity: 0 } : { opacity: 0, x: -4, scale: 0.99 },
3030
+ transition: reduceMotion ? { duration: 0.08 } : { duration: 0.14, ease: [0.25, 0.46, 0.45, 0.94] },
2983
3031
  style: {
2984
3032
  position: "absolute",
2985
3033
  left: "calc(100% + 6px)",
@@ -2989,17 +3037,24 @@ function CollapsedButton({
2989
3037
  zIndex: 50,
2990
3038
  display: "flex",
2991
3039
  flexDirection: "column",
2992
- overflow: "hidden"
3040
+ overflow: "hidden",
3041
+ transformOrigin: "left center"
2993
3042
  },
2994
3043
  children: [
2995
- /* @__PURE__ */ jsxRuntime.jsx(SidebarHeader, {}),
3044
+ /* @__PURE__ */ jsxRuntime.jsx(
3045
+ SidebarTopBar,
3046
+ {
3047
+ showNewSessionButton,
3048
+ onNewSession,
3049
+ newSessionDisabled
3050
+ }
3051
+ ),
2996
3052
  /* @__PURE__ */ jsxRuntime.jsx(
2997
3053
  SessionList,
2998
3054
  {
2999
3055
  history,
3000
3056
  activeSessionId,
3001
3057
  loadingSessionId,
3002
- streamingSessionIds,
3003
3058
  recentlyCompletedSessionIds,
3004
3059
  onSelectSession: (s) => {
3005
3060
  onSelectSession(s);
@@ -3008,8 +3063,9 @@ function CollapsedButton({
3008
3063
  }
3009
3064
  )
3010
3065
  ]
3011
- }
3012
- )
3066
+ },
3067
+ "payman-sidebar-hover-popover"
3068
+ ) })
3013
3069
  ]
3014
3070
  }
3015
3071
  );
@@ -3021,10 +3077,16 @@ function MobileDrawer({
3021
3077
  history,
3022
3078
  activeSessionId,
3023
3079
  loadingSessionId,
3024
- streamingSessionIds,
3025
3080
  recentlyCompletedSessionIds,
3081
+ showNewSessionButton,
3082
+ onNewSession,
3083
+ newSessionDisabled,
3026
3084
  onSelectSession
3027
3085
  }) {
3086
+ const handleNewSession = onNewSession ? () => {
3087
+ onOpenChange(false);
3088
+ onNewSession();
3089
+ } : void 0;
3028
3090
  if (!open || typeof document === "undefined") return null;
3029
3091
  return reactDom.createPortal(
3030
3092
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -3055,14 +3117,22 @@ function MobileDrawer({
3055
3117
  },
3056
3118
  children: [
3057
3119
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "payman-sidebar-sheet-grabber", "aria-hidden": true }),
3058
- /* @__PURE__ */ jsxRuntime.jsx(SidebarHeader, { onCollapse: () => onOpenChange(false), mobile: true }),
3120
+ /* @__PURE__ */ jsxRuntime.jsx(
3121
+ SidebarTopBar,
3122
+ {
3123
+ onCollapse: () => onOpenChange(false),
3124
+ mobile: true,
3125
+ showNewSessionButton,
3126
+ onNewSession: handleNewSession,
3127
+ newSessionDisabled
3128
+ }
3129
+ ),
3059
3130
  /* @__PURE__ */ jsxRuntime.jsx(
3060
3131
  SessionList,
3061
3132
  {
3062
3133
  history,
3063
3134
  activeSessionId,
3064
3135
  loadingSessionId,
3065
- streamingSessionIds,
3066
3136
  recentlyCompletedSessionIds,
3067
3137
  onSelectSession
3068
3138
  }
@@ -3075,12 +3145,48 @@ function MobileDrawer({
3075
3145
  document.body
3076
3146
  );
3077
3147
  }
3148
+ function SidebarTopBar({
3149
+ onCollapse,
3150
+ mobile = false,
3151
+ showNewSessionButton = false,
3152
+ onNewSession,
3153
+ newSessionDisabled = false
3154
+ }) {
3155
+ const shouldShowNewSession = showNewSessionButton && onNewSession != null;
3156
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3157
+ "div",
3158
+ {
3159
+ className: cn(
3160
+ "payman-sidebar-topbar",
3161
+ shouldShowNewSession && "has-new-session"
3162
+ ),
3163
+ children: [
3164
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarHeader, { onCollapse, mobile }),
3165
+ shouldShowNewSession && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "payman-sidebar-new-session-wrap", children: /* @__PURE__ */ jsxRuntime.jsxs(
3166
+ "button",
3167
+ {
3168
+ type: "button",
3169
+ className: "payman-sidebar-new-session-button",
3170
+ onClick: onNewSession,
3171
+ disabled: newSessionDisabled,
3172
+ "aria-label": "New Session",
3173
+ title: "New Session",
3174
+ children: [
3175
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { size: 13, strokeWidth: 2.4 }),
3176
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "New Session" })
3177
+ ]
3178
+ }
3179
+ ) })
3180
+ ]
3181
+ }
3182
+ );
3183
+ }
3078
3184
  function SidebarHeader({
3079
3185
  onCollapse,
3080
3186
  mobile = false
3081
3187
  }) {
3082
3188
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "payman-sidebar-header", children: [
3083
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Recent sessions" }),
3189
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "payman-sidebar-header-title", children: "Recent sessions" }),
3084
3190
  onCollapse && /* @__PURE__ */ jsxRuntime.jsx(
3085
3191
  "button",
3086
3192
  {
@@ -3088,7 +3194,8 @@ function SidebarHeader({
3088
3194
  "aria-label": mobile ? "Close recent sessions" : "Collapse sidebar",
3089
3195
  title: mobile ? "Close recent sessions" : "Collapse sidebar",
3090
3196
  onClick: onCollapse,
3091
- children: mobile ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 16 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelLeftClose, { size: 14 })
3197
+ className: "payman-sidebar-header-icon-button",
3198
+ children: mobile ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 15 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelLeftClose, { size: 13 })
3092
3199
  }
3093
3200
  )
3094
3201
  ] });
@@ -3097,7 +3204,6 @@ function SessionList({
3097
3204
  history,
3098
3205
  activeSessionId,
3099
3206
  loadingSessionId,
3100
- streamingSessionIds,
3101
3207
  recentlyCompletedSessionIds,
3102
3208
  onSelectSession
3103
3209
  }) {
@@ -3134,7 +3240,6 @@ function SessionList({
3134
3240
  session: s,
3135
3241
  isActive: s.sessionId === activeSessionId,
3136
3242
  isLoading: s.sessionId === loadingSessionId,
3137
- isStreaming: streamingSessionIds?.has(s.sessionId) ?? false,
3138
3243
  isRecentlyCompleted: recentlyCompletedSessionIds?.has(s.sessionId) ?? false,
3139
3244
  onSelect: onSelectSession
3140
3245
  },
@@ -3167,26 +3272,12 @@ function SessionRow({
3167
3272
  session,
3168
3273
  isActive,
3169
3274
  isLoading,
3170
- isStreaming,
3171
3275
  isRecentlyCompleted,
3172
3276
  onSelect
3173
3277
  }) {
3174
3278
  let statusNode = null;
3175
3279
  let statusLabel;
3176
- if (isStreaming) {
3177
- statusNode = /* @__PURE__ */ jsxRuntime.jsxs(
3178
- "span",
3179
- {
3180
- className: "payman-sidebar-row-status payman-sidebar-row-status-live",
3181
- "aria-hidden": true,
3182
- children: [
3183
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "payman-sidebar-row-live-dot" }),
3184
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "payman-sidebar-row-live-track" })
3185
- ]
3186
- }
3187
- );
3188
- statusLabel = "Running";
3189
- } else if (isRecentlyCompleted) {
3280
+ if (isRecentlyCompleted) {
3190
3281
  statusNode = /* @__PURE__ */ jsxRuntime.jsx(
3191
3282
  "span",
3192
3283
  {
@@ -3207,7 +3298,7 @@ function SessionRow({
3207
3298
  onClick: () => onSelect(session),
3208
3299
  className: cn("payman-sidebar-row", isActive && "is-active"),
3209
3300
  title: statusLabel ? `${session.sessionTitle || "Untitled session"} \u2014 ${statusLabel}` : session.sessionTitle,
3210
- "aria-busy": isLoading || isStreaming || void 0,
3301
+ "aria-busy": isLoading || void 0,
3211
3302
  children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "payman-sidebar-row-main", children: [
3212
3303
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "payman-sidebar-row-title", children: session.sessionTitle || "Untitled session" }),
3213
3304
  statusNode
@@ -3296,10 +3387,17 @@ function groupSessionsByDate(sessions, now) {
3296
3387
  }
3297
3388
  return orderedGroups;
3298
3389
  }
3390
+ function titleCaseDateHeading(label) {
3391
+ return label.replace(/[\p{L}\p{M}]+/gu, (word) => {
3392
+ const lower = word.toLocaleLowerCase(void 0);
3393
+ const first = lower.charAt(0).toLocaleUpperCase(void 0);
3394
+ return first + lower.slice(1);
3395
+ });
3396
+ }
3299
3397
  function getSessionDateBucket(iso, now) {
3300
3398
  const date = new Date(iso);
3301
3399
  if (Number.isNaN(date.getTime())) {
3302
- return { key: "older", label: "Older" };
3400
+ return { key: "older", label: titleCaseDateHeading("Older") };
3303
3401
  }
3304
3402
  const dayKey = [
3305
3403
  date.getFullYear(),
@@ -3311,22 +3409,26 @@ function getSessionDateBucket(iso, now) {
3311
3409
  const dayDiff = Math.round(
3312
3410
  (today.getTime() - sessionDay.getTime()) / 864e5
3313
3411
  );
3314
- if (dayDiff <= 0) return { key: dayKey, label: "Today" };
3315
- if (dayDiff === 1) return { key: dayKey, label: "Yesterday" };
3412
+ if (dayDiff <= 0) return { key: dayKey, label: titleCaseDateHeading("Today") };
3413
+ if (dayDiff === 1) return { key: dayKey, label: titleCaseDateHeading("Yesterday") };
3316
3414
  if (dayDiff < 7) {
3317
3415
  return {
3318
3416
  key: dayKey,
3319
- label: date.toLocaleDateString(void 0, { weekday: "long" })
3417
+ label: titleCaseDateHeading(
3418
+ date.toLocaleDateString(void 0, { weekday: "long" })
3419
+ )
3320
3420
  };
3321
3421
  }
3322
3422
  const sameYear = date.getFullYear() === now.getFullYear();
3323
3423
  return {
3324
3424
  key: dayKey,
3325
- label: date.toLocaleDateString(void 0, {
3326
- month: "short",
3327
- day: "numeric",
3328
- year: sameYear ? void 0 : "numeric"
3329
- })
3425
+ label: titleCaseDateHeading(
3426
+ date.toLocaleDateString(void 0, {
3427
+ month: "long",
3428
+ day: "numeric",
3429
+ year: sameYear ? void 0 : "numeric"
3430
+ })
3431
+ )
3330
3432
  };
3331
3433
  }
3332
3434
  var DEFAULT_PLACEHOLDER = "Type your message...";
@@ -3460,19 +3562,12 @@ var PaymanChat = react.forwardRef(function PaymanChat2({
3460
3562
  const [isResetSessionConfirmOpen, setIsResetSessionConfirmOpen] = react.useState(false);
3461
3563
  const [mobileSidebarOpen, setMobileSidebarOpen] = react.useState(false);
3462
3564
  const [optimisticSessionActivity, setOptimisticSessionActivity] = react.useState(null);
3463
- const [streamingSessionIds, setStreamingSessionIds] = react.useState(() => /* @__PURE__ */ new Set());
3464
3565
  const [recentlyCompletedSessionIds, setRecentlyCompletedSessionIds] = react.useState(() => /* @__PURE__ */ new Set());
3465
3566
  const recentlyCompletedTimersRef = react.useRef(
3466
3567
  /* @__PURE__ */ new Map()
3467
3568
  );
3468
3569
  const RECENTLY_COMPLETED_DURATION_MS = 4e3;
3469
- const markSessionStreaming = react.useCallback((sessionId) => {
3470
- setStreamingSessionIds((prev) => {
3471
- if (prev.has(sessionId)) return prev;
3472
- const next = new Set(prev);
3473
- next.add(sessionId);
3474
- return next;
3475
- });
3570
+ const clearRecentlyCompletedForSession = react.useCallback((sessionId) => {
3476
3571
  setRecentlyCompletedSessionIds((prev) => {
3477
3572
  if (!prev.has(sessionId)) return prev;
3478
3573
  const next = new Set(prev);
@@ -3486,12 +3581,6 @@ var PaymanChat = react.forwardRef(function PaymanChat2({
3486
3581
  }
3487
3582
  }, []);
3488
3583
  const markSessionCompleted = react.useCallback((sessionId) => {
3489
- setStreamingSessionIds((prev) => {
3490
- if (!prev.has(sessionId)) return prev;
3491
- const next = new Set(prev);
3492
- next.delete(sessionId);
3493
- return next;
3494
- });
3495
3584
  setRecentlyCompletedSessionIds((prev) => {
3496
3585
  const next = new Set(prev);
3497
3586
  next.add(sessionId);
@@ -3540,7 +3629,7 @@ var PaymanChat = react.forwardRef(function PaymanChat2({
3540
3629
  const sessionId = latestSessionIdRef.current;
3541
3630
  if (!sessionId) return;
3542
3631
  lastOptimisticSessionIdRef.current = sessionId;
3543
- markSessionStreaming(sessionId);
3632
+ clearRecentlyCompletedForSession(sessionId);
3544
3633
  setOptimisticSessionActivity({
3545
3634
  key: `message:${sessionId}:${Date.now()}`,
3546
3635
  sessionId,
@@ -3552,15 +3641,6 @@ var PaymanChat = react.forwardRef(function PaymanChat2({
3552
3641
  const previousSessionId = latestSessionIdRef.current;
3553
3642
  latestSessionIdRef.current = sessionId;
3554
3643
  sentryCallbacks.onSessionIdChange?.(sessionId);
3555
- if (previousSessionId && previousSessionId !== sessionId) {
3556
- setStreamingSessionIds((prev) => {
3557
- if (!prev.has(previousSessionId)) return prev;
3558
- const next = new Set(prev);
3559
- next.delete(previousSessionId);
3560
- next.add(sessionId);
3561
- return next;
3562
- });
3563
- }
3564
3644
  if (previousSessionId && previousSessionId !== sessionId && lastOptimisticSessionIdRef.current === previousSessionId) {
3565
3645
  lastOptimisticSessionIdRef.current = sessionId;
3566
3646
  setOptimisticSessionActivity(
@@ -3587,20 +3667,12 @@ var PaymanChat = react.forwardRef(function PaymanChat2({
3587
3667
  },
3588
3668
  onError: (error) => {
3589
3669
  sentryCallbacks.onError?.(error);
3590
- const sessionId = latestSessionIdRef.current;
3591
- if (!sessionId) return;
3592
- setStreamingSessionIds((prev) => {
3593
- if (!prev.has(sessionId)) return prev;
3594
- const next = new Set(prev);
3595
- next.delete(sessionId);
3596
- return next;
3597
- });
3598
3670
  }
3599
3671
  }),
3600
3672
  [
3601
3673
  buildOptimisticSessionTitle,
3674
+ clearRecentlyCompletedForSession,
3602
3675
  markSessionCompleted,
3603
- markSessionStreaming,
3604
3676
  sentryCallbacks
3605
3677
  ]
3606
3678
  );
@@ -3894,10 +3966,11 @@ var PaymanChat = react.forwardRef(function PaymanChat2({
3894
3966
  options: sessionHistory.options,
3895
3967
  activeSessionId: currentSessionId,
3896
3968
  loadingSessionId,
3897
- streamingSessionIds,
3898
3969
  recentlyCompletedSessionIds,
3899
3970
  optimisticActivity: optimisticSessionActivity,
3900
3971
  onSelectSession: handleSelectSession,
3972
+ onNewSession: requestResetSession,
3973
+ newSessionDisabled: isWaitingForResponse || isRecording,
3901
3974
  mobileOpen: mobileSidebarOpen,
3902
3975
  onMobileOpenChange: setMobileSidebarOpen
3903
3976
  }
@@ -3914,7 +3987,7 @@ var PaymanChat = react.forwardRef(function PaymanChat2({
3914
3987
  },
3915
3988
  children: [
3916
3989
  sidebarElement,
3917
- /* @__PURE__ */ jsxRuntime.jsxs(
3990
+ /* @__PURE__ */ jsxRuntime.jsx(
3918
3991
  "div",
3919
3992
  {
3920
3993
  style: {
@@ -3924,32 +3997,48 @@ var PaymanChat = react.forwardRef(function PaymanChat2({
3924
3997
  display: "flex",
3925
3998
  flexDirection: "column",
3926
3999
  overflow: "hidden",
3927
- alignItems: showEmptyShell ? "center" : "stretch",
3928
- justifyContent: showEmptyShell ? "center" : "flex-start"
4000
+ alignItems: "stretch",
4001
+ justifyContent: "flex-start"
3929
4002
  },
3930
- children: [
3931
- showEmptyShell ? /* @__PURE__ */ jsxRuntime.jsx(
3932
- "div",
3933
- {
3934
- style: {
3935
- display: "flex",
3936
- flexDirection: "column",
3937
- alignItems: "center",
3938
- justifyContent: "center",
3939
- width: "100%",
3940
- minHeight: 0,
3941
- marginTop: "1.5rem"
3942
- },
3943
- children: /* @__PURE__ */ jsxRuntime.jsx(
4003
+ children: showEmptyShell ? /* @__PURE__ */ jsxRuntime.jsxs(
4004
+ "div",
4005
+ {
4006
+ style: {
4007
+ flex: "1 1 0%",
4008
+ display: "flex",
4009
+ flexDirection: "column",
4010
+ alignItems: "center",
4011
+ justifyContent: "center",
4012
+ width: "100%",
4013
+ minHeight: 0,
4014
+ gap: "1.25rem",
4015
+ padding: "0 1rem 1rem",
4016
+ boxSizing: "border-box"
4017
+ },
4018
+ children: [
4019
+ /* @__PURE__ */ jsxRuntime.jsx(
3944
4020
  EmptyState2,
3945
4021
  {
3946
4022
  text: emptyStateText,
3947
4023
  content: emptyStateComponent,
3948
4024
  showIcon: showEmptyStateIcon
3949
4025
  }
4026
+ ),
4027
+ /* @__PURE__ */ jsxRuntime.jsx(
4028
+ "div",
4029
+ {
4030
+ style: {
4031
+ width: "100%",
4032
+ maxWidth: "var(--payman-v2-max-content-width, 42rem)",
4033
+ flexShrink: 0
4034
+ },
4035
+ children: inputElement
4036
+ }
3950
4037
  )
3951
- }
3952
- ) : /* @__PURE__ */ jsxRuntime.jsx(
4038
+ ]
4039
+ }
4040
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4041
+ /* @__PURE__ */ jsxRuntime.jsx(
3953
4042
  MessageListV2,
3954
4043
  {
3955
4044
  ref: messageListV2Ref,
@@ -3996,7 +4085,7 @@ var PaymanChat = react.forwardRef(function PaymanChat2({
3996
4085
  children: inputElement
3997
4086
  }
3998
4087
  )
3999
- ]
4088
+ ] })
4000
4089
  }
4001
4090
  )
4002
4091
  ]
@@ -4052,10 +4141,9 @@ function EmptyState2({
4052
4141
  alignItems: "center",
4053
4142
  justifyContent: "center",
4054
4143
  textAlign: "center",
4055
- padding: "24px 16px",
4144
+ padding: "8px 8px 0",
4056
4145
  gap: 12,
4057
- flex: 1,
4058
- minHeight: 0
4146
+ flex: "0 0 auto"
4059
4147
  },
4060
4148
  children: [
4061
4149
  content,