@@ -356,4 +356,65 @@ describe('<ShellToolMessage />', () => {
356356 unmount ( ) ;
357357 } ) ;
358358 } ) ;
359+
360+ describe ( 'Header Expansion' , ( ) => {
361+ const LONG_DESCRIPTION = 'very long ' . repeat ( 20 ) ;
362+
363+ it ( 'truncates header by default' , async ( ) => {
364+ const { lastFrame, waitUntilReady } = await renderWithProviders (
365+ < ShellToolMessage
366+ { ...baseProps }
367+ description = { LONG_DESCRIPTION }
368+ availableTerminalHeight = { 10 }
369+ /> ,
370+ { uiActions } ,
371+ ) ;
372+
373+ await waitUntilReady ( ) ;
374+ const output = lastFrame ( ) ;
375+ // Should be a single line header
376+ expect ( output . split ( '\n' ) [ 1 ] ) . toContain ( SHELL_COMMAND_NAME ) ; // name
377+ // We check if it's truncated. In our ToolInfo, it's height 1.
378+ // The StickyHeader adds some structure, but the ToolInfo Box is inside.
379+ } ) ;
380+
381+ it ( 'expands header when availableTerminalHeight is undefined' , async ( ) => {
382+ const { lastFrame, waitUntilReady } = await renderWithProviders (
383+ < ShellToolMessage
384+ { ...baseProps }
385+ description = { LONG_DESCRIPTION }
386+ availableTerminalHeight = { undefined }
387+ /> ,
388+ { uiActions } ,
389+ ) ;
390+
391+ await waitUntilReady ( ) ;
392+ const output = lastFrame ( ) ;
393+ // When expanded, the header (ToolInfo) should wrap and take multiple lines.
394+ // Since it's at the top, we check if the first few lines contain parts of the description.
395+ const lines = output . split ( '\n' ) ;
396+ expect ( lines . length ) . toBeGreaterThan ( 5 ) ;
397+ } ) ;
398+
399+ it ( 'expands header when isExpanded is true in context' , async ( ) => {
400+ const { lastFrame, waitUntilReady } = await renderWithProviders (
401+ < ShellToolMessage
402+ { ...baseProps }
403+ description = { LONG_DESCRIPTION }
404+ availableTerminalHeight = { 10 }
405+ /> ,
406+ {
407+ uiActions,
408+ toolActions : {
409+ isExpanded : ( id : string ) => id === baseProps . callId ,
410+ } ,
411+ } ,
412+ ) ;
413+
414+ await waitUntilReady ( ) ;
415+ const output = lastFrame ( ) ;
416+ // Should be expanded due to context
417+ expect ( output . split ( '\n' ) . length ) . toBeGreaterThan ( 5 ) ;
418+ } ) ;
419+ } ) ;
359420} ) ;
0 commit comments