@@ -25,6 +25,7 @@ import {
2525 useEffect ,
2626 useId ,
2727 useLayoutEffect ,
28+ useMemo ,
2829 useRef ,
2930 useState ,
3031 type ComponentProps ,
@@ -36,6 +37,7 @@ import {
3637 Pressable ,
3738 ScrollView ,
3839 StyleSheet ,
40+ Text as RNText ,
3941 useAnimatedValue ,
4042 View ,
4143} from "react-native" ;
@@ -54,6 +56,11 @@ import { useAtomCommand } from "../../state/use-atom-command";
5456import { toolActivityFaviconUrl } from "@t3tools/shared/favicon" ;
5557import { isJavaScriptReplTool } from "@t3tools/shared/toolActivity" ;
5658import { useMarkdownCodeHighlight } from "./markdownCodeHighlightState" ;
59+ import { highlightCommand , type HighlightedLines } from "../../lib/highlights" ;
60+ import {
61+ commandHighlightLanguage ,
62+ withVisibleControlCharacters ,
63+ } from "@t3tools/client-runtime/work-log/command-label" ;
5764
5865import { AppText as Text } from "../../components/ui/AppText" ;
5966import { T3Wordmark } from "../../components/T3Wordmark" ;
@@ -807,6 +814,31 @@ function ToolCodeText({
807814 readonly theme : "light" | "dark" ;
808815} ) {
809816 const lines = useMarkdownCodeHighlight ( { code, language, theme, enabled : true } ) ;
817+ return < HighlightedCodeText code = { code } lines = { lines } /> ;
818+ }
819+
820+ function CommandCodeText ( {
821+ command,
822+ theme,
823+ } : {
824+ readonly command : string ;
825+ readonly theme : "light" | "dark" ;
826+ } ) {
827+ const code = withVisibleControlCharacters ( command . trim ( ) ) ;
828+ const lines = useMemo (
829+ ( ) => highlightCommand ( code , commandHighlightLanguage ( code ) , theme ) ,
830+ [ code , theme ] ,
831+ ) ;
832+ return < HighlightedCodeText code = { code } lines = { lines } /> ;
833+ }
834+
835+ function HighlightedCodeText ( {
836+ code,
837+ lines,
838+ } : {
839+ readonly code : string ;
840+ readonly lines : HighlightedLines | null ;
841+ } ) {
810842 let offset = 0 ;
811843 const highlighted = lines ?. flatMap ( ( line , lineIndex ) => {
812844 const separator = lineIndex > 0 ? "\n" : "" ;
@@ -816,10 +848,11 @@ function ToolCodeText({
816848 ...line . map ( ( token ) => {
817849 const start = offset ;
818850 offset += token . content . length ;
851+ // Plain RN Text inherits the mono font; AppText would reset it to sans.
819852 return (
820- < Text key = { start } style = { token . color ? { color : token . color } : undefined } >
853+ < RNText key = { start } style = { token . color ? { color : token . color } : undefined } >
821854 { token . content }
822- </ Text >
855+ </ RNText >
823856 ) ;
824857 } ) ,
825858 ] ;
@@ -1179,7 +1212,13 @@ const ThreadWorkLogRow = function ThreadWorkLogRow(
11791212 props . renderReasoning ( reasoning . text )
11801213 ) : call ? (
11811214 [
1182- call . command ,
1215+ call . command ? (
1216+ < CommandCodeText
1217+ key = "command"
1218+ command = { call . command }
1219+ theme = { props . themeAppearance }
1220+ />
1221+ ) : null ,
11831222 ...( call . args ?? [ ] ) . map ( ( [ key , value ] ) => {
11841223 const language =
11851224 key === "html"
0 commit comments