@paymanai/payman-ask-sdk 2.0.3 → 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/README.md +6 -3
- package/dist/index.d.mts +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +210 -122
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +212 -124
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +163 -65
- package/dist/index.native.js.map +1 -1
- package/dist/styles.css +137 -126
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,9 +4,9 @@ import { createContext, forwardRef, useRef, useState, useCallback, useImperative
|
|
|
4
4
|
import { clsx } from 'clsx';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
6
6
|
import * as Sentry from '@sentry/react';
|
|
7
|
-
import { AnimatePresence, motion } from 'framer-motion';
|
|
7
|
+
import { AnimatePresence, motion, useReducedMotion } from 'framer-motion';
|
|
8
8
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
9
|
-
import { ArrowDown, Pencil, X, RotateCcw, Plus, ImagePlus, Paperclip, Mic, ArrowUp, Check, AlertCircle, Copy, WifiOff, SearchCode, ShieldCheck, PanelBottomOpen, Download, Loader2, ChevronRight,
|
|
9
|
+
import { ArrowDown, Pencil, X, RotateCcw, Plus, ImagePlus, Paperclip, Mic, ArrowUp, Check, AlertCircle, Copy, WifiOff, SearchCode, ShieldCheck, PanelBottomOpen, Download, Loader2, ChevronRight, PanelLeftOpen, ImageOff, Eye, PanelLeftClose, MessageSquare, Menu, MessageCircle, ChevronDown } from 'lucide-react';
|
|
10
10
|
import { createPortal } from 'react-dom';
|
|
11
11
|
import ReactMarkdown from 'react-markdown';
|
|
12
12
|
import remarkGfm from 'remark-gfm';
|
|
@@ -346,6 +346,7 @@ function UserMessageV2({
|
|
|
346
346
|
"payman-v2-toast-inner",
|
|
347
347
|
toast.tone === "success" ? "payman-v2-toast-success" : "payman-v2-toast-error"
|
|
348
348
|
),
|
|
349
|
+
style: { borderRadius: 9999 },
|
|
349
350
|
children: [
|
|
350
351
|
toast.tone === "success" ? /* @__PURE__ */ jsx(Check, { className: "h-4 w-4", style: { color: "#059669" } }) : /* @__PURE__ */ jsx(
|
|
351
352
|
AlertCircle,
|
|
@@ -1403,6 +1404,7 @@ function AssistantMessageV2({
|
|
|
1403
1404
|
"payman-v2-toast-inner",
|
|
1404
1405
|
toast.tone === "success" ? "payman-v2-toast-success" : "payman-v2-toast-error"
|
|
1405
1406
|
),
|
|
1407
|
+
style: { borderRadius: 9999 },
|
|
1406
1408
|
children: [
|
|
1407
1409
|
toast.tone === "success" ? /* @__PURE__ */ jsx(
|
|
1408
1410
|
Check,
|
|
@@ -2081,6 +2083,7 @@ var ChatInputV2 = forwardRef(
|
|
|
2081
2083
|
if (textareaRef.current) {
|
|
2082
2084
|
textareaRef.current.style.height = "auto";
|
|
2083
2085
|
textareaRef.current.focus();
|
|
2086
|
+
textareaRef.current.scrollIntoView({ block: "nearest", behavior: "smooth" });
|
|
2084
2087
|
}
|
|
2085
2088
|
});
|
|
2086
2089
|
}, [value, disabled, onClearEditing, onSend]);
|
|
@@ -2168,6 +2171,7 @@ var ChatInputV2 = forwardRef(
|
|
|
2168
2171
|
"textarea",
|
|
2169
2172
|
{
|
|
2170
2173
|
ref: textareaRef,
|
|
2174
|
+
autoFocus: true,
|
|
2171
2175
|
value,
|
|
2172
2176
|
onChange: (e) => {
|
|
2173
2177
|
if (isRecording) return;
|
|
@@ -2494,9 +2498,9 @@ function ImageLightboxV2({ src, alt, onClose }) {
|
|
|
2494
2498
|
document.body
|
|
2495
2499
|
);
|
|
2496
2500
|
}
|
|
2497
|
-
var DEFAULT_WIDTH =
|
|
2498
|
-
var DEFAULT_MIN_WIDTH =
|
|
2499
|
-
var DEFAULT_MAX_WIDTH =
|
|
2501
|
+
var DEFAULT_WIDTH = 260;
|
|
2502
|
+
var DEFAULT_MIN_WIDTH = 220;
|
|
2503
|
+
var DEFAULT_MAX_WIDTH = 440;
|
|
2500
2504
|
var DEFAULT_PAGE_SIZE = 20;
|
|
2501
2505
|
function getPersistKey(config, opts) {
|
|
2502
2506
|
if (opts.persistKey) return opts.persistKey;
|
|
@@ -2715,10 +2719,11 @@ function SessionHistorySidebar({
|
|
|
2715
2719
|
options,
|
|
2716
2720
|
activeSessionId,
|
|
2717
2721
|
loadingSessionId,
|
|
2718
|
-
streamingSessionIds,
|
|
2719
2722
|
recentlyCompletedSessionIds,
|
|
2720
2723
|
optimisticActivity,
|
|
2721
2724
|
onSelectSession,
|
|
2725
|
+
onNewSession,
|
|
2726
|
+
newSessionDisabled = false,
|
|
2722
2727
|
mobileOpen,
|
|
2723
2728
|
onMobileOpenChange
|
|
2724
2729
|
}) {
|
|
@@ -2726,6 +2731,7 @@ function SessionHistorySidebar({
|
|
|
2726
2731
|
const mobileThemeSourceRef = useRef(null);
|
|
2727
2732
|
const [mobilePortalThemeStyle, setMobilePortalThemeStyle] = useState({});
|
|
2728
2733
|
const history = useSessionHistory(config, options, optimisticActivity);
|
|
2734
|
+
const showNewSessionButton = options.showNewSessionButton === true;
|
|
2729
2735
|
useEffect(() => {
|
|
2730
2736
|
if (!isMobile) return;
|
|
2731
2737
|
setMobilePortalThemeStyle(readPortalThemeStyle(mobileThemeSourceRef.current));
|
|
@@ -2752,8 +2758,10 @@ function SessionHistorySidebar({
|
|
|
2752
2758
|
history,
|
|
2753
2759
|
activeSessionId,
|
|
2754
2760
|
loadingSessionId,
|
|
2755
|
-
streamingSessionIds,
|
|
2756
2761
|
recentlyCompletedSessionIds,
|
|
2762
|
+
showNewSessionButton,
|
|
2763
|
+
onNewSession,
|
|
2764
|
+
newSessionDisabled,
|
|
2757
2765
|
onSelectSession: (s) => {
|
|
2758
2766
|
onSelectSession(s);
|
|
2759
2767
|
onMobileOpenChange(false);
|
|
@@ -2768,8 +2776,10 @@ function SessionHistorySidebar({
|
|
|
2768
2776
|
history,
|
|
2769
2777
|
activeSessionId,
|
|
2770
2778
|
loadingSessionId,
|
|
2771
|
-
streamingSessionIds,
|
|
2772
2779
|
recentlyCompletedSessionIds,
|
|
2780
|
+
showNewSessionButton,
|
|
2781
|
+
onNewSession,
|
|
2782
|
+
newSessionDisabled,
|
|
2773
2783
|
onSelectSession
|
|
2774
2784
|
}
|
|
2775
2785
|
);
|
|
@@ -2778,11 +2788,14 @@ function DesktopSidebar({
|
|
|
2778
2788
|
history,
|
|
2779
2789
|
activeSessionId,
|
|
2780
2790
|
loadingSessionId,
|
|
2781
|
-
streamingSessionIds,
|
|
2782
2791
|
recentlyCompletedSessionIds,
|
|
2792
|
+
showNewSessionButton,
|
|
2793
|
+
onNewSession,
|
|
2794
|
+
newSessionDisabled,
|
|
2783
2795
|
onSelectSession
|
|
2784
2796
|
}) {
|
|
2785
2797
|
const { width, setWidth, collapsed, setCollapsed, minWidth, maxWidth } = history;
|
|
2798
|
+
const reduceMotion = useReducedMotion();
|
|
2786
2799
|
const dragStateRef = useRef(null);
|
|
2787
2800
|
const [isDragging, setIsDragging] = useState(false);
|
|
2788
2801
|
const [handleHover, setHandleHover] = useState(false);
|
|
@@ -2814,25 +2827,42 @@ function DesktopSidebar({
|
|
|
2814
2827
|
window.removeEventListener("pointercancel", onEnd);
|
|
2815
2828
|
};
|
|
2816
2829
|
}, [isDragging, setWidth]);
|
|
2830
|
+
const handleActive = handleHover || isDragging;
|
|
2831
|
+
const sidebarEnter = reduceMotion ? { duration: 0.1, ease: "easeOut" } : { duration: 0.16, ease: [0.25, 0.46, 0.45, 0.94] };
|
|
2817
2832
|
if (collapsed) {
|
|
2818
2833
|
return /* @__PURE__ */ jsx(
|
|
2819
|
-
|
|
2834
|
+
motion.div,
|
|
2820
2835
|
{
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2836
|
+
className: "payman-sidebar-collapsed-mount",
|
|
2837
|
+
initial: reduceMotion ? false : { opacity: 0, scale: 0.96 },
|
|
2838
|
+
animate: { opacity: 1, scale: 1 },
|
|
2839
|
+
transition: sidebarEnter,
|
|
2840
|
+
style: { alignSelf: "flex-start" },
|
|
2841
|
+
children: /* @__PURE__ */ jsx(
|
|
2842
|
+
CollapsedButton,
|
|
2843
|
+
{
|
|
2844
|
+
onExpand: () => setCollapsed(false),
|
|
2845
|
+
history,
|
|
2846
|
+
activeSessionId,
|
|
2847
|
+
loadingSessionId,
|
|
2848
|
+
recentlyCompletedSessionIds,
|
|
2849
|
+
showNewSessionButton,
|
|
2850
|
+
onNewSession,
|
|
2851
|
+
newSessionDisabled,
|
|
2852
|
+
onSelectSession
|
|
2853
|
+
}
|
|
2854
|
+
)
|
|
2855
|
+
},
|
|
2856
|
+
"payman-sidebar-desktop-collapsed"
|
|
2829
2857
|
);
|
|
2830
2858
|
}
|
|
2831
|
-
const handleActive = handleHover || isDragging;
|
|
2832
2859
|
return /* @__PURE__ */ jsxs(
|
|
2833
|
-
|
|
2860
|
+
motion.aside,
|
|
2834
2861
|
{
|
|
2835
2862
|
className: "payman-sidebar payman-sidebar-desktop",
|
|
2863
|
+
initial: reduceMotion ? false : { opacity: 0 },
|
|
2864
|
+
animate: { opacity: 1 },
|
|
2865
|
+
transition: sidebarEnter,
|
|
2836
2866
|
style: {
|
|
2837
2867
|
width,
|
|
2838
2868
|
minWidth,
|
|
@@ -2843,17 +2873,24 @@ function DesktopSidebar({
|
|
|
2843
2873
|
display: "flex",
|
|
2844
2874
|
flexDirection: "column",
|
|
2845
2875
|
overflow: "hidden",
|
|
2846
|
-
transition: isDragging ? "none" : "width
|
|
2876
|
+
transition: isDragging ? "none" : "width 100ms ease"
|
|
2847
2877
|
},
|
|
2848
2878
|
children: [
|
|
2849
|
-
/* @__PURE__ */ jsx(
|
|
2879
|
+
/* @__PURE__ */ jsx(
|
|
2880
|
+
SidebarTopBar,
|
|
2881
|
+
{
|
|
2882
|
+
onCollapse: () => setCollapsed(true),
|
|
2883
|
+
showNewSessionButton,
|
|
2884
|
+
onNewSession,
|
|
2885
|
+
newSessionDisabled
|
|
2886
|
+
}
|
|
2887
|
+
),
|
|
2850
2888
|
/* @__PURE__ */ jsx(
|
|
2851
2889
|
SessionList,
|
|
2852
2890
|
{
|
|
2853
2891
|
history,
|
|
2854
2892
|
activeSessionId,
|
|
2855
2893
|
loadingSessionId,
|
|
2856
|
-
streamingSessionIds,
|
|
2857
2894
|
recentlyCompletedSessionIds,
|
|
2858
2895
|
onSelectSession
|
|
2859
2896
|
}
|
|
@@ -2891,26 +2928,30 @@ function DesktopSidebar({
|
|
|
2891
2928
|
borderRadius: 999,
|
|
2892
2929
|
background: handleActive ? "var(--payman-v2-text-3)" : "transparent",
|
|
2893
2930
|
opacity: handleActive ? 1 : 0,
|
|
2894
|
-
transition: "opacity
|
|
2931
|
+
transition: "opacity 100ms ease, background 100ms ease"
|
|
2895
2932
|
}
|
|
2896
2933
|
}
|
|
2897
2934
|
)
|
|
2898
2935
|
}
|
|
2899
2936
|
)
|
|
2900
2937
|
]
|
|
2901
|
-
}
|
|
2938
|
+
},
|
|
2939
|
+
"payman-sidebar-desktop-expanded"
|
|
2902
2940
|
);
|
|
2903
2941
|
}
|
|
2904
|
-
var POPOVER_LEAVE_DELAY_MS =
|
|
2942
|
+
var POPOVER_LEAVE_DELAY_MS = 220;
|
|
2905
2943
|
function CollapsedButton({
|
|
2906
2944
|
onExpand,
|
|
2907
2945
|
history,
|
|
2908
2946
|
activeSessionId,
|
|
2909
2947
|
loadingSessionId,
|
|
2910
|
-
streamingSessionIds,
|
|
2911
2948
|
recentlyCompletedSessionIds,
|
|
2949
|
+
showNewSessionButton,
|
|
2950
|
+
onNewSession,
|
|
2951
|
+
newSessionDisabled,
|
|
2912
2952
|
onSelectSession
|
|
2913
2953
|
}) {
|
|
2954
|
+
const reduceMotion = useReducedMotion();
|
|
2914
2955
|
const [hoverOpen, setHoverOpen] = useState(false);
|
|
2915
2956
|
const leaveTimerRef = useRef(null);
|
|
2916
2957
|
const openPopover = () => {
|
|
@@ -2939,22 +2980,29 @@ function CollapsedButton({
|
|
|
2939
2980
|
style: { position: "relative", alignSelf: "flex-start" },
|
|
2940
2981
|
children: [
|
|
2941
2982
|
/* @__PURE__ */ jsx(
|
|
2942
|
-
|
|
2983
|
+
motion.button,
|
|
2943
2984
|
{
|
|
2944
2985
|
type: "button",
|
|
2945
2986
|
"aria-label": "Expand sidebar",
|
|
2946
2987
|
title: "Expand sidebar",
|
|
2947
2988
|
onClick: onExpand,
|
|
2948
2989
|
className: "payman-sidebar-collapsed-button",
|
|
2990
|
+
whileHover: reduceMotion ? void 0 : { scale: 1.04 },
|
|
2991
|
+
whileTap: reduceMotion ? void 0 : { scale: 0.97 },
|
|
2992
|
+
transition: { type: "spring", stiffness: 620, damping: 32 },
|
|
2949
2993
|
children: /* @__PURE__ */ jsx(PanelLeftOpen, { size: 16 })
|
|
2950
2994
|
}
|
|
2951
2995
|
),
|
|
2952
|
-
hoverOpen && /* @__PURE__ */ jsxs(
|
|
2953
|
-
|
|
2996
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: hoverOpen && /* @__PURE__ */ jsxs(
|
|
2997
|
+
motion.div,
|
|
2954
2998
|
{
|
|
2955
2999
|
className: "payman-sidebar-popover",
|
|
2956
3000
|
onMouseEnter: openPopover,
|
|
2957
3001
|
onMouseLeave: schedulePopoverClose,
|
|
3002
|
+
initial: reduceMotion ? { opacity: 0 } : { opacity: 0, x: -6, scale: 0.98 },
|
|
3003
|
+
animate: reduceMotion ? { opacity: 1 } : { opacity: 1, x: 0, scale: 1 },
|
|
3004
|
+
exit: reduceMotion ? { opacity: 0 } : { opacity: 0, x: -4, scale: 0.99 },
|
|
3005
|
+
transition: reduceMotion ? { duration: 0.08 } : { duration: 0.14, ease: [0.25, 0.46, 0.45, 0.94] },
|
|
2958
3006
|
style: {
|
|
2959
3007
|
position: "absolute",
|
|
2960
3008
|
left: "calc(100% + 6px)",
|
|
@@ -2964,17 +3012,24 @@ function CollapsedButton({
|
|
|
2964
3012
|
zIndex: 50,
|
|
2965
3013
|
display: "flex",
|
|
2966
3014
|
flexDirection: "column",
|
|
2967
|
-
overflow: "hidden"
|
|
3015
|
+
overflow: "hidden",
|
|
3016
|
+
transformOrigin: "left center"
|
|
2968
3017
|
},
|
|
2969
3018
|
children: [
|
|
2970
|
-
/* @__PURE__ */ jsx(
|
|
3019
|
+
/* @__PURE__ */ jsx(
|
|
3020
|
+
SidebarTopBar,
|
|
3021
|
+
{
|
|
3022
|
+
showNewSessionButton,
|
|
3023
|
+
onNewSession,
|
|
3024
|
+
newSessionDisabled
|
|
3025
|
+
}
|
|
3026
|
+
),
|
|
2971
3027
|
/* @__PURE__ */ jsx(
|
|
2972
3028
|
SessionList,
|
|
2973
3029
|
{
|
|
2974
3030
|
history,
|
|
2975
3031
|
activeSessionId,
|
|
2976
3032
|
loadingSessionId,
|
|
2977
|
-
streamingSessionIds,
|
|
2978
3033
|
recentlyCompletedSessionIds,
|
|
2979
3034
|
onSelectSession: (s) => {
|
|
2980
3035
|
onSelectSession(s);
|
|
@@ -2983,8 +3038,9 @@ function CollapsedButton({
|
|
|
2983
3038
|
}
|
|
2984
3039
|
)
|
|
2985
3040
|
]
|
|
2986
|
-
}
|
|
2987
|
-
|
|
3041
|
+
},
|
|
3042
|
+
"payman-sidebar-hover-popover"
|
|
3043
|
+
) })
|
|
2988
3044
|
]
|
|
2989
3045
|
}
|
|
2990
3046
|
);
|
|
@@ -2996,10 +3052,16 @@ function MobileDrawer({
|
|
|
2996
3052
|
history,
|
|
2997
3053
|
activeSessionId,
|
|
2998
3054
|
loadingSessionId,
|
|
2999
|
-
streamingSessionIds,
|
|
3000
3055
|
recentlyCompletedSessionIds,
|
|
3056
|
+
showNewSessionButton,
|
|
3057
|
+
onNewSession,
|
|
3058
|
+
newSessionDisabled,
|
|
3001
3059
|
onSelectSession
|
|
3002
3060
|
}) {
|
|
3061
|
+
const handleNewSession = onNewSession ? () => {
|
|
3062
|
+
onOpenChange(false);
|
|
3063
|
+
onNewSession();
|
|
3064
|
+
} : void 0;
|
|
3003
3065
|
if (!open || typeof document === "undefined") return null;
|
|
3004
3066
|
return createPortal(
|
|
3005
3067
|
/* @__PURE__ */ jsx(
|
|
@@ -3030,14 +3092,22 @@ function MobileDrawer({
|
|
|
3030
3092
|
},
|
|
3031
3093
|
children: [
|
|
3032
3094
|
/* @__PURE__ */ jsx("div", { className: "payman-sidebar-sheet-grabber", "aria-hidden": true }),
|
|
3033
|
-
/* @__PURE__ */ jsx(
|
|
3095
|
+
/* @__PURE__ */ jsx(
|
|
3096
|
+
SidebarTopBar,
|
|
3097
|
+
{
|
|
3098
|
+
onCollapse: () => onOpenChange(false),
|
|
3099
|
+
mobile: true,
|
|
3100
|
+
showNewSessionButton,
|
|
3101
|
+
onNewSession: handleNewSession,
|
|
3102
|
+
newSessionDisabled
|
|
3103
|
+
}
|
|
3104
|
+
),
|
|
3034
3105
|
/* @__PURE__ */ jsx(
|
|
3035
3106
|
SessionList,
|
|
3036
3107
|
{
|
|
3037
3108
|
history,
|
|
3038
3109
|
activeSessionId,
|
|
3039
3110
|
loadingSessionId,
|
|
3040
|
-
streamingSessionIds,
|
|
3041
3111
|
recentlyCompletedSessionIds,
|
|
3042
3112
|
onSelectSession
|
|
3043
3113
|
}
|
|
@@ -3050,12 +3120,48 @@ function MobileDrawer({
|
|
|
3050
3120
|
document.body
|
|
3051
3121
|
);
|
|
3052
3122
|
}
|
|
3123
|
+
function SidebarTopBar({
|
|
3124
|
+
onCollapse,
|
|
3125
|
+
mobile = false,
|
|
3126
|
+
showNewSessionButton = false,
|
|
3127
|
+
onNewSession,
|
|
3128
|
+
newSessionDisabled = false
|
|
3129
|
+
}) {
|
|
3130
|
+
const shouldShowNewSession = showNewSessionButton && onNewSession != null;
|
|
3131
|
+
return /* @__PURE__ */ jsxs(
|
|
3132
|
+
"div",
|
|
3133
|
+
{
|
|
3134
|
+
className: cn(
|
|
3135
|
+
"payman-sidebar-topbar",
|
|
3136
|
+
shouldShowNewSession && "has-new-session"
|
|
3137
|
+
),
|
|
3138
|
+
children: [
|
|
3139
|
+
/* @__PURE__ */ jsx(SidebarHeader, { onCollapse, mobile }),
|
|
3140
|
+
shouldShowNewSession && /* @__PURE__ */ jsx("div", { className: "payman-sidebar-new-session-wrap", children: /* @__PURE__ */ jsxs(
|
|
3141
|
+
"button",
|
|
3142
|
+
{
|
|
3143
|
+
type: "button",
|
|
3144
|
+
className: "payman-sidebar-new-session-button",
|
|
3145
|
+
onClick: onNewSession,
|
|
3146
|
+
disabled: newSessionDisabled,
|
|
3147
|
+
"aria-label": "New Session",
|
|
3148
|
+
title: "New Session",
|
|
3149
|
+
children: [
|
|
3150
|
+
/* @__PURE__ */ jsx(Plus, { size: 13, strokeWidth: 2.4 }),
|
|
3151
|
+
/* @__PURE__ */ jsx("span", { children: "New Session" })
|
|
3152
|
+
]
|
|
3153
|
+
}
|
|
3154
|
+
) })
|
|
3155
|
+
]
|
|
3156
|
+
}
|
|
3157
|
+
);
|
|
3158
|
+
}
|
|
3053
3159
|
function SidebarHeader({
|
|
3054
3160
|
onCollapse,
|
|
3055
3161
|
mobile = false
|
|
3056
3162
|
}) {
|
|
3057
3163
|
return /* @__PURE__ */ jsxs("div", { className: "payman-sidebar-header", children: [
|
|
3058
|
-
/* @__PURE__ */ jsx("span", { children: "Recent sessions" }),
|
|
3164
|
+
/* @__PURE__ */ jsx("span", { className: "payman-sidebar-header-title", children: "Recent sessions" }),
|
|
3059
3165
|
onCollapse && /* @__PURE__ */ jsx(
|
|
3060
3166
|
"button",
|
|
3061
3167
|
{
|
|
@@ -3063,7 +3169,8 @@ function SidebarHeader({
|
|
|
3063
3169
|
"aria-label": mobile ? "Close recent sessions" : "Collapse sidebar",
|
|
3064
3170
|
title: mobile ? "Close recent sessions" : "Collapse sidebar",
|
|
3065
3171
|
onClick: onCollapse,
|
|
3066
|
-
|
|
3172
|
+
className: "payman-sidebar-header-icon-button",
|
|
3173
|
+
children: mobile ? /* @__PURE__ */ jsx(X, { size: 15 }) : /* @__PURE__ */ jsx(PanelLeftClose, { size: 13 })
|
|
3067
3174
|
}
|
|
3068
3175
|
)
|
|
3069
3176
|
] });
|
|
@@ -3072,7 +3179,6 @@ function SessionList({
|
|
|
3072
3179
|
history,
|
|
3073
3180
|
activeSessionId,
|
|
3074
3181
|
loadingSessionId,
|
|
3075
|
-
streamingSessionIds,
|
|
3076
3182
|
recentlyCompletedSessionIds,
|
|
3077
3183
|
onSelectSession
|
|
3078
3184
|
}) {
|
|
@@ -3109,7 +3215,6 @@ function SessionList({
|
|
|
3109
3215
|
session: s,
|
|
3110
3216
|
isActive: s.sessionId === activeSessionId,
|
|
3111
3217
|
isLoading: s.sessionId === loadingSessionId,
|
|
3112
|
-
isStreaming: streamingSessionIds?.has(s.sessionId) ?? false,
|
|
3113
3218
|
isRecentlyCompleted: recentlyCompletedSessionIds?.has(s.sessionId) ?? false,
|
|
3114
3219
|
onSelect: onSelectSession
|
|
3115
3220
|
},
|
|
@@ -3142,26 +3247,12 @@ function SessionRow({
|
|
|
3142
3247
|
session,
|
|
3143
3248
|
isActive,
|
|
3144
3249
|
isLoading,
|
|
3145
|
-
isStreaming,
|
|
3146
3250
|
isRecentlyCompleted,
|
|
3147
3251
|
onSelect
|
|
3148
3252
|
}) {
|
|
3149
3253
|
let statusNode = null;
|
|
3150
3254
|
let statusLabel;
|
|
3151
|
-
if (
|
|
3152
|
-
statusNode = /* @__PURE__ */ jsxs(
|
|
3153
|
-
"span",
|
|
3154
|
-
{
|
|
3155
|
-
className: "payman-sidebar-row-status payman-sidebar-row-status-live",
|
|
3156
|
-
"aria-hidden": true,
|
|
3157
|
-
children: [
|
|
3158
|
-
/* @__PURE__ */ jsx("span", { className: "payman-sidebar-row-live-dot" }),
|
|
3159
|
-
/* @__PURE__ */ jsx("span", { className: "payman-sidebar-row-live-track" })
|
|
3160
|
-
]
|
|
3161
|
-
}
|
|
3162
|
-
);
|
|
3163
|
-
statusLabel = "Running";
|
|
3164
|
-
} else if (isRecentlyCompleted) {
|
|
3255
|
+
if (isRecentlyCompleted) {
|
|
3165
3256
|
statusNode = /* @__PURE__ */ jsx(
|
|
3166
3257
|
"span",
|
|
3167
3258
|
{
|
|
@@ -3182,7 +3273,7 @@ function SessionRow({
|
|
|
3182
3273
|
onClick: () => onSelect(session),
|
|
3183
3274
|
className: cn("payman-sidebar-row", isActive && "is-active"),
|
|
3184
3275
|
title: statusLabel ? `${session.sessionTitle || "Untitled session"} \u2014 ${statusLabel}` : session.sessionTitle,
|
|
3185
|
-
"aria-busy": isLoading ||
|
|
3276
|
+
"aria-busy": isLoading || void 0,
|
|
3186
3277
|
children: /* @__PURE__ */ jsxs("span", { className: "payman-sidebar-row-main", children: [
|
|
3187
3278
|
/* @__PURE__ */ jsx("span", { className: "payman-sidebar-row-title", children: session.sessionTitle || "Untitled session" }),
|
|
3188
3279
|
statusNode
|
|
@@ -3271,10 +3362,17 @@ function groupSessionsByDate(sessions, now) {
|
|
|
3271
3362
|
}
|
|
3272
3363
|
return orderedGroups;
|
|
3273
3364
|
}
|
|
3365
|
+
function titleCaseDateHeading(label) {
|
|
3366
|
+
return label.replace(/[\p{L}\p{M}]+/gu, (word) => {
|
|
3367
|
+
const lower = word.toLocaleLowerCase(void 0);
|
|
3368
|
+
const first = lower.charAt(0).toLocaleUpperCase(void 0);
|
|
3369
|
+
return first + lower.slice(1);
|
|
3370
|
+
});
|
|
3371
|
+
}
|
|
3274
3372
|
function getSessionDateBucket(iso, now) {
|
|
3275
3373
|
const date = new Date(iso);
|
|
3276
3374
|
if (Number.isNaN(date.getTime())) {
|
|
3277
|
-
return { key: "older", label: "Older" };
|
|
3375
|
+
return { key: "older", label: titleCaseDateHeading("Older") };
|
|
3278
3376
|
}
|
|
3279
3377
|
const dayKey = [
|
|
3280
3378
|
date.getFullYear(),
|
|
@@ -3286,22 +3384,26 @@ function getSessionDateBucket(iso, now) {
|
|
|
3286
3384
|
const dayDiff = Math.round(
|
|
3287
3385
|
(today.getTime() - sessionDay.getTime()) / 864e5
|
|
3288
3386
|
);
|
|
3289
|
-
if (dayDiff <= 0) return { key: dayKey, label: "Today" };
|
|
3290
|
-
if (dayDiff === 1) return { key: dayKey, label: "Yesterday" };
|
|
3387
|
+
if (dayDiff <= 0) return { key: dayKey, label: titleCaseDateHeading("Today") };
|
|
3388
|
+
if (dayDiff === 1) return { key: dayKey, label: titleCaseDateHeading("Yesterday") };
|
|
3291
3389
|
if (dayDiff < 7) {
|
|
3292
3390
|
return {
|
|
3293
3391
|
key: dayKey,
|
|
3294
|
-
label:
|
|
3392
|
+
label: titleCaseDateHeading(
|
|
3393
|
+
date.toLocaleDateString(void 0, { weekday: "long" })
|
|
3394
|
+
)
|
|
3295
3395
|
};
|
|
3296
3396
|
}
|
|
3297
3397
|
const sameYear = date.getFullYear() === now.getFullYear();
|
|
3298
3398
|
return {
|
|
3299
3399
|
key: dayKey,
|
|
3300
|
-
label:
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3400
|
+
label: titleCaseDateHeading(
|
|
3401
|
+
date.toLocaleDateString(void 0, {
|
|
3402
|
+
month: "long",
|
|
3403
|
+
day: "numeric",
|
|
3404
|
+
year: sameYear ? void 0 : "numeric"
|
|
3405
|
+
})
|
|
3406
|
+
)
|
|
3305
3407
|
};
|
|
3306
3408
|
}
|
|
3307
3409
|
var DEFAULT_PLACEHOLDER = "Type your message...";
|
|
@@ -3435,19 +3537,12 @@ var PaymanChat = forwardRef(function PaymanChat2({
|
|
|
3435
3537
|
const [isResetSessionConfirmOpen, setIsResetSessionConfirmOpen] = useState(false);
|
|
3436
3538
|
const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false);
|
|
3437
3539
|
const [optimisticSessionActivity, setOptimisticSessionActivity] = useState(null);
|
|
3438
|
-
const [streamingSessionIds, setStreamingSessionIds] = useState(() => /* @__PURE__ */ new Set());
|
|
3439
3540
|
const [recentlyCompletedSessionIds, setRecentlyCompletedSessionIds] = useState(() => /* @__PURE__ */ new Set());
|
|
3440
3541
|
const recentlyCompletedTimersRef = useRef(
|
|
3441
3542
|
/* @__PURE__ */ new Map()
|
|
3442
3543
|
);
|
|
3443
3544
|
const RECENTLY_COMPLETED_DURATION_MS = 4e3;
|
|
3444
|
-
const
|
|
3445
|
-
setStreamingSessionIds((prev) => {
|
|
3446
|
-
if (prev.has(sessionId)) return prev;
|
|
3447
|
-
const next = new Set(prev);
|
|
3448
|
-
next.add(sessionId);
|
|
3449
|
-
return next;
|
|
3450
|
-
});
|
|
3545
|
+
const clearRecentlyCompletedForSession = useCallback((sessionId) => {
|
|
3451
3546
|
setRecentlyCompletedSessionIds((prev) => {
|
|
3452
3547
|
if (!prev.has(sessionId)) return prev;
|
|
3453
3548
|
const next = new Set(prev);
|
|
@@ -3461,12 +3556,6 @@ var PaymanChat = forwardRef(function PaymanChat2({
|
|
|
3461
3556
|
}
|
|
3462
3557
|
}, []);
|
|
3463
3558
|
const markSessionCompleted = useCallback((sessionId) => {
|
|
3464
|
-
setStreamingSessionIds((prev) => {
|
|
3465
|
-
if (!prev.has(sessionId)) return prev;
|
|
3466
|
-
const next = new Set(prev);
|
|
3467
|
-
next.delete(sessionId);
|
|
3468
|
-
return next;
|
|
3469
|
-
});
|
|
3470
3559
|
setRecentlyCompletedSessionIds((prev) => {
|
|
3471
3560
|
const next = new Set(prev);
|
|
3472
3561
|
next.add(sessionId);
|
|
@@ -3515,7 +3604,7 @@ var PaymanChat = forwardRef(function PaymanChat2({
|
|
|
3515
3604
|
const sessionId = latestSessionIdRef.current;
|
|
3516
3605
|
if (!sessionId) return;
|
|
3517
3606
|
lastOptimisticSessionIdRef.current = sessionId;
|
|
3518
|
-
|
|
3607
|
+
clearRecentlyCompletedForSession(sessionId);
|
|
3519
3608
|
setOptimisticSessionActivity({
|
|
3520
3609
|
key: `message:${sessionId}:${Date.now()}`,
|
|
3521
3610
|
sessionId,
|
|
@@ -3527,15 +3616,6 @@ var PaymanChat = forwardRef(function PaymanChat2({
|
|
|
3527
3616
|
const previousSessionId = latestSessionIdRef.current;
|
|
3528
3617
|
latestSessionIdRef.current = sessionId;
|
|
3529
3618
|
sentryCallbacks.onSessionIdChange?.(sessionId);
|
|
3530
|
-
if (previousSessionId && previousSessionId !== sessionId) {
|
|
3531
|
-
setStreamingSessionIds((prev) => {
|
|
3532
|
-
if (!prev.has(previousSessionId)) return prev;
|
|
3533
|
-
const next = new Set(prev);
|
|
3534
|
-
next.delete(previousSessionId);
|
|
3535
|
-
next.add(sessionId);
|
|
3536
|
-
return next;
|
|
3537
|
-
});
|
|
3538
|
-
}
|
|
3539
3619
|
if (previousSessionId && previousSessionId !== sessionId && lastOptimisticSessionIdRef.current === previousSessionId) {
|
|
3540
3620
|
lastOptimisticSessionIdRef.current = sessionId;
|
|
3541
3621
|
setOptimisticSessionActivity(
|
|
@@ -3562,20 +3642,12 @@ var PaymanChat = forwardRef(function PaymanChat2({
|
|
|
3562
3642
|
},
|
|
3563
3643
|
onError: (error) => {
|
|
3564
3644
|
sentryCallbacks.onError?.(error);
|
|
3565
|
-
const sessionId = latestSessionIdRef.current;
|
|
3566
|
-
if (!sessionId) return;
|
|
3567
|
-
setStreamingSessionIds((prev) => {
|
|
3568
|
-
if (!prev.has(sessionId)) return prev;
|
|
3569
|
-
const next = new Set(prev);
|
|
3570
|
-
next.delete(sessionId);
|
|
3571
|
-
return next;
|
|
3572
|
-
});
|
|
3573
3645
|
}
|
|
3574
3646
|
}),
|
|
3575
3647
|
[
|
|
3576
3648
|
buildOptimisticSessionTitle,
|
|
3649
|
+
clearRecentlyCompletedForSession,
|
|
3577
3650
|
markSessionCompleted,
|
|
3578
|
-
markSessionStreaming,
|
|
3579
3651
|
sentryCallbacks
|
|
3580
3652
|
]
|
|
3581
3653
|
);
|
|
@@ -3869,10 +3941,11 @@ var PaymanChat = forwardRef(function PaymanChat2({
|
|
|
3869
3941
|
options: sessionHistory.options,
|
|
3870
3942
|
activeSessionId: currentSessionId,
|
|
3871
3943
|
loadingSessionId,
|
|
3872
|
-
streamingSessionIds,
|
|
3873
3944
|
recentlyCompletedSessionIds,
|
|
3874
3945
|
optimisticActivity: optimisticSessionActivity,
|
|
3875
3946
|
onSelectSession: handleSelectSession,
|
|
3947
|
+
onNewSession: requestResetSession,
|
|
3948
|
+
newSessionDisabled: isWaitingForResponse || isRecording,
|
|
3876
3949
|
mobileOpen: mobileSidebarOpen,
|
|
3877
3950
|
onMobileOpenChange: setMobileSidebarOpen
|
|
3878
3951
|
}
|
|
@@ -3889,7 +3962,7 @@ var PaymanChat = forwardRef(function PaymanChat2({
|
|
|
3889
3962
|
},
|
|
3890
3963
|
children: [
|
|
3891
3964
|
sidebarElement,
|
|
3892
|
-
/* @__PURE__ */
|
|
3965
|
+
/* @__PURE__ */ jsx(
|
|
3893
3966
|
"div",
|
|
3894
3967
|
{
|
|
3895
3968
|
style: {
|
|
@@ -3899,32 +3972,48 @@ var PaymanChat = forwardRef(function PaymanChat2({
|
|
|
3899
3972
|
display: "flex",
|
|
3900
3973
|
flexDirection: "column",
|
|
3901
3974
|
overflow: "hidden",
|
|
3902
|
-
alignItems:
|
|
3903
|
-
justifyContent:
|
|
3975
|
+
alignItems: "stretch",
|
|
3976
|
+
justifyContent: "flex-start"
|
|
3904
3977
|
},
|
|
3905
|
-
children:
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
{
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3978
|
+
children: showEmptyShell ? /* @__PURE__ */ jsxs(
|
|
3979
|
+
"div",
|
|
3980
|
+
{
|
|
3981
|
+
style: {
|
|
3982
|
+
flex: "1 1 0%",
|
|
3983
|
+
display: "flex",
|
|
3984
|
+
flexDirection: "column",
|
|
3985
|
+
alignItems: "center",
|
|
3986
|
+
justifyContent: "center",
|
|
3987
|
+
width: "100%",
|
|
3988
|
+
minHeight: 0,
|
|
3989
|
+
gap: "1.25rem",
|
|
3990
|
+
padding: "0 1rem 1rem",
|
|
3991
|
+
boxSizing: "border-box"
|
|
3992
|
+
},
|
|
3993
|
+
children: [
|
|
3994
|
+
/* @__PURE__ */ jsx(
|
|
3919
3995
|
EmptyState2,
|
|
3920
3996
|
{
|
|
3921
3997
|
text: emptyStateText,
|
|
3922
3998
|
content: emptyStateComponent,
|
|
3923
3999
|
showIcon: showEmptyStateIcon
|
|
3924
4000
|
}
|
|
4001
|
+
),
|
|
4002
|
+
/* @__PURE__ */ jsx(
|
|
4003
|
+
"div",
|
|
4004
|
+
{
|
|
4005
|
+
style: {
|
|
4006
|
+
width: "100%",
|
|
4007
|
+
maxWidth: "var(--payman-v2-max-content-width, 42rem)",
|
|
4008
|
+
flexShrink: 0
|
|
4009
|
+
},
|
|
4010
|
+
children: inputElement
|
|
4011
|
+
}
|
|
3925
4012
|
)
|
|
3926
|
-
|
|
3927
|
-
|
|
4013
|
+
]
|
|
4014
|
+
}
|
|
4015
|
+
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4016
|
+
/* @__PURE__ */ jsx(
|
|
3928
4017
|
MessageListV2,
|
|
3929
4018
|
{
|
|
3930
4019
|
ref: messageListV2Ref,
|
|
@@ -3971,7 +4060,7 @@ var PaymanChat = forwardRef(function PaymanChat2({
|
|
|
3971
4060
|
children: inputElement
|
|
3972
4061
|
}
|
|
3973
4062
|
)
|
|
3974
|
-
]
|
|
4063
|
+
] })
|
|
3975
4064
|
}
|
|
3976
4065
|
)
|
|
3977
4066
|
]
|
|
@@ -4027,10 +4116,9 @@ function EmptyState2({
|
|
|
4027
4116
|
alignItems: "center",
|
|
4028
4117
|
justifyContent: "center",
|
|
4029
4118
|
textAlign: "center",
|
|
4030
|
-
padding: "
|
|
4119
|
+
padding: "8px 8px 0",
|
|
4031
4120
|
gap: 12,
|
|
4032
|
-
flex:
|
|
4033
|
-
minHeight: 0
|
|
4121
|
+
flex: "0 0 auto"
|
|
4034
4122
|
},
|
|
4035
4123
|
children: [
|
|
4036
4124
|
content,
|