633b5953bb
When Claude Code refuses an operator chat's turn for a usage limit and the server does not continue it on another account, the server now queues a durable prompt (auto-continue-<refusal id>, sent as Pipelines (automatic)) for a minute after the reset: the refused operator message when the turn did no work, else "continue". The reset comes from the refusal's text, else the rejected rate_limit_event. Refusals of turns Claude Code started itself are handled too, with no client attached; a restarted server or a device scheduling the same refusal adds nothing. The choice is kept per Claude home beside auto-switch (or by the server for chats without one), read and set with chat_auto_continue, on by default. The app's limit banner now finds the refusal as the latest turn, ignoring notices, agent reports and activity rows after it, reads and writes the server's choice, and only schedules its own prompt for older servers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
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
|
|
}
|