66} from "@t3tools/contracts" ;
77import {
88 createContext ,
9+ Fragment ,
910 memo ,
1011 use ,
1112 useCallback ,
@@ -394,6 +395,7 @@ function UserTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "message"
394395 text = { displayedUserMessage . visibleText }
395396 terminalContexts = { terminalContexts }
396397 skills = { ctx . skills }
398+ markdownCwd = { ctx . markdownCwd }
397399 />
398400 </ div >
399401 < div className = "flex w-full max-w-[80%] items-center justify-end pe-1 text-xs tabular-nums opacity-0 transition-opacity duration-200 focus-within:opacity-100 group-hover:opacity-100" >
@@ -784,6 +786,7 @@ const CollapsibleUserMessageBody = memo(function CollapsibleUserMessageBody(prop
784786 text : string ;
785787 terminalContexts : ParsedTerminalContextEntry [ ] ;
786788 skills : ReadonlyArray < Pick < ServerProviderSkill , "name" | "displayName" > > ;
789+ markdownCwd : string | undefined ;
787790 footer ?: ReactNode ;
788791} ) {
789792 const [ expanded , setExpanded ] = useState ( false ) ;
@@ -813,6 +816,7 @@ const CollapsibleUserMessageBody = memo(function CollapsibleUserMessageBody(prop
813816 text = { props . text }
814817 terminalContexts = { props . terminalContexts }
815818 skills = { props . skills }
819+ markdownCwd = { props . markdownCwd }
816820 />
817821 </ div >
818822 ) : null }
@@ -850,16 +854,49 @@ const UserMessageBody = memo(function UserMessageBody(props: {
850854 text : string ;
851855 terminalContexts : ParsedTerminalContextEntry [ ] ;
852856 skills : ReadonlyArray < Pick < ServerProviderSkill , "name" | "displayName" > > ;
857+ markdownCwd : string | undefined ;
853858} ) {
859+ const renderInlineMarkdownSegment = ( text : string , key : string ) => {
860+ const leadingWhitespace = / ^ \s + / . exec ( text ) ?. [ 0 ] ?? "" ;
861+ const textWithoutLeadingWhitespace = text . slice ( leadingWhitespace . length ) ;
862+ const trailingWhitespace = / \s + $ / . exec ( textWithoutLeadingWhitespace ) ?. [ 0 ] ?? "" ;
863+ const content = textWithoutLeadingWhitespace . slice (
864+ 0 ,
865+ textWithoutLeadingWhitespace . length - trailingWhitespace . length ,
866+ ) ;
867+
868+ return (
869+ < Fragment key = { key } >
870+ { leadingWhitespace ? < span aria-hidden = "true" > { leadingWhitespace } </ span > : null }
871+ { content ? (
872+ < ChatMarkdown
873+ text = { content }
874+ cwd = { props . markdownCwd }
875+ skills = { props . skills }
876+ className = "text-foreground"
877+ lineBreaks
878+ />
879+ ) : null }
880+ { trailingWhitespace ? < span aria-hidden = "true" > { trailingWhitespace } </ span > : null }
881+ </ Fragment >
882+ ) ;
883+ } ;
884+
854885 const reviewCommentSegments = parseReviewCommentMessageSegments ( props . text ) ;
855886 if ( reviewCommentSegments . some ( ( segment ) => segment . kind === "review-comment" ) ) {
856887 return (
857888 < div className = "space-y-3 text-sm leading-relaxed text-foreground" >
858889 { reviewCommentSegments . map ( ( segment ) =>
859890 segment . kind === "text" ? (
860891 segment . text . trim ( ) . length > 0 ? (
861- < div key = { segment . id } className = "whitespace-pre-wrap wrap-break-word" >
862- < SkillInlineText text = { segment . text . trim ( ) } skills = { props . skills } />
892+ < div key = { segment . id } className = "wrap-break-word" >
893+ < ChatMarkdown
894+ text = { segment . text . trim ( ) }
895+ cwd = { props . markdownCwd }
896+ skills = { props . skills }
897+ className = "text-foreground"
898+ lineBreaks
899+ />
863900 </ div >
864901 ) : null
865902 ) : (
@@ -890,9 +927,10 @@ const UserMessageBody = memo(function UserMessageBody(props: {
890927 }
891928 if ( matchIndex > cursor ) {
892929 inlineNodes . push (
893- < span key = { `user-terminal-context-inline-before:${ context . header } :${ cursor } ` } >
894- < SkillInlineText text = { props . text . slice ( cursor , matchIndex ) } skills = { props . skills } />
895- </ span > ,
930+ renderInlineMarkdownSegment (
931+ props . text . slice ( cursor , matchIndex ) ,
932+ `user-terminal-context-inline-before:${ context . header } :${ cursor } ` ,
933+ ) ,
896934 ) ;
897935 }
898936 inlineNodes . push (
@@ -907,9 +945,10 @@ const UserMessageBody = memo(function UserMessageBody(props: {
907945 if ( inlineNodes . length > 0 ) {
908946 if ( cursor < props . text . length ) {
909947 inlineNodes . push (
910- < span key = { `user-message-terminal-context-inline-rest:${ cursor } ` } >
911- < SkillInlineText text = { props . text . slice ( cursor ) } skills = { props . skills } />
912- </ span > ,
948+ renderInlineMarkdownSegment (
949+ props . text . slice ( cursor ) ,
950+ `user-message-terminal-context-inline-rest:${ cursor } ` ,
951+ ) ,
913952 ) ;
914953 }
915954
@@ -937,9 +976,14 @@ const UserMessageBody = memo(function UserMessageBody(props: {
937976
938977 if ( props . text . length > 0 ) {
939978 inlineNodes . push (
940- < span key = "user-message-terminal-context-inline-text" >
941- < SkillInlineText text = { props . text } skills = { props . skills } />
942- </ span > ,
979+ < ChatMarkdown
980+ key = "user-message-terminal-context-inline-text"
981+ text = { props . text }
982+ cwd = { props . markdownCwd }
983+ skills = { props . skills }
984+ className = "text-foreground"
985+ lineBreaks
986+ /> ,
943987 ) ;
944988 } else if ( inlinePrefix . length === 0 ) {
945989 return null ;
@@ -957,9 +1001,13 @@ const UserMessageBody = memo(function UserMessageBody(props: {
9571001 }
9581002
9591003 return (
960- < div className = "whitespace-pre-wrap wrap-break-word text-sm leading-relaxed text-foreground" >
961- < SkillInlineText text = { props . text } skills = { props . skills } />
962- </ div >
1004+ < ChatMarkdown
1005+ text = { props . text }
1006+ cwd = { props . markdownCwd }
1007+ skills = { props . skills }
1008+ className = "text-foreground"
1009+ lineBreaks
1010+ />
9631011 ) ;
9641012} ) ;
9651013
0 commit comments