Chat: the server continues a usage-refused Claude chat at the reset

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>
This commit is contained in:
2026-12-02 19:52:03 +00:00
parent c441400f36
commit 633b5953bb
23 changed files with 1380 additions and 71 deletions
+38 -18
View File
@@ -17,6 +17,8 @@ const settingsFile = "settings.json"
type settings struct {
// AutoSwitch is nil until the operator chooses; the default is on.
AutoSwitch *bool `json:"auto_switch,omitempty"`
// AutoContinue is nil until the operator chooses; the default is on.
AutoContinue *bool `json:"auto_continue,omitempty"`
}
func (s Store) readSettings() settings {
@@ -40,25 +42,43 @@ func (s Store) AutoSwitch() bool {
// SetAutoSwitch records the automatic-switch preference and returns the
// accounts list, which reports it.
func (s Store) SetAutoSwitch(on bool) (protocol.ClaudeAccountList, error) {
if err := s.check(); err != nil {
return protocol.ClaudeAccountList{}, err
}
dir := s.slotsDir()
if err := os.Mkdir(dir, 0o700); err != nil && !errors.Is(err, fs.ErrExist) {
return protocol.ClaudeAccountList{}, err
}
current := s.readSettings()
current.AutoSwitch = &on
data, err := marshal(current)
if err != nil {
return protocol.ClaudeAccountList{}, err
}
path := filepath.Join(dir, settingsFile)
if err := writeAtomic(path, data, 0o600); err != nil {
return protocol.ClaudeAccountList{}, err
}
if err := os.Chmod(path, 0o600); err != nil {
if err := s.updateSettings(func(current *settings) { current.AutoSwitch = &on }); err != nil {
return protocol.ClaudeAccountList{}, err
}
return s.List()
}
// AutoContinue reports whether a chat on this Claude home that a usage limit
// refused is continued automatically once the limit resets (on by default).
func (s Store) AutoContinue() bool {
if on := s.readSettings().AutoContinue; on != nil {
return *on
}
return true
}
// SetAutoContinue records the auto-continue-at-reset preference.
func (s Store) SetAutoContinue(on bool) error {
return s.updateSettings(func(current *settings) { current.AutoContinue = &on })
}
func (s Store) updateSettings(change func(*settings)) error {
if err := s.check(); err != nil {
return err
}
dir := s.slotsDir()
if err := os.Mkdir(dir, 0o700); err != nil && !errors.Is(err, fs.ErrExist) {
return err
}
current := s.readSettings()
change(&current)
data, err := marshal(current)
if err != nil {
return err
}
path := filepath.Join(dir, settingsFile)
if err := writeAtomic(path, data, 0o600); err != nil {
return err
}
return os.Chmod(path, 0o600)
}