@@ -22,13 +22,6 @@ export function useCommandOutputStreaming(environmentId: EnvironmentId): boolean
2222 * shows its final output. Mount it only when `useCommandOutputStreaming` holds.
2323 * It subscribes only while mounted, so collapsed rows and other threads receive nothing.
2424 */
25- // Parsing ANSI output is linear in its length, and the compiler would redo it on
26- // every render because the layout effect runs after it.
27- function useTerminalOutputSpans ( text : string , resolvedTheme : keyof typeof TERMINAL_PALETTES ) {
28- "use memo" ;
29- return terminalOutputSpans ( text , TERMINAL_PALETTES [ resolvedTheme ] ) ;
30- }
31-
3225export function CommandOutputPanel ( props : {
3326 readonly environmentId : EnvironmentId ;
3427 readonly threadId : ThreadId ;
@@ -45,7 +38,6 @@ export function CommandOutputPanel(props: {
4538 const followRef = useRef ( true ) ;
4639 const text = data ?. output . text ?? "" ;
4740 const { resolvedTheme } = useTheme ( ) ;
48- const spans = useTerminalOutputSpans ( text , resolvedTheme ) ;
4941
5042 // This panel only re-renders when its output changes, so keep the end in view after each.
5143 useLayoutEffect ( ( ) => {
@@ -58,6 +50,8 @@ export function CommandOutputPanel(props: {
5850 if ( data === null ) return < div className = "text-muted-foreground italic" > Loading output…</ div > ;
5951 return data . running ? null : < div className = "text-muted-foreground italic" > No output.</ div > ;
6052 }
53+ // Parsed after the layout effect, the last hook, so the compiler caches it on text and theme.
54+ const spans = terminalOutputSpans ( text , TERMINAL_PALETTES [ resolvedTheme ] ) ;
6155 return (
6256 < div >
6357 { data ?. output . truncated ? (
0 commit comments