11package root
22
33import (
4+ "context"
45 "strings"
56
67 tea "charm.land/bubbletea/v2"
@@ -54,7 +55,7 @@ func (f *newFlags) runNewCommand(cmd *cobra.Command, args []string) error {
5455 return err
5556 }
5657
57- var prompt * string
58+ var firstMessage * string
5859 opts := []session.Opt {
5960 session .WithTitle ("New agent" ),
6061 session .WithMaxIterations (f .maxIterationsParam ),
@@ -63,12 +64,16 @@ func (f *newFlags) runNewCommand(cmd *cobra.Command, args []string) error {
6364 if len (args ) > 0 {
6465 arg := strings .Join (args , " " )
6566 opts = append (opts , session .WithUserMessage ("" , arg ))
66- prompt = & arg
67+ firstMessage = & arg
6768 }
6869
6970 sess := session .New (opts ... )
7071
71- a := app .New (ctx , "" , rt , sess , prompt )
72+ return runTUI (ctx , "" , rt , sess , firstMessage )
73+ }
74+
75+ func runTUI (ctx context.Context , agentFilename string , rt runtime.Runtime , sess * session.Session , firstMessage * string ) error {
76+ a := app .New (ctx , agentFilename , rt , sess , firstMessage )
7277 m := tui .New (a )
7378
7479 progOpts := []tea.ProgramOption {
@@ -79,6 +84,6 @@ func (f *newFlags) runNewCommand(cmd *cobra.Command, args []string) error {
7984
8085 go a .Subscribe (ctx , p )
8186
82- _ , err = p .Run ()
87+ _ , err : = p .Run ()
8388 return err
8489}
0 commit comments