package claude import ( "context" "strings" "git.a-wan.net/alan/pipelines/internal/claudeaccounts" ) // The operator's "Auto-continue when limits reset" choice is kept per Claude // home, beside the automatic-switch choice (claudeaccounts settings.json), so // every chat on that home and every device share it. A chat whose directory // selects no Claude home of its own reports ErrNoConfigDir; the server keeps // the choice for those itself. // AutoContinue reports whether chats on the Claude home of sessionID's // directory ("" uses the open session's) continue automatically once a usage // limit resets. func (c *Chat) AutoContinue(ctx context.Context, sessionID, directory string) (bool, error) { store, err := c.homeStore(ctx, sessionID, directory) if err != nil { return false, err } return store.AutoContinue(), nil } // SetAutoContinue records the auto-continue choice of that Claude home. func (c *Chat) SetAutoContinue(ctx context.Context, sessionID, directory string, on bool) error { store, err := c.homeStore(ctx, sessionID, directory) if err != nil { return err } return store.SetAutoContinue(on) } func (c *Chat) homeStore(ctx context.Context, sessionID, directory string) (claudeaccounts.Store, error) { if strings.TrimSpace(directory) == "" { if s := c.session(sessionID); s != nil { s.mu.Lock() directory = s.directory s.mu.Unlock() } } configDir, err := c.accountConfigDir(ctx, directory) if err != nil { return claudeaccounts.Store{}, err } return claudeaccounts.Store{ConfigDir: configDir}, nil }