@@ -135,6 +135,12 @@ func runServer(ctx context.Context, logger *slog.Logger, argsToPass []string) er
135135 }
136136 }
137137
138+ experimentalACP := viper .GetBool (FlagExperimentalACP )
139+
140+ if experimentalACP && (saveState || loadState ) {
141+ return xerrors .Errorf ("ACP mode doesn't support state persistence" )
142+ }
143+
138144 pidFile := viper .GetString (FlagPidFile )
139145
140146 // Write PID file if configured
@@ -146,7 +152,6 @@ func runServer(ctx context.Context, logger *slog.Logger, argsToPass []string) er
146152 }
147153
148154 printOpenAPI := viper .GetBool (FlagPrintOpenAPI )
149- experimentalACP := viper .GetBool (FlagExperimentalACP )
150155
151156 if printOpenAPI && experimentalACP {
152157 return xerrors .Errorf ("flags --%s and --%s are mutually exclusive" , FlagPrintOpenAPI , FlagExperimentalACP )
@@ -222,17 +227,17 @@ func runServer(ctx context.Context, logger *slog.Logger, argsToPass []string) er
222227 // Monitor process exit
223228 processExitCh := make (chan error , 1 )
224229 if process != nil {
225- go func () {
226- defer close (processExitCh )
227- defer gracefulCancel ()
228- if err := process .Wait (); err != nil {
229- if errors .Is (err , termexec .ErrNonZeroExitCode ) {
230- processExitCh <- xerrors .Errorf ("========\n %s\n ========\n : %w" , strings .TrimSpace (process .ReadScreen ()), err )
231- } else {
232- processExitCh <- xerrors .Errorf ("failed to wait for process: %w" , err )
230+ go func () {
231+ defer close (processExitCh )
232+ defer gracefulCancel ()
233+ if err := process .Wait (); err != nil {
234+ if errors .Is (err , termexec .ErrNonZeroExitCode ) {
235+ processExitCh <- xerrors .Errorf ("========\n %s\n ========\n : %w" , strings .TrimSpace (process .ReadScreen ()), err )
236+ } else {
237+ processExitCh <- xerrors .Errorf ("failed to wait for process: %w" , err )
238+ }
233239 }
234- }
235- }()
240+ }()
236241 }
237242 if acpResult != nil {
238243 go func () {
@@ -362,20 +367,20 @@ type flagSpec struct {
362367}
363368
364369const (
365- FlagType = "type"
366- FlagPort = "port"
367- FlagPrintOpenAPI = "print-openapi"
368- FlagChatBasePath = "chat-base-path"
369- FlagTermWidth = "term-width"
370- FlagTermHeight = "term-height"
371- FlagAllowedHosts = "allowed-hosts"
372- FlagAllowedOrigins = "allowed-origins"
373- FlagExit = "exit"
374- FlagInitialPrompt = "initial-prompt"
375- FlagStateFile = "state-file"
376- FlagLoadState = "load-state"
377- FlagSaveState = "save-state"
378- FlagPidFile = "pid-file"
370+ FlagType = "type"
371+ FlagPort = "port"
372+ FlagPrintOpenAPI = "print-openapi"
373+ FlagChatBasePath = "chat-base-path"
374+ FlagTermWidth = "term-width"
375+ FlagTermHeight = "term-height"
376+ FlagAllowedHosts = "allowed-hosts"
377+ FlagAllowedOrigins = "allowed-origins"
378+ FlagExit = "exit"
379+ FlagInitialPrompt = "initial-prompt"
380+ FlagStateFile = "state-file"
381+ FlagLoadState = "load-state"
382+ FlagSaveState = "save-state"
383+ FlagPidFile = "pid-file"
379384 FlagExperimentalACP = "experimental-acp"
380385)
381386
0 commit comments