11import { TextAttributes } from '@opentui/core'
2- import React from 'react'
3- import stringWidth from 'string-width'
42
53import { useTheme } from '../../hooks/use-theme'
64import { defineToolComponent } from './types'
@@ -20,71 +18,32 @@ const ReadFilesSimpleToolCallItem = ({
2018} : ReadFilesSimpleToolCallItemProps ) => {
2119 const theme = useTheme ( )
2220 const bulletChar = '• '
23- const baseIndentWidth = stringWidth ( bulletChar ) + stringWidth ( name + ' ' )
24-
25- // Split files into two groups
26- const firstFilePath = filePaths [ 0 ]
27- const newlineFiles = filePaths . slice ( 1 , maxNewlineFiles )
28- const inlineFiles = filePaths . slice ( maxNewlineFiles )
21+ const labelWidth = 7 // Width of "• Read " in characters
2922
3023 return (
3124 < box style = { { flexDirection : 'column' , gap : 0 , width : '100%' } } >
32- { /* First line with name */ }
33- < box
34- style = { { flexDirection : 'row' , alignItems : 'center' , width : '100%' } }
35- >
36- < text style = { { wrapMode : 'word' } } >
37- < span fg = { theme . foreground } > { bulletChar } </ span >
38- < span fg = { theme . foreground } attributes = { TextAttributes . BOLD } >
39- { name }
40- </ span >
41- </ text >
42- { firstFilePath && (
43- < text style = { { wrapMode : 'word' } } >
44- < span fg = { theme . foreground } > { ' ' + firstFilePath } </ span >
45- </ text >
46- ) }
47- </ box >
48-
49- { /* Files on newlines */ }
50- { newlineFiles . map ( ( file , index ) => (
51- < box
52- key = { `newline-${ index } ` }
53- style = { {
54- flexDirection : 'row' ,
55- alignItems : 'center' ,
56- width : '100%' ,
57- paddingLeft : baseIndentWidth ,
58- } }
59- >
60- < text style = { { wrapMode : 'word' } } >
61- < span fg = { theme . foreground } > { file } </ span >
25+ < box style = { { flexDirection : 'row' , width : '100%' } } >
26+ < box style = { { width : labelWidth , flexShrink : 0 } } >
27+ < text style = { { wrapMode : 'none' } } >
28+ < span fg = { theme . foreground } > { bulletChar } </ span >
29+ < span fg = { theme . foreground } attributes = { TextAttributes . BOLD } >
30+ { name }
31+ </ span >
6232 </ text >
6333 </ box >
64- ) ) }
65-
66- { /* Remaining files inline */ }
67- { inlineFiles . length > 0 && (
68- < box
69- style = { {
70- flexDirection : 'row' ,
71- alignItems : 'center' ,
72- width : '100%' ,
73- paddingLeft : baseIndentWidth ,
74- } }
75- >
34+ < box style = { { flexGrow : 1 } } >
7635 < text style = { { wrapMode : 'word' } } >
77- < span fg = { theme . foreground } > { inlineFiles . join ( ', ' ) } </ span >
36+ < span fg = { theme . foreground } > { filePaths . join ( ', ' ) } </ span >
7837 </ text >
7938 </ box >
80- ) }
39+ </ box >
8140 </ box >
8241 )
8342}
8443
8544/**
8645 * UI component for read_files tool.
87- * Displays file paths with first few on newlines, rest inline .
46+ * Displays all file paths as comma-separated list .
8847 * Does not support expand/collapse - always shows as a simple list.
8948 */
9049export const ReadFilesComponent = defineToolComponent ( {
@@ -108,10 +67,7 @@ export const ReadFilesComponent = defineToolComponent({
10867
10968 return {
11069 content : (
111- < ReadFilesSimpleToolCallItem
112- name = "Read"
113- filePaths = { filePaths }
114- />
70+ < ReadFilesSimpleToolCallItem name = "Read" filePaths = { filePaths } />
11571 ) ,
11672 }
11773 } ,
0 commit comments