A Windows user on Discord asked for a manual warm-up of a Codex account.
Settings > Warm-up and check-in now ends both the ChatGPT and the Claude
tab with a "Warm up now" row. Its text button sends the account's warm-up
right away. With one account it sends straight off. With several it opens
the app menu ("Warm up which account"), not a select. The row then says
"Warmed up {who} {when}", or "Couldn't warm up {who}: {why}" in red, and
the status line says the same.
What is sent: provider.WarmNow(agent, user) sends the scheduled warm-up's
own request to that one account and to no other. For Codex that is
warmCodexLogin; for Claude it is warmClaudeLogin over the gateway's
warmClaude (Claude Code's run in that account's config directory), set
through WarmClaudeVia. It works whether the warm-ups are on or off. An
account whose sign-in lapsed is refused with the reason. Afterwards the
allowance is read again (StaleAllowance / claudeWarmedNow), as after a
scheduled warm-up. The schedule's file is left to the schedule. The
Codex prompt, identity and base_instructions are unchanged: it is the
same body. The route is POST /api/warm-now, and /api/settings carries
claudeUsers beside codexUsers.
Claude gets the item too. It shares the warm-up engine and the same tab,
and the send is the same warmClaude the schedule uses.
No size budget was raised.
Run:
- WSL (wsl-run), Chromium and WebKit, with the GUI test
warm-now.test.cjs in en/zh/zh-TW/ja/de at 900px and 440px: 22/22.
The pressed button stays in place within 1px after two frames.
- WSL, the related files (warm-now, warm-at-own, warm-at-times,
warm-reset-asleep, settings-groups, settings-search, i18n-keys):
102/102.
- WSL, the other files that touch these lists (checkin-account,
checkin-reason, checkin-reason-once, plugin-checkin, segs-press-redraw,
settings-sections, usage-checkin): 169/170. The red is segs-press-redraw
"webkit ja 440px: every Settings option..." with "could not bring the
option into view" after 103s under load. It passed 3/3 alone and is
filed as #4189.
- mote (macOS) at the final tree: go vet for internal/gui, provider and
gateway; go test -run 'WarmNow|Budget|Warm' ./internal/gui
./internal/provider: ok. An earlier mote run, before the route move,
ran go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
vet ./..., go build ./... and the budget tests: ok.
- Windows (win-run): go test -run 'TestWarmNow|TestCodexWarm|TestClaudeWarm'
./internal/provider/ ./internal/gui/: ok.
- WSL: go vet -tags nogui ./... is ok and gofmt -l is empty.
go test -tags nogui -timeout 45m ./...: 75 packages ok, including
internal/gui and internal/provider. internal/agent has 4 reds on the WSL
box (TestInstalledVersion, TestGrokInstalled,
TestCursorFolderFromTheEditorIsNotTheCLI, TestOmpDetectedWithPiDir). They
are already filed as #4033 and #3548 (fake binaries hit WSL interop).
internal/gateway has 1 red, TestUnroutedRequestShownThenAnswered: giveUp
answers the 504 before it marks the route done. That is not this change,
and it is filed as #4200.
At the head rebased on origin/main 9474eaf9c:
- mote: gofmt -l is empty. go vet passes for gui, provider and gateway,
and GOOS=windows go vet passes for gui and provider. go test -run
'WarmNow|Budget|Warm|I18n' ./internal/gui ./internal/provider: ok.
- WSL: warm-now, i18n-keys and warm-at-own GUI tests: 44/44.
Broken by hand (each was red, then restored and checked with cmp):
- WarmNow swallowing the Codex error: TestWarmNowSendsTheScheduledWarmUp
went red on the refused request.
- Running Claude in ls[0]'s directory: TestWarmNowClaudeRunsClaudeCode
went red.
- Dropping the lapsed check: TestWarmNowLapsedAccount went red.
- The menu always sending users[0]: warm-now.test.cjs went red (timed
out) in both engines.
Not tried:
- A warm-up of a real account. The request-equality test compares
against the scheduled warm-up's request through a fake vendor.
- Breaking the request-equality check by changing the body itself.
- The GUI suite on macOS, because mote's browsers hang (#4125).
72 lines
2.4 KiB
Go
72 lines
2.4 KiB
Go
package provider
|
||
|
||
// Warm up now (a Windows user on Discord): one account's warm-up sent at
|
||
// once from Settings › Warm-up and check-in, whatever the warm-up settings
|
||
// say. It is the request the scheduled warm-up sends — warmCodexLogin for
|
||
// a ChatGPT account, Claude Code's own run (WarmClaudeVia) for a Claude
|
||
// one — to that account alone, and what it says back is the result. The
|
||
// scheduled warm-up's file is left to the scheduled one: its next look
|
||
// reads the window as started, from its own read.
|
||
|
||
import (
|
||
"context"
|
||
"errors"
|
||
"fmt"
|
||
"slices"
|
||
"strings"
|
||
"time"
|
||
)
|
||
|
||
// warmNowWait is how long Warm up now waits on its request, as long as
|
||
// the scheduled warm-up gives one look.
|
||
const warmNowWait = 2 * time.Minute
|
||
|
||
// claudeWarmSend is a Claude warm-up's send, Claude Code asked with
|
||
// configDir the config directory of a saved account, "" for the one it is
|
||
// signed in to. The gateway, which runs Claude Code, sets it (WarmClaudeVia).
|
||
var claudeWarmSend func(ctx context.Context, configDir string) error
|
||
|
||
// WarmClaudeVia sets how a Claude account's warm-up runs Claude Code.
|
||
func WarmClaudeVia(f func(ctx context.Context, configDir string) error) { claudeWarmSend = f }
|
||
|
||
// WarmNow sends agent's ("codex" or "claude") account user the warm-up's
|
||
// one tiny request now, and says why it failed. Once it went, what the
|
||
// account has left is read again, as after a scheduled warm-up.
|
||
func WarmNow(ctx context.Context, agent, user string) error {
|
||
var name string
|
||
switch agent {
|
||
case "codex":
|
||
name = "ChatGPT"
|
||
case "claude":
|
||
name = "Claude"
|
||
default:
|
||
return fmt.Errorf("%q has no warm-up", agent)
|
||
}
|
||
ls := Logins(agent)
|
||
i := slices.IndexFunc(ls, func(l Login) bool { return strings.EqualFold(l.User, user) })
|
||
if user == "" || i < 0 {
|
||
return fmt.Errorf("no %s account %q", name, user)
|
||
}
|
||
if ls[i].Lapsed != "" {
|
||
// as the scheduled warm-up leaves it out (codexWarmUsage)
|
||
return fmt.Errorf("%s needs signing in again: %s", ls[i].User, ls[i].Lapsed)
|
||
}
|
||
ctx, cancel := context.WithTimeout(ctx, warmNowWait)
|
||
defer cancel()
|
||
if agent == "codex" {
|
||
if err := warmCodexLogin(ctx, ls[i].User); err != nil {
|
||
return err
|
||
}
|
||
StaleAllowance("codex", ls[i].User)
|
||
return nil
|
||
}
|
||
if claudeWarmSend == nil {
|
||
return errors.New("Claude Code isn't available to send the warm-up")
|
||
}
|
||
if err := warmClaudeLogin(claudeWarmSend)(ctx, ls[i].User); err != nil {
|
||
return err
|
||
}
|
||
claudeWarmedNow(ls[i].User)
|
||
return nil
|
||
}
|