@@ -411,23 +411,21 @@ describe("tool.feedback_submit", () => {
411411
412412 expect ( result . title ) . toBe ( "Feedback submitted" )
413413 expect ( result . metadata . error ) . toBe ( "" )
414- expect ( result . metadata . issueUrl ) . toBe (
415- "https://github.com/AltimateAI/altimate-code/issues/42" ,
416- )
414+ expect ( result . metadata . issueUrl ) . toBe ( "https://github.com/AltimateAI/altimate-code/issues/42" )
417415 expect ( result . output ) . toContain ( "successfully" )
418- expect ( result . output ) . toContain (
419- "https://github.com/AltimateAI/altimate-code/issues/42" ,
420- )
416+ expect ( result . output ) . toContain ( "https://github.com/AltimateAI/altimate-code/issues/42" )
421417 } )
422418
423- test ( "returns failure when issue creation output has no github URL" , async ( ) => {
419+ test ( "returns failure when both label and no-label attempts have no github URL" , async ( ) => {
424420 const tool = await FeedbackSubmitTool . init ( )
425421
426422 // gh --version
427423 pushShellResult ( "gh version 2.40.0" )
428424 // gh auth status
429425 pushShellResult ( "Logged in as user" , 0 )
430- // gh issue create fails with unexpected output
426+ // gh issue create with labels — fails
427+ pushShellResult ( "some error occurred" )
428+ // gh issue create without labels — also fails
431429 pushShellResult ( "some error occurred" )
432430
433431 const result = await tool . execute (
@@ -445,11 +443,14 @@ describe("tool.feedback_submit", () => {
445443 expect ( result . output ) . toContain ( "Failed to create GitHub issue" )
446444 } )
447445
448- test ( "returns failure when issue creation returns empty output" , async ( ) => {
446+ test ( "returns failure when both attempts return empty output" , async ( ) => {
449447 const tool = await FeedbackSubmitTool . init ( )
450448
451449 pushShellResult ( "gh version 2.40.0" )
452450 pushShellResult ( "Logged in" , 0 )
451+ // with labels — empty
452+ pushShellResult ( "" )
453+ // without labels — also empty
453454 pushShellResult ( "" )
454455
455456 const result = await tool . execute (
@@ -466,13 +467,40 @@ describe("tool.feedback_submit", () => {
466467 expect ( result . metadata . error ) . toBe ( "issue_creation_failed" )
467468 } )
468469
469- test ( "returns failure when issue creation has non-zero exitCode even with stdout" , async ( ) => {
470+ test ( "succeeds via fallback when label creation fails but no-label attempt works" , async ( ) => {
471+ const tool = await FeedbackSubmitTool . init ( )
472+
473+ pushShellResult ( "gh version 2.40.0" )
474+ pushShellResult ( "Logged in" , 0 )
475+ // gh issue create with labels — fails (e.g. missing label)
476+ shellResults . push ( { text : "label 'from-cli' not found" , exitCode : 1 } )
477+ // gh issue create without labels — succeeds
478+ pushShellResult ( "https://github.com/AltimateAI/altimate-code/issues/99" )
479+
480+ const result = await tool . execute (
481+ {
482+ title : "Test fallback" ,
483+ category : "feature" as const ,
484+ description : "test" ,
485+ include_context : false ,
486+ } ,
487+ ctx ,
488+ )
489+
490+ expect ( result . title ) . toBe ( "Feedback submitted" )
491+ expect ( result . metadata . error ) . toBe ( "" )
492+ expect ( result . metadata . issueUrl ) . toBe ( "https://github.com/AltimateAI/altimate-code/issues/99" )
493+ } )
494+
495+ test ( "returns failure when label attempt has non-zero exitCode and retry also fails" , async ( ) => {
470496 const tool = await FeedbackSubmitTool . init ( )
471497
472498 pushShellResult ( "gh version 2.40.0" )
473499 pushShellResult ( "Logged in" , 0 )
474- // gh issue create exits non-zero (e.g. label doesn't exist) with partial output
500+ // gh issue create with labels — exits non-zero
475501 shellResults . push ( { text : "https://github.com/AltimateAI/altimate-code/issues/1" , exitCode : 1 } )
502+ // retry without labels — also fails
503+ shellResults . push ( { text : "rate limit exceeded" , exitCode : 1 } )
476504
477505 const result = await tool . execute (
478506 {
@@ -509,6 +537,30 @@ describe("tool.feedback_submit", () => {
509537 expect ( result . title ) . toBe ( "Feedback submission failed" )
510538 expect ( result . metadata . error ) . toBe ( "issue_creation_failed" )
511539 } )
540+
541+ test ( "returns failure when retry without labels throws" , async ( ) => {
542+ const tool = await FeedbackSubmitTool . init ( )
543+
544+ pushShellResult ( "gh version 2.40.0" )
545+ pushShellResult ( "Logged in" , 0 )
546+ // first attempt fails (non-zero exit)
547+ shellResults . push ( { text : "label not found" , exitCode : 1 } )
548+ // retry throws
549+ pushShellThrow ( )
550+
551+ const result = await tool . execute (
552+ {
553+ title : "Test" ,
554+ category : "bug" as const ,
555+ description : "test" ,
556+ include_context : false ,
557+ } ,
558+ ctx ,
559+ )
560+
561+ expect ( result . title ) . toBe ( "Feedback submission failed" )
562+ expect ( result . metadata . error ) . toBe ( "issue_creation_failed" )
563+ } )
512564 } )
513565
514566 // -------------------------------------------------------------------------
@@ -687,7 +739,7 @@ describe("tool.feedback_submit", () => {
687739 expect ( createCall ) . toContain ( "My specific title" )
688740 } )
689741
690- test ( "makes exactly 3 shell calls for successful submission" , async ( ) => {
742+ test ( "makes exactly 3 shell calls for successful submission when labels exist " , async ( ) => {
691743 const tool = await FeedbackSubmitTool . init ( )
692744
693745 pushShellResult ( "gh version 2.40.0" )
@@ -707,6 +759,32 @@ describe("tool.feedback_submit", () => {
707759 expect ( shellCalls . length ) . toBe ( 3 )
708760 } )
709761
762+ test ( "makes exactly 4 shell calls when label attempt fails and retry succeeds" , async ( ) => {
763+ const tool = await FeedbackSubmitTool . init ( )
764+
765+ pushShellResult ( "gh version 2.40.0" )
766+ pushShellResult ( "Logged in" , 0 )
767+ // with labels — fails
768+ shellResults . push ( { text : "label not found" , exitCode : 1 } )
769+ // without labels — succeeds
770+ pushShellResult ( "https://github.com/AltimateAI/altimate-code/issues/1" )
771+
772+ await tool . execute (
773+ {
774+ title : "Test" ,
775+ category : "bug" as const ,
776+ description : "test" ,
777+ include_context : false ,
778+ } ,
779+ ctx ,
780+ )
781+
782+ expect ( shellCalls . length ) . toBe ( 4 )
783+ // Verify the retry call does NOT contain --label
784+ const retryCall = shellCalls [ 3 ] . join ( "" )
785+ expect ( retryCall ) . not . toContain ( "--label" )
786+ } )
787+
710788 test ( "makes only 1 shell call when gh is not installed" , async ( ) => {
711789 const tool = await FeedbackSubmitTool . init ( )
712790
0 commit comments