@@ -40,6 +40,7 @@ import {
4040 type MessageId ,
4141 type OrchestrationV2ProjectedTurnItem ,
4242 type RunId ,
43+ type ScheduledTaskId ,
4344} from "@t3tools/contracts" ;
4445import { renderAssistantCitationsAsText } from "@t3tools/shared/assistantCitations" ;
4546import { encodeComposerContextFragment } from "@t3tools/shared/composerContextClipboard" ;
@@ -236,6 +237,8 @@ import {
236237} from "@t3tools/client-runtime/workspace-basename-lookup" ;
237238import { useLiveThreadLinkLabels } from "../../state/entities" ;
238239import { useThreadSelection } from "../../state/use-thread-selection" ;
240+ import { useEnvironmentQuery } from "../../state/query" ;
241+ import { serverEnvironment } from "../../state/server" ;
239242import { composerDocumentAttachmentRecord } from "../../lib/composerContext" ;
240243import * as Option from "effect/Option" ;
241244import { appAtomRegistry } from "../../state/atom-registry" ;
@@ -983,6 +986,125 @@ function AgentMessageAttribution(props: {
983986 ) ;
984987}
985988
989+ /** Automation prompts are long, repeated runbooks; a folded bubble keeps them out of the way. */
990+ function ThreadAutomationMessageRow ( props : {
991+ readonly environmentId : EnvironmentId ;
992+ readonly text : string ;
993+ readonly context ?: OrchestrationMessageContext ;
994+ readonly scheduledTaskId : ScheduledTaskId | undefined ;
995+ readonly timestampLabel : string ;
996+ readonly expanded : boolean ;
997+ readonly onToggle : ( ) => void ;
998+ readonly bubbleColor : ColorValue ;
999+ readonly bubbleMaxWidth : number | "85%" ;
1000+ readonly contentMaxWidth : number ;
1001+ readonly iconSubtleColor : ColorValue ;
1002+ readonly markdownStyles : MarkdownStyleSet ;
1003+ readonly reviewCommentColors : ReviewCommentColors ;
1004+ readonly skills ?: ReadonlyArray < SelectableMarkdownSkill > ;
1005+ readonly linkHandlers : MarkdownLinkHandlers ;
1006+ readonly renderImage : MarkdownImageRenderer ;
1007+ } ) {
1008+ const navigation = useNavigation ( ) ;
1009+ const tasks = useEnvironmentQuery (
1010+ props . scheduledTaskId
1011+ ? serverEnvironment . scheduledTasksLive ( { environmentId : props . environmentId , input : { } } )
1012+ : null ,
1013+ ) ;
1014+ const taskTitle = tasks . data ?. tasks . find ( ( task ) => task . id === props . scheduledTaskId ) ?. title ;
1015+ const summary = taskTitle ?? props . text . trim ( ) . split ( / \r ? \n / , 1 ) [ 0 ] ?? "" ;
1016+
1017+ return (
1018+ < View className = "mb-5 items-end" >
1019+ < View
1020+ className = "min-w-0 rounded-[20px]"
1021+ style = { {
1022+ backgroundColor : props . bubbleColor ,
1023+ maxWidth : props . bubbleMaxWidth ,
1024+ ...( props . expanded ? { width : props . bubbleMaxWidth } : null ) ,
1025+ } }
1026+ >
1027+ < Pressable
1028+ accessibilityRole = "button"
1029+ accessibilityLabel = { `Automation: ${ summary } ` }
1030+ accessibilityHint = { `Double tap to ${ props . expanded ? "hide" : "show" } the prompt.` }
1031+ accessibilityState = { { expanded : props . expanded } }
1032+ hitSlop = { 4 }
1033+ className = "min-h-10 flex-row items-center gap-1.5 px-3.5 py-2"
1034+ onPress = { ( ) => {
1035+ void Haptics . selectionAsync ( ) ;
1036+ props . onToggle ( ) ;
1037+ } }
1038+ >
1039+ < SymbolView
1040+ name = "calendar.badge.clock"
1041+ size = { 14 }
1042+ weight = "medium"
1043+ tintColorClassName = "accent-user-bubble-foreground-muted"
1044+ type = "monochrome"
1045+ />
1046+ < Text className = "font-t3-medium text-sm text-user-bubble-foreground-muted" >
1047+ Automation
1048+ </ Text >
1049+ < Text numberOfLines = { 1 } className = "min-w-0 shrink text-sm text-user-bubble-foreground" >
1050+ { summary }
1051+ </ Text >
1052+ < ThreadDisclosureChevron
1053+ expanded = { props . expanded }
1054+ collapsedDirection = "down"
1055+ size = { 11 }
1056+ tintColor = { props . iconSubtleColor }
1057+ />
1058+ </ Pressable >
1059+ { props . expanded ? (
1060+ < View className = "px-3.5 pb-2.5" >
1061+ < MarkdownImageAvailableWidthContext value = { props . contentMaxWidth } >
1062+ < UserMessageContent
1063+ text = { renderAssistantCitationsAsText ( props . text ) }
1064+ environmentId = { props . environmentId }
1065+ context = { props . context }
1066+ markdownStyles = { props . markdownStyles }
1067+ reviewCommentColors = { props . reviewCommentColors }
1068+ skills = { props . skills }
1069+ linkHandlers = { props . linkHandlers }
1070+ renderImage = { props . renderImage }
1071+ />
1072+ </ MarkdownImageAvailableWidthContext >
1073+ </ View >
1074+ ) : null }
1075+ </ View >
1076+ { props . expanded ? (
1077+ < View className = "mt-1 flex-row items-center justify-end gap-2 pr-0.5" >
1078+ { props . scheduledTaskId ? (
1079+ < Pressable
1080+ accessibilityRole = "link"
1081+ hitSlop = { 6 }
1082+ onPress = { ( ) =>
1083+ navigation . navigate ( "SettingsSheet" , {
1084+ screen : "SettingsContent" ,
1085+ params : { screen : "SettingsScheduledTasks" } ,
1086+ } )
1087+ }
1088+ >
1089+ < Text className = "font-t3-medium text-xs text-foreground-secondary" >
1090+ Open automation
1091+ </ Text >
1092+ </ Pressable >
1093+ ) : null }
1094+ < Text className = "font-t3-medium text-xs tabular-nums text-foreground-secondary" >
1095+ { props . timestampLabel }
1096+ </ Text >
1097+ < UserMessageCopyButton
1098+ text = { props . text }
1099+ onCopy = { undefined }
1100+ tintColor = { props . iconSubtleColor }
1101+ />
1102+ </ View >
1103+ ) : null }
1104+ </ View >
1105+ ) ;
1106+ }
1107+
9861108function renderFeedEntry (
9871109 info : { item : PendingThreadFeedEntry ; index : number } ,
9881110 props : Pick <
@@ -1200,6 +1322,29 @@ function renderFeedEntry(
12001322 />
12011323 ) ;
12021324 }
1325+ if ( isUser && presentation . attribution === "automation" ) {
1326+ const rowId = `automation:${ message . id } ` ;
1327+ return (
1328+ < ThreadAutomationMessageRow
1329+ environmentId = { props . environmentId }
1330+ text = { presentation . text }
1331+ context = { message . context }
1332+ scheduledTaskId = { presentation . scheduledTaskId }
1333+ timestampLabel = { timestampLabel }
1334+ expanded = { props . expandedWorkRows [ rowId ] ?? false }
1335+ onToggle = { ( ) => props . onToggleWorkRow ( rowId , entry . id ) }
1336+ bubbleColor = { userBubbleColor }
1337+ bubbleMaxWidth = { props . duoColumns ? "85%" : props . userBubbleMaxWidth }
1338+ contentMaxWidth = { props . userBubbleMaxWidth - USER_BUBBLE_HORIZONTAL_PADDING * 2 }
1339+ iconSubtleColor = { iconSubtleColor }
1340+ markdownStyles = { markdownStyles . user }
1341+ reviewCommentColors = { props . reviewCommentColors }
1342+ skills = { props . skills }
1343+ linkHandlers = { props . markdownLinkHandlers }
1344+ renderImage = { props . renderMarkdownImage }
1345+ />
1346+ ) ;
1347+ }
12031348 if ( isUser ) {
12041349 const enterAnimated = isFreshTimestamp ( message . createdAt ) ;
12051350 const intentBadge = resolveUserMessageIntentBadge ( message . inputIntent ) ;
@@ -1221,11 +1366,7 @@ function renderFeedEntry(
12211366 className = "mb-5 items-end"
12221367 { ...( enterAnimated ? { entering : FadeInUp . duration ( 220 ) } : { } ) }
12231368 >
1224- { presentation . attribution === "automation" ? (
1225- < Text className = "mb-1 pr-1 font-t3-medium text-2xs text-foreground-muted opacity-60" >
1226- Sent by automation
1227- </ Text >
1228- ) : presentation . attribution === "t3code" ? (
1369+ { presentation . attribution === "t3code" ? (
12291370 < Text className = "mb-1 pr-1 font-t3-medium text-2xs text-foreground-muted opacity-60" >
12301371 Sent by T3 Code
12311372 </ Text >
@@ -2739,7 +2880,11 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
27392880 viewabilityConfig = { THREAD_MEDIA_VIEWABILITY_CONFIG }
27402881 keyExtractor = { ( entry ) => entry . id }
27412882 getItemType = { ( entry ) =>
2742- entry . type === "message" ? `message:${ entry . message . role } ` : entry . type
2883+ entry . type !== "message"
2884+ ? entry . type
2885+ : resolveUserMessagePresentation ( entry . message ) . attribution === "automation"
2886+ ? "message:automation"
2887+ : `message:${ entry . message . role } `
27432888 }
27442889 getFixedItemSize = { getFixedItemSize }
27452890 // Virtualized rows must move with their measurements. Native layout
0 commit comments