@@ -352,6 +352,14 @@ describe("tool-cards", () => {
352352 expect ( isToolErrorOutput ( "TOOL NOT FOUND" ) ) . toBe ( true ) ;
353353 } ) ;
354354
355+ it ( "flags JSON payloads with top-level failure statuses" , ( ) => {
356+ expect ( isToolErrorOutput ( JSON . stringify ( { status : "error" } ) ) ) . toBe ( true ) ;
357+ expect ( isToolErrorOutput ( JSON . stringify ( { status : "failed" } ) ) ) . toBe ( true ) ;
358+ expect ( isToolErrorOutput ( JSON . stringify ( { status : "timeout" } ) ) ) . toBe ( true ) ;
359+ expect ( isToolErrorOutput ( JSON . stringify ( { status : "completed" } ) ) ) . toBe ( false ) ;
360+ expect ( isToolErrorOutput ( JSON . stringify ( { status : "ok" } ) ) ) . toBe ( false ) ;
361+ } ) ;
362+
355363 it ( "does not flag successful payloads or strings without a tool error signal" , ( ) => {
356364 expect ( isToolErrorOutput ( undefined ) ) . toBe ( false ) ;
357365 expect ( isToolErrorOutput ( "" ) ) . toBe ( false ) ;
@@ -397,6 +405,26 @@ describe("tool-cards", () => {
397405 expect ( container . querySelector ( ".chat-tool-card__status-badge" ) ) . not . toBeNull ( ) ;
398406 } ) ;
399407
408+ it ( "renders a Tool error label when output has a status-only error payload" , ( ) => {
409+ const container = document . createElement ( "div" ) ;
410+ render (
411+ renderToolCard (
412+ {
413+ id : "msg:err:status-only" ,
414+ name : "sessions_spawn" ,
415+ outputText : JSON . stringify ( { status : "error" } ) ,
416+ } ,
417+ { expanded : true , onToggleExpanded : vi . fn ( ) } ,
418+ ) ,
419+ container ,
420+ ) ;
421+
422+ expect ( container . textContent ) . toContain ( "Tool error" ) ;
423+ expect ( container . textContent ) . not . toMatch ( / \b T o o l o u t p u t \b / ) ;
424+ expect ( container . querySelector ( ".chat-tool-msg-summary--error" ) ) . not . toBeNull ( ) ;
425+ expect ( container . querySelector ( ".chat-tool-card--error" ) ) . not . toBeNull ( ) ;
426+ } ) ;
427+
400428 it ( "renders a Tool error label when output is the literal 'Tool not found'" , ( ) => {
401429 const container = document . createElement ( "div" ) ;
402430 render (
@@ -509,6 +537,27 @@ describe("tool-cards", () => {
509537 expect ( action ?. textContent ) . not . toContain ( "✓" ) ;
510538 } ) ;
511539
540+ it ( "marks status-only sidebar output as an error instead of View with a checkmark" , ( ) => {
541+ const container = document . createElement ( "div" ) ;
542+ render (
543+ renderToolCardSidebar (
544+ {
545+ id : "msg:err:sidebar-status" ,
546+ name : "sessions_wait" ,
547+ outputText : JSON . stringify ( { status : "timeout" } ) ,
548+ } ,
549+ vi . fn ( ) ,
550+ ) ,
551+ container ,
552+ ) ;
553+
554+ const action = container . querySelector ( ".chat-tool-card__action" ) ;
555+ expect ( container . querySelector ( ".chat-tool-card--error" ) ) . not . toBeNull ( ) ;
556+ expect ( action ?. textContent ) . toContain ( "View error" ) ;
557+ expect ( action ?. textContent ) . toContain ( "✕" ) ;
558+ expect ( action ?. textContent ) . not . toContain ( "✓" ) ;
559+ } ) ;
560+
512561 it ( "keeps Tool output labelling for successful results" , ( ) => {
513562 const container = document . createElement ( "div" ) ;
514563 render (
0 commit comments