@adminide-stack/yantra-mobile 12.0.87-alpha.0 → 12.0.87-alpha.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/lib/features/chat/PreResponseStrip.js +4 -4
- package/lib/features/chat/PreResponseStrip.js.map +1 -1
- package/lib/features/chat/ToolTimeline.js +4 -4
- package/lib/features/chat/ToolTimeline.js.map +1 -1
- package/lib/features/shopping/ProductPhoto.js +9 -3
- package/lib/features/shopping/ProductPhoto.js.map +1 -1
- package/lib/features/shopping/ShoppingAgentChatPane.js +19 -9
- package/lib/features/shopping/ShoppingAgentChatPane.js.map +1 -1
- package/lib/features/shopping/chat/openShopNative.js +15 -3
- package/lib/features/shopping/chat/openShopNative.js.map +1 -1
- package/lib/features/shopping/chat/searchScope.js +33 -0
- package/lib/features/shopping/chat/searchScope.js.map +1 -0
- package/lib/features/shopping/chat/streamAssistantReply.js +3 -2
- package/lib/features/shopping/chat/streamAssistantReply.js.map +1 -1
- package/lib/hooks/useHostConnectorCard.js +35 -3
- package/lib/hooks/useHostConnectorCard.js.map +1 -1
- package/lib/screens/Chat/index.js +19 -11
- package/lib/screens/Chat/index.js.map +1 -1
- package/lib/screens/Home/HomeScreen.js +14 -13
- package/lib/screens/Home/HomeScreen.js.map +1 -1
- package/lib/screens/ShoppingNative/useShoppingHostChat.js +5 -4
- package/lib/screens/ShoppingNative/useShoppingHostChat.js.map +1 -1
- package/package.json +2 -2
|
@@ -21,16 +21,16 @@ const PreResponseStrip = memo(function PreResponseStrip2({
|
|
|
21
21
|
borderColor: border,
|
|
22
22
|
backgroundColor: bg
|
|
23
23
|
}], children: [
|
|
24
|
-
/* @__PURE__ */
|
|
24
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityState: {
|
|
25
25
|
expanded: open
|
|
26
26
|
}, accessibilityLabel: "Quick answer", accessibilityHint: open ? "Hides the quick answer" : "Shows the quick answer", onPress: () => {
|
|
27
27
|
touchedRef.current = true;
|
|
28
28
|
setOpen((v) => !v);
|
|
29
29
|
}, style: ({
|
|
30
30
|
pressed
|
|
31
|
-
}) =>
|
|
31
|
+
}) => ({
|
|
32
32
|
opacity: pressed ? 0.7 : 1
|
|
33
|
-
}
|
|
33
|
+
}), children: /* @__PURE__ */ jsxs(View, { style: styles.header, children: [
|
|
34
34
|
/* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "lightning-bolt", size: 14, color: live ? ACCENT : muted, style: styles.headerIcon }),
|
|
35
35
|
/* @__PURE__ */ jsx(Text, { style: [styles.label, {
|
|
36
36
|
color: muted
|
|
@@ -39,7 +39,7 @@ const PreResponseStrip = memo(function PreResponseStrip2({
|
|
|
39
39
|
color: muted
|
|
40
40
|
}], numberOfLines: 1, children: open ? "" : ` \xB7 ${preview}` }),
|
|
41
41
|
/* @__PURE__ */ jsx(MaterialCommunityIcons, { name: open ? "chevron-down" : "chevron-right", size: 18, color: muted })
|
|
42
|
-
] }),
|
|
42
|
+
] }) }),
|
|
43
43
|
open ? /* @__PURE__ */ jsx(View, { style: [styles.body, {
|
|
44
44
|
borderTopColor: border
|
|
45
45
|
}], children: /* @__PURE__ */ jsx(Text, { style: [styles.bodyText, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreResponseStrip.js","sources":["../../../src/features/chat/PreResponseStrip.tsx"],"sourcesContent":["/**\n * <PreResponseStrip> — the fast lane's \"Quick answer\", as a collapsible strip.\n *\n * With `CDECLI_FAST_LANE=pre` (or the brain assist) a toolless model answers in\n * about a second while the real agent turn runs behind it. That answer is why\n * the turn felt fast, so it stays with the turn - but it must not compete with\n * the agent's reply, so once the agent starts talking it folds down to one\n * quiet line the user can re-open. Rendered raw it was the\n * `[PRE_RESPONSE]…[/PRE_RESPONSE]` markup in the bubble.\n *\n * Mobile counterpart of the browser `PreResponseStrip`, drawn like\n * {@link ./ToolTimeline} (same border, fill, 44pt header and chevron) so a turn\n * that shows both reads as one stack of secondary detail above the answer.\n */\nimport { MaterialCommunityIcons } from '@expo/vector-icons';\nimport React, { memo, useEffect, useRef, useState } from 'react';\nimport { Pressable, StyleSheet, Text, View } from 'react-native';\nimport { plainPreResponse } from './preResponse';\n\nconst ACCENT = '#2563eb';\n\nexport const PreResponseStrip = memo(function PreResponseStrip({\n text,\n expanded,\n live = false,\n isDark = false,\n}: {\n /** The fast answer. Nothing renders when empty. */\n text: string;\n /**\n * Open while the quick answer is all there is to read; folds once the\n * agent's own reply arrives.\n */\n expanded: boolean;\n /** True while this turn is still running: the bolt takes the accent color. */\n live?: boolean;\n isDark?: boolean;\n}) {\n const [open, setOpen] = useState(expanded);\n // Once the user opens or closes it themselves, stop steering it - an\n // auto-collapse that fights a deliberate tap reads as a bug.\n const touchedRef = useRef(false);\n\n useEffect(() => {\n if (!touchedRef.current) setOpen(expanded);\n }, [expanded]);\n\n const body = plainPreResponse(text);\n if (!body) return null;\n\n const border = isDark ? '#1f2937' : '#e5e7eb';\n const bg = isDark ? '#0b1220' : '#f9fafb';\n const muted = isDark ? '#94a3b8' : '#6b7280';\n const ink = isDark ? '#cbd5e1' : '#374151';\n const preview = body.replace(/\\s+/g, ' ');\n\n return (\n <View style={[styles.wrap, { borderColor: border, backgroundColor: bg }]}>\n <Pressable\n accessibilityRole=\"button\"\n accessibilityState={{ expanded: open }}\n accessibilityLabel=\"Quick answer\"\n accessibilityHint={open ? 'Hides the quick answer' : 'Shows the quick answer'}\n onPress={() => {\n touchedRef.current = true;\n setOpen((v) => !v);\n }}\n style={({ pressed }) =>
|
|
1
|
+
{"version":3,"file":"PreResponseStrip.js","sources":["../../../src/features/chat/PreResponseStrip.tsx"],"sourcesContent":["/**\n * <PreResponseStrip> — the fast lane's \"Quick answer\", as a collapsible strip.\n *\n * With `CDECLI_FAST_LANE=pre` (or the brain assist) a toolless model answers in\n * about a second while the real agent turn runs behind it. That answer is why\n * the turn felt fast, so it stays with the turn - but it must not compete with\n * the agent's reply, so once the agent starts talking it folds down to one\n * quiet line the user can re-open. Rendered raw it was the\n * `[PRE_RESPONSE]…[/PRE_RESPONSE]` markup in the bubble.\n *\n * Mobile counterpart of the browser `PreResponseStrip`, drawn like\n * {@link ./ToolTimeline} (same border, fill, 44pt header and chevron) so a turn\n * that shows both reads as one stack of secondary detail above the answer.\n */\nimport { MaterialCommunityIcons } from '@expo/vector-icons';\nimport React, { memo, useEffect, useRef, useState } from 'react';\nimport { Pressable, StyleSheet, Text, View } from 'react-native';\nimport { plainPreResponse } from './preResponse';\n\nconst ACCENT = '#2563eb';\n\nexport const PreResponseStrip = memo(function PreResponseStrip({\n text,\n expanded,\n live = false,\n isDark = false,\n}: {\n /** The fast answer. Nothing renders when empty. */\n text: string;\n /**\n * Open while the quick answer is all there is to read; folds once the\n * agent's own reply arrives.\n */\n expanded: boolean;\n /** True while this turn is still running: the bolt takes the accent color. */\n live?: boolean;\n isDark?: boolean;\n}) {\n const [open, setOpen] = useState(expanded);\n // Once the user opens or closes it themselves, stop steering it - an\n // auto-collapse that fights a deliberate tap reads as a bug.\n const touchedRef = useRef(false);\n\n useEffect(() => {\n if (!touchedRef.current) setOpen(expanded);\n }, [expanded]);\n\n const body = plainPreResponse(text);\n if (!body) return null;\n\n const border = isDark ? '#1f2937' : '#e5e7eb';\n const bg = isDark ? '#0b1220' : '#f9fafb';\n const muted = isDark ? '#94a3b8' : '#6b7280';\n const ink = isDark ? '#cbd5e1' : '#374151';\n const preview = body.replace(/\\s+/g, ' ');\n\n return (\n <View style={[styles.wrap, { borderColor: border, backgroundColor: bg }]}>\n <Pressable\n accessibilityRole=\"button\"\n accessibilityState={{ expanded: open }}\n accessibilityLabel=\"Quick answer\"\n accessibilityHint={open ? 'Hides the quick answer' : 'Shows the quick answer'}\n onPress={() => {\n touchedRef.current = true;\n setOpen((v) => !v);\n }}\n style={({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })}\n >\n {/* The row lives on a View: on the Pressable's style callback the\n header lost its row layout and padding and stacked vertically. */}\n <View style={styles.header}>\n <MaterialCommunityIcons\n name=\"lightning-bolt\"\n size={14}\n color={live ? ACCENT : muted}\n style={styles.headerIcon}\n />\n <Text style={[styles.label, { color: muted }]}>Quick answer</Text>\n <Text style={[styles.preview, { color: muted }]} numberOfLines={1}>\n {open ? '' : ` · ${preview}`}\n </Text>\n <MaterialCommunityIcons name={open ? 'chevron-down' : 'chevron-right'} size={18} color={muted} />\n </View>\n </Pressable>\n\n {open ? (\n <View style={[styles.body, { borderTopColor: border }]}>\n <Text style={[styles.bodyText, { color: ink }]} selectable>\n {body}\n </Text>\n </View>\n ) : null}\n </View>\n );\n});\n\nconst styles = StyleSheet.create({\n wrap: {\n width: '100%',\n borderWidth: 1,\n borderRadius: 10,\n marginBottom: 8,\n overflow: 'hidden',\n },\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 10,\n minHeight: 44, // touch target\n },\n headerIcon: { width: 18, marginRight: 6 },\n label: { fontSize: 12, fontWeight: '600' },\n preview: { flex: 1, fontSize: 12, marginRight: 4 },\n body: { borderTopWidth: 1, paddingHorizontal: 10, paddingVertical: 10 },\n bodyText: { fontSize: 14, lineHeight: 20 },\n});\n\nexport default PreResponseStrip;\n"],"names":["PreResponseStrip"],"mappings":"8PAkBA,MAAM,MAAS,GAAA,SAAA;AACF,MAAA,gBAAA,GAAmB,IAAK,CAAA,SAASA,iBAAiB,CAAA;AAAA,EAC7D,IAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAO,GAAA,KAAA;AAAA,EACP,MAAS,GAAA;AACX,CAWG,EAAA;AACD,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAS,QAAQ,CAAA;AAGzC,EAAM,MAAA,UAAA,GAAa,OAAO,KAAK,CAAA;AAC/B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,UAAA,CAAW,OAAS,EAAA,OAAA,CAAQ,QAAQ,CAAA;AAAA,GAC3C,EAAG,CAAC,QAAQ,CAAC,CAAA;AACb,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A,EAAA;AAAA,IACnB,SAAW,EAAA;AAAA;AAAA,GACb;AAAA,EACA,UAAY,EAAA;AAAA,IACV,KAAO,EAAA,EAAA;AAAA,IACP,WAAa,EAAA;AAAA,GACf;AAAA,EACA,KAAO,EAAA;AAAA,IACL,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA;AAAA,GACd;AAAA,EACA,OAAS,EAAA;AAAA,IACP,IAAM,EAAA,CAAA;AAAA,IACN,QAAU,EAAA,EAAA;AAAA,IACV,WAAa,EAAA;AAAA,GACf;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,cAAgB,EAAA,CAAA;AAAA,IAChB,iBAAmB,EAAA,EAAA;AAAA,IACnB,eAAiB,EAAA;AAAA,GACnB;AAAA,EACA,QAAU,EAAA;AAAA,IACR,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA;AAAA;AAEhB,CAAC,CAAA"}
|
|
@@ -39,19 +39,19 @@ const ToolTimeline = memo(function ToolTimeline2({
|
|
|
39
39
|
borderColor: border,
|
|
40
40
|
backgroundColor: bg
|
|
41
41
|
}], children: [
|
|
42
|
-
/* @__PURE__ */
|
|
42
|
+
/* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityState: {
|
|
43
43
|
expanded: open
|
|
44
44
|
}, accessibilityLabel: summary, onPress: () => setOpen((v) => !v), style: ({
|
|
45
45
|
pressed
|
|
46
|
-
}) =>
|
|
46
|
+
}) => ({
|
|
47
47
|
opacity: pressed ? 0.7 : 1
|
|
48
|
-
}
|
|
48
|
+
}), children: /* @__PURE__ */ jsxs(View, { style: styles.header, children: [
|
|
49
49
|
active ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: ACCENT, style: styles.headerIcon }) : /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "wrench-outline", size: 14, color: muted, style: styles.headerIcon }),
|
|
50
50
|
/* @__PURE__ */ jsx(Text, { style: [styles.summary, {
|
|
51
51
|
color: muted
|
|
52
52
|
}], numberOfLines: 1, children: summary }),
|
|
53
53
|
/* @__PURE__ */ jsx(MaterialCommunityIcons, { name: open ? "chevron-down" : "chevron-right", size: 18, color: muted })
|
|
54
|
-
] }),
|
|
54
|
+
] }) }),
|
|
55
55
|
open ? /* @__PURE__ */ jsx(View, { style: [styles.list, {
|
|
56
56
|
borderTopColor: border
|
|
57
57
|
}], children: steps.map((step) => /* @__PURE__ */ jsxs(View, { style: styles.step, children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolTimeline.js","sources":["../../../src/features/chat/ToolTimeline.tsx"],"sourcesContent":["/**\n * <ToolTimeline> — the agent's tool activity, as a collapsible strip.\n *\n * The cdecli agent narrates tool use into the streamed assistant text as bare\n * `⚙ ToolSearch` rows. Rendered raw they read as debug noise — which is exactly\n * what mobile was showing. {@link ./toolActivity} pulls them out of the prose;\n * this draws them.\n *\n * Same behaviour as the web timeline (auto-expand while working, last step\n * spins, collapse to \"Used N tools\" when done), rebuilt for touch: a full-width\n * 44pt header row instead of a hover-styled button, ActivityIndicator instead of\n * a CSS spin, and no title tooltips (there is nowhere to hover) so details\n * truncate in place.\n */\nimport { MaterialCommunityIcons } from '@expo/vector-icons';\nimport React, { memo, useEffect, useRef, useState } from 'react';\nimport { ActivityIndicator, Pressable, StyleSheet, Text, View } from 'react-native';\nimport type { ToolStep } from './toolActivity';\n\nconst ACCENT = '#2563eb';\nconst DONE = '#10b981';\n\nfunction formatElapsed(ms: number): string {\n const s = Math.round(ms / 1000);\n if (s < 60) return `${s}s`;\n const m = Math.floor(s / 60);\n return `${m}m ${s % 60}s`;\n}\n\nexport const ToolTimeline = memo(function ToolTimeline({\n steps,\n active,\n isDark = false,\n}: {\n steps: ToolStep[];\n /** True while the turn is still streaming: drives the spinner and the timer. */\n active: boolean;\n isDark?: boolean;\n}) {\n // Expanded while working so live progress is visible; collapses once done.\n const [open, setOpen] = useState(active);\n // Captured on first activity, frozen at completion. Ref-held so re-renders\n // do not restart it.\n const startedAtRef = useRef<number | null>(null);\n const [elapsed, setElapsed] = useState(0);\n\n useEffect(() => {\n if (active) {\n if (startedAtRef.current === null) startedAtRef.current = Date.now();\n const tick = () => setElapsed(Date.now() - (startedAtRef.current ?? Date.now()));\n tick();\n const timer = setInterval(tick, 1000);\n return () => clearInterval(timer);\n }\n setOpen(false);\n return undefined;\n }, [active]);\n\n if (steps.length === 0) return null;\n\n const border = isDark ? '#1f2937' : '#e5e7eb';\n const bg = isDark ? '#0b1220' : '#f9fafb';\n const muted = isDark ? '#94a3b8' : '#6b7280';\n const strong = isDark ? '#e2e8f0' : '#111827';\n\n const count = steps.length;\n const summary = active\n ? `Working · ${formatElapsed(elapsed)}`\n : `Used ${count} tool${count === 1 ? '' : 's'}${elapsed ? ` · ${formatElapsed(elapsed)}` : ''}`;\n\n return (\n <View style={[styles.wrap, { borderColor: border, backgroundColor: bg }]}>\n <Pressable\n accessibilityRole=\"button\"\n accessibilityState={{ expanded: open }}\n accessibilityLabel={summary}\n onPress={() => setOpen((v) => !v)}\n style={({ pressed }) => [styles.header, { opacity: pressed ? 0.7 : 1 }]}\n >\n {active ? (\n <ActivityIndicator size=\"small\" color={ACCENT} style={styles.headerIcon} />\n ) : (\n <MaterialCommunityIcons name=\"wrench-outline\" size={14} color={muted} style={styles.headerIcon} />\n )}\n <Text style={[styles.summary, { color: muted }]} numberOfLines={1}>\n {summary}\n </Text>\n <MaterialCommunityIcons name={open ? 'chevron-down' : 'chevron-right'} size={18} color={muted} />\n </Pressable>\n\n {open ? (\n <View style={[styles.list, { borderTopColor: border }]}>\n {steps.map((step) => (\n <View key={step.id} style={styles.step}>\n {step.status === 'running' ? (\n <ActivityIndicator size=\"small\" color={ACCENT} style={styles.stepIcon} />\n ) : (\n <MaterialCommunityIcons name=\"check\" size={13} color={DONE} style={styles.stepIcon} />\n )}\n <Text\n style={[styles.stepLabel, { color: step.status === 'running' ? strong : muted }]}\n numberOfLines={1}\n >\n {step.label}\n </Text>\n {step.detail ? (\n <Text style={[styles.stepDetail, { color: muted }]} numberOfLines={1}>\n · {step.detail}\n </Text>\n ) : null}\n </View>\n ))}\n </View>\n ) : null}\n </View>\n );\n});\n\nconst styles = StyleSheet.create({\n wrap: {\n width: '100%',\n borderWidth: 1,\n borderRadius: 10,\n marginBottom: 8,\n overflow: 'hidden',\n },\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 10,\n minHeight: 44, // touch target\n },\n headerIcon: { width: 18, marginRight: 6 },\n summary: { flex: 1, fontSize: 12, fontWeight: '600' },\n list: { borderTopWidth: 1, paddingHorizontal: 10, paddingVertical: 6 },\n step: { flexDirection: 'row', alignItems: 'center', paddingVertical: 3 },\n stepIcon: { width: 16, marginRight: 6 },\n stepLabel: { fontSize: 12, flexShrink: 1 },\n stepDetail: { fontSize: 12, marginLeft: 4, flexShrink: 1 },\n});\n\nexport default ToolTimeline;\n"],"names":["ToolTimeline"],"mappings":"gOAkBA,MAAM,MAAS,GAAA,SAAA;AACf,MAAM,IAAO,GAAA,SAAA;AACb,SAAS,cAAc,EAAoB,EAAA;AACzC,EAAA,MAAM,CAAI,GAAA,IAAA,CAAK,KAAM,CAAA,EAAA,GAAK,GAAI,CAAA;AAC9B,EAAA,IAAI,CAAI,GAAA,EAAA,EAAW,OAAA,CAAA,EAAG,CAAC,CAAA,CAAA,CAAA;AACvB,EAAA,MAAM,CAAI,GAAA,IAAA,CAAK,KAAM,CAAA,CAAA,GAAI,EAAE,CAAA;AAC3B,EAAA,OAAO,CAAG,EAAA,CAAC,CAAK,EAAA,EAAA,CAAA,GAAI,EAAE,CAAA,CAAA,CAAA;AACxB;AACa,MAAA,YAAA,GAAe,IAAK,CAAA,SAASA,aAAa,CAAA;AAAA,EACrD,KAAA;AAAA,EACA,MAAA;AAAA,EACA,MAAS,GAAA;AACX,CAKG,EAAA;AAED,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAS,MAAM,CAAA;AAGvC,EAAM,MAAA,YAAA,GAAe,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EAAA;AAAA,IACd,YAAc,EAAA,CAAA;AAAA,IACd,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,aAAe,EAAA,KAAA;AAAA,IACf,UAAY,EAAA,QAAA;AAAA,IACZ,iBAAmB,EAAA,EAAA;AAAA,IACnB,SAAW,EAAA;AAAA;AAAA,GACb;AAAA,EACA,UAAY,EAAA;AAAA,IACV,KAAO,EAAA,EAAA;AAAA,IACP,WAAa,EAAA;AAAA,GACf;AAAA,EACA,OAAS,EAAA;AAAA,IACP,IAAM,EAAA,CAAA;AAAA,IACN,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA;AAAA,GACd;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,cAAgB,EAAA,CAAA;AAAA,IAChB,iBAAmB,EAAA,EAAA;AAAA,IACnB,eAAiB,EAAA;AAAA,GACnB;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,aAAe,EAAA,KAAA;AAAA,IACf,UAAY,EAAA,QAAA;AAAA,IACZ,eAAiB,EAAA;AAAA,GACnB;AAAA,EACA,QAAU,EAAA;AAAA,IACR,KAAO,EAAA,EAAA;AAAA,IACP,WAAa,EAAA;AAAA,GACf;AAAA,EACA,SAAW,EAAA;AAAA,IACT,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA;AAAA,GACd;AAAA,EACA,UAAY,EAAA;AAAA,IACV,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,CAAA;AAAA,IACZ,UAAY,EAAA;AAAA;AAEhB,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"ToolTimeline.js","sources":["../../../src/features/chat/ToolTimeline.tsx"],"sourcesContent":["/**\n * <ToolTimeline> — the agent's tool activity, as a collapsible strip.\n *\n * The cdecli agent narrates tool use into the streamed assistant text as bare\n * `⚙ ToolSearch` rows. Rendered raw they read as debug noise — which is exactly\n * what mobile was showing. {@link ./toolActivity} pulls them out of the prose;\n * this draws them.\n *\n * Same behaviour as the web timeline (auto-expand while working, last step\n * spins, collapse to \"Used N tools\" when done), rebuilt for touch: a full-width\n * 44pt header row instead of a hover-styled button, ActivityIndicator instead of\n * a CSS spin, and no title tooltips (there is nowhere to hover) so details\n * truncate in place.\n */\nimport { MaterialCommunityIcons } from '@expo/vector-icons';\nimport React, { memo, useEffect, useRef, useState } from 'react';\nimport { ActivityIndicator, Pressable, StyleSheet, Text, View } from 'react-native';\nimport type { ToolStep } from './toolActivity';\n\nconst ACCENT = '#2563eb';\nconst DONE = '#10b981';\n\nfunction formatElapsed(ms: number): string {\n const s = Math.round(ms / 1000);\n if (s < 60) return `${s}s`;\n const m = Math.floor(s / 60);\n return `${m}m ${s % 60}s`;\n}\n\nexport const ToolTimeline = memo(function ToolTimeline({\n steps,\n active,\n isDark = false,\n}: {\n steps: ToolStep[];\n /** True while the turn is still streaming: drives the spinner and the timer. */\n active: boolean;\n isDark?: boolean;\n}) {\n // Expanded while working so live progress is visible; collapses once done.\n const [open, setOpen] = useState(active);\n // Captured on first activity, frozen at completion. Ref-held so re-renders\n // do not restart it.\n const startedAtRef = useRef<number | null>(null);\n const [elapsed, setElapsed] = useState(0);\n\n useEffect(() => {\n if (active) {\n if (startedAtRef.current === null) startedAtRef.current = Date.now();\n const tick = () => setElapsed(Date.now() - (startedAtRef.current ?? Date.now()));\n tick();\n const timer = setInterval(tick, 1000);\n return () => clearInterval(timer);\n }\n setOpen(false);\n return undefined;\n }, [active]);\n\n if (steps.length === 0) return null;\n\n const border = isDark ? '#1f2937' : '#e5e7eb';\n const bg = isDark ? '#0b1220' : '#f9fafb';\n const muted = isDark ? '#94a3b8' : '#6b7280';\n const strong = isDark ? '#e2e8f0' : '#111827';\n\n const count = steps.length;\n const summary = active\n ? `Working · ${formatElapsed(elapsed)}`\n : `Used ${count} tool${count === 1 ? '' : 's'}${elapsed ? ` · ${formatElapsed(elapsed)}` : ''}`;\n\n return (\n <View style={[styles.wrap, { borderColor: border, backgroundColor: bg }]}>\n <Pressable\n accessibilityRole=\"button\"\n accessibilityState={{ expanded: open }}\n accessibilityLabel={summary}\n onPress={() => setOpen((v) => !v)}\n style={({ pressed }) => ({ opacity: pressed ? 0.7 : 1 })}\n >\n {/* The row lives on a View: on the Pressable's style callback the\n header lost its row layout and padding and stacked vertically. */}\n <View style={styles.header}>\n {active ? (\n <ActivityIndicator size=\"small\" color={ACCENT} style={styles.headerIcon} />\n ) : (\n <MaterialCommunityIcons\n name=\"wrench-outline\"\n size={14}\n color={muted}\n style={styles.headerIcon}\n />\n )}\n <Text style={[styles.summary, { color: muted }]} numberOfLines={1}>\n {summary}\n </Text>\n <MaterialCommunityIcons name={open ? 'chevron-down' : 'chevron-right'} size={18} color={muted} />\n </View>\n </Pressable>\n\n {open ? (\n <View style={[styles.list, { borderTopColor: border }]}>\n {steps.map((step) => (\n <View key={step.id} style={styles.step}>\n {step.status === 'running' ? (\n <ActivityIndicator size=\"small\" color={ACCENT} style={styles.stepIcon} />\n ) : (\n <MaterialCommunityIcons name=\"check\" size={13} color={DONE} style={styles.stepIcon} />\n )}\n <Text\n style={[styles.stepLabel, { color: step.status === 'running' ? strong : muted }]}\n numberOfLines={1}\n >\n {step.label}\n </Text>\n {step.detail ? (\n <Text style={[styles.stepDetail, { color: muted }]} numberOfLines={1}>\n · {step.detail}\n </Text>\n ) : null}\n </View>\n ))}\n </View>\n ) : null}\n </View>\n );\n});\n\nconst styles = StyleSheet.create({\n wrap: {\n width: '100%',\n borderWidth: 1,\n borderRadius: 10,\n marginBottom: 8,\n overflow: 'hidden',\n },\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 10,\n minHeight: 44, // touch target\n },\n headerIcon: { width: 18, marginRight: 6 },\n summary: { flex: 1, fontSize: 12, fontWeight: '600' },\n list: { borderTopWidth: 1, paddingHorizontal: 10, paddingVertical: 6 },\n step: { flexDirection: 'row', alignItems: 'center', paddingVertical: 3 },\n stepIcon: { width: 16, marginRight: 6 },\n stepLabel: { fontSize: 12, flexSh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GACd;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,cAAgB,EAAA,CAAA;AAAA,IAChB,iBAAmB,EAAA,EAAA;AAAA,IACnB,eAAiB,EAAA;AAAA,GACnB;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,aAAe,EAAA,KAAA;AAAA,IACf,UAAY,EAAA,QAAA;AAAA,IACZ,eAAiB,EAAA;AAAA,GACnB;AAAA,EACA,QAAU,EAAA;AAAA,IACR,KAAO,EAAA,EAAA;AAAA,IACP,WAAa,EAAA;AAAA,GACf;AAAA,EACA,SAAW,EAAA;AAAA,IACT,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA;AAAA,GACd;AAAA,EACA,UAAY,EAAA;AAAA,IACV,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,CAAA;AAAA,IACZ,UAAY,EAAA;AAAA;AAEhB,CAAC,CAAA"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {jsx}from'react/jsx-runtime';import {useState,useEffect}from'react';import {Image}from'expo-image';import {StyleSheet,View,Text}from'react-native';import {productImageCandidates}from'./productImage.js';function
|
|
1
|
+
import {jsx}from'react/jsx-runtime';import {useState,useEffect}from'react';import {Image}from'expo-image';import {StyleSheet,View,Text}from'react-native';import {productImageCandidates}from'./productImage.js';function isPlaceholderImage(source) {
|
|
2
|
+
return source.width <= 1 || source.height <= 1;
|
|
3
|
+
}
|
|
4
|
+
function ProductPhoto({
|
|
2
5
|
product,
|
|
3
6
|
style,
|
|
4
7
|
contentFit = "contain"
|
|
@@ -7,6 +10,7 @@ import {jsx}from'react/jsx-runtime';import {useState,useEffect}from'react';impor
|
|
|
7
10
|
const [index, setIndex] = useState(0);
|
|
8
11
|
useEffect(() => setIndex(0), [product.id, product.imageUrl, product.asin]);
|
|
9
12
|
const uri = candidates[index];
|
|
13
|
+
const tryNext = () => setIndex((i) => i + 1);
|
|
10
14
|
if (!uri) {
|
|
11
15
|
return /* @__PURE__ */ jsx(View, { style: [styles.fallback, style, {
|
|
12
16
|
backgroundColor: `${product.accent}22`
|
|
@@ -14,7 +18,9 @@ import {jsx}from'react/jsx-runtime';import {useState,useEffect}from'react';impor
|
|
|
14
18
|
}
|
|
15
19
|
return /* @__PURE__ */ jsx(Image, { source: {
|
|
16
20
|
uri
|
|
17
|
-
}, style, contentFit,
|
|
21
|
+
}, style, contentFit, onLoad: (event) => {
|
|
22
|
+
if (isPlaceholderImage(event.source)) tryNext();
|
|
23
|
+
}, onError: tryNext });
|
|
18
24
|
}
|
|
19
25
|
const styles = StyleSheet.create({
|
|
20
26
|
fallback: {
|
|
@@ -24,4 +30,4 @@ const styles = StyleSheet.create({
|
|
|
24
30
|
icon: {
|
|
25
31
|
fontSize: 36
|
|
26
32
|
}
|
|
27
|
-
});export{ProductPhoto};//# sourceMappingURL=ProductPhoto.js.map
|
|
33
|
+
});export{ProductPhoto,isPlaceholderImage};//# sourceMappingURL=ProductPhoto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductPhoto.js","sources":["../../../src/features/shopping/ProductPhoto.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { Image } from 'expo-image';\nimport { StyleSheet, Text, View } from 'react-native';\nimport type { Product } from './catalog';\nimport { productImageCandidates } from './productImage';\n\nexport function ProductPhoto({\n product,\n style,\n contentFit = 'contain',\n}: {\n product: Product;\n style?: object;\n contentFit?: 'contain' | 'cover';\n}) {\n const candidates = productImageCandidates(product);\n const [index, setIndex] = useState(0);\n useEffect(() => setIndex(0), [product.id, product.imageUrl, product.asin]);\n const uri = candidates[index];\n\n if (!uri) {\n return (\n <View style={[styles.fallback, style, { backgroundColor: `${product.accent}22` }]}>\n <Text style={styles.icon}>{product.icon}</Text>\n </View>\n );\n }\n\n return (\n <Image\n source={{ uri }}\n style={style}\n contentFit={contentFit}\n
|
|
1
|
+
{"version":3,"file":"ProductPhoto.js","sources":["../../../src/features/shopping/ProductPhoto.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { Image, type ImageLoadEventData } from 'expo-image';\nimport { StyleSheet, Text, View } from 'react-native';\nimport type { Product } from './catalog';\nimport { productImageCandidates } from './productImage';\n\n/**\n * A load that is really a \"no image\" answer. Amazon serves a missing\n * `/images/P/<ASIN>` as HTTP 200 with a 1x1 transparent GIF, so it never\n * errors - the tile just stayed blank and the next candidate was never tried.\n */\nexport function isPlaceholderImage(source: Pick<ImageLoadEventData['source'], 'width' | 'height'>): boolean {\n return source.width <= 1 || source.height <= 1;\n}\n\nexport function ProductPhoto({\n product,\n style,\n contentFit = 'contain',\n}: {\n product: Product;\n style?: object;\n contentFit?: 'contain' | 'cover';\n}) {\n const candidates = productImageCandidates(product);\n const [index, setIndex] = useState(0);\n useEffect(() => setIndex(0), [product.id, product.imageUrl, product.asin]);\n // Past the last candidate once every one has failed: the fallback, not a blank tile.\n const uri = candidates[index];\n const tryNext = () => setIndex((i) => i + 1);\n\n if (!uri) {\n return (\n <View style={[styles.fallback, style, { backgroundColor: `${product.accent}22` }]}>\n <Text style={styles.icon}>{product.icon}</Text>\n </View>\n );\n }\n\n return (\n <Image\n source={{ uri }}\n style={style}\n contentFit={contentFit}\n onLoad={(event) => {\n if (isPlaceholderImage(event.source)) tryNext();\n }}\n onError={tryNext}\n />\n );\n}\n\nconst styles = StyleSheet.create({\n fallback: { alignItems: 'center', justifyContent: 'center' },\n icon: { fontSize: 36 },\n});\n"],"names":[],"mappings":"iNAWO,SAAS,mBAAmB,MAAyE,EAAA;AAC1G,EAAA,OAAO,MAAO,CAAA,KAAA,IAAS,CAAK,IAAA,MAAA,CAAO,MAAU,IAAA,CAAA;AAC/C;AACO,SAAS,YAAa,CAAA;AAAA,EAC3B,OAAA;AAAA,EACA,KAAA;AAAA,EACA,UAAa,GAAA;AACf,CAIG,EAAA;AACD,EAAM,MAAA,UAAA,GAAa,uBAAuB,OAAO,CAAA;AACjD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,C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isProductSource}from'./catalog.js';import {ShoppingChatResultCard}from'./chat/ShoppingChatResultCard.js';import {extractShoppingAttachment,extractProductQueryFromAssistant,visibleAssistantContent,shouldUseHostLane,shouldRunNativeShopSearch,isGenericProductFindAsk,isVisualIdentifyQuery,isShoppingConversation,buildShoppingWidgetMessage}from'./chat/widgetContent.js';import {searchingLead,splitReplyChunks,delayMs}from'./chat/streamAssistantReply.js';import {parsePriceCheckStop,parsePriceCheckIntent}from'./services/parsePriceCheckIntent.js';import {SHOPPING_AGENT_FALLBACK,replyToNonShoppingTurn}from'./services/shoppingChatReply.js';import {classifyShoppingViaBrain}from'../../services/brainQuickReply.js';var __defProp = Object.defineProperty;
|
|
1
|
+
import {jsx}from'react/jsx-runtime';import {useState,useRef,useEffect}from'react';import {NativeAgentChat}from'../agent-chat/NativeAgentChat.js';import {departmentBadge,isProductSource}from'./catalog.js';import {ShoppingChatResultCard}from'./chat/ShoppingChatResultCard.js';import {extractShoppingAttachment,extractProductQueryFromAssistant,visibleAssistantContent,shouldUseHostLane,shouldRunNativeShopSearch,isGenericProductFindAsk,isVisualIdentifyQuery,isShoppingConversation,buildShoppingWidgetMessage}from'./chat/widgetContent.js';import {searchingLead,splitReplyChunks,delayMs}from'./chat/streamAssistantReply.js';import {listsProducts,namedRetailer,refersToAttachment,keepShownOrder,scopeToRetailer,retailerLabel}from'./chat/searchScope.js';import {parsePriceCheckStop,parsePriceCheckIntent}from'./services/parsePriceCheckIntent.js';import {SHOPPING_AGENT_FALLBACK,replyToNonShoppingTurn}from'./services/shoppingChatReply.js';import {classifyShoppingViaBrain}from'../../services/brainQuickReply.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -84,6 +84,7 @@ function ShoppingAgentChatPane({
|
|
|
84
84
|
const resultPumpStartedRef = useRef(false);
|
|
85
85
|
const latestResultRef = useRef(null);
|
|
86
86
|
const mirroredUiTurnRef = useRef(null);
|
|
87
|
+
const turnRetailerRef = useRef(null);
|
|
87
88
|
const hostMessages = (_a = hostChat == null ? void 0 : hostChat.messages) != null ? _a : [];
|
|
88
89
|
const shopTurns = localMessages.filter((m) => m.id.startsWith("shop-"));
|
|
89
90
|
const messages = hostMessages.length > 0 ? [...hostMessages, ...shopTurns] : localMessages;
|
|
@@ -172,10 +173,17 @@ function ShoppingAgentChatPane({
|
|
|
172
173
|
};
|
|
173
174
|
const runNativeShop = (query, showLocalTurns) => {
|
|
174
175
|
const gen = ++streamGen.current;
|
|
176
|
+
const retailer = turnRetailerRef.current;
|
|
175
177
|
committedShopRef.current = false;
|
|
176
178
|
resultPumpStartedRef.current = false;
|
|
177
179
|
latestResultRef.current = null;
|
|
178
|
-
|
|
180
|
+
const shaped = (result) => {
|
|
181
|
+
var _a2, _b;
|
|
182
|
+
return __spreadProps(__spreadValues({}, result), {
|
|
183
|
+
products: keepShownOrder((_b = (_a2 = latestResultRef.current) == null ? void 0 : _a2.products) != null ? _b : [], scopeToRetailer(result.products, retailer))
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
liveRef.current = searchingLead(query, retailer ? retailerLabel(retailer) : null);
|
|
179
187
|
setBusy(true);
|
|
180
188
|
setCardAttachment(null);
|
|
181
189
|
setCardProducts([]);
|
|
@@ -183,25 +191,26 @@ function ShoppingAgentChatPane({
|
|
|
183
191
|
void applyFromChat(query, (partial) => {
|
|
184
192
|
if (streamGen.current !== gen) return;
|
|
185
193
|
if (!partial.products.length && !partial.error) return;
|
|
186
|
-
latestResultRef.current = partial;
|
|
187
|
-
const shopBody = applyShopCard(
|
|
194
|
+
latestResultRef.current = shaped(partial);
|
|
195
|
+
const shopBody = applyShopCard(latestResultRef.current);
|
|
188
196
|
if (committedShopRef.current || resultPumpStartedRef.current) return;
|
|
189
197
|
resultPumpStartedRef.current = true;
|
|
190
198
|
void enqueuePump(gen, shopBody);
|
|
191
199
|
}).then(async (result) => {
|
|
192
200
|
if (streamGen.current !== gen) return;
|
|
193
|
-
if (result
|
|
201
|
+
if (!("products" in result)) {
|
|
194
202
|
if (showLocalTurns) await replyConversation(gen, query);
|
|
195
203
|
return;
|
|
196
204
|
}
|
|
197
205
|
if (!resultPumpStartedRef.current) {
|
|
198
206
|
resultPumpStartedRef.current = true;
|
|
199
|
-
|
|
207
|
+
latestResultRef.current = shaped(result);
|
|
208
|
+
await enqueuePump(gen, applyShopCard(latestResultRef.current));
|
|
200
209
|
} else {
|
|
201
210
|
await pumpChain.current;
|
|
202
211
|
}
|
|
203
212
|
if (streamGen.current !== gen) return;
|
|
204
|
-
const latest = latestResultRef.current || result;
|
|
213
|
+
const latest = latestResultRef.current || shaped(result);
|
|
205
214
|
commitShopTurn(gen, liveRef.current || bodyFromResult(latest).shopBody);
|
|
206
215
|
applyShopCard(latest);
|
|
207
216
|
}).catch(async (err) => {
|
|
@@ -229,7 +238,7 @@ ${(_b = hostChat == null ? void 0 : hostChat.streaming) != null ? _b : ""}`;
|
|
|
229
238
|
pendingVisionShop.current = false;
|
|
230
239
|
return;
|
|
231
240
|
}
|
|
232
|
-
const query = extractProductQueryFromAssistant(text);
|
|
241
|
+
const query = listsProducts(text) ? null : extractProductQueryFromAssistant(text);
|
|
233
242
|
if (!query) {
|
|
234
243
|
pendingVisionShop.current = false;
|
|
235
244
|
return;
|
|
@@ -285,6 +294,7 @@ ${(_b = hostChat == null ? void 0 : hostChat.streaming) != null ? _b : ""}`;
|
|
|
285
294
|
streamGen.current += 1;
|
|
286
295
|
setShopStream(null);
|
|
287
296
|
inFlight.current = true;
|
|
297
|
+
turnRetailerRef.current = namedRetailer(trimmed);
|
|
288
298
|
const fileCount = (_a2 = files == null ? void 0 : files.length) != null ? _a2 : 0;
|
|
289
299
|
const useHost = Boolean(hostChat) && shouldUseHostLane(trimmed, fileCount);
|
|
290
300
|
const fillShop = shouldRunNativeShopSearch(trimmed);
|
|
@@ -306,7 +316,7 @@ ${(_b = hostChat == null ? void 0 : hostChat.streaming) != null ? _b : ""}`;
|
|
|
306
316
|
}
|
|
307
317
|
hostChat.send(trimmed, files);
|
|
308
318
|
setLocalMessages((prev) => prev.filter((m) => !m.id.startsWith("shop-")));
|
|
309
|
-
if (fillShop && isGenericProductFindAsk(trimmed)) {
|
|
319
|
+
if (fillShop && (isGenericProductFindAsk(trimmed) || fileCount > 0 && refersToAttachment(trimmed))) {
|
|
310
320
|
pendingVisionShop.current = true;
|
|
311
321
|
inFlight.current = false;
|
|
312
322
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShoppingAgentChatPane.js","sources":["../../../src/features/shopping/ShoppingAgentChatPane.tsx"],"sourcesContent":["/**\n * Shopping Agent adapter — same role as web HostedShoppingChatPane:\n * product asks fill the shop grid; images and open questions go on host chat\n * (vision + tools). \"Find products\" + a photo still runs native shop search\n * once the agent names the item.\n */\nimport React, { useEffect, useRef, useState } from 'react';\nimport { NativeAgentChat, type AgentChatMessage } from '../agent-chat';\nimport { departmentBadge, isProductSource, type Product } from './catalog';\nimport { ShoppingChatResultCard } from './chat/ShoppingChatResultCard';\nimport {\n buildShoppingWidgetMessage,\n extractProductQueryFromAssistant,\n extractShoppingAttachment,\n isGenericProductFindAsk,\n isShoppingConversation,\n isVisualIdentifyQuery,\n shouldRunNativeShopSearch,\n shouldUseHostLane,\n visibleAssistantContent,\n type ShoppingChatAttachment,\n} from './chat/widgetContent';\nimport { delayMs, searchingLead, splitReplyChunks } from './chat/streamAssistantReply';\nimport { parsePriceCheckIntent, parsePriceCheckStop } from './services/parsePriceCheckIntent';\nimport { replyToNonShoppingTurn, SHOPPING_AGENT_FALLBACK } from './services/shoppingChatReply';\nimport { classifyShoppingViaBrain } from '../../services/brainQuickReply';\nimport type { MessageAttachment } from '../../hooks/useChatStream';\nimport type {\n ApplyFromChatResult,\n ShoppingSearchProgress,\n ShoppingSearchRunResult,\n ShoppingUiSearchTurn,\n} from './useShoppingSearch';\nimport type { ShoppingHostChat } from './hostChat';\n\nconst STREAM_TICK_MS = 16;\n\nfunction productsFromAttachment(attachment: ShoppingChatAttachment): Product[] {\n const dept = departmentBadge();\n return attachment.properties.map((item, index) => ({\n id: item.id ?? `attach-${index}`,\n name: item.title,\n departmentId: dept.id,\n price: typeof item.price === 'number' ? item.price : 0,\n rating: typeof item.rating === 'number' ? item.rating : 0,\n reviews: typeof item.reviews === 'number' ? item.reviews : 0,\n icon: dept.icon,\n accent: dept.accent,\n ...(item.imageUrl ? { imageUrl: item.imageUrl } : {}),\n ...(item.url ? { url: item.url } : {}),\n ...(item.source && isProductSource(item.source) ? { source: item.source } : {}),\n ...(typeof item.inStock === 'boolean' ? { inStock: item.inStock } : {}),\n }));\n}\n\nfunction priceMonitorReply(kind: 'watch' | 'stop', query: string, targetPrice?: number): string {\n if (kind === 'stop') {\n return 'Price checks on this phone use the Watchlist tab. Open Watchlist and refresh — live browser checks still run on Computer, not here.';\n }\n const target =\n typeof targetPrice === 'number' && targetPrice > 0 ? ` (alert below $${Math.round(targetPrice)})` : '';\n const named = query.trim() ? `I can watch **${query.trim()}**${target}.` : `I can watch prices for you${target}.`;\n return `${named} Search the product first, open it, then tap **Watch this price**. Live hourly checks run on Computer; this phone shows the indexed watchlist.`;\n}\n\nexport function ShoppingAgentChatPane({\n visible,\n onClose,\n hostChat,\n applyFromChat,\n products,\n onViewProducts,\n onOpenProduct,\n isDark,\n ink,\n muted,\n screen,\n border,\n card,\n seedTurn = null,\n uiSearchTurn = null,\n}: {\n visible: boolean;\n onClose: () => void;\n hostChat?: ShoppingHostChat;\n applyFromChat: (\n text: string,\n onProgress?: (progress: ShoppingSearchProgress) => void,\n ) => Promise<ApplyFromChatResult>;\n products: Product[];\n onViewProducts: () => void;\n onOpenProduct: (product: Product) => void;\n isDark: boolean;\n ink: string;\n muted: string;\n screen: string;\n border: string;\n card: string;\n seedTurn?: { text: string; files?: MessageAttachment[] } | null;\n /** Page search box turn — mirrored into this pane like web HostedShoppingChatPane. */\n uiSearchTurn?: ShoppingUiSearchTurn | null;\n}) {\n const [localMessages, setLocalMessages] = useState<AgentChatMessage[]>([]);\n const [busy, setBusy] = useState(false);\n const [cardAttachment, setCardAttachment] = useState<ShoppingChatAttachment | null>(null);\n const [cardProducts, setCardProducts] = useState<Product[]>([]);\n const [shopStream, setShopStream] = useState<string | null>(null);\n const inFlight = useRef(false);\n const pendingVisionShop = useRef(false);\n const wasHostBusy = useRef(false);\n const seededKey = useRef<string | null>(null);\n const streamGen = useRef(0);\n const liveRef = useRef('');\n const pumpChain = useRef(Promise.resolve());\n const committedShopRef = useRef(false);\n const resultPumpStartedRef = useRef(false);\n const latestResultRef = useRef<ShoppingSearchRunResult | null>(null);\n const mirroredUiTurnRef = useRef<{ id: number; phase: string } | null>(null);\n\n const hostMessages = hostChat?.messages ?? [];\n const shopTurns = localMessages.filter((m) => m.id.startsWith('shop-'));\n const messages = hostMessages.length > 0 ? [...hostMessages, ...shopTurns] : localMessages;\n\n const pumpTo = async (gen: number, target: string) => {\n if (streamGen.current !== gen) return;\n let current = liveRef.current;\n if (target === current) return;\n if (!target.startsWith(current)) {\n current = '';\n liveRef.current = '';\n }\n const rest = target.slice(current.length);\n for (const chunk of splitReplyChunks(rest)) {\n if (streamGen.current !== gen) return;\n liveRef.current += chunk;\n setShopStream(liveRef.current);\n await delayMs(STREAM_TICK_MS);\n }\n };\n\n const enqueuePump = (gen: number, target: string) => {\n pumpChain.current = pumpChain.current.then(() => pumpTo(gen, target)).catch(() => undefined);\n return pumpChain.current;\n };\n\n const bodyFromResult = (result: ShoppingSearchRunResult) => {\n const raw =\n result.products.length > 0\n ? buildShoppingWidgetMessage(result.products, result.query)\n : result.error || SHOPPING_AGENT_FALLBACK;\n const shopBody = visibleAssistantContent(raw) || result.error || SHOPPING_AGENT_FALLBACK;\n return { shopBody, attachment: extractShoppingAttachment(raw) };\n };\n\n const applyShopCard = (result: ShoppingSearchRunResult) => {\n const { shopBody, attachment } = bodyFromResult(result);\n if (attachment) {\n setCardAttachment(attachment);\n setCardProducts(productsFromAttachment(attachment));\n }\n if (committedShopRef.current) {\n setLocalMessages((prev) =>\n prev.map((row) => (row.id.startsWith('shop-') ? { ...row, content: shopBody } : row)),\n );\n }\n return shopBody;\n };\n\n const commitShopTurn = (gen: number, shopBody: string) => {\n if (streamGen.current !== gen || committedShopRef.current) return;\n committedShopRef.current = true;\n setLocalMessages((prev) => [\n ...prev.filter((row) => !row.id.startsWith('shop-')),\n { id: `shop-${Date.now()}`, role: 'assistant', content: shopBody },\n ]);\n setShopStream(null);\n liveRef.current = '';\n };\n\n const replyLocalAssistant = async (gen: number, body: string) => {\n await enqueuePump(gen, body);\n if (streamGen.current !== gen) return;\n setLocalMessages((prev) => [...prev, { id: `a-${Date.now()}`, role: 'assistant', content: body }]);\n setShopStream(null);\n liveRef.current = '';\n };\n\n /**\n * Give the turn to the agent instead of answering it here.\n *\n * This pane can search a catalog and keep a cart, and that is all. A turn\n * about a PAGE - their Computer, a retailer's own site, the cart on their\n * account, checkout, or an item already on screen - needs the connectors\n * the host chat has and this pane does not. Answering it from here is what\n * produced \"I don't use your computer to add items\" and then five rounds\n * of \"I don't see a specific product mentioned yet\" while the person was\n * looking at the product on their Computer.\n *\n * Returns false when there is no agent to hand to, so the caller can fall\n * back to its own reply rather than swallowing the turn.\n */\n const handOffToAgent = (gen: number, text: string, files?: MessageAttachment[], userId?: string) => {\n if (!hostChat?.connected) return false;\n // The host transcript renders the user's turn itself; drop the local\n // echo so the question is not asked twice on screen.\n if (userId) setLocalMessages((prev) => prev.filter((m) => m.id !== userId));\n streamGen.current = gen;\n setShopStream(null);\n liveRef.current = '';\n hostChat.send(text, files);\n return true;\n };\n\n const replyConversation = async (gen: number, text: string) => {\n const history = messages\n .filter((m) => m.role === 'user' || m.role === 'assistant')\n .map((m) => ({ role: m.role as 'user' | 'assistant', content: m.content }));\n const brain = await replyToNonShoppingTurn(text, history);\n await replyLocalAssistant(gen, brain || SHOPPING_AGENT_FALLBACK);\n };\n\n const runNativeShop = (query: string, showLocalTurns: boolean) => {\n const gen = ++streamGen.current;\n committedShopRef.current = false;\n resultPumpStartedRef.current = false;\n latestResultRef.current = null;\n liveRef.current = searchingLead(query);\n setBusy(true);\n setCardAttachment(null);\n setCardProducts([]);\n setShopStream(liveRef.current);\n void applyFromChat(query, (partial) => {\n if (streamGen.current !== gen) return;\n if (!partial.products.length && !partial.error) return;\n latestResultRef.current = partial;\n const shopBody = applyShopCard(partial);\n if (committedShopRef.current || resultPumpStartedRef.current) return;\n resultPumpStartedRef.current = true;\n void enqueuePump(gen, shopBody);\n })\n .then(async (result) => {\n if (streamGen.current !== gen) return;\n if (result.conversation) {\n if (showLocalTurns) await replyConversation(gen, query);\n return;\n }\n if (!resultPumpStartedRef.current) {\n resultPumpStartedRef.current = true;\n await enqueuePump(gen, applyShopCard(result));\n } else {\n await pumpChain.current;\n }\n if (streamGen.current !== gen) return;\n const latest = latestResultRef.current || result;\n commitShopTurn(gen, liveRef.current || bodyFromResult(latest).shopBody);\n applyShopCard(latest);\n })\n .catch(async (err) => {\n if (streamGen.current !== gen || !showLocalTurns) return;\n const message = err instanceof Error ? err.message : 'Shopping search failed.';\n await replyLocalAssistant(gen, message);\n })\n .finally(() => {\n if (streamGen.current !== gen) return;\n inFlight.current = false;\n setBusy(false);\n });\n };\n\n useEffect(() => {\n const hostBusy = Boolean(hostChat?.busy);\n const finished = wasHostBusy.current && !hostBusy;\n wasHostBusy.current = hostBusy;\n if (!finished || !pendingVisionShop.current) return;\n const last = [...hostMessages].reverse().find((m) => m.role === 'assistant');\n const text = `${last?.content ?? ''}\\n${hostChat?.streaming ?? ''}`;\n const widget = extractShoppingAttachment(text);\n if (widget) {\n setCardAttachment(widget);\n pendingVisionShop.current = false;\n return;\n }\n const query = extractProductQueryFromAssistant(text);\n if (!query) {\n pendingVisionShop.current = false;\n return;\n }\n pendingVisionShop.current = false;\n runNativeShop(query, false);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- fire once when the host turn ends\n }, [hostChat?.busy, hostMessages, hostChat?.streaming]);\n\n useEffect(() => {\n if (!uiSearchTurn || !visible) return;\n if (\n mirroredUiTurnRef.current?.id === uiSearchTurn.id &&\n mirroredUiTurnRef.current.phase === uiSearchTurn.status\n ) {\n return;\n }\n mirroredUiTurnRef.current = { id: uiSearchTurn.id, phase: uiSearchTurn.status };\n\n if (uiSearchTurn.status === 'running') {\n streamGen.current += 1;\n setShopStream(null);\n liveRef.current = '';\n setCardAttachment(null);\n setCardProducts([]);\n setBusy(true);\n setLocalMessages((prev) => [\n ...prev.filter((m) => !m.id.startsWith('ui-')),\n {\n id: `ui-u-${uiSearchTurn.id}`,\n role: 'user',\n content: uiSearchTurn.query,\n createdAt: new Date().toISOString(),\n },\n ]);\n return;\n }\n\n setBusy(false);\n const raw = uiSearchTurn.messageContent ?? '';\n const visibleProse = visibleAssistantContent(raw) || raw;\n if (visibleProse.trim()) {\n setLocalMessages((prev) => [\n ...prev.filter((m) => m.id !== `ui-a-${uiSearchTurn.id}`),\n {\n id: `ui-a-${uiSearchTurn.id}`,\n role: 'assistant',\n content: visibleProse,\n createdAt: new Date().toISOString(),\n },\n ]);\n }\n if (uiSearchTurn.attachment?.properties?.length) {\n setCardAttachment(uiSearchTurn.attachment);\n setCardProducts(productsFromAttachment(uiSearchTurn.attachment));\n }\n }, [uiSearchTurn, visible]);\n\n const send = (text: string, files?: MessageAttachment[]) => {\n const trimmed = text.trim();\n if (!trimmed && !files?.length) return;\n streamGen.current += 1;\n setShopStream(null);\n inFlight.current = true;\n const fileCount = files?.length ?? 0;\n const useHost = Boolean(hostChat) && shouldUseHostLane(trimmed, fileCount);\n const fillShop = shouldRunNativeShopSearch(trimmed);\n\n if (useHost && hostChat) {\n if (!hostChat.connected) {\n setLocalMessages((prev) => [\n ...prev,\n {\n id: `u-${Date.now()}`,\n role: 'user',\n content: trimmed,\n ...(files?.length ? { attachments: files } : {}),\n },\n {\n id: `a-${Date.now()}`,\n role: 'assistant',\n content:\n hostChat.error ||\n 'CDeCLI is not connected yet. Check gateway status in the header, then send the image again.',\n },\n ]);\n inFlight.current = false;\n return;\n }\n hostChat.send(trimmed, files);\n setLocalMessages((prev) => prev.filter((m) => !m.id.startsWith('shop-')));\n if (fillShop && isGenericProductFindAsk(trimmed)) {\n pendingVisionShop.current = true;\n inFlight.current = false;\n return;\n }\n if (fillShop) {\n runNativeShop(trimmed, false);\n return;\n }\n inFlight.current = false;\n return;\n }\n\n const user: AgentChatMessage = {\n id: `u-${Date.now()}`,\n role: 'user',\n content: trimmed,\n createdAt: new Date().toISOString(),\n ...(files?.length ? { attachments: files } : {}),\n };\n setLocalMessages((prev) => [...prev, user]);\n setCardAttachment(null);\n setCardProducts([]);\n\n if (fileCount > 0 || isVisualIdentifyQuery(trimmed)) {\n setLocalMessages((prev) => [\n ...prev,\n {\n id: `a-${Date.now()}`,\n role: 'assistant',\n content:\n 'I received the image, but this shop session is not connected to the agent yet. Connect CDeCLI in the header and send again — same as web Shopping Agent.',\n },\n ]);\n inFlight.current = false;\n return;\n }\n\n const gen = ++streamGen.current;\n setBusy(true);\n void (async () => {\n try {\n if (parsePriceCheckStop(trimmed)) {\n await replyLocalAssistant(gen, priceMonitorReply('stop', ''));\n return;\n }\n const priceCheck = parsePriceCheckIntent(trimmed);\n if (priceCheck) {\n await replyLocalAssistant(\n gen,\n priceMonitorReply('watch', priceCheck.query, priceCheck.targetPrice),\n );\n return;\n }\n\n let brainQuery: string | null = null;\n try {\n const verdict = await classifyShoppingViaBrain(trimmed, { timeoutMs: 2500 });\n if (verdict.status === 'ok' && verdict.monitor === 'stop') {\n await replyLocalAssistant(gen, priceMonitorReply('stop', ''));\n return;\n }\n if (verdict.status === 'ok' && verdict.monitor === 'watch') {\n await replyLocalAssistant(gen, priceMonitorReply('watch', verdict.query, verdict.targetPrice));\n return;\n }\n if (isShoppingConversation(trimmed)) {\n await replyConversation(gen, trimmed);\n return;\n }\n if (verdict.status === 'declined') {\n // The brain declined to read this as a product search.\n // That verdict is the routing decision - the pane does\n // not second-guess it with a regex - and what is left\n // is almost always a page the person is looking at.\n if (handOffToAgent(gen, trimmed, files, user.id)) return;\n await replyConversation(gen, trimmed);\n return;\n }\n if (verdict.status === 'ok' && verdict.query) brainQuery = verdict.query;\n } catch {\n if (isShoppingConversation(trimmed)) {\n await replyConversation(gen, trimmed);\n return;\n }\n }\n\n if (isShoppingConversation(trimmed)) {\n await replyConversation(gen, trimmed);\n return;\n }\n\n // Hand off to search — it owns busy/streamGen from here.\n inFlight.current = false;\n runNativeShop(brainQuery || trimmed, true);\n } finally {\n // Only clear busy when we did not hand off to runNativeShop\n // (runNativeShop bumps streamGen and manages its own busy flag).\n if (streamGen.current === gen) {\n inFlight.current = false;\n setBusy(false);\n }\n }\n })();\n };\n\n useEffect(() => {\n inFlight.current = false;\n streamGen.current += 1;\n setShopStream(null);\n }, [visible]);\n\n useEffect(() => {\n if (!visible || !seedTurn) return;\n const key = `${seedTurn.text}\\0${(seedTurn.files ?? []).map((file) => file.id ?? file.name ?? '').join(',')}`;\n if (seededKey.current === key) return;\n seededKey.current = key;\n const timer = setTimeout(() => send(seedTurn.text, seedTurn.files), 50);\n return () => clearTimeout(timer);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- seed once per handoff\n }, [visible, seedTurn]);\n\n return (\n <NativeAgentChat\n title=\"Shopping Agent\"\n visible={visible}\n onClose={onClose}\n onSwipeLeft={onClose}\n messages={messages}\n onSend={send}\n renderConnectorCard={hostChat?.renderConnectorCard}\n onClear={() => {\n streamGen.current += 1;\n setLocalMessages([]);\n setCardAttachment(null);\n setCardProducts([]);\n setShopStream(null);\n pendingVisionShop.current = false;\n hostChat?.clear?.();\n }}\n busy={busy || Boolean(hostChat?.busy)}\n streamingContent={shopStream || hostChat?.streaming}\n error={hostChat?.error}\n placeholder={'What are you looking for? e.g. \"running shoes under $120\"'}\n emptyTitle=\"What are you shopping for?\"\n emptyBody=\"Ask for a product in plain language, or send a photo — I'll look at it the same way as web Shop.\"\n suggestions={[\n { id: 'shoes', label: 'Running shoes under $120', prompt: 'running shoes under $120' },\n { id: 'laptop', label: 'Apple laptop', prompt: 'apple laptop' },\n { id: 'iphone', label: 'iPhone 17', prompt: 'buy iPhone 17' },\n ]}\n isDark={isDark}\n ink={ink}\n muted={muted}\n screen={screen}\n border={border}\n composerLead={\n cardAttachment ? (\n <ShoppingChatResultCard\n attachment={cardAttachment}\n products={[...products, ...cardProducts]}\n ink={ink}\n muted={muted}\n border={border}\n card={card}\n onViewProducts={onViewProducts}\n onOpenItem={onOpenProduct}\n />\n ) : null\n }\n />\n );\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAM,cAAiB,GAAA,EAAA;AACvB,SAAS,uBAAuB,UAA+C,EAAA;AAC7E,EAAA,MAAM,OAAO,eAAgB,EAAA;AAC7B,EAAA,OAAO,UAAW,CAAA,UAAA,CAAW,GAAI,CAAA,CAAC,MAAM,KAAO,KAAA;AArBjD,IAAA,IAAA,EAAA;AAqBqD,IAAA,OAAA,cAAA,CAAA,cAAA,CAAA,cAAA,CAAA,cAAA,CAAA;AAAA,MACjD,EAAI,EAAA,CAAA,EAAA,GAAA,IAAA,CAAK,EAAL,KAAA,IAAA,GAAA,EAAA,GAAW,UAAU,KAAK,CAAA,CAAA;AAAA,MAC9B,MAAM,IAAK,CAAA,KAAA;AAAA,MACX,cAAc,IAAK,CAAA,EAAA;AAAA,MACnB,OAAO,OAAO,IAAA,CAAK,KAAU,KAAA,QAAA,GAAW,KAAK,KAAQ,GAAA,CAAA;AAAA,MACrD,QAAQ,OAAO,IAAA,CAAK,MAAW,KAAA,QAAA,GAAW,KAAK,MAAS,GAAA,CAAA;AAAA,MACxD,SAAS,OAAO,IAAA,CAAK,OAAY,KAAA,QAAA,GAAW,KAAK,OAAU,GAAA,CAAA;AAAA,MAC3D,MAAM,IAAK,CAAA,IAAA;AAAA,MACX,QAAQ,IAAK,C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shopping/ShoppingAgentChatPane.tsx"],"sourcesContent":["/**\n * Shopping Agent adapter — same role as web HostedShoppingChatPane:\n * product asks fill the shop grid; images and open questions go on host chat\n * (vision + tools). \"Find products\" + a photo still runs native shop search\n * once the agent names the item.\n */\nimport React, { useEffect, useRef, useState } from 'react';\nimport { NativeAgentChat, type AgentChatMessage } from '../agent-chat';\nimport { departmentBadge, isProductSource, type Product, type ProductSource } from './catalog';\nimport { ShoppingChatResultCard } from './chat/ShoppingChatResultCard';\nimport {\n buildShoppingWidgetMessage,\n extractProductQueryFromAssistant,\n extractShoppingAttachment,\n isGenericProductFindAsk,\n isShoppingConversation,\n isVisualIdentifyQuery,\n shouldRunNativeShopSearch,\n shouldUseHostLane,\n visibleAssistantContent,\n type ShoppingChatAttachment,\n} from './chat/widgetContent';\nimport { delayMs, searchingLead, splitReplyChunks } from './chat/streamAssistantReply';\nimport {\n keepShownOrder,\n listsProducts,\n namedRetailer,\n refersToAttachment,\n retailerLabel,\n scopeToRetailer,\n} from './chat/searchScope';\nimport { parsePriceCheckIntent, parsePriceCheckStop } from './services/parsePriceCheckIntent';\nimport { replyToNonShoppingTurn, SHOPPING_AGENT_FALLBACK } from './services/shoppingChatReply';\nimport { classifyShoppingViaBrain } from '../../services/brainQuickReply';\nimport type { MessageAttachment } from '../../hooks/useChatStream';\nimport type {\n ApplyFromChatResult,\n ShoppingSearchProgress,\n ShoppingSearchRunResult,\n ShoppingUiSearchTurn,\n} from './useShoppingSearch';\nimport type { ShoppingHostChat } from './hostChat';\n\nconst STREAM_TICK_MS = 16;\n\nfunction productsFromAttachment(attachment: ShoppingChatAttachment): Product[] {\n const dept = departmentBadge();\n return attachment.properties.map((item, index) => ({\n id: item.id ?? `attach-${index}`,\n name: item.title,\n departmentId: dept.id,\n price: typeof item.price === 'number' ? item.price : 0,\n rating: typeof item.rating === 'number' ? item.rating : 0,\n reviews: typeof item.reviews === 'number' ? item.reviews : 0,\n icon: dept.icon,\n accent: dept.accent,\n ...(item.imageUrl ? { imageUrl: item.imageUrl } : {}),\n ...(item.url ? { url: item.url } : {}),\n ...(item.source && isProductSource(item.source) ? { source: item.source } : {}),\n ...(typeof item.inStock === 'boolean' ? { inStock: item.inStock } : {}),\n }));\n}\n\nfunction priceMonitorReply(kind: 'watch' | 'stop', query: string, targetPrice?: number): string {\n if (kind === 'stop') {\n return 'Price checks on this phone use the Watchlist tab. Open Watchlist and refresh — live browser checks still run on Computer, not here.';\n }\n const target =\n typeof targetPrice === 'number' && targetPrice > 0 ? ` (alert below $${Math.round(targetPrice)})` : '';\n const named = query.trim() ? `I can watch **${query.trim()}**${target}.` : `I can watch prices for you${target}.`;\n return `${named} Search the product first, open it, then tap **Watch this price**. Live hourly checks run on Computer; this phone shows the indexed watchlist.`;\n}\n\nexport function ShoppingAgentChatPane({\n visible,\n onClose,\n hostChat,\n applyFromChat,\n products,\n onViewProducts,\n onOpenProduct,\n isDark,\n ink,\n muted,\n screen,\n border,\n card,\n seedTurn = null,\n uiSearchTurn = null,\n}: {\n visible: boolean;\n onClose: () => void;\n hostChat?: ShoppingHostChat;\n applyFromChat: (\n text: string,\n onProgress?: (progress: ShoppingSearchProgress) => void,\n ) => Promise<ApplyFromChatResult>;\n products: Product[];\n onViewProducts: () => void;\n onOpenProduct: (product: Product) => void;\n isDark: boolean;\n ink: string;\n muted: string;\n screen: string;\n border: string;\n card: string;\n seedTurn?: { text: string; files?: MessageAttachment[] } | null;\n /** Page search box turn — mirrored into this pane like web HostedShoppingChatPane. */\n uiSearchTurn?: ShoppingUiSearchTurn | null;\n}) {\n const [localMessages, setLocalMessages] = useState<AgentChatMessage[]>([]);\n const [busy, setBusy] = useState(false);\n const [cardAttachment, setCardAttachment] = useState<ShoppingChatAttachment | null>(null);\n const [cardProducts, setCardProducts] = useState<Product[]>([]);\n const [shopStream, setShopStream] = useState<string | null>(null);\n const inFlight = useRef(false);\n const pendingVisionShop = useRef(false);\n const wasHostBusy = useRef(false);\n const seededKey = useRef<string | null>(null);\n const streamGen = useRef(0);\n const liveRef = useRef('');\n const pumpChain = useRef(Promise.resolve());\n const committedShopRef = useRef(false);\n const resultPumpStartedRef = useRef(false);\n const latestResultRef = useRef<ShoppingSearchRunResult | null>(null);\n const mirroredUiTurnRef = useRef<{ id: number; phase: string } | null>(null);\n /** The retailer the current ask named (\"in amazon\"); its search is scoped to it. */\n const turnRetailerRef = useRef<ProductSource | null>(null);\n\n const hostMessages = hostChat?.messages ?? [];\n const shopTurns = localMessages.filter((m) => m.id.startsWith('shop-'));\n const messages = hostMessages.length > 0 ? [...hostMessages, ...shopTurns] : localMessages;\n\n const pumpTo = async (gen: number, target: string) => {\n if (streamGen.current !== gen) return;\n let current = liveRef.current;\n if (target === current) return;\n if (!target.startsWith(current)) {\n current = '';\n liveRef.current = '';\n }\n const rest = target.slice(current.length);\n for (const chunk of splitReplyChunks(rest)) {\n if (streamGen.current !== gen) return;\n liveRef.current += chunk;\n setShopStream(liveRef.current);\n await delayMs(STREAM_TICK_MS);\n }\n };\n\n const enqueuePump = (gen: number, target: string) => {\n pumpChain.current = pumpChain.current.then(() => pumpTo(gen, target)).catch(() => undefined);\n return pumpChain.current;\n };\n\n const bodyFromResult = (result: ShoppingSearchRunResult) => {\n const raw =\n result.products.length > 0\n ? buildShoppingWidgetMessage(result.products, result.query)\n : result.error || SHOPPING_AGENT_FALLBACK;\n const shopBody = visibleAssistantContent(raw) || result.error || SHOPPING_AGENT_FALLBACK;\n return { shopBody, attachment: extractShoppingAttachment(raw) };\n };\n\n const applyShopCard = (result: ShoppingSearchRunResult) => {\n const { shopBody, attachment } = bodyFromResult(result);\n if (attachment) {\n setCardAttachment(attachment);\n setCardProducts(productsFromAttachment(attachment));\n }\n if (committedShopRef.current) {\n setLocalMessages((prev) =>\n prev.map((row) => (row.id.startsWith('shop-') ? { ...row, content: shopBody } : row)),\n );\n }\n return shopBody;\n };\n\n const commitShopTurn = (gen: number, shopBody: string) => {\n if (streamGen.current !== gen || committedShopRef.current) return;\n committedShopRef.current = true;\n setLocalMessages((prev) => [\n ...prev.filter((row) => !row.id.startsWith('shop-')),\n { id: `shop-${Date.now()}`, role: 'assistant', content: shopBody },\n ]);\n setShopStream(null);\n liveRef.current = '';\n };\n\n const replyLocalAssistant = async (gen: number, body: string) => {\n await enqueuePump(gen, body);\n if (streamGen.current !== gen) return;\n setLocalMessages((prev) => [...prev, { id: `a-${Date.now()}`, role: 'assistant', content: body }]);\n setShopStream(null);\n liveRef.current = '';\n };\n\n /**\n * Give the turn to the agent instead of answering it here.\n *\n * This pane can search a catalog and keep a cart, and that is all. A turn\n * about a PAGE - their Computer, a retailer's own site, the cart on their\n * account, checkout, or an item already on screen - needs the connectors\n * the host chat has and this pane does not. Answering it from here is what\n * produced \"I don't use your computer to add items\" and then five rounds\n * of \"I don't see a specific product mentioned yet\" while the person was\n * looking at the product on their Computer.\n *\n * Returns false when there is no agent to hand to, so the caller can fall\n * back to its own reply rather than swallowing the turn.\n */\n const handOffToAgent = (gen: number, text: string, files?: MessageAttachment[], userId?: string) => {\n if (!hostChat?.connected) return false;\n // The host transcript renders the user's turn itself; drop the local\n // echo so the question is not asked twice on screen.\n if (userId) setLocalMessages((prev) => prev.filter((m) => m.id !== userId));\n streamGen.current = gen;\n setShopStream(null);\n liveRef.current = '';\n hostChat.send(text, files);\n return true;\n };\n\n const replyConversation = async (gen: number, text: string) => {\n const history = messages\n .filter((m) => m.role === 'user' || m.role === 'assistant')\n .map((m) => ({ role: m.role as 'user' | 'assistant', content: m.content }));\n const brain = await replyToNonShoppingTurn(text, history);\n await replyLocalAssistant(gen, brain || SHOPPING_AGENT_FALLBACK);\n };\n\n const runNativeShop = (query: string, showLocalTurns: boolean) => {\n const gen = ++streamGen.current;\n const retailer = turnRetailerRef.current;\n committedShopRef.current = false;\n resultPumpStartedRef.current = false;\n latestResultRef.current = null;\n // Each phase is scoped to the retailer the ask named and keeps the rows\n // already shown where they are, so the cross-retailer phase grows the\n // card instead of rewriting the reply under the person's eyes.\n const shaped = (result: ShoppingSearchRunResult): ShoppingSearchRunResult => ({\n ...result,\n products: keepShownOrder(\n latestResultRef.current?.products ?? [],\n scopeToRetailer(result.products, retailer),\n ),\n });\n liveRef.current = searchingLead(query, retailer ? retailerLabel(retailer) : null);\n setBusy(true);\n setCardAttachment(null);\n setCardProducts([]);\n setShopStream(liveRef.current);\n void applyFromChat(query, (partial) => {\n if (streamGen.current !== gen) return;\n if (!partial.products.length && !partial.error) return;\n latestResultRef.current = shaped(partial);\n const shopBody = applyShopCard(latestResultRef.current);\n if (committedShopRef.current || resultPumpStartedRef.current) return;\n resultPumpStartedRef.current = true;\n void enqueuePump(gen, shopBody);\n })\n .then(async (result) => {\n if (streamGen.current !== gen) return;\n // `in`, not `result.conversation`: without strictNullChecks a boolean\n // discriminant does not narrow the union.\n if (!('products' in result)) {\n if (showLocalTurns) await replyConversation(gen, query);\n return;\n }\n if (!resultPumpStartedRef.current) {\n resultPumpStartedRef.current = true;\n latestResultRef.current = shaped(result);\n await enqueuePump(gen, applyShopCard(latestResultRef.current));\n } else {\n await pumpChain.current;\n }\n if (streamGen.current !== gen) return;\n const latest = latestResultRef.current || shaped(result);\n commitShopTurn(gen, liveRef.current || bodyFromResult(latest).shopBody);\n applyShopCard(latest);\n })\n .catch(async (err) => {\n if (streamGen.current !== gen || !showLocalTurns) return;\n const message = err instanceof Error ? err.message : 'Shopping search failed.';\n await replyLocalAssistant(gen, message);\n })\n .finally(() => {\n if (streamGen.current !== gen) return;\n inFlight.current = false;\n setBusy(false);\n });\n };\n\n useEffect(() => {\n const hostBusy = Boolean(hostChat?.busy);\n const finished = wasHostBusy.current && !hostBusy;\n wasHostBusy.current = hostBusy;\n if (!finished || !pendingVisionShop.current) return;\n const last = [...hostMessages].reverse().find((m) => m.role === 'assistant');\n const text = `${last?.content ?? ''}\\n${hostChat?.streaming ?? ''}`;\n const widget = extractShoppingAttachment(text);\n if (widget) {\n setCardAttachment(widget);\n pendingVisionShop.current = false;\n return;\n }\n // An agent that already searched answers with linked products. A second,\n // native search on a query guessed from that prose only adds a weaker answer\n // under the real one.\n const query = listsProducts(text) ? null : extractProductQueryFromAssistant(text);\n if (!query) {\n pendingVisionShop.current = false;\n return;\n }\n pendingVisionShop.current = false;\n runNativeShop(query, false);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- fire once when the host turn ends\n }, [hostChat?.busy, hostMessages, hostChat?.streaming]);\n\n useEffect(() => {\n if (!uiSearchTurn || !visible) return;\n if (\n mirroredUiTurnRef.current?.id === uiSearchTurn.id &&\n mirroredUiTurnRef.current.phase === uiSearchTurn.status\n ) {\n return;\n }\n mirroredUiTurnRef.current = { id: uiSearchTurn.id, phase: uiSearchTurn.status };\n\n if (uiSearchTurn.status === 'running') {\n streamGen.current += 1;\n setShopStream(null);\n liveRef.current = '';\n setCardAttachment(null);\n setCardProducts([]);\n setBusy(true);\n setLocalMessages((prev) => [\n ...prev.filter((m) => !m.id.startsWith('ui-')),\n {\n id: `ui-u-${uiSearchTurn.id}`,\n role: 'user',\n content: uiSearchTurn.query,\n createdAt: new Date().toISOString(),\n },\n ]);\n return;\n }\n\n setBusy(false);\n const raw = uiSearchTurn.messageContent ?? '';\n const visibleProse = visibleAssistantContent(raw) || raw;\n if (visibleProse.trim()) {\n setLocalMessages((prev) => [\n ...prev.filter((m) => m.id !== `ui-a-${uiSearchTurn.id}`),\n {\n id: `ui-a-${uiSearchTurn.id}`,\n role: 'assistant',\n content: visibleProse,\n createdAt: new Date().toISOString(),\n },\n ]);\n }\n if (uiSearchTurn.attachment?.properties?.length) {\n setCardAttachment(uiSearchTurn.attachment);\n setCardProducts(productsFromAttachment(uiSearchTurn.attachment));\n }\n }, [uiSearchTurn, visible]);\n\n const send = (text: string, files?: MessageAttachment[]) => {\n const trimmed = text.trim();\n if (!trimmed && !files?.length) return;\n streamGen.current += 1;\n setShopStream(null);\n inFlight.current = true;\n turnRetailerRef.current = namedRetailer(trimmed);\n const fileCount = files?.length ?? 0;\n const useHost = Boolean(hostChat) && shouldUseHostLane(trimmed, fileCount);\n const fillShop = shouldRunNativeShopSearch(trimmed);\n\n if (useHost && hostChat) {\n if (!hostChat.connected) {\n setLocalMessages((prev) => [\n ...prev,\n {\n id: `u-${Date.now()}`,\n role: 'user',\n content: trimmed,\n ...(files?.length ? { attachments: files } : {}),\n },\n {\n id: `a-${Date.now()}`,\n role: 'assistant',\n content:\n hostChat.error ||\n 'CDeCLI is not connected yet. Check gateway status in the header, then send the image again.',\n },\n ]);\n inFlight.current = false;\n return;\n }\n hostChat.send(trimmed, files);\n setLocalMessages((prev) => prev.filter((m) => !m.id.startsWith('shop-')));\n // With photos, \"find a replacement for this\" names no product: the photo\n // is the query, so search once the agent has said what is in it.\n if (fillShop && (isGenericProductFindAsk(trimmed) || (fileCount > 0 && refersToAttachment(trimmed)))) {\n pendingVisionShop.current = true;\n inFlight.current = false;\n return;\n }\n if (fillShop) {\n runNativeShop(trimmed, false);\n return;\n }\n inFlight.current = false;\n return;\n }\n\n const user: AgentChatMessage = {\n id: `u-${Date.now()}`,\n role: 'user',\n content: trimmed,\n createdAt: new Date().toISOString(),\n ...(files?.length ? { attachments: files } : {}),\n };\n setLocalMessages((prev) => [...prev, user]);\n setCardAttachment(null);\n setCardProducts([]);\n\n if (fileCount > 0 || isVisualIdentifyQuery(trimmed)) {\n setLocalMessages((prev) => [\n ...prev,\n {\n id: `a-${Date.now()}`,\n role: 'assistant',\n content:\n 'I received the image, but this shop session is not connected to the agent yet. Connect CDeCLI in the header and send again — same as web Shopping Agent.',\n },\n ]);\n inFlight.current = false;\n return;\n }\n\n const gen = ++streamGen.current;\n setBusy(true);\n void (async () => {\n try {\n if (parsePriceCheckStop(trimmed)) {\n await replyLocalAssistant(gen, priceMonitorReply('stop', ''));\n return;\n }\n const priceCheck = parsePriceCheckIntent(trimmed);\n if (priceCheck) {\n await replyLocalAssistant(\n gen,\n priceMonitorReply('watch', priceCheck.query, priceCheck.targetPrice),\n );\n return;\n }\n\n let brainQuery: string | null = null;\n try {\n const verdict = await classifyShoppingViaBrain(trimmed, { timeoutMs: 2500 });\n if (verdict.status === 'ok' && verdict.monitor === 'stop') {\n await replyLocalAssistant(gen, priceMonitorReply('stop', ''));\n return;\n }\n if (verdict.status === 'ok' && verdict.monitor === 'watch') {\n await replyLocalAssistant(gen, priceMonitorReply('watch', verdict.query, verdict.targetPrice));\n return;\n }\n if (isShoppingConversation(trimmed)) {\n await replyConversation(gen, trimmed);\n return;\n }\n if (verdict.status === 'declined') {\n // The brain declined to read this as a product search.\n // That verdict is the routing decision - the pane does\n // not second-guess it with a regex - and what is left\n // is almost always a page the person is looking at.\n if (handOffToAgent(gen, trimmed, files, user.id)) return;\n await replyConversation(gen, trimmed);\n return;\n }\n if (verdict.status === 'ok' && verdict.query) brainQuery = verdict.query;\n } catch {\n if (isShoppingConversation(trimmed)) {\n await replyConversation(gen, trimmed);\n return;\n }\n }\n\n if (isShoppingConversation(trimmed)) {\n await replyConversation(gen, trimmed);\n return;\n }\n\n // Hand off to search — it owns busy/streamGen from here.\n inFlight.current = false;\n runNativeShop(brainQuery || trimmed, true);\n } finally {\n // Only clear busy when we did not hand off to runNativeShop\n // (runNativeShop bumps streamGen and manages its own busy flag).\n if (streamGen.current === gen) {\n inFlight.current = false;\n setBusy(false);\n }\n }\n })();\n };\n\n useEffect(() => {\n inFlight.current = false;\n streamGen.current += 1;\n setShopStream(null);\n }, [visible]);\n\n useEffect(() => {\n if (!visible || !seedTurn) return;\n const key = `${seedTurn.text}\\0${(seedTurn.files ?? []).map((file) => file.id ?? file.name ?? '').join(',')}`;\n if (seededKey.current === key) return;\n seededKey.current = key;\n const timer = setTimeout(() => send(seedTurn.text, seedTurn.files), 50);\n return () => clearTimeout(timer);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- seed once per handoff\n }, [visible, seedTurn]);\n\n return (\n <NativeAgentChat\n title=\"Shopping Agent\"\n visible={visible}\n onClose={onClose}\n onSwipeLeft={onClose}\n messages={messages}\n onSend={send}\n renderConnectorCard={hostChat?.renderConnectorCard}\n onClear={() => {\n streamGen.current += 1;\n setLocalMessages([]);\n setCardAttachment(null);\n setCardProducts([]);\n setShopStream(null);\n pendingVisionShop.current = false;\n hostChat?.clear?.();\n }}\n busy={busy || Boolean(hostChat?.busy)}\n streamingContent={shopStream || hostChat?.streaming}\n error={hostChat?.error}\n placeholder={'What are you looking for? e.g. \"running shoes under $120\"'}\n emptyTitle=\"What are you shopping for?\"\n emptyBody=\"Ask for a product in plain language, or send a photo — I'll look at it the same way as web Shop.\"\n suggestions={[\n { id: 'shoes', label: 'Running shoes under $120', prompt: 'running shoes under $120' },\n { id: 'laptop', label: 'Apple laptop', prompt: 'apple laptop' },\n { id: 'iphone', label: 'iPhone 17', prompt: 'buy iPhone 17' },\n ]}\n isDark={isDark}\n ink={ink}\n muted={muted}\n screen={screen}\n border={border}\n composerLead={\n cardAttachment ? (\n <ShoppingChatResultCard\n attachment={cardAttachment}\n products={[...products, ...cardProducts]}\n ink={ink}\n muted={muted}\n border={border}\n card={card}\n onViewProducts={onViewProducts}\n onOpenItem={onOpenProduct}\n />\n ) : null\n }\n />\n );\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,cAAiB,GAAA,EAAA;AACvB,SAAS,uBAAuB,UAA+C,EAAA;AAC7E,EAAA,MAAM,OAAO,eAAgB,EAAA;AAC7B,EAAA,OAAO,UAAW,CAAA,UAAA,CAAW,GAAI,CAAA,CAAC,MAAM,KAAO,KAAA;AAtBjD,IAAA,IAAA,EAAA;AAsBqD,IAAA,OAAA,cAAA,CAAA,cAAA,CAAA,cAAA,CAAA,cAAA,CAAA;AAAA,MACjD,EAAI,EAAA,CAAA,EAAA,GAAA,IAAA,CAAK,EAAL,KAAA,IAAA,GAAA,EAAA,GAAW,UAAU,KAAK,CAAA,CAAA;AAAA,MAC9B,MAAM,IAAK,CAAA,KAAA;AAAA,MACX,cAAc,IAAK,CAAA,EAAA;AAAA,MACnB,OAAO,OAAO,IAAA,CAAK,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
|
|
23
|
-
const params = __spreadProps(__spreadValues({}, opts.orgName ? {
|
|
23
|
+
const params = __spreadProps(__spreadValues(__spreadValues({}, opts.orgName ? {
|
|
24
24
|
orgName: opts.orgName
|
|
25
|
+
} : {}), opts.channelId ? {
|
|
26
|
+
channelId: opts.channelId
|
|
25
27
|
} : {}), {
|
|
26
28
|
initialAgentQuery: opts.query,
|
|
27
29
|
openAgent: true
|
|
@@ -32,6 +34,13 @@ function shopHandoffParams(opts) {
|
|
|
32
34
|
function isBareChatRoute(name) {
|
|
33
35
|
return /(^|\.)Chat$/.test(name);
|
|
34
36
|
}
|
|
37
|
+
function navigatorOwning(navigation, routeName) {
|
|
38
|
+
var _a, _b, _c, _d;
|
|
39
|
+
for (let nav = navigation; nav; nav = (_a = nav.getParent) == null ? void 0 : _a.call(nav)) {
|
|
40
|
+
if ((_d = (_c = (_b = nav.getState) == null ? void 0 : _b.call(nav)) == null ? void 0 : _c.routeNames) == null ? void 0 : _d.includes(routeName)) return nav;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
35
44
|
function replaceWithShopNative(navigation, params) {
|
|
36
45
|
if (typeof navigation.replace === "function") {
|
|
37
46
|
navigation.replace(SHOP_ROUTE, params);
|
|
@@ -46,7 +55,9 @@ function pushShopNative(navigation, params) {
|
|
|
46
55
|
}));
|
|
47
56
|
}
|
|
48
57
|
function openShopFromHome(navigation, params) {
|
|
49
|
-
navigation
|
|
58
|
+
const stack = navigatorOwning(navigation, SHOP_ROUTE);
|
|
59
|
+
if (!stack) return false;
|
|
60
|
+
stack.dispatch((state) => {
|
|
50
61
|
const kept = state.routes.filter((route) => !isBareChatRoute(route.name) && !/(^|\.)ShoppingNative$/.test(route.name));
|
|
51
62
|
const routes = [...kept, {
|
|
52
63
|
name: SHOP_ROUTE,
|
|
@@ -57,4 +68,5 @@ function openShopFromHome(navigation, params) {
|
|
|
57
68
|
index: routes.length - 1
|
|
58
69
|
}));
|
|
59
70
|
});
|
|
60
|
-
|
|
71
|
+
return true;
|
|
72
|
+
}export{isBareChatRoute,navigatorOwning,openShopFromHome,pushShopNative,replaceWithShopNative,shopHandoffParams};//# sourceMappingURL=openShopNative.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openShopNative.js","sources":["../../../../src/features/shopping/chat/openShopNative.ts"],"sourcesContent":["import { CommonActions, StackActions } from '@react-navigation/native';\nimport type { MessageAttachment } from '../../../hooks/useChatStream';\n\nconst SHOP_ROUTE = 'MainStack.ShoppingNative';\n\nexport function shopHandoffParams(opts: {\n orgName?: string | null;\n query: string;\n files?: MessageAttachment[] | null;\n}): Record<string, unknown> {\n const params: Record<string, unknown> = {\n ...(opts.orgName ? { orgName: opts.orgName } : {}),\n initialAgentQuery: opts.query,\n openAgent: true,\n };\n if (opts.files?.length) params.initialAgentAttachments = opts.files;\n return params;\n}\n\nexport function isBareChatRoute(name: string): boolean {\n return /(^|\\.)Chat$/.test(name);\n}\n\n/** From Chat: swap Chat for Shop so Back returns to Home, not an empty thread. */\nexport function replaceWithShopNative(\n navigation: { dispatch: (action: unknown) => void; replace?: (name: string, params?: object) => void },\n params: Record<string, unknown>,\n) {\n if (typeof navigation.replace === 'function') {\n navigation.replace(SHOP_ROUTE, params);\n return;\n }\n navigation.dispatch(StackActions.replace(SHOP_ROUTE, params));\n}\n\n/** Push Shop on top of the current screen (keeps an existing Chat thread). */\nexport function pushShopNative(navigation: { dispatch: (action: unknown) => void }, params: Record<string, unknown>) {\n navigation.dispatch(CommonActions.navigate({ name: SHOP_ROUTE, params }));\n}\n\n/**\n * From Home: open Shop and drop leftover Chat routes so Back is Home,\n * not a blank Chat that never received the shopping message.\n
|
|
1
|
+
{"version":3,"file":"openShopNative.js","sources":["../../../../src/features/shopping/chat/openShopNative.ts"],"sourcesContent":["import { CommonActions, StackActions } from '@react-navigation/native';\nimport type { MessageAttachment } from '../../../hooks/useChatStream';\n\nconst SHOP_ROUTE = 'MainStack.ShoppingNative';\n\n/** The slice of a React Navigation `navigation` object the hand-off needs. */\nexport interface ShopNavigation {\n dispatch: (action: unknown) => void;\n getParent?: () => ShopNavigation | undefined;\n getState?: () => { routeNames?: readonly string[] } | undefined;\n}\n\ntype StackState = { routes: Array<{ name: string; params?: object }>; [key: string]: unknown };\n\nexport function shopHandoffParams(opts: {\n orgName?: string | null;\n query: string;\n files?: MessageAttachment[] | null;\n /**\n * The chat this turn was typed into, when it has nothing else in it. Shop\n * continues that conversation instead of minting a second one, so History\n * does not gain an empty \"New chat\" for every hand-off.\n */\n channelId?: string | null;\n}): Record<string, unknown> {\n const params: Record<string, unknown> = {\n ...(opts.orgName ? { orgName: opts.orgName } : {}),\n ...(opts.channelId ? { channelId: opts.channelId } : {}),\n initialAgentQuery: opts.query,\n openAgent: true,\n };\n if (opts.files?.length) params.initialAgentAttachments = opts.files;\n return params;\n}\n\nexport function isBareChatRoute(name: string): boolean {\n return /(^|\\.)Chat$/.test(name);\n}\n\n/**\n * The navigator that declares `routeName`: the screen's own, or the nearest\n * ancestor that does. A screen's `dispatch(state => …)` hands the callback the\n * state of the navigator the SCREEN lives in, so a reset built for a different\n * navigator has to be dispatched from that navigator.\n */\nexport function navigatorOwning(navigation: ShopNavigation, routeName: string): ShopNavigation | null {\n for (let nav: ShopNavigation | undefined = navigation; nav; nav = nav.getParent?.()) {\n if (nav.getState?.()?.routeNames?.includes(routeName)) return nav;\n }\n return null;\n}\n\n/** From Chat: swap Chat for Shop so Back returns to Home, not an empty thread. */\nexport function replaceWithShopNative(\n navigation: { dispatch: (action: unknown) => void; replace?: (name: string, params?: object) => void },\n params: Record<string, unknown>,\n) {\n if (typeof navigation.replace === 'function') {\n navigation.replace(SHOP_ROUTE, params);\n return;\n }\n navigation.dispatch(StackActions.replace(SHOP_ROUTE, params));\n}\n\n/** Push Shop on top of the current screen (keeps an existing Chat thread). */\nexport function pushShopNative(navigation: { dispatch: (action: unknown) => void }, params: Record<string, unknown>) {\n navigation.dispatch(CommonActions.navigate({ name: SHOP_ROUTE, params }));\n}\n\n/**\n * From Home: open Shop and drop leftover Chat routes so Back is Home,\n * not a blank Chat that never received the shopping message.\n *\n * Home is a DRAWER screen and Shop is a route of the ROOT stack around it. The\n * reset therefore has to run on the stack: built from the drawer's state it\n * names routes the drawer does not have, every router answers it with `null`,\n * and a release build drops the action without a word - the composer had\n * already been cleared, so the person's message and photos were simply gone.\n *\n * Returns false when no navigator owns the Shop route, so the caller keeps the\n * message and takes the chat path instead of losing the turn.\n */\nexport function openShopFromHome(navigation: ShopNavigation, params: Record<string, unknown>): boolean {\n const stack = navigatorOwning(navigation, SHOP_ROUTE);\n if (!stack) return false;\n stack.dispatch((state: StackState) => {\n const kept = state.routes.filter(\n (route) => !isBareChatRoute(route.name) && !/(^|\\.)ShoppingNative$/.test(route.name),\n );\n const routes = [...kept, { name: SHOP_ROUTE, params }];\n return CommonActions.reset({\n ...state,\n routes,\n index: routes.length - 1,\n });\n });\n return true;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAEA,MAAM,UAAa,GAAA,0BAAA;AAiBZ,SAAS,kBAAkB,IAUN,EAAA;AA7B5B,EAAA,IAAA,EAAA;AA8BE,EAAM,MAAA,MAAA,GAAkC,aAClC,CAAA,cAAA,CAAA,cAAA,CAAA,EAAA,EAAA,IAAA,CAAK,OAAU,GAAA;AAAA,IACjB,SAAS,IAAK,CAAA;AAAA,GACZ,GAAA,EACA,CAAA,EAAA,IAAA,CAAK,SAAY,GAAA;AAAA,IACnB,WAAW,IAAK,CAAA;AAAA,GAClB,GAAI,EANkC,CAAA,EAAA;AAAA,IAOtC,mBAAmB,IAAK,CAAA,KAAA;AAAA,IACxB,SAAW,EAAA;AAAA,GACb,CAAA;AACA,EAAA,IAAA,CAAI,UAAK,KAAL,KAAA,IAAA,GAAA,MAAA,GAAA,EAAA,CAAY,MAAQ,EAAA,MAAA,CAAO,0BAA0B,IAAK,CAAA,KAAA;AAC9D,EAAO,OAAA,MAAA;AACT;AACO,SAAS,g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AAM,KAAA,CAAA,QAAA,CAAS,CAAC,KAAsB,KAAA;AACpC,IAAA,MAAM,IAAO,GAAA,KAAA,CAAM,MAAO,CAAA,MAAA,CAAO,WAAS,CAAC,eAAA,CAAgB,KAAM,CAAA,IAAI,KAAK,CAAC,uBAAA,CAAwB,IAAK,CAAA,KAAA,CAAM,IAAI,CAAC,CAAA;AACnH,IAAM,MAAA,MAAA,GAAS,CAAC,GAAG,IAAM,EAAA;AAAA,MACvB,IAAM,EAAA,UAAA;AAAA,MACN;AAAA,KACD,CAAA;AACD,IAAO,OAAA,aAAA,CAAc,KAAM,CAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACtB,KADsB,CAAA,EAAA;AAAA,MAEzB,MAAA;AAAA,MACA,KAAA,EAAO,OAAO,MAAS,GAAA;AAAA,KACxB,CAAA,CAAA;AAAA,GACF,CAAA;AACD,EAAO,OAAA,IAAA;AACT"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {SOURCE_LABELS}from'../catalog.js';const RETAILER_NAMES = [[/amazon(?:\.com)?/, "amazon"], [/walmart(?:\.com)?/, "walmart"], [/best\s*buy/, "bestbuy"], [/e-?bay/, "ebay"], [/target(?:\.com)?/, "target"], [/costco/, "costco"], [/(?:the\s+)?home\s*depot/, "homedepot"], [/lowe'?s/, "lowes"], [/newegg/, "newegg"]];
|
|
2
|
+
function namedRetailer(text) {
|
|
3
|
+
const lowered = text.toLowerCase();
|
|
4
|
+
for (const [name, source] of RETAILER_NAMES) {
|
|
5
|
+
const scoped = new RegExp(`\\b(?:in|on|at|from|via|through)\\s+${name.source}(?![a-z])`);
|
|
6
|
+
if (scoped.test(lowered)) return source;
|
|
7
|
+
}
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
function retailerLabel(source) {
|
|
11
|
+
return SOURCE_LABELS[source];
|
|
12
|
+
}
|
|
13
|
+
function scopeToRetailer(products, retailer) {
|
|
14
|
+
if (!retailer) return products;
|
|
15
|
+
const only = products.filter((product) => product.source === retailer);
|
|
16
|
+
return only.length > 0 ? only : products;
|
|
17
|
+
}
|
|
18
|
+
function productKey(product) {
|
|
19
|
+
return product.url || product.id;
|
|
20
|
+
}
|
|
21
|
+
function keepShownOrder(shown, next) {
|
|
22
|
+
if (shown.length === 0) return [...next];
|
|
23
|
+
const byKey = new Map(next.map((product) => [productKey(product), product]));
|
|
24
|
+
const kept = shown.map((product) => byKey.get(productKey(product))).filter((p) => Boolean(p));
|
|
25
|
+
const keptKeys = new Set(kept.map(productKey));
|
|
26
|
+
return [...kept, ...next.filter((product) => !keptKeys.has(productKey(product)))];
|
|
27
|
+
}
|
|
28
|
+
function refersToAttachment(text) {
|
|
29
|
+
return /\b(?:this|these|that|those|it|them)\b/i.test(text);
|
|
30
|
+
}
|
|
31
|
+
function listsProducts(text) {
|
|
32
|
+
return /\]\(https?:\/\/[^)\s]+\)/.test(text);
|
|
33
|
+
}export{keepShownOrder,listsProducts,namedRetailer,refersToAttachment,retailerLabel,scopeToRetailer};//# sourceMappingURL=searchScope.js.map
|