@@ -53,9 +53,12 @@ import { scopeThreadRef } from "@t3tools/client-runtime/environment";
5353import { environmentThreadDetails , threadEnvironment } from "../../state/threads" ;
5454import { useAtomCommand } from "../../state/use-atom-command" ;
5555import { toolActivityFaviconUrl } from "@t3tools/shared/favicon" ;
56+ import { isJavaScriptReplTool } from "@t3tools/shared/toolActivity" ;
57+ import { useMarkdownCodeHighlight } from "./markdownCodeHighlightState" ;
5658
5759import { AppText as Text } from "../../components/AppText" ;
5860import { T3Wordmark } from "../../components/T3Wordmark" ;
61+ import { BrowserAppIcon } from "../../components/BrowserAppIcon" ;
5962import { cn } from "../../lib/cn" ;
6063import { THREAD_WORK_ROW_MIN_HEIGHT , type deriveThreadWorkLogSizing } from "../../lib/layout" ;
6164import {
@@ -111,7 +114,13 @@ export const THREAD_DISCLOSURE_TRANSITION_MS = 180;
111114const WORK_LOG_LAYOUT_TRANSITION = LinearTransition . duration ( THREAD_DISCLOSURE_TRANSITION_MS ) ;
112115const WORK_LOG_DETAIL_ENTER_TRANSITION = FadeIn . duration ( 140 ) ;
113116const WORK_LOG_DETAIL_EXIT_TRANSITION = FadeOut . duration ( 120 ) ;
114- type WorkContentIcon = AppSymbolName | "browser" | "device" | "t3-code" | "pull-request" ;
117+ type WorkContentIcon =
118+ | AppSymbolName
119+ | "browser"
120+ | "computer"
121+ | "device"
122+ | "t3-code"
123+ | "pull-request" ;
115124
116125function WorkLogIcon ( props : {
117126 readonly icon : WorkContentIcon ;
@@ -125,6 +134,14 @@ function WorkLogIcon(props: {
125134 < T3Wordmark height = { 10 } { ...( colorClassName ? { colorClassName } : { color : props . color } ) } />
126135 ) ;
127136 }
137+ if ( props . icon === "computer" ) {
138+ return (
139+ < BrowserAppIcon
140+ size = { 14 }
141+ { ...( colorClassName ? { colorClassName } : { color : props . color } ) }
142+ />
143+ ) ;
144+ }
128145 return (
129146 < SymbolView
130147 name = {
@@ -372,7 +389,7 @@ export function ShimmeringWorkContent(props: {
372389 ) ;
373390}
374391
375- function workRowSymbolName ( icon : ThreadFeedActivity [ "icon" ] ) : AppSymbolName {
392+ function workRowSymbolName ( icon : ThreadFeedActivity [ "icon" ] ) : WorkContentIcon {
376393 switch ( icon ) {
377394 case "agent" :
378395 return { ios : "sparkles" , android : "auto_awesome" } ;
@@ -385,7 +402,9 @@ function workRowSymbolName(icon: ThreadFeedActivity["icon"]): AppSymbolName {
385402 case "command" :
386403 return { ios : "terminal" , android : "terminal" } ;
387404 case "computer" :
388- return { ios : "desktopcomputer" , android : "desktop_windows" } ;
405+ return "computer" ;
406+ case "code" :
407+ return "chevron.left.forwardslash.chevron.right" ;
389408 case "edit" :
390409 return { ios : "square.and.pencil" , android : "edit" } ;
391410 case "eye" :
@@ -832,6 +851,38 @@ function WorkspacePreparationRetryButton(props: {
832851 ) ;
833852}
834853
854+ function ReplCodeText ( {
855+ code,
856+ theme,
857+ } : {
858+ readonly code : string ;
859+ readonly theme : "light" | "dark" ;
860+ } ) {
861+ const lines = useMarkdownCodeHighlight ( { code, language : "typescript" , theme, enabled : true } ) ;
862+ let offset = 0 ;
863+ const highlighted = lines ?. flatMap ( ( line , lineIndex ) => {
864+ const separator = lineIndex > 0 ? "\n" : "" ;
865+ offset += separator . length ;
866+ return [
867+ separator ,
868+ ...line . map ( ( token ) => {
869+ const start = offset ;
870+ offset += token . content . length ;
871+ return (
872+ < Text key = { start } style = { token . color ? { color : token . color } : undefined } >
873+ { token . content }
874+ </ Text >
875+ ) ;
876+ } ) ,
877+ ] ;
878+ } ) ;
879+ return (
880+ < Text selectable className = "font-mono text-2xs leading-normal text-foreground" >
881+ { highlighted ?? code }
882+ </ Text >
883+ ) ;
884+ }
885+
835886const ThreadWorkLogRow = memo ( function ThreadWorkLogRow (
836887 props : Omit <
837888 ThreadWorkLogProps ,
@@ -1177,19 +1228,36 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
11771228 ) : call ? (
11781229 [
11791230 call . command ,
1180- ...( call . args ?? [ ] ) . map ( ( [ key , value ] ) => `${ key } ${ value } ` ) ,
1231+ ...( call . args ?? [ ] ) . map ( ( [ key , value ] ) =>
1232+ key === "code" &&
1233+ shownItem . type === "dynamic_tool" &&
1234+ isJavaScriptReplTool ( shownItem . toolName ) ? (
1235+ < View key = { key } >
1236+ < Text className = "font-mono text-2xs leading-normal text-foreground-muted" >
1237+ { key }
1238+ </ Text >
1239+ < ReplCodeText code = { value } theme = { props . themeAppearance } />
1240+ </ View >
1241+ ) : (
1242+ `${ key } ${ value } `
1243+ ) ,
1244+ ) ,
11811245 call . argsText ,
11821246 ]
1183- . filter ( ( line ) : line is string => Boolean ( line ) )
1184- . map ( ( line , index ) => (
1185- < Text
1186- key = { `${ index } :${ line } ` }
1187- selectable
1188- className = "font-mono text-2xs leading-normal text-foreground"
1189- >
1190- { line }
1191- </ Text >
1192- ) )
1247+ . filter ( ( line ) => Boolean ( line ) )
1248+ . map ( ( line , index ) =>
1249+ typeof line === "string" ? (
1250+ < Text
1251+ key = { `${ index } :${ line } ` }
1252+ selectable
1253+ className = "font-mono text-2xs leading-normal text-foreground"
1254+ >
1255+ { line }
1256+ </ Text >
1257+ ) : (
1258+ line
1259+ ) ,
1260+ )
11931261 ) : fullDetail ? (
11941262 < Text selectable className = "font-mono text-2xs leading-normal text-foreground-muted" >
11951263 { fullDetail }
0 commit comments