@buoy-gg/ask-buoy 7.0.34 → 7.0.35
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 +1 -1
- package/lib/commonjs/blocks/AskBlocks.js +338 -1
- package/lib/commonjs/blocks/AskBlocks.js.map +1 -0
- package/lib/commonjs/blocks/BlockRenderer.js +250 -1
- package/lib/commonjs/blocks/BlockRenderer.js.map +1 -0
- package/lib/commonjs/blocks/ChromePrototypes.js +514 -1
- package/lib/commonjs/blocks/ChromePrototypes.js.map +1 -0
- package/lib/commonjs/blocks/DataBlocks.js +688 -1
- package/lib/commonjs/blocks/DataBlocks.js.map +1 -0
- package/lib/commonjs/blocks/ExtraBlocks.js +1854 -1
- package/lib/commonjs/blocks/ExtraBlocks.js.map +1 -0
- package/lib/commonjs/blocks/MediaBlocks.js +140 -1
- package/lib/commonjs/blocks/MediaBlocks.js.map +1 -0
- package/lib/commonjs/blocks/ReceiptBlocks.js +586 -1
- package/lib/commonjs/blocks/ReceiptBlocks.js.map +1 -0
- package/lib/commonjs/blocks/context.js +42 -1
- package/lib/commonjs/blocks/context.js.map +1 -0
- package/lib/commonjs/blocks/icons.js +96 -1
- package/lib/commonjs/blocks/icons.js.map +1 -0
- package/lib/commonjs/blocks/index.js +95 -1
- package/lib/commonjs/blocks/index.js.map +1 -0
- package/lib/commonjs/blocks/listRow.test.js +55 -0
- package/lib/commonjs/blocks/listRow.test.js.map +1 -0
- package/lib/commonjs/blocks/pageState.js +34 -0
- package/lib/commonjs/blocks/pageState.js.map +1 -0
- package/lib/commonjs/blocks/pageState.test.js +57 -0
- package/lib/commonjs/blocks/pageState.test.js.map +1 -0
- package/lib/commonjs/blocks/primitives.js +401 -1
- package/lib/commonjs/blocks/primitives.js.map +1 -0
- package/lib/commonjs/blocks/primitivesIndex.js +62 -1
- package/lib/commonjs/blocks/primitivesIndex.js.map +1 -0
- package/lib/commonjs/components/ApprovalCard.js +140 -1
- package/lib/commonjs/components/ApprovalCard.js.map +1 -0
- package/lib/commonjs/components/AskBuoyHeader.js +164 -1
- package/lib/commonjs/components/AskBuoyHeader.js.map +1 -0
- package/lib/commonjs/components/AskBuoyIcon.js +19 -1
- package/lib/commonjs/components/AskBuoyIcon.js.map +1 -0
- package/lib/commonjs/components/AskBuoyModal.js +353 -1
- package/lib/commonjs/components/AskBuoyModal.js.map +1 -0
- package/lib/commonjs/components/AskBuoySettings.js +69 -0
- package/lib/commonjs/components/AskBuoySettings.js.map +1 -0
- package/lib/commonjs/components/ChangesBar.js +211 -1
- package/lib/commonjs/components/ChangesBar.js.map +1 -0
- package/lib/commonjs/components/Composer.js +175 -1
- package/lib/commonjs/components/Composer.js.map +1 -0
- package/lib/commonjs/components/EmptyState.js +154 -1
- package/lib/commonjs/components/EmptyState.js.map +1 -0
- package/lib/commonjs/components/Markdown.js +252 -1
- package/lib/commonjs/components/Markdown.js.map +1 -0
- package/lib/commonjs/components/MessageList.js +683 -1
- package/lib/commonjs/components/MessageList.js.map +1 -0
- package/lib/commonjs/components/ThinkingStrip.js +223 -0
- package/lib/commonjs/components/ThinkingStrip.js.map +1 -0
- package/lib/commonjs/components/TypingDots.js +63 -1
- package/lib/commonjs/components/TypingDots.js.map +1 -0
- package/lib/commonjs/components/useCopyAction.js +50 -0
- package/lib/commonjs/components/useCopyAction.js.map +1 -0
- package/lib/commonjs/index.js +252 -1
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/preset.js +90 -1
- package/lib/commonjs/preset.js.map +1 -0
- package/lib/commonjs/store/askBuoySettings.js +67 -0
- package/lib/commonjs/store/askBuoySettings.js.map +1 -0
- package/lib/commonjs/store/askBuoyStore.js +365 -1
- package/lib/commonjs/store/askBuoyStore.js.map +1 -0
- package/lib/commonjs/store/restoredIds.test.js +47 -0
- package/lib/commonjs/store/restoredIds.test.js.map +1 -0
- package/lib/commonjs/store/traceText.js +81 -0
- package/lib/commonjs/store/traceText.js.map +1 -0
- package/lib/commonjs/store/traceText.test.js +112 -0
- package/lib/commonjs/store/traceText.test.js.map +1 -0
- package/lib/commonjs/store/transcriptPersistence.js +208 -0
- package/lib/commonjs/store/transcriptPersistence.js.map +1 -0
- package/lib/commonjs/store/transcriptPersistence.test.js +185 -0
- package/lib/commonjs/store/transcriptPersistence.test.js.map +1 -0
- package/lib/commonjs/store/useAskBuoy.js +400 -1
- package/lib/commonjs/store/useAskBuoy.js.map +1 -0
- package/lib/commonjs/store/useAskBuoySettings.js +14 -0
- package/lib/commonjs/store/useAskBuoySettings.js.map +1 -0
- package/lib/commonjs/sync/askBuoySyncAdapter.js +119 -1
- package/lib/commonjs/sync/askBuoySyncAdapter.js.map +1 -0
- package/lib/commonjs/sync/askBuoySyncAdapter.test.js +141 -1
- package/lib/commonjs/sync/askBuoySyncAdapter.test.js.map +1 -0
- package/lib/commonjs/sync/wire.js +58 -1
- package/lib/commonjs/sync/wire.js.map +1 -0
- package/lib/commonjs/types.js +6 -1
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/blocks/AskBlocks.js +331 -1
- package/lib/module/blocks/AskBlocks.js.map +1 -0
- package/lib/module/blocks/BlockRenderer.js +245 -1
- package/lib/module/blocks/BlockRenderer.js.map +1 -0
- package/lib/module/blocks/ChromePrototypes.js +503 -1
- package/lib/module/blocks/ChromePrototypes.js.map +1 -0
- package/lib/module/blocks/DataBlocks.js +674 -1
- package/lib/module/blocks/DataBlocks.js.map +1 -0
- package/lib/module/blocks/ExtraBlocks.js +1827 -1
- package/lib/module/blocks/ExtraBlocks.js.map +1 -0
- package/lib/module/blocks/MediaBlocks.js +135 -1
- package/lib/module/blocks/MediaBlocks.js.map +1 -0
- package/lib/module/blocks/ReceiptBlocks.js +574 -1
- package/lib/module/blocks/ReceiptBlocks.js.map +1 -0
- package/lib/module/blocks/context.js +35 -1
- package/lib/module/blocks/context.js.map +1 -0
- package/lib/module/blocks/icons.js +91 -1
- package/lib/module/blocks/icons.js.map +1 -0
- package/lib/module/blocks/index.js +8 -1
- package/lib/module/blocks/index.js.map +1 -0
- package/lib/module/blocks/listRow.test.js +56 -0
- package/lib/module/blocks/listRow.test.js.map +1 -0
- package/lib/module/blocks/pageState.js +30 -0
- package/lib/module/blocks/pageState.js.map +1 -0
- package/lib/module/blocks/pageState.test.js +56 -0
- package/lib/module/blocks/pageState.test.js.map +1 -0
- package/lib/module/blocks/primitives.js +389 -1
- package/lib/module/blocks/primitives.js.map +1 -0
- package/lib/module/blocks/primitivesIndex.js +5 -1
- package/lib/module/blocks/primitivesIndex.js.map +1 -0
- package/lib/module/components/ApprovalCard.js +135 -1
- package/lib/module/components/ApprovalCard.js.map +1 -0
- package/lib/module/components/AskBuoyHeader.js +161 -1
- package/lib/module/components/AskBuoyHeader.js.map +1 -0
- package/lib/module/components/AskBuoyIcon.js +8 -1
- package/lib/module/components/AskBuoyIcon.js.map +1 -0
- package/lib/module/components/AskBuoyModal.js +348 -1
- package/lib/module/components/AskBuoyModal.js.map +1 -0
- package/lib/module/components/AskBuoySettings.js +64 -0
- package/lib/module/components/AskBuoySettings.js.map +1 -0
- package/lib/module/components/ChangesBar.js +206 -1
- package/lib/module/components/ChangesBar.js.map +1 -0
- package/lib/module/components/Composer.js +170 -1
- package/lib/module/components/Composer.js.map +1 -0
- package/lib/module/components/EmptyState.js +149 -1
- package/lib/module/components/EmptyState.js.map +1 -0
- package/lib/module/components/Markdown.js +246 -1
- package/lib/module/components/Markdown.js.map +1 -0
- package/lib/module/components/MessageList.js +677 -1
- package/lib/module/components/MessageList.js.map +1 -0
- package/lib/module/components/ThinkingStrip.js +218 -0
- package/lib/module/components/ThinkingStrip.js.map +1 -0
- package/lib/module/components/TypingDots.js +58 -1
- package/lib/module/components/TypingDots.js.map +1 -0
- package/lib/module/components/useCopyAction.js +46 -0
- package/lib/module/components/useCopyAction.js.map +1 -0
- package/lib/module/index.js +34 -1
- package/lib/module/index.js.map +1 -0
- package/lib/module/preset.js +73 -1
- package/lib/module/preset.js.map +1 -0
- package/lib/module/store/askBuoySettings.js +62 -0
- package/lib/module/store/askBuoySettings.js.map +1 -0
- package/lib/module/store/askBuoyStore.js +361 -1
- package/lib/module/store/askBuoyStore.js.map +1 -0
- package/lib/module/store/restoredIds.test.js +46 -0
- package/lib/module/store/restoredIds.test.js.map +1 -0
- package/lib/module/store/traceText.js +75 -0
- package/lib/module/store/traceText.js.map +1 -0
- package/lib/module/store/traceText.test.js +111 -0
- package/lib/module/store/traceText.test.js.map +1 -0
- package/lib/module/store/transcriptPersistence.js +198 -0
- package/lib/module/store/transcriptPersistence.js.map +1 -0
- package/lib/module/store/transcriptPersistence.test.js +184 -0
- package/lib/module/store/transcriptPersistence.test.js.map +1 -0
- package/lib/module/store/useAskBuoy.js +394 -1
- package/lib/module/store/useAskBuoy.js.map +1 -0
- package/lib/module/store/useAskBuoySettings.js +9 -0
- package/lib/module/store/useAskBuoySettings.js.map +1 -0
- package/lib/module/sync/askBuoySyncAdapter.js +114 -1
- package/lib/module/sync/askBuoySyncAdapter.js.map +1 -0
- package/lib/module/sync/askBuoySyncAdapter.test.js +140 -1
- package/lib/module/sync/askBuoySyncAdapter.test.js.map +1 -0
- package/lib/module/sync/wire.js +47 -1
- package/lib/module/sync/wire.js.map +1 -0
- package/lib/module/types.js +4 -1
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/blocks/AskBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/BlockRenderer.d.ts.map +1 -0
- package/lib/typescript/blocks/ChromePrototypes.d.ts.map +1 -0
- package/lib/typescript/blocks/DataBlocks.d.ts +31 -0
- package/lib/typescript/blocks/DataBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/ExtraBlocks.d.ts +11 -0
- package/lib/typescript/blocks/ExtraBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/MediaBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/ReceiptBlocks.d.ts.map +1 -0
- package/lib/typescript/blocks/context.d.ts.map +1 -0
- package/lib/typescript/blocks/icons.d.ts.map +1 -0
- package/lib/typescript/blocks/index.d.ts.map +1 -0
- package/lib/typescript/blocks/listRow.test.d.ts +2 -0
- package/lib/typescript/blocks/listRow.test.d.ts.map +1 -0
- package/lib/typescript/blocks/pageState.d.ts +23 -0
- package/lib/typescript/blocks/pageState.d.ts.map +1 -0
- package/lib/typescript/blocks/pageState.test.d.ts +2 -0
- package/lib/typescript/blocks/pageState.test.d.ts.map +1 -0
- package/lib/typescript/blocks/primitives.d.ts +39 -9
- package/lib/typescript/blocks/primitives.d.ts.map +1 -0
- package/lib/typescript/blocks/primitivesIndex.d.ts +2 -1
- package/lib/typescript/blocks/primitivesIndex.d.ts.map +1 -0
- package/lib/typescript/components/ApprovalCard.d.ts.map +1 -0
- package/lib/typescript/components/AskBuoyHeader.d.ts +11 -1
- package/lib/typescript/components/AskBuoyHeader.d.ts.map +1 -0
- package/lib/typescript/components/AskBuoyIcon.d.ts.map +1 -0
- package/lib/typescript/components/AskBuoyModal.d.ts.map +1 -0
- package/lib/typescript/components/AskBuoySettings.d.ts +2 -0
- package/lib/typescript/components/AskBuoySettings.d.ts.map +1 -0
- package/lib/typescript/components/ChangesBar.d.ts.map +1 -0
- package/lib/typescript/components/Composer.d.ts.map +1 -0
- package/lib/typescript/components/EmptyState.d.ts.map +1 -0
- package/lib/typescript/components/Markdown.d.ts.map +1 -0
- package/lib/typescript/components/MessageList.d.ts +12 -5
- package/lib/typescript/components/MessageList.d.ts.map +1 -0
- package/lib/typescript/components/ThinkingStrip.d.ts +5 -0
- package/lib/typescript/components/ThinkingStrip.d.ts.map +1 -0
- package/lib/typescript/components/TypingDots.d.ts.map +1 -0
- package/lib/typescript/components/useCopyAction.d.ts +5 -0
- package/lib/typescript/components/useCopyAction.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/preset.d.ts.map +1 -0
- package/lib/typescript/store/askBuoySettings.d.ts +22 -0
- package/lib/typescript/store/askBuoySettings.d.ts.map +1 -0
- package/lib/typescript/store/askBuoyStore.d.ts +74 -13
- package/lib/typescript/store/askBuoyStore.d.ts.map +1 -0
- package/lib/typescript/store/restoredIds.test.d.ts +2 -0
- package/lib/typescript/store/restoredIds.test.d.ts.map +1 -0
- package/lib/typescript/store/traceText.d.ts +33 -0
- package/lib/typescript/store/traceText.d.ts.map +1 -0
- package/lib/typescript/store/traceText.test.d.ts +2 -0
- package/lib/typescript/store/traceText.test.d.ts.map +1 -0
- package/lib/typescript/store/transcriptPersistence.d.ts +40 -0
- package/lib/typescript/store/transcriptPersistence.d.ts.map +1 -0
- package/lib/typescript/store/transcriptPersistence.test.d.ts +2 -0
- package/lib/typescript/store/transcriptPersistence.test.d.ts.map +1 -0
- package/lib/typescript/store/useAskBuoy.d.ts.map +1 -0
- package/lib/typescript/store/useAskBuoySettings.d.ts +3 -0
- package/lib/typescript/store/useAskBuoySettings.d.ts.map +1 -0
- package/lib/typescript/sync/askBuoySyncAdapter.d.ts.map +1 -0
- package/lib/typescript/sync/askBuoySyncAdapter.test.d.ts.map +1 -0
- package/lib/typescript/sync/wire.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +24 -1
- package/lib/typescript/types.d.ts.map +1 -0
- package/package.json +8 -8
|
@@ -1 +1,677 @@
|
|
|
1
|
-
"use strict";import{useCallback,useEffect,useRef,useState}from"react";import{ActivityIndicator,FlatList,Pressable,Share,StyleSheet,Text,View}from"react-native";import{AlertTriangle,Check,ChevronDown,ChevronRight,night,X}from"@buoy-gg/shared-ui";import{isAskBlock,toolTitle}from"@buoy-gg/agent-core";import{BlockRenderer}from"../blocks/BlockRenderer";import{Markdown}from"./Markdown";import{TypingDots}from"./TypingDots";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";function StatusMark({status:e}){switch(e){case"running":return _jsx(ActivityIndicator,{size:"small",color:night.color.textSecondary});case"ok":return _jsx(View,{style:[styles.mark,styles.markOk],children:_jsx(Check,{size:10,color:night.color.onAccent})});case"failed":return _jsx(View,{style:[styles.mark,styles.markFailed],children:_jsx(X,{size:10,color:night.color.text})});case"refused":return _jsx(View,{style:[styles.mark,styles.markRefused],children:_jsx(AlertTriangle,{size:10,color:night.color.onAccent})})}}function statusText(e){return"running"===e.status?{text:"",tone:"muted"}:"refused"===e.status?{text:"Refused",tone:"warning"}:"failed"===e.status?{text:"Failed",tone:"danger"}:{text:e.summary||"Done",tone:"muted"}}function ActivityRow({call:e,last:t}){const[s,r]=useState(!1),o=statusText(e),n=s?ChevronDown:ChevronRight,i="failed"===e.status&&e.summary&&"Failed"!==e.summary?e.summary:null;return _jsxs(Pressable,{testID:`buoy-ask-buoy-tool-${e.toolId}`,accessibilityRole:"button",accessibilityLabel:`${e.label}, ${o.text||"running"}`,accessibilityState:{expanded:s},onPress:()=>r(e=>!e),style:[styles.row,!t&&styles.rowDivider],children:[_jsxs(View,{style:styles.rowLine,children:[_jsx(View,{style:styles.markSlot,children:_jsx(StatusMark,{status:e.status})}),_jsx(Text,{style:styles.rowTitle,children:e.label}),o.text?_jsx(Text,{style:[styles.rowStatus,"danger"===o.tone&&styles.rowStatusDanger,"warning"===o.tone&&styles.rowStatusWarning],numberOfLines:1,children:o.text}):null,_jsx(n,{size:12,color:night.color.textTertiary})]}),s&&_jsxs(View,{style:styles.rowDetail,children:[_jsx(Text,{style:styles.rowTool,children:toolTitle(e.toolId).toUpperCase()}),e.description?_jsx(Text,{style:styles.rowDescription,children:e.description}):null,i?_jsx(Text,{style:styles.rowFailure,children:i}):null]})]})}const COLLAPSE_AFTER=4;function ActivityCard({calls:e}){const[t,s]=useState(!1),r=e.some(e=>"running"===e.status),o=e.length>4&&!t&&!r,n=e.filter(e=>"failed"===e.status).length,i=e.filter(e=>"refused"===e.status).length,l=o?e.filter(e=>"failed"===e.status||"refused"===e.status):e;return _jsxs(View,{style:styles.card,testID:"buoy-ask-buoy-activity",children:[o&&_jsx(Pressable,{onPress:()=>s(!0),accessibilityRole:"button",style:[styles.row,l.length>0&&styles.rowDivider],testID:"buoy-ask-buoy-activity-expand",children:_jsxs(View,{style:styles.rowLine,children:[_jsxs(Text,{style:styles.rowTitle,children:["Did ",e.length," things",n?` · ${n} failed`:"",i?` · ${i} refused`:""]}),_jsx(ChevronRight,{size:12,color:night.color.textTertiary})]})}),l.map((e,t)=>_jsx(ActivityRow,{call:e,last:t===l.length-1},e.id))]})}function Blocks({blocks:e}){return 0===e.length?null:_jsx(View,{style:styles.blocks,children:e.map(({block:e})=>_jsx(BlockRenderer,{block:e},e.id))})}function UserMessage({message:e}){return _jsx(View,{style:styles.userWrap,children:_jsx(View,{style:styles.userBubble,children:_jsx(Text,{style:styles.userText,selectable:!0,children:e.text})})})}function AssistantMessage({message:e,onRetry:t}){const s=e.toolCalls.some(e=>"running"===e.status),r=!!e.streaming&&0===e.text.length&&!s,o=e.blocks.filter(e=>isAskBlock(e.block)),n=e.blocks.filter(e=>!isAskBlock(e.block));return _jsxs(View,{style:styles.assistantWrap,children:[e.toolCalls.length>0&&_jsx(ActivityCard,{calls:e.toolCalls}),_jsx(Blocks,{blocks:n}),e.text.length>0&&_jsx(Markdown,{text:e.text,style:styles.assistantText}),_jsx(Blocks,{blocks:o}),r&&_jsx(TypingDots,{}),e.error&&_jsx(ErrorNote,{error:e.error,onRetry:t})]})}function ErrorNote({error:e,onRetry:t}){const s=/fetch failed|network|ECONN|timed? ?out|socket|abort/i.test(e)?"Couldn't reach your AI endpoint. Check the connection and try again.":"Something went wrong with that turn.";return _jsxs(View,{style:styles.errorBox,testID:"buoy-ask-buoy-error",children:[_jsx(AlertTriangle,{size:14,color:night.color.danger}),_jsxs(View,{style:styles.errorBody,children:[_jsx(Text,{style:styles.errorText,children:s}),_jsx(Text,{style:styles.errorDetail,selectable:!0,children:e}),t&&_jsx(Pressable,{testID:"buoy-ask-buoy-retry",accessibilityRole:"button",onPress:t,style:({pressed:e})=>[styles.retry,e&&styles.retryPressed],children:_jsx(Text,{style:styles.retryText,children:"Retry"})})]})]})}export function transcriptToText(e){const t=[];for(const s of e)if("user"===s.role)t.push(`You: ${s.text}`);else{for(const e of s.toolCalls){const s="failed"===e.status||"refused"===e.status?` (${e.status})`:"";t.push(` · ${e.label}${e.summary?` — ${e.summary}`:""}${s}`)}s.text&&t.push(`Ask Buoy: ${s.text}`),s.error&&t.push(` ! ${s.error}`)}return t.join("\n")}function TranscriptActions({message:e,messages:t}){const s=useCallback(()=>{Share.share({message:e.text}).catch(()=>{})},[e.text]),r=useCallback(()=>{Share.share({message:transcriptToText(t)}).catch(()=>{})},[t]);return _jsxs(View,{style:styles.transcriptActions,children:[e.text.length>0&&_jsx(Pressable,{testID:"buoy-ask-buoy-share-reply",accessibilityRole:"button",onPress:s,style:({pressed:e})=>[styles.shareBtn,e&&styles.sharePressed],children:_jsx(Text,{style:styles.shareText,children:"Share reply"})}),_jsx(Pressable,{testID:"buoy-ask-buoy-share-session",accessibilityRole:"button",onPress:r,style:({pressed:e})=>[styles.shareBtn,e&&styles.sharePressed],children:_jsx(Text,{style:styles.shareText,children:"Share session"})})]})}function Row({message:e,messages:t,onRetry:s,isLast:r}){if("user"===e.role)return _jsx(UserMessage,{message:e});const o=!e.streaming&&!e.error;return _jsxs(View,{children:[_jsx(AssistantMessage,{message:e,onRetry:s}),r&&o&&_jsx(TranscriptActions,{message:e,messages:t})]})}export function MessageList({messages:e,ListHeaderComponent:t,ListEmptyComponent:s,ListFooterComponent:r,onRetry:o}){const n=useRef(null),i=useRef(!0),l=useRef(!1),a=useCallback(e=>{const{contentOffset:t,contentSize:s,layoutMeasurement:r}=e.nativeEvent,o=s.height-r.height-t.y;i.current=o<80},[]),c=useCallback(()=>{l.current=!0},[]),d=useCallback(e=>{l.current&&a(e)},[a]),g=useCallback(e=>{l.current=!1,a(e)},[a]),u=useCallback(()=>{i.current&&(n.current?.scrollToEnd({animated:!1}),requestAnimationFrame(()=>n.current?.scrollToEnd({animated:!1})))},[]),h=e[e.length-1],y=h?`${h.id}:${h.text.length}:${h.toolCalls.length}:${h.error??""}`:"";return useEffect(()=>{u()},[y,u]),_jsx(FlatList,{ref:n,testID:"buoy-ask-buoy-messages-scroll",style:styles.list,contentContainerStyle:styles.listContent,data:e,keyExtractor:e=>e.id,renderItem:({item:t})=>_jsx(Row,{message:t,messages:e,isLast:t.id===h?.id,onRetry:t.id===h?.id?o:void 0}),onScroll:d,onScrollBeginDrag:c,onScrollEndDrag:g,onMomentumScrollEnd:a,scrollEventThrottle:32,onContentSizeChange:u,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"interactive",ListHeaderComponent:t,ListEmptyComponent:s,ListFooterComponent:r})}const styles=StyleSheet.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingHorizontal:night.gutter,paddingTop:12,paddingBottom:16,gap:16,flexGrow:1},userWrap:{alignItems:"flex-end"},userBubble:{maxWidth:"84%",paddingHorizontal:14,paddingVertical:9,borderRadius:18,borderBottomRightRadius:6,backgroundColor:night.color.accentFill,borderWidth:StyleSheet.hairlineWidth,borderColor:night.color.accentBorder},userText:{color:night.color.text,fontSize:night.font.row,lineHeight:21},assistantWrap:{alignItems:"stretch",gap:10},blocks:{gap:10},assistantText:{color:night.color.text,fontSize:night.font.row,lineHeight:22,paddingHorizontal:2},card:{borderRadius:night.radius.card,borderWidth:StyleSheet.hairlineWidth,borderColor:night.color.border,backgroundColor:night.color.surface,overflow:"hidden"},row:{paddingHorizontal:12,paddingVertical:10},rowDivider:{borderBottomWidth:StyleSheet.hairlineWidth,borderBottomColor:night.color.separator},rowLine:{flexDirection:"row",alignItems:"center",gap:10},markSlot:{width:18,height:18,alignItems:"center",justifyContent:"center"},mark:{width:16,height:16,borderRadius:8,alignItems:"center",justifyContent:"center"},markOk:{backgroundColor:night.color.accent},markFailed:{backgroundColor:night.color.danger},markRefused:{backgroundColor:night.color.warning},rowTitle:{flex:1,color:night.color.text,fontSize:night.font.body,lineHeight:19},rowStatus:{color:night.color.textTertiary,fontSize:night.font.caption,maxWidth:120},rowStatusDanger:{color:night.color.danger},rowStatusWarning:{color:night.color.warning},rowDetail:{paddingLeft:28,paddingTop:8,gap:4},rowTool:{color:night.color.textTertiary,fontSize:night.font.micro,fontWeight:"600",letterSpacing:.8},rowDescription:{color:night.color.textSecondary,fontSize:night.font.caption,lineHeight:18},rowFailure:{color:night.color.danger,fontSize:night.font.caption,lineHeight:18},errorBox:{flexDirection:"row",alignItems:"flex-start",gap:8,paddingHorizontal:12,paddingVertical:10,borderRadius:night.radius.row,backgroundColor:night.color.dangerSoft},errorBody:{flex:1,gap:4},errorText:{color:night.color.danger,fontSize:night.font.caption,fontWeight:"600",lineHeight:18},errorDetail:{color:night.color.textSecondary,fontSize:night.font.micro,lineHeight:15},retry:{alignSelf:"flex-start",marginTop:6,paddingHorizontal:14,paddingVertical:7,borderRadius:night.radius.row,backgroundColor:night.color.button},retryPressed:{opacity:.7},retryText:{color:night.color.accent,fontSize:night.font.caption,fontWeight:"600"},transcriptActions:{flexDirection:"row",gap:8,marginTop:8},shareBtn:{paddingHorizontal:10,paddingVertical:5,borderRadius:night.radius.badge,backgroundColor:night.color.fill},sharePressed:{opacity:.7},shareText:{color:night.color.textSecondary,fontSize:night.font.micro,fontWeight:"600"}});
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The transcript.
|
|
5
|
+
*
|
|
6
|
+
* Owns the ONLY scroller in the sheet. JsModal's default wrapper uses
|
|
7
|
+
* `contentContainerStyle: { flexGrow: 1 }`, so a `flex: 1` scroller nested
|
|
8
|
+
* inside resolves against the CONTENT rather than the viewport: it grows to
|
|
9
|
+
* full content height, never scrolls, and the outer wrapper scrolls instead.
|
|
10
|
+
* That is invisible to a human and fatal to Detox ("View is not scrollable at
|
|
11
|
+
* the given start point"). The sheet passes `disableScrollWrapper` and this
|
|
12
|
+
* list is the one scroller.
|
|
13
|
+
*
|
|
14
|
+
* Layout, and why:
|
|
15
|
+
* - The user's messages are bubbles on the right; the assistant's text is
|
|
16
|
+
* plain, full-width prose on the left. A grey bubble around every answer
|
|
17
|
+
* cost 28pt of width per line and made the two sides look like the same
|
|
18
|
+
* speaker.
|
|
19
|
+
* - Tool calls render as an ACTIVITY CARD above the answer they produced —
|
|
20
|
+
* one row per call, a status mark, a short human title ("Open /bag") and a
|
|
21
|
+
* result word ("Done", "12 items", "Not found"). Nothing in a row is
|
|
22
|
+
* truncated to the point of being unreadable: the title wraps, and tapping
|
|
23
|
+
* the row expands it to the catalog's full sentence plus the tool it ran on.
|
|
24
|
+
* The previous version showed the model-facing sentence cut off at two
|
|
25
|
+
* lines with the result's JSON key names beside it, which was unreadable
|
|
26
|
+
* AND uninformative.
|
|
27
|
+
*/
|
|
28
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
29
|
+
import { ActivityIndicator, FlatList, Pressable, StyleSheet, Text, View } from "react-native";
|
|
30
|
+
import { AlertTriangle, Check, ChevronDown, ChevronRight, Copy, night, X } from "@buoy-gg/shared-ui";
|
|
31
|
+
import { isAskBlock, toolTitle } from "@buoy-gg/agent-core";
|
|
32
|
+
import { BlockRenderer } from "../blocks/BlockRenderer";
|
|
33
|
+
import { Markdown } from "./Markdown";
|
|
34
|
+
import { ThinkingStrip } from "./ThinkingStrip";
|
|
35
|
+
import { TypingDots } from "./TypingDots";
|
|
36
|
+
import { useCopyAction } from "./useCopyAction";
|
|
37
|
+
import { traceToText } from "../store/traceText";
|
|
38
|
+
import { useAskBuoySettings } from "../store/useAskBuoySettings";
|
|
39
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
40
|
+
function StatusMark({
|
|
41
|
+
status
|
|
42
|
+
}) {
|
|
43
|
+
switch (status) {
|
|
44
|
+
case "running":
|
|
45
|
+
return /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
46
|
+
size: "small",
|
|
47
|
+
color: night.color.textSecondary
|
|
48
|
+
});
|
|
49
|
+
case "ok":
|
|
50
|
+
return /*#__PURE__*/_jsx(View, {
|
|
51
|
+
style: [styles.mark, styles.markOk],
|
|
52
|
+
children: /*#__PURE__*/_jsx(Check, {
|
|
53
|
+
size: 10,
|
|
54
|
+
color: night.color.onAccent
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
case "failed":
|
|
58
|
+
return /*#__PURE__*/_jsx(View, {
|
|
59
|
+
style: [styles.mark, styles.markFailed],
|
|
60
|
+
children: /*#__PURE__*/_jsx(X, {
|
|
61
|
+
size: 10,
|
|
62
|
+
color: night.color.text
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
case "refused":
|
|
66
|
+
return /*#__PURE__*/_jsx(View, {
|
|
67
|
+
style: [styles.mark, styles.markRefused],
|
|
68
|
+
children: /*#__PURE__*/_jsx(AlertTriangle, {
|
|
69
|
+
size: 10,
|
|
70
|
+
color: night.color.onAccent
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The trailing word: what happened, in one glance. */
|
|
77
|
+
function statusText(call) {
|
|
78
|
+
if (call.status === "running") return {
|
|
79
|
+
text: "",
|
|
80
|
+
tone: "muted"
|
|
81
|
+
};
|
|
82
|
+
if (call.status === "refused") return {
|
|
83
|
+
text: "Refused",
|
|
84
|
+
tone: "warning"
|
|
85
|
+
};
|
|
86
|
+
if (call.status === "failed") return {
|
|
87
|
+
text: "Failed",
|
|
88
|
+
tone: "danger"
|
|
89
|
+
};
|
|
90
|
+
return {
|
|
91
|
+
text: call.summary || "Done",
|
|
92
|
+
tone: "muted"
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function ActivityRow({
|
|
96
|
+
call,
|
|
97
|
+
last
|
|
98
|
+
}) {
|
|
99
|
+
const [open, setOpen] = useState(false);
|
|
100
|
+
const status = statusText(call);
|
|
101
|
+
const Chevron = open ? ChevronDown : ChevronRight;
|
|
102
|
+
const failureDetail = call.status === "failed" && call.summary && call.summary !== "Failed" ? call.summary : null;
|
|
103
|
+
return /*#__PURE__*/_jsxs(Pressable, {
|
|
104
|
+
testID: `buoy-ask-buoy-tool-${call.toolId}`,
|
|
105
|
+
accessibilityRole: "button",
|
|
106
|
+
accessibilityLabel: `${call.label}, ${status.text || "running"}`,
|
|
107
|
+
accessibilityState: {
|
|
108
|
+
expanded: open
|
|
109
|
+
},
|
|
110
|
+
onPress: () => setOpen(v => !v),
|
|
111
|
+
style: [styles.row, !last && styles.rowDivider],
|
|
112
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
113
|
+
style: styles.rowLine,
|
|
114
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
115
|
+
style: styles.markSlot,
|
|
116
|
+
children: /*#__PURE__*/_jsx(StatusMark, {
|
|
117
|
+
status: call.status
|
|
118
|
+
})
|
|
119
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
120
|
+
style: styles.rowTitle,
|
|
121
|
+
children: call.label
|
|
122
|
+
}), status.text ? /*#__PURE__*/_jsx(Text, {
|
|
123
|
+
style: [styles.rowStatus, status.tone === "danger" && styles.rowStatusDanger, status.tone === "warning" && styles.rowStatusWarning],
|
|
124
|
+
numberOfLines: 1,
|
|
125
|
+
children: status.text
|
|
126
|
+
}) : null, /*#__PURE__*/_jsx(Chevron, {
|
|
127
|
+
size: 12,
|
|
128
|
+
color: night.color.textTertiary
|
|
129
|
+
})]
|
|
130
|
+
}), open && /*#__PURE__*/_jsxs(View, {
|
|
131
|
+
style: styles.rowDetail,
|
|
132
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
133
|
+
style: styles.rowTool,
|
|
134
|
+
children: toolTitle(call.toolId).toUpperCase()
|
|
135
|
+
}), call.description ? /*#__PURE__*/_jsx(Text, {
|
|
136
|
+
style: styles.rowDescription,
|
|
137
|
+
children: call.description
|
|
138
|
+
}) : null, failureDetail ? /*#__PURE__*/_jsx(Text, {
|
|
139
|
+
style: styles.rowFailure,
|
|
140
|
+
children: failureDetail
|
|
141
|
+
}) : null]
|
|
142
|
+
})]
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const COLLAPSE_AFTER = 4;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* More than four steps collapse to one line — "Did 15 things · 5 failed" —
|
|
149
|
+
* with the failed and refused rows pinned so the bad news is never hidden.
|
|
150
|
+
*/
|
|
151
|
+
function ActivityCard({
|
|
152
|
+
calls
|
|
153
|
+
}) {
|
|
154
|
+
const [expanded, setExpanded] = useState(false);
|
|
155
|
+
const running = calls.some(c => c.status === "running");
|
|
156
|
+
const collapse = calls.length > COLLAPSE_AFTER && !expanded && !running;
|
|
157
|
+
const failed = calls.filter(c => c.status === "failed").length;
|
|
158
|
+
const refused = calls.filter(c => c.status === "refused").length;
|
|
159
|
+
const shown = collapse ? calls.filter(c => c.status === "failed" || c.status === "refused") : calls;
|
|
160
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
161
|
+
style: styles.card,
|
|
162
|
+
testID: "buoy-ask-buoy-activity",
|
|
163
|
+
children: [collapse && /*#__PURE__*/_jsx(Pressable, {
|
|
164
|
+
onPress: () => setExpanded(true),
|
|
165
|
+
accessibilityRole: "button",
|
|
166
|
+
style: [styles.row, shown.length > 0 && styles.rowDivider],
|
|
167
|
+
testID: "buoy-ask-buoy-activity-expand",
|
|
168
|
+
children: /*#__PURE__*/_jsxs(View, {
|
|
169
|
+
style: styles.rowLine,
|
|
170
|
+
children: [/*#__PURE__*/_jsxs(Text, {
|
|
171
|
+
style: styles.rowTitle,
|
|
172
|
+
children: ["Did ", calls.length, " things", failed ? ` · ${failed} failed` : "", refused ? ` · ${refused} refused` : ""]
|
|
173
|
+
}), /*#__PURE__*/_jsx(ChevronRight, {
|
|
174
|
+
size: 12,
|
|
175
|
+
color: night.color.textTertiary
|
|
176
|
+
})]
|
|
177
|
+
})
|
|
178
|
+
}), shown.map((c, i) => /*#__PURE__*/_jsx(ActivityRow, {
|
|
179
|
+
call: c,
|
|
180
|
+
last: i === shown.length - 1
|
|
181
|
+
}, c.id))]
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Receipts and model blocks render between the activity card and the prose; Ask blocks last. */
|
|
186
|
+
function Blocks({
|
|
187
|
+
blocks
|
|
188
|
+
}) {
|
|
189
|
+
if (blocks.length === 0) return null;
|
|
190
|
+
return /*#__PURE__*/_jsx(View, {
|
|
191
|
+
style: styles.blocks,
|
|
192
|
+
children: blocks.map(({
|
|
193
|
+
block
|
|
194
|
+
}) => /*#__PURE__*/_jsx(BlockRenderer, {
|
|
195
|
+
block: block
|
|
196
|
+
}, block.id))
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
function UserMessage({
|
|
200
|
+
message
|
|
201
|
+
}) {
|
|
202
|
+
return /*#__PURE__*/_jsx(View, {
|
|
203
|
+
style: styles.userWrap,
|
|
204
|
+
children: /*#__PURE__*/_jsx(View, {
|
|
205
|
+
style: styles.userBubble,
|
|
206
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
207
|
+
style: styles.userText,
|
|
208
|
+
selectable: true,
|
|
209
|
+
children: message.text
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function AssistantMessage({
|
|
215
|
+
message,
|
|
216
|
+
onRetry
|
|
217
|
+
}) {
|
|
218
|
+
const {
|
|
219
|
+
showThinking
|
|
220
|
+
} = useAskBuoySettings();
|
|
221
|
+
const running = message.toolCalls.some(c => c.status === "running");
|
|
222
|
+
const waiting = !!message.streaming && message.text.length === 0 && !running;
|
|
223
|
+
const askBlocks = message.blocks.filter(b => isAskBlock(b.block));
|
|
224
|
+
const showBlocks = message.blocks.filter(b => !isAskBlock(b.block));
|
|
225
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
226
|
+
style: styles.assistantWrap,
|
|
227
|
+
children: [message.toolCalls.length > 0 && /*#__PURE__*/_jsx(ActivityCard, {
|
|
228
|
+
calls: message.toolCalls
|
|
229
|
+
}), /*#__PURE__*/_jsx(Blocks, {
|
|
230
|
+
blocks: showBlocks
|
|
231
|
+
}), message.text.length > 0 && /*#__PURE__*/_jsx(Markdown, {
|
|
232
|
+
text: message.text,
|
|
233
|
+
style: styles.assistantText
|
|
234
|
+
}), /*#__PURE__*/_jsx(Blocks, {
|
|
235
|
+
blocks: askBlocks
|
|
236
|
+
}), showThinking && !message.streaming && /*#__PURE__*/_jsx(ThinkingStrip, {
|
|
237
|
+
message: message
|
|
238
|
+
}), waiting && /*#__PURE__*/_jsx(TypingDots, {}), message.error && /*#__PURE__*/_jsx(ErrorNote, {
|
|
239
|
+
error: message.error,
|
|
240
|
+
onRetry: onRetry
|
|
241
|
+
})]
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* A failed turn. The headline is for the tester ("couldn't reach the
|
|
247
|
+
* endpoint"); the raw message stays underneath for whoever gets the bug
|
|
248
|
+
* report, because "fetch failed: UnexpectedException: The network connection
|
|
249
|
+
* was lost" is what a developer needs and nothing a tester can act on.
|
|
250
|
+
*/
|
|
251
|
+
function ErrorNote({
|
|
252
|
+
error,
|
|
253
|
+
onRetry
|
|
254
|
+
}) {
|
|
255
|
+
const network = /fetch failed|network|ECONN|timed? ?out|socket|abort/i.test(error);
|
|
256
|
+
const headline = network ? "Couldn't reach your AI endpoint. Check the connection and try again." : "Something went wrong with that turn.";
|
|
257
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
258
|
+
style: styles.errorBox,
|
|
259
|
+
testID: "buoy-ask-buoy-error",
|
|
260
|
+
children: [/*#__PURE__*/_jsx(AlertTriangle, {
|
|
261
|
+
size: 14,
|
|
262
|
+
color: night.color.danger
|
|
263
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
264
|
+
style: styles.errorBody,
|
|
265
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
266
|
+
style: styles.errorText,
|
|
267
|
+
children: headline
|
|
268
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
269
|
+
style: styles.errorDetail,
|
|
270
|
+
selectable: true,
|
|
271
|
+
children: error
|
|
272
|
+
}), onRetry && /*#__PURE__*/_jsx(Pressable, {
|
|
273
|
+
testID: "buoy-ask-buoy-retry",
|
|
274
|
+
accessibilityRole: "button",
|
|
275
|
+
onPress: onRetry,
|
|
276
|
+
style: ({
|
|
277
|
+
pressed
|
|
278
|
+
}) => [styles.retry, pressed && styles.retryPressed],
|
|
279
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
280
|
+
style: styles.retryText,
|
|
281
|
+
children: "Retry"
|
|
282
|
+
})
|
|
283
|
+
})]
|
|
284
|
+
})]
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* The whole conversation as plain text — the only thing Copy ever produces,
|
|
290
|
+
* and the only way a session leaves the DEVICE (what it saves to disk for a
|
|
291
|
+
* reload goes nowhere — see `transcriptPersistence`).
|
|
292
|
+
*
|
|
293
|
+
* Plain text on purpose. This lands in a Slack message, a ticket comment or a
|
|
294
|
+
* notes file, all of which are read by a person; a JSON document is a worse
|
|
295
|
+
* version of that everywhere except a parser, and nothing here parses it.
|
|
296
|
+
*
|
|
297
|
+
* With `Show agent thinking` on it carries the working too — the reasoning and
|
|
298
|
+
* each step with its parameters — because reading the run somewhere that is
|
|
299
|
+
* not a phone is the entire point of that setting.
|
|
300
|
+
*/
|
|
301
|
+
export function transcriptToText(messages, withTrace = false) {
|
|
302
|
+
const lines = [];
|
|
303
|
+
for (const m of messages) {
|
|
304
|
+
if (m.role === "user") {
|
|
305
|
+
lines.push(`You: ${m.text}`);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (withTrace) {
|
|
309
|
+
lines.push(...traceToText(m));
|
|
310
|
+
} else {
|
|
311
|
+
for (const c of m.toolCalls) {
|
|
312
|
+
const status = c.status === "failed" || c.status === "refused" ? ` (${c.status})` : "";
|
|
313
|
+
lines.push(` · ${c.label}${c.summary ? ` — ${c.summary}` : ""}${status}`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (m.text) lines.push(`Ask Buoy: ${m.text}`);
|
|
317
|
+
if (m.error) lines.push(` ! ${m.error}`);
|
|
318
|
+
}
|
|
319
|
+
return lines.join("\n");
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** Copy, with the result visible for a moment. Shares the header's behaviour. */
|
|
323
|
+
function CopyPill({
|
|
324
|
+
testID,
|
|
325
|
+
label,
|
|
326
|
+
getText
|
|
327
|
+
}) {
|
|
328
|
+
const {
|
|
329
|
+
copied,
|
|
330
|
+
copy
|
|
331
|
+
} = useCopyAction(getText);
|
|
332
|
+
return /*#__PURE__*/_jsxs(Pressable, {
|
|
333
|
+
testID: testID,
|
|
334
|
+
accessibilityRole: "button",
|
|
335
|
+
accessibilityLabel: label,
|
|
336
|
+
onPress: copy,
|
|
337
|
+
style: ({
|
|
338
|
+
pressed
|
|
339
|
+
}) => [styles.copyBtn, styles.iconBtn, pressed && styles.copyPressed],
|
|
340
|
+
children: [copied ? /*#__PURE__*/_jsx(Check, {
|
|
341
|
+
size: 11,
|
|
342
|
+
color: night.color.accent
|
|
343
|
+
}) : /*#__PURE__*/_jsx(Copy, {
|
|
344
|
+
size: 11,
|
|
345
|
+
color: night.color.textSecondary
|
|
346
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
347
|
+
style: [styles.copyText, copied && styles.copiedText],
|
|
348
|
+
children: copied ? "Copied" : label
|
|
349
|
+
})]
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Under a finished answer: one Copy, and nothing else.
|
|
355
|
+
*
|
|
356
|
+
* It is on EVERY answer rather than only the newest, because the moment you
|
|
357
|
+
* decide to keep a conversation is usually a few replies after the one that
|
|
358
|
+
* went wrong, and scrolling to the bottom to find the button is friction at
|
|
359
|
+
* exactly the wrong time. Every one of them copies the WHOLE chat — one button
|
|
360
|
+
* with one meaning beats four pills the reader has to choose between.
|
|
361
|
+
*/
|
|
362
|
+
function TranscriptActions({
|
|
363
|
+
messages
|
|
364
|
+
}) {
|
|
365
|
+
const {
|
|
366
|
+
showThinking
|
|
367
|
+
} = useAskBuoySettings();
|
|
368
|
+
const getText = useCallback(() => transcriptToText(messages, showThinking), [messages, showThinking]);
|
|
369
|
+
return /*#__PURE__*/_jsx(View, {
|
|
370
|
+
style: styles.transcriptActions,
|
|
371
|
+
children: /*#__PURE__*/_jsx(CopyPill, {
|
|
372
|
+
testID: "buoy-ask-buoy-copy",
|
|
373
|
+
label: "Copy",
|
|
374
|
+
getText: getText
|
|
375
|
+
})
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
function Row({
|
|
379
|
+
message,
|
|
380
|
+
messages,
|
|
381
|
+
onRetry
|
|
382
|
+
}) {
|
|
383
|
+
if (message.role === "user") return /*#__PURE__*/_jsx(UserMessage, {
|
|
384
|
+
message: message
|
|
385
|
+
});
|
|
386
|
+
const finished = !message.streaming && !message.error;
|
|
387
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
388
|
+
children: [/*#__PURE__*/_jsx(AssistantMessage, {
|
|
389
|
+
message: message,
|
|
390
|
+
onRetry: onRetry
|
|
391
|
+
}), finished && /*#__PURE__*/_jsx(TranscriptActions, {
|
|
392
|
+
messages: messages
|
|
393
|
+
})]
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
export function MessageList({
|
|
397
|
+
messages,
|
|
398
|
+
ListHeaderComponent,
|
|
399
|
+
ListEmptyComponent,
|
|
400
|
+
ListFooterComponent,
|
|
401
|
+
onRetry
|
|
402
|
+
}) {
|
|
403
|
+
const ref = useRef(null);
|
|
404
|
+
// Only auto-scroll when the user is already at the bottom. Yanking them back
|
|
405
|
+
// down while they are reading an earlier answer is the classic chat-UI sin.
|
|
406
|
+
//
|
|
407
|
+
// "At the bottom" is decided from the USER's gestures, not from every scroll
|
|
408
|
+
// event. An animated scrollToEnd fires intermediate events while the content
|
|
409
|
+
// is still growing under it, and reading those as "the user scrolled up"
|
|
410
|
+
// silently unpinned the list mid-answer — the reply then streamed in below
|
|
411
|
+
// the fold and the last thing on screen was the question.
|
|
412
|
+
const pinned = useRef(true);
|
|
413
|
+
const dragging = useRef(false);
|
|
414
|
+
const measure = useCallback(e => {
|
|
415
|
+
const {
|
|
416
|
+
contentOffset,
|
|
417
|
+
contentSize,
|
|
418
|
+
layoutMeasurement
|
|
419
|
+
} = e.nativeEvent;
|
|
420
|
+
const distance = contentSize.height - layoutMeasurement.height - contentOffset.y;
|
|
421
|
+
pinned.current = distance < 80;
|
|
422
|
+
}, []);
|
|
423
|
+
const onScrollBeginDrag = useCallback(() => {
|
|
424
|
+
dragging.current = true;
|
|
425
|
+
}, []);
|
|
426
|
+
const onScroll = useCallback(e => {
|
|
427
|
+
if (dragging.current) measure(e);
|
|
428
|
+
}, [measure]);
|
|
429
|
+
const onScrollEndDrag = useCallback(e => {
|
|
430
|
+
dragging.current = false;
|
|
431
|
+
measure(e);
|
|
432
|
+
}, [measure]);
|
|
433
|
+
const scrollToEnd = useCallback(() => {
|
|
434
|
+
if (!pinned.current) return;
|
|
435
|
+
// The size change fires before the new row has finished laying out its
|
|
436
|
+
// wrapped text; one frame later the end really is the end.
|
|
437
|
+
ref.current?.scrollToEnd({
|
|
438
|
+
animated: false
|
|
439
|
+
});
|
|
440
|
+
requestAnimationFrame(() => ref.current?.scrollToEnd({
|
|
441
|
+
animated: false
|
|
442
|
+
}));
|
|
443
|
+
}, []);
|
|
444
|
+
|
|
445
|
+
// A row can grow without the list reporting a size change in the same tick
|
|
446
|
+
// (an error box appended to the last message). Follow the transcript too.
|
|
447
|
+
const last = messages[messages.length - 1];
|
|
448
|
+
const tail = last ? `${last.id}:${last.text.length}:${last.toolCalls.length}:${last.error ?? ""}` : "";
|
|
449
|
+
useEffect(() => {
|
|
450
|
+
scrollToEnd();
|
|
451
|
+
}, [tail, scrollToEnd]);
|
|
452
|
+
return /*#__PURE__*/_jsx(FlatList, {
|
|
453
|
+
ref: ref,
|
|
454
|
+
testID: "buoy-ask-buoy-messages-scroll",
|
|
455
|
+
style: styles.list,
|
|
456
|
+
contentContainerStyle: styles.listContent,
|
|
457
|
+
data: messages,
|
|
458
|
+
keyExtractor: m => m.id,
|
|
459
|
+
renderItem: ({
|
|
460
|
+
item
|
|
461
|
+
}) => /*#__PURE__*/_jsx(Row, {
|
|
462
|
+
message: item,
|
|
463
|
+
messages: messages,
|
|
464
|
+
onRetry: item.id === last?.id ? onRetry : undefined
|
|
465
|
+
}),
|
|
466
|
+
onScroll: onScroll,
|
|
467
|
+
onScrollBeginDrag: onScrollBeginDrag,
|
|
468
|
+
onScrollEndDrag: onScrollEndDrag,
|
|
469
|
+
onMomentumScrollEnd: measure,
|
|
470
|
+
scrollEventThrottle: 32,
|
|
471
|
+
onContentSizeChange: scrollToEnd
|
|
472
|
+
// Mandatory with a focused input below: without it the first tap after
|
|
473
|
+
// typing only dismisses the keyboard and the button never fires.
|
|
474
|
+
,
|
|
475
|
+
keyboardShouldPersistTaps: "handled",
|
|
476
|
+
keyboardDismissMode: "interactive",
|
|
477
|
+
ListHeaderComponent: ListHeaderComponent,
|
|
478
|
+
ListEmptyComponent: ListEmptyComponent,
|
|
479
|
+
ListFooterComponent: ListFooterComponent
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
const styles = StyleSheet.create({
|
|
483
|
+
list: {
|
|
484
|
+
flex: 1,
|
|
485
|
+
backgroundColor: "transparent"
|
|
486
|
+
},
|
|
487
|
+
listContent: {
|
|
488
|
+
paddingHorizontal: night.gutter,
|
|
489
|
+
paddingTop: 12,
|
|
490
|
+
paddingBottom: 16,
|
|
491
|
+
gap: 16,
|
|
492
|
+
flexGrow: 1
|
|
493
|
+
},
|
|
494
|
+
// User
|
|
495
|
+
userWrap: {
|
|
496
|
+
alignItems: "flex-end"
|
|
497
|
+
},
|
|
498
|
+
userBubble: {
|
|
499
|
+
maxWidth: "84%",
|
|
500
|
+
paddingHorizontal: 14,
|
|
501
|
+
paddingVertical: 9,
|
|
502
|
+
borderRadius: 18,
|
|
503
|
+
borderBottomRightRadius: 6,
|
|
504
|
+
backgroundColor: night.color.accentFill,
|
|
505
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
506
|
+
borderColor: night.color.accentBorder
|
|
507
|
+
},
|
|
508
|
+
userText: {
|
|
509
|
+
color: night.color.text,
|
|
510
|
+
fontSize: night.font.row,
|
|
511
|
+
lineHeight: 21
|
|
512
|
+
},
|
|
513
|
+
// Assistant
|
|
514
|
+
assistantWrap: {
|
|
515
|
+
alignItems: "stretch",
|
|
516
|
+
gap: 10
|
|
517
|
+
},
|
|
518
|
+
blocks: {
|
|
519
|
+
gap: 10
|
|
520
|
+
},
|
|
521
|
+
assistantText: {
|
|
522
|
+
color: night.color.text,
|
|
523
|
+
fontSize: night.font.row,
|
|
524
|
+
lineHeight: 22,
|
|
525
|
+
paddingHorizontal: 2
|
|
526
|
+
},
|
|
527
|
+
// Activity card
|
|
528
|
+
card: {
|
|
529
|
+
borderRadius: night.radius.card,
|
|
530
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
531
|
+
borderColor: night.color.border,
|
|
532
|
+
backgroundColor: night.color.surface,
|
|
533
|
+
overflow: "hidden"
|
|
534
|
+
},
|
|
535
|
+
row: {
|
|
536
|
+
paddingHorizontal: 12,
|
|
537
|
+
paddingVertical: 10
|
|
538
|
+
},
|
|
539
|
+
rowDivider: {
|
|
540
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
541
|
+
borderBottomColor: night.color.separator
|
|
542
|
+
},
|
|
543
|
+
rowLine: {
|
|
544
|
+
flexDirection: "row",
|
|
545
|
+
alignItems: "center",
|
|
546
|
+
gap: 10
|
|
547
|
+
},
|
|
548
|
+
markSlot: {
|
|
549
|
+
width: 18,
|
|
550
|
+
height: 18,
|
|
551
|
+
alignItems: "center",
|
|
552
|
+
justifyContent: "center"
|
|
553
|
+
},
|
|
554
|
+
mark: {
|
|
555
|
+
width: 16,
|
|
556
|
+
height: 16,
|
|
557
|
+
borderRadius: 8,
|
|
558
|
+
alignItems: "center",
|
|
559
|
+
justifyContent: "center"
|
|
560
|
+
},
|
|
561
|
+
markOk: {
|
|
562
|
+
backgroundColor: night.color.accent
|
|
563
|
+
},
|
|
564
|
+
markFailed: {
|
|
565
|
+
backgroundColor: night.color.danger
|
|
566
|
+
},
|
|
567
|
+
markRefused: {
|
|
568
|
+
backgroundColor: night.color.warning
|
|
569
|
+
},
|
|
570
|
+
rowTitle: {
|
|
571
|
+
flex: 1,
|
|
572
|
+
color: night.color.text,
|
|
573
|
+
fontSize: night.font.body,
|
|
574
|
+
lineHeight: 19
|
|
575
|
+
},
|
|
576
|
+
rowStatus: {
|
|
577
|
+
color: night.color.textTertiary,
|
|
578
|
+
fontSize: night.font.caption,
|
|
579
|
+
maxWidth: 120
|
|
580
|
+
},
|
|
581
|
+
rowStatusDanger: {
|
|
582
|
+
color: night.color.danger
|
|
583
|
+
},
|
|
584
|
+
rowStatusWarning: {
|
|
585
|
+
color: night.color.warning
|
|
586
|
+
},
|
|
587
|
+
rowDetail: {
|
|
588
|
+
paddingLeft: 28,
|
|
589
|
+
paddingTop: 8,
|
|
590
|
+
gap: 4
|
|
591
|
+
},
|
|
592
|
+
rowTool: {
|
|
593
|
+
color: night.color.textTertiary,
|
|
594
|
+
fontSize: night.font.micro,
|
|
595
|
+
fontWeight: "600",
|
|
596
|
+
letterSpacing: 0.8
|
|
597
|
+
},
|
|
598
|
+
rowDescription: {
|
|
599
|
+
color: night.color.textSecondary,
|
|
600
|
+
fontSize: night.font.caption,
|
|
601
|
+
lineHeight: 18
|
|
602
|
+
},
|
|
603
|
+
rowFailure: {
|
|
604
|
+
color: night.color.danger,
|
|
605
|
+
fontSize: night.font.caption,
|
|
606
|
+
lineHeight: 18
|
|
607
|
+
},
|
|
608
|
+
// Error
|
|
609
|
+
errorBox: {
|
|
610
|
+
flexDirection: "row",
|
|
611
|
+
alignItems: "flex-start",
|
|
612
|
+
gap: 8,
|
|
613
|
+
paddingHorizontal: 12,
|
|
614
|
+
paddingVertical: 10,
|
|
615
|
+
borderRadius: night.radius.row,
|
|
616
|
+
backgroundColor: night.color.dangerSoft
|
|
617
|
+
},
|
|
618
|
+
errorBody: {
|
|
619
|
+
flex: 1,
|
|
620
|
+
gap: 4
|
|
621
|
+
},
|
|
622
|
+
errorText: {
|
|
623
|
+
color: night.color.danger,
|
|
624
|
+
fontSize: night.font.caption,
|
|
625
|
+
fontWeight: "600",
|
|
626
|
+
lineHeight: 18
|
|
627
|
+
},
|
|
628
|
+
errorDetail: {
|
|
629
|
+
color: night.color.textSecondary,
|
|
630
|
+
fontSize: night.font.micro,
|
|
631
|
+
lineHeight: 15
|
|
632
|
+
},
|
|
633
|
+
retry: {
|
|
634
|
+
alignSelf: "flex-start",
|
|
635
|
+
marginTop: 6,
|
|
636
|
+
paddingHorizontal: 14,
|
|
637
|
+
paddingVertical: 7,
|
|
638
|
+
borderRadius: night.radius.row,
|
|
639
|
+
backgroundColor: night.color.button
|
|
640
|
+
},
|
|
641
|
+
retryPressed: {
|
|
642
|
+
opacity: 0.7
|
|
643
|
+
},
|
|
644
|
+
retryText: {
|
|
645
|
+
color: night.color.accent,
|
|
646
|
+
fontSize: night.font.caption,
|
|
647
|
+
fontWeight: "600"
|
|
648
|
+
},
|
|
649
|
+
transcriptActions: {
|
|
650
|
+
flexDirection: "row",
|
|
651
|
+
marginTop: 8
|
|
652
|
+
},
|
|
653
|
+
copyBtn: {
|
|
654
|
+
paddingHorizontal: 10,
|
|
655
|
+
paddingVertical: 5,
|
|
656
|
+
borderRadius: night.radius.badge,
|
|
657
|
+
backgroundColor: night.color.fill
|
|
658
|
+
},
|
|
659
|
+
iconBtn: {
|
|
660
|
+
flexDirection: "row",
|
|
661
|
+
alignItems: "center",
|
|
662
|
+
gap: 4,
|
|
663
|
+
paddingHorizontal: 8
|
|
664
|
+
},
|
|
665
|
+
copyPressed: {
|
|
666
|
+
opacity: 0.7
|
|
667
|
+
},
|
|
668
|
+
copyText: {
|
|
669
|
+
color: night.color.textSecondary,
|
|
670
|
+
fontSize: night.font.micro,
|
|
671
|
+
fontWeight: "600"
|
|
672
|
+
},
|
|
673
|
+
copiedText: {
|
|
674
|
+
color: night.color.accent
|
|
675
|
+
}
|
|
676
|
+
});
|
|
677
|
+
//# sourceMappingURL=MessageList.js.map
|