@@ -815,128 +815,7 @@ func TestRunFresh_SkipsMultipickerWhenAgentsFlagPresent(t *testing.T) {
815815 require .Equal (t , 0 , pickerCalls , "multipicker must not run when --agents is set" )
816816}
817817
818- func TestRunFresh_InvokesMultipickerWhenTwoAgentsAndNoFlag (t * testing.T ) {
819- tmp := t .TempDir ()
820- t .Chdir (tmp )
821- testutil .InitRepo (t , tmp )
822- testutil .WriteFile (t , tmp , "f.txt" , "x" )
823- testutil .GitAdd (t , tmp , "f.txt" )
824- testutil .GitCommit (t , tmp , "init" )
825- require .NoError (t , os .MkdirAll (filepath .Join (tmp , ".trace" ), 0o755 ))
826- require .NoError (t , os .WriteFile (
827- filepath .Join (tmp , ".trace/settings.local.json" ),
828- []byte (`{"investigate":{"agents":["claude-code","codex"]}}` ), 0o644 ,
829- ))
830-
831- var pickerCalled bool
832- var pickerAskPrompt bool
833- var receivedAgents []string
834- deps := investigate.Deps {
835- GetAgentsWithHooksInstalled : func (_ context.Context ) []types.AgentName {
836- return []types.AgentName {"claude-code" , "codex" }
837- },
838- NewSilentError : func (err error ) error { return err },
839- SpawnerFor : func (name string ) spawn.Spawner { return stubSpawner {name : name } },
840- InvestigateMultipicker : func (_ context.Context , choices []investigate.AgentChoice , askPrompt bool ) (investigate.PickedInvestigate , error ) {
841- pickerCalled = true
842- pickerAskPrompt = askPrompt
843- require .Len (t , choices , 2 )
844- return investigate.PickedInvestigate {
845- Names : []string {"claude-code" },
846- }, nil
847- },
848- LoopRun : func (_ context.Context , in investigate.LoopInput , _ investigate.LoopDeps ) (investigate.LoopResult , error ) {
849- receivedAgents = in .Agents
850- return investigate.LoopResult {Outcome : investigate .OutcomeQuorum }, nil
851- },
852- }
853- cmd := investigate .NewCommand (deps )
854- cmd .SetArgs ([]string {seedArg (t , "foo" )})
855- cmd .SetOut (io .Discard )
856- cmd .SetErr (io .Discard )
857- _ = cmd .ExecuteContext (context .Background ()) //nolint:errcheck // contract checked via captured loop input
858- require .True (t , pickerCalled , "multipicker must run when >=2 agents and no --agents flag" )
859- require .False (t , pickerAskPrompt , "askPrompt must be false when a seed-doc is supplied" )
860- require .Equal (t , []string {"claude-code" }, receivedAgents , "narrowed list must reach the loop" )
861- }
862-
863- func TestRunInvestigate_SoftWarnAcceptedRunsLoop (t * testing.T ) {
864- tmp := t .TempDir ()
865- t .Chdir (tmp )
866- testutil .InitRepo (t , tmp )
867- testutil .WriteFile (t , tmp , "f.txt" , "x" )
868- testutil .GitAdd (t , tmp , "f.txt" )
869- testutil .GitCommit (t , tmp , "init" )
870- require .NoError (t , os .MkdirAll (filepath .Join (tmp , ".trace" ), 0o755 ))
871- require .NoError (t , os .WriteFile (
872- filepath .Join (tmp , ".trace/settings.local.json" ),
873- []byte (`{"investigate":{"agents":["claude-code"],"max_turns":1}}` ), 0o644 ,
874- ))
875-
876- var loopCalled bool
877- deps := investigate.Deps {
878- GetAgentsWithHooksInstalled : func (_ context.Context ) []types.AgentName {
879- return []types.AgentName {types .AgentName ("claude-code" )}
880- },
881- NewSilentError : func (err error ) error { return err },
882- SpawnerFor : func (_ string ) spawn.Spawner { return stubSpawner {name : "claude-code" } },
883- HeadHasInvestigateCheckpoint : func (_ context.Context ) (bool , string ) {
884- return true , "checkpoint xyz"
885- },
886- PromptYN : func (_ context.Context , _ string , _ bool ) (bool , error ) {
887- return true , nil // accept
888- },
889- LoopRun : func (_ context.Context , _ investigate.LoopInput , _ investigate.LoopDeps ) (investigate.LoopResult , error ) {
890- loopCalled = true
891- return investigate.LoopResult {Outcome : investigate .OutcomeQuorum }, nil
892- },
893- }
894- cmd := investigate .NewCommand (deps )
895- cmd .SetArgs ([]string {seedArg (t , "foo" )})
896- cmd .SetOut (io .Discard )
897- cmd .SetErr (io .Discard )
898- _ = cmd .ExecuteContext (context .Background ()) //nolint:errcheck // soft-warn accept proceeds; ignore downstream errors
899- require .True (t , loopCalled , "loop must run when user accepts soft warn" )
900- }
901-
902818// TestRunInvestigate_SoftWarnSilentInNonInteractive verifies that when
903819// the user can't prompt (PromptYN is nil and CanPromptInteractively
904820// returns false under `go test`), the soft-warn does NOT block the loop
905821// — it proceeds and a single informational log line is emitted.
906- func TestRunInvestigate_SoftWarnSilentInNonInteractive (t * testing.T ) {
907- tmp := t .TempDir ()
908- t .Chdir (tmp )
909- testutil .InitRepo (t , tmp )
910- testutil .WriteFile (t , tmp , "f.txt" , "x" )
911- testutil .GitAdd (t , tmp , "f.txt" )
912- testutil .GitCommit (t , tmp , "init" )
913- require .NoError (t , os .MkdirAll (filepath .Join (tmp , ".trace" ), 0o755 ))
914- require .NoError (t , os .WriteFile (
915- filepath .Join (tmp , ".trace/settings.local.json" ),
916- []byte (`{"investigate":{"agents":["claude-code"],"max_turns":1}}` ), 0o644 ,
917- ))
918-
919- var loopCalled bool
920- deps := investigate.Deps {
921- GetAgentsWithHooksInstalled : func (_ context.Context ) []types.AgentName {
922- return []types.AgentName {types .AgentName ("claude-code" )}
923- },
924- NewSilentError : func (err error ) error { return err },
925- SpawnerFor : func (_ string ) spawn.Spawner { return stubSpawner {name : "claude-code" } },
926- HeadHasInvestigateCheckpoint : func (_ context.Context ) (bool , string ) {
927- return true , "checkpoint nonint"
928- },
929- // PromptYN intentionally nil → falls back to interactive.CanPromptInteractively(),
930- // which returns false under `go test` → soft-warn is silent.
931- LoopRun : func (_ context.Context , _ investigate.LoopInput , _ investigate.LoopDeps ) (investigate.LoopResult , error ) {
932- loopCalled = true
933- return investigate.LoopResult {Outcome : investigate .OutcomeQuorum }, nil
934- },
935- }
936- cmd := investigate .NewCommand (deps )
937- cmd .SetArgs ([]string {seedArg (t , "foo" )})
938- cmd .SetOut (io .Discard )
939- cmd .SetErr (io .Discard )
940- _ = cmd .ExecuteContext (context .Background ()) //nolint:errcheck // non-interactive path proceeds
941- require .True (t , loopCalled , "loop must run when soft-warn is silent (non-interactive)" )
942- }
0 commit comments