codex: how early an expiring reset is used is a setting
A Codex reset card that would run out unused was spent 30 minutes before it expired, a fixed resetExpiryLead. Now the lead is codexResetLead in settings.json (minutes, 15 to 1440). Unset, out of range or unreadable reads as 30m, never 0, and magpie never writes it unless the user does. - settings: CodexResetLead and Settings.ResetLead(); the menu's values are 15m, 30m (default), 1h, 2h, 3h, 6h, 12h, 24h. - provider: the spend (expiringResetSpent) and routing (Allowance.Restarts, through nextResetLook) read the same resetLead(), so they still agree (#717, #718). The "near" look cadence follows it: lead + 30m, at least 1h, so a look lands inside a long lead. - GUI: Settings > Usage, under the Codex auto-use rows, a row "Codex: how early before one expires" with an app menu (no <select>), and the sub text says spending earlier loses what the windows have left. The four "before it expires" strings say the chosen lead. POST /api/settings/codex-reset-lead; the general save keeps the field. en, zh, zh-TW, ja, de. - CLI: magpie quota auto-reset lead [30m|3h|<minutes>|default]. - app.js budget: the auto-use rows moved out to lazy autoresetown.js (painted in the same draw once loaded), so app.js and the core script stay under their budgets with no raise. The button sizes to its widest label (a grid of every label), so picking one never rewraps the row. Run (all on mote through mote-run): - go vet: darwin, GOOS=linux -tags nogui, GOOS=windows; nogui build. - go test -tags nogui -timeout 45m ./... at 3955adccf (this change before the paint and sizer fixes, which touch only GUI assets): 81 ok. go test ./internal/gui at this head: ok. - GUI, Chromium: codex-reset-lead, codex-auto-reset, codex-auto-reset-settings, segs-press-redraw, i18n-keys: 62/62. WebKit: every case of those files failed at browserType.launch (180s timeout) before a page loaded, both runs; mote's browser launches hang under #4125 (load ~26), so WebKit is not run. - Rebased ontof7f2d75f2(old-webkit's lazy list now has traywindows.js too): go build ./..., go vet -tags nogui ./internal/..., go test internal/gui (budgets included), cli, settings, gateway: ok. provider: ok but TestQuotaSpanCarriesEveryWindowField, red on main since7d4a63148(#4457, fixed inccbefe2a2). GUI old-webkit, i18n-keys, codex-reset-lead in Chromium: pass. - Rebased again onto62a1dcdd7(clean): go test internal/gui (budgets) and internal/provider: ok; i18n-keys and Chromium codex-reset-lead 12/12 pass; old-webkit 9/10, its Safari 15.0 case a WebKit launch timeout (#4125). Broken by hand, each went red: - resetLead() pinned to 30m: all 3 provider tests. - resetExpiryNear pinned to 1h: the long-lead look test. - ResetLead's range check turned into m == 0: TestResetLeadUnreadIsDefault. - GUI resetLeadMinutes returning 30: codex-reset-lead in every language. - The button without the sizer: de at 420px, "no click moved the page". Not tried: a real Codex account spending a card at a non-default lead; Windows and Linux runs (vet only). The whole GUI suite in Chromium on mote has ~45 tests in 31 files crash with "browser has been closed" on untouched origin/mainc84c3e1c0too (reducedMotion files, #4458).
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
const quotaUsage = `usage: magpie quota [<provider>…] [--json]
|
||||
magpie quota reset [<codex account>] [--yes]
|
||||
magpie quota auto-reset [<codex account>] [week|expiring] [on|off]
|
||||
magpie quota auto-reset lead [<minutes or hours, like 30m or 3h>|default]
|
||||
magpie quota credits [<codex account>] [on|off]
|
||||
magpie quota alert [<percent>|off] [--balance <amount>|off]
|
||||
magpie quota wait <provider|account> [--timeout <duration>] [--quiet]
|
||||
@@ -33,7 +34,7 @@ const quotaUsage = `usage: magpie quota [<provider>…] [--json]
|
||||
named). It can't be undone, so it asks first; --yes doesn't. quota auto-reset on lets
|
||||
the account spend one by itself when its weekly window is used up and no other
|
||||
account can take a request, or before a request goes on its credits, one a week
|
||||
at most (the five hours running out never does), and spend the one about to expire about half an hour before it does, if
|
||||
at most (the five hours running out never does), and spend the one about to expire half an hour before it does, if
|
||||
the account's windows have been used, so what they have left can be used until
|
||||
then and it isn't lost; at once when the account is held up until after then.
|
||||
week on|off or expiring on|off turns only one of those two times on or off, the
|
||||
@@ -41,6 +42,9 @@ const quotaUsage = `usage: magpie quota [<provider>…] [--json]
|
||||
reset it) and still spends the reset about to expire.
|
||||
It is the account's standing setting, held resets or not; off stops it, and alone
|
||||
it says which accounts have it on. It is off until turned on.
|
||||
quota auto-reset lead 2h spends the one about to expire two hours before it does
|
||||
instead, for every account, from 15m to 24h; default puts back the half hour, and
|
||||
alone it says what is set. Earlier loses what the windows have left then.
|
||||
quota credits off keeps a Codex account from spending its credits: once one of
|
||||
its windows is used up, by magpie's latest reading (refreshed about every
|
||||
minute), routing holds it as used up until that window renews and the request
|
||||
@@ -266,6 +270,9 @@ func quotaResetCmd(args []string) error {
|
||||
// [on|off] — whether the account spends a reset by itself once its week is
|
||||
// used up, before one expires, or both (#2078).
|
||||
func quotaAutoResetCmd(args []string) error {
|
||||
if len(args) > 0 && strings.EqualFold(args[0], "lead") {
|
||||
return quotaResetLeadCmd(args[1:])
|
||||
}
|
||||
user, when, set, on := "", "", false, false
|
||||
for _, a := range args {
|
||||
switch strings.ToLower(a) {
|
||||
@@ -316,17 +323,75 @@ func quotaAutoResetCmd(args []string) error {
|
||||
}
|
||||
switch week, expiring := provider.CodexAutoResetWhen(user); {
|
||||
case week && expiring:
|
||||
fmt.Println(green.Render("✓"), user+":", "uses a reset by itself once its week is used up and no other account can answer, or before its credits are spent, one a week at most, and the one about to expire half an hour before it does, or at once when held up past then")
|
||||
fmt.Println(green.Render("✓"), user+":", "uses a reset by itself once its week is used up and no other account can answer, or before its credits are spent, one a week at most, and the one about to expire "+leadWords(settings.Load().ResetLead())+" before it does, or at once when held up past then")
|
||||
case week:
|
||||
fmt.Println(green.Render("✓"), user+":", "uses a reset by itself once its week is used up and no other account can answer, or before its credits are spent, one a week at most; one about to expire is left to run out")
|
||||
case expiring:
|
||||
fmt.Println(green.Render("✓"), user+":", "uses the reset about to expire half an hour before it does, or at once when held up past then; a week used up is waited out")
|
||||
fmt.Println(green.Render("✓"), user+":", "uses the reset about to expire "+leadWords(settings.Load().ResetLead())+" before it does, or at once when held up past then; a week used up is waited out")
|
||||
default:
|
||||
fmt.Println(green.Render("✓"), user+":", "no longer uses a reset by itself")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// quotaResetLeadCmd: magpie quota auto-reset lead [<duration>|default] —
|
||||
// how long before a reset about to expire unused it is spent, for every
|
||||
// account with expiring on (the owner, 10-30).
|
||||
func quotaResetLeadCmd(args []string) error {
|
||||
switch {
|
||||
case len(args) > 1:
|
||||
return fmt.Errorf("one lead at a time, like: magpie quota auto-reset lead 2h")
|
||||
case len(args) == 0:
|
||||
s := settings.Load()
|
||||
say := "used " + leadWords(s.ResetLead()) + " before it expires"
|
||||
if s.CodexResetLead == 0 {
|
||||
say += " (the default)"
|
||||
}
|
||||
fmt.Println("a reset about to expire unused is", say)
|
||||
return nil
|
||||
}
|
||||
a := strings.ToLower(strings.TrimSpace(args[0]))
|
||||
minutes := 0
|
||||
switch a {
|
||||
case "help", "-h", "--help":
|
||||
fmt.Println(quotaUsage)
|
||||
return nil
|
||||
case "default", "0":
|
||||
default:
|
||||
d, err := time.ParseDuration(a)
|
||||
if err != nil {
|
||||
n, nerr := strconv.Atoi(a)
|
||||
if nerr != nil {
|
||||
return fmt.Errorf("a lead looks like 30m or 3h, or default, not %q", args[0])
|
||||
}
|
||||
d = time.Duration(n) * time.Minute
|
||||
}
|
||||
if d%time.Minute != 0 {
|
||||
return fmt.Errorf("a lead is whole minutes, not %v", d)
|
||||
}
|
||||
minutes = int(d / time.Minute)
|
||||
if minutes <= 0 {
|
||||
return fmt.Errorf("a lead is from %dm to %dh, not %q", settings.CodexResetLeadLeast, settings.CodexResetLeadMost/60, args[0])
|
||||
}
|
||||
}
|
||||
if err := provider.SetCodexResetLead(minutes); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(green.Render("✓"), "a reset about to expire unused is used", leadWords(settings.Load().ResetLead()), "before it does, for every account with auto-reset's expiring on")
|
||||
return nil
|
||||
}
|
||||
|
||||
// leadWords says a lead as 30m or 3h.
|
||||
func leadWords(d time.Duration) string {
|
||||
if d%time.Hour == 0 {
|
||||
return strconv.Itoa(int(d/time.Hour)) + "h"
|
||||
}
|
||||
if d > time.Hour {
|
||||
return strconv.Itoa(int(d/time.Hour)) + "h" + strconv.Itoa(int(d%time.Hour/time.Minute)) + "m"
|
||||
}
|
||||
return strconv.Itoa(int(d/time.Minute)) + "m"
|
||||
}
|
||||
|
||||
// autoResetSay says when user spends a reset by itself.
|
||||
func autoResetSay(user string) string {
|
||||
switch week, expiring := provider.CodexAutoResetWhen(user); {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// magpie quota auto-reset lead sets how long before a reset about to
|
||||
// expire it is used, says it alone, puts back the default, and refuses a
|
||||
// value out of range or not whole minutes, writing nothing then.
|
||||
func TestQuotaResetLeadCmd(t *testing.T) {
|
||||
groupsHome(t)
|
||||
if out, err := runOut(t, "quota", "auto-reset", "lead"); err != nil || !strings.Contains(out, "used 30m before it expires (the default)") {
|
||||
t.Fatalf("unset: %q %v", out, err)
|
||||
}
|
||||
for _, c := range []struct {
|
||||
arg string
|
||||
want int
|
||||
}{{"2h", 120}, {"15m", 15}, {"24h", 1440}, {"90", 90}, {"1h30m", 90}} {
|
||||
arg, want := c.arg, c.want
|
||||
if out, err := runOut(t, "quota", "auto-reset", "lead", arg); err != nil || settings.Load().CodexResetLead != want {
|
||||
t.Fatalf("%s: %q %v, set %d", arg, out, err, settings.Load().CodexResetLead)
|
||||
}
|
||||
}
|
||||
if out, err := runOut(t, "quota", "auto-reset", "lead"); err != nil || !strings.Contains(out, "used 1h30m before it expires") || strings.Contains(out, "default") {
|
||||
t.Fatalf("set: %q %v", out, err)
|
||||
}
|
||||
for _, bad := range []string{"10m", "25h", "-1h", "30s", "90s", "soon", "--help"} {
|
||||
if bad == "--help" {
|
||||
if out, err := runOut(t, "quota", "auto-reset", "lead", bad); err != nil || !strings.Contains(out, "usage:") {
|
||||
t.Fatalf("--help: %q %v", out, err)
|
||||
}
|
||||
} else if _, err := runOut(t, "quota", "auto-reset", "lead", bad); err == nil {
|
||||
t.Fatalf("%s: taken", bad)
|
||||
}
|
||||
if got := settings.Load().CodexResetLead; got != 90 {
|
||||
t.Fatalf("%s: wrote %d", bad, got)
|
||||
}
|
||||
}
|
||||
if out, err := runOut(t, "quota", "auto-reset", "lead", "default"); err != nil || settings.Load().CodexResetLead != 0 || !strings.Contains(out, "30m") {
|
||||
t.Fatalf("default: %q %v", out, err)
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
// A Codex account that spends a reset about to run out by itself (auto-use
|
||||
// on, its windows used) loses what its week has left when that reset is
|
||||
// spent, resetExpiryLead (half an hour) before it runs out: Weekly pace and Smart take
|
||||
// spent, resetLead (half an hour unless set) before it runs out: Weekly pace and Smart take
|
||||
// that for its deadline when it is sooner than the week renews (#717,
|
||||
// #718, thedavidweng: A with 80% left renewing in five days and a reset
|
||||
// running out that afternoon went behind B with 50% left renewing in two).
|
||||
|
||||
@@ -1443,6 +1443,7 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
|
||||
// which Codex accounts spend a reset by themselves, set on the Usage card
|
||||
in.CodexAutoReset = cur.CodexAutoReset
|
||||
in.CodexAutoResetOnly = cur.CodexAutoResetOnly // and at which of the two times
|
||||
in.CodexResetLead = cur.CodexResetLead // and how early before one expires (codex-reset-lead)
|
||||
// and which of them spend their credits, set there too
|
||||
in.CodexNoCredits = cur.CodexNoCredits
|
||||
// and each Codex account's own daily warm-up (codex-warm-at below)
|
||||
@@ -1928,6 +1929,20 @@ func Handler(w Windows, gw *gateway.Server) http.Handler {
|
||||
}
|
||||
writeJSON(rw, settingsState())
|
||||
})
|
||||
// how long before a Codex reset about to run out unused it is spent,
|
||||
// for every account with "before one expires" on; 0 is the default
|
||||
mux.HandleFunc("POST /api/settings/codex-reset-lead", func(rw http.ResponseWriter, r *http.Request) {
|
||||
var in struct{ Minutes int }
|
||||
if err := json.NewDecoder(r.Body).Decode(&in); err != nil {
|
||||
fail(rw, err)
|
||||
return
|
||||
}
|
||||
if err := provider.SetCodexResetLead(in.Minutes); err != nil {
|
||||
fail(rw, err)
|
||||
return
|
||||
}
|
||||
writeJSON(rw, settingsState())
|
||||
})
|
||||
// whether a Codex account spends its credits once its allowance is
|
||||
// used up, the Usage card's toggle, set on its own
|
||||
mux.HandleFunc("POST /api/settings/codex-credits", func(rw http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -1573,6 +1573,9 @@ details.cx-part[open] > summary .cx-h { margin-bottom: 2px; }
|
||||
.sess-filter:focus { border-color: var(--accent); }
|
||||
.sess-tools { flex-wrap: wrap; row-gap: 6px; }
|
||||
.sess-pick { flex: none; display: inline-flex; align-items: center; gap: 4px; max-width: 180px; height: 26px; padding: 0 7px 0 9px; border-radius: 7px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font: inherit; font-size: 12px; cursor: default; }
|
||||
.rl-say { display: grid; }
|
||||
.rl-say > span { grid-area: 1 / 1; white-space: nowrap; }
|
||||
.rl-say > span:not(.on) { visibility: hidden; }
|
||||
.sess-pick span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.sess-pick svg { flex: none; opacity: .7; transition: transform .15s var(--ease); }
|
||||
.sess-pick:hover { background: var(--pill); }
|
||||
|
||||
+27
-58
@@ -17751,9 +17751,9 @@ function resetsWords(r, q) {
|
||||
if (q && autoResetKept(q)) {
|
||||
const { expiring: x, week } = autoResetWhen(q);
|
||||
w.append(el("span", "resets-kept" + (x || week ? " on" : ""), " · " + t(x ? "auto-used before it expires" : week ? "auto-used when the week runs out" : "not auto-used")));
|
||||
w.title += "\n" + t(x ? "Auto-use is on: the reset that runs out first is used about half an hour before it does, if this account's windows have been used, so what they have left can be used until then and it isn't lost; at once if the account is held up until after then."
|
||||
w.title += "\n" + t(x ? "Auto-use is on: the reset that runs out first is used {lead} before it does, if this account's windows have been used, so what they have left can be used until then and it isn't lost; at once if the account is held up until after then."
|
||||
: week ? "Auto-use is on for a used-up week: a reset is used by itself when this account's week is used up, before its credits are spent. One about to run out is otherwise lost unless it's used by hand or the week runs out before then."
|
||||
: "Auto-use is off: the reset that runs out first is lost unless it's used by hand before then.");
|
||||
: "Auto-use is off: the reset that runs out first is lost unless it's used by hand before then.", resetLeadVars());
|
||||
}
|
||||
} else if (r.each?.length) w.title = resetsEach(r);
|
||||
return w;
|
||||
@@ -17813,7 +17813,7 @@ const AUTO_RESET_CASES = [
|
||||
on: "On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most. The five hours running out never uses one. Click to turn it off.",
|
||||
off: "Off: a used-up week is waited out, and the vendor may start it again sooner; requests go to your other accounts, or are refused with why. Click to turn it on." },
|
||||
{ id: "expiring", say: "before one expires",
|
||||
on: "On: the reset that runs out first is used about half an hour before it does, if this account's windows have been used, or at once when the account is held up until after then. Click to turn it off.",
|
||||
on: "On: the reset that runs out first is used {lead} before it does, if this account's windows have been used, or at once when the account is held up until after then. Click to turn it off.",
|
||||
off: "Off: a reset that runs out unused is lost. Click to turn it on." },
|
||||
];
|
||||
// autoResetStatus says what the account does now, after a switch.
|
||||
@@ -17841,7 +17841,7 @@ function autoResetRow(q, cls) {
|
||||
const line = el("div", "ar-case" + (w[c.id] ? " on" : ""));
|
||||
line.dataset.case = c.id;
|
||||
const words = el("span", "ar-case-say", t(c.say));
|
||||
words.title = t(w[c.id] ? c.on : c.off);
|
||||
words.title = t(w[c.id] ? c.on : c.off, resetLeadVars());
|
||||
line.append(words, autoResetButton(q, c));
|
||||
cases.append(line);
|
||||
}
|
||||
@@ -17870,10 +17870,25 @@ function resetUsedWhy(why) {
|
||||
return t("by hand");
|
||||
}
|
||||
function autoResetTitle(on) {
|
||||
return t(on ? "On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most, and the one about to run out is used about half an hour before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one. Click to turn it off."
|
||||
: "Off: this account's resets are used only by hand. Turned on, one is used by itself when its week is used up and no other account can answer, one a week at most, and the one about to run out about half an hour before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one.");
|
||||
return t(on ? "On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most, and the one about to run out is used {lead} before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one. Click to turn it off."
|
||||
: "Off: this account's resets are used only by hand. Turned on, one is used by itself when its week is used up and no other account can answer, one a week at most, and the one about to run out {lead} before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one.", resetLeadVars());
|
||||
}
|
||||
|
||||
// The reset about to run out is used this long before it does, for every
|
||||
// account with "before one expires" on (settings' codexResetLead, the CLI's
|
||||
// quota auto-reset lead; the owner, 10-30): half an hour unless set, and a
|
||||
// value out of range is the half hour, as the gateway reads it.
|
||||
// RESET_LEADS are the choices, in minutes.
|
||||
const RESET_LEADS = [15, 30, 60, 120, 180, 360, 720, 1440];
|
||||
function resetLeadMinutes(s = state?.settings) {
|
||||
const m = s?.codexResetLead;
|
||||
return Number.isInteger(m) && m >= 15 && m <= 1440 ? m : 30;
|
||||
}
|
||||
function resetLeadWords(m) {
|
||||
return m < 60 || m % 60 ? t("{n} min", { n: m }) : t("{n} h", { n: m / 60 });
|
||||
}
|
||||
const resetLeadVars = (s) => ({ lead: resetLeadWords(resetLeadMinutes(s)) });
|
||||
|
||||
// autoResetBrief: an account in brief says it too, beside its name — the
|
||||
// resets it holds and the say — with its switch: the account a week ran
|
||||
// out on is the one not served, so the one shown in brief, and its switch
|
||||
@@ -17902,7 +17917,7 @@ function autoResetButton(q, c) {
|
||||
b.setAttribute("role", "switch");
|
||||
b.setAttribute("aria-checked", String(on));
|
||||
b.setAttribute("aria-label", t("Auto-use resets") + (c ? " · " + t(c.say) : ""));
|
||||
b.title = c ? t(on ? c.on : c.off) : autoResetTitle(on);
|
||||
b.title = c ? t(on ? c.on : c.off, resetLeadVars()) : autoResetTitle(on);
|
||||
if (c) b.dataset.case = c.id;
|
||||
b.append(el("i"));
|
||||
b.onclick = async (e) => {
|
||||
@@ -21046,58 +21061,12 @@ function renderWarmAt(box, sub, ats, onReset, via, save) {
|
||||
box.append(segs([["off", t("Off")], ["on", t("On")]], ats.length ? "on" : "off", (v) => save(v === "on" ? (ats.length ? ats : ["06:00"]) : [])));
|
||||
}
|
||||
|
||||
// renderAutoResetOwn lists each ChatGPT account under Settings › Usage's
|
||||
// "Codex: auto-use resets", with its switch, the same say as on the
|
||||
// account's card (settings' codexAutoReset, the CLI's quota auto-reset).
|
||||
// Avalon on Discord, after foobra12 asked where it was: it was only on the
|
||||
// accounts' cards, and they found it from the menu bar's panel alone,
|
||||
// nothing for it in the window's Settings. The row shows while a Codex
|
||||
// account is signed in, or one is still on.
|
||||
// Settings › Usage's Codex auto-use rows and how early one expiring is
|
||||
// used are drawn by autoresetown.js, imported as Settings first draws
|
||||
// them; then in the same draw, so a redraw leaves a pressed switch in place
|
||||
function renderAutoResetOwn(s) {
|
||||
const head = $("#codexAutoResetRow");
|
||||
const list = head.parentElement;
|
||||
list.querySelectorAll(".ar-own").forEach((r) => r.remove());
|
||||
const on = s.codexAutoReset || [];
|
||||
const users = [...(s.codexUsers || [])];
|
||||
for (const u of on) if (!users.some((x) => x.toLowerCase() === u)) users.push(u);
|
||||
head.hidden = !users.length;
|
||||
let after = head;
|
||||
for (const user of users) {
|
||||
const r = el("div", "row pref ar-own");
|
||||
r.dataset.user = user;
|
||||
const who = el("div", "who");
|
||||
const name = el("div", "name", user);
|
||||
name.title = user;
|
||||
who.append(name);
|
||||
// each of the two times its own Off/On (#2078)
|
||||
const was = on.includes(user.toLowerCase()) ? autoResetWhenOf(s.codexAutoResetOnly?.[user.toLowerCase()]) : { week: false, expiring: false };
|
||||
const cases = el("div", "ar-own-cases");
|
||||
for (const c of AUTO_RESET_CASES) {
|
||||
const line = el("div", "ar-own-case");
|
||||
line.dataset.case = c.id;
|
||||
const say = el("span", "ar-own-say", t(c.say));
|
||||
say.title = t(was[c.id] ? c.on : c.off);
|
||||
const pick = segs([["off", t("Off")], ["on", t("On")]], was[c.id] ? "on" : "off", async (v) => {
|
||||
try {
|
||||
prefs = await writingPrefs(api("settings/codex-auto-reset", { user, on: v === "on", when: c.id }));
|
||||
if (state) state.settings = prefs;
|
||||
const now = (prefs.codexAutoReset || []).includes(user.toLowerCase()) ? autoResetWhenOf(prefs.codexAutoResetOnly?.[user.toLowerCase()]) : { week: false, expiring: false };
|
||||
status(autoResetStatus(user, now), "ok");
|
||||
renderSettings();
|
||||
if (quotas) renderQuotas(); // the account's card says the same
|
||||
} catch (e) {
|
||||
statusTErr(e);
|
||||
renderSettings();
|
||||
}
|
||||
});
|
||||
pick.setAttribute("aria-label", t("Auto-use resets") + " · " + t(c.say) + " · " + user);
|
||||
line.append(say, pick);
|
||||
cases.append(line);
|
||||
}
|
||||
r.append(who, cases);
|
||||
after.after(r);
|
||||
after = r;
|
||||
}
|
||||
if (window.autoResetOwnPaint) return autoResetOwnPaint(s);
|
||||
import("./autoresetown.js").then(() => autoResetOwnPaint(s), statusErr);
|
||||
}
|
||||
|
||||
// renderWarmAtOwn gives each ChatGPT account its own row under Daily
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
// Settings › Usage's Codex auto-use rows: each ChatGPT account's switches
|
||||
// and, under them, how early a reset about to expire is used. app.js
|
||||
// imports this when Settings draws them (renderAutoResetOwn), so it weighs
|
||||
// nothing on the core.
|
||||
|
||||
// renderAutoResetOwn lists each ChatGPT account under Settings › Usage's
|
||||
// "Codex: auto-use resets", with its switch, the same say as on the
|
||||
// account's card (settings' codexAutoReset, the CLI's quota auto-reset).
|
||||
// Avalon on Discord, after foobra12 asked where it was: it was only on the
|
||||
// accounts' cards, and they found it from the menu bar's panel alone,
|
||||
// nothing for it in the window's Settings. The row shows while a Codex
|
||||
// account is signed in, or one is still on.
|
||||
window.autoResetOwnPaint = function (s) {
|
||||
const head = $("#codexAutoResetRow");
|
||||
const list = head.parentElement;
|
||||
list.querySelectorAll(".ar-own").forEach((r) => r.remove());
|
||||
const on = s.codexAutoReset || [];
|
||||
const users = [...(s.codexUsers || [])];
|
||||
for (const u of on) if (!users.some((x) => x.toLowerCase() === u)) users.push(u);
|
||||
head.hidden = !users.length;
|
||||
let after = head;
|
||||
for (const user of users) {
|
||||
const r = el("div", "row pref ar-own");
|
||||
r.dataset.user = user;
|
||||
const who = el("div", "who");
|
||||
const name = el("div", "name", user);
|
||||
name.title = user;
|
||||
who.append(name);
|
||||
// each of the two times its own Off/On (#2078)
|
||||
const was = on.includes(user.toLowerCase()) ? autoResetWhenOf(s.codexAutoResetOnly?.[user.toLowerCase()]) : { week: false, expiring: false };
|
||||
const cases = el("div", "ar-own-cases");
|
||||
for (const c of AUTO_RESET_CASES) {
|
||||
const line = el("div", "ar-own-case");
|
||||
line.dataset.case = c.id;
|
||||
const say = el("span", "ar-own-say", t(c.say));
|
||||
say.title = t(was[c.id] ? c.on : c.off, resetLeadVars());
|
||||
const pick = segs([["off", t("Off")], ["on", t("On")]], was[c.id] ? "on" : "off", async (v) => {
|
||||
try {
|
||||
prefs = await writingPrefs(api("settings/codex-auto-reset", { user, on: v === "on", when: c.id }));
|
||||
if (state) state.settings = prefs;
|
||||
const now = (prefs.codexAutoReset || []).includes(user.toLowerCase()) ? autoResetWhenOf(prefs.codexAutoResetOnly?.[user.toLowerCase()]) : { week: false, expiring: false };
|
||||
status(autoResetStatus(user, now), "ok");
|
||||
renderSettings();
|
||||
if (quotas) renderQuotas(); // the account's card says the same
|
||||
} catch (e) {
|
||||
statusTErr(e);
|
||||
renderSettings();
|
||||
}
|
||||
});
|
||||
pick.setAttribute("aria-label", t("Auto-use resets") + " · " + t(c.say) + " · " + user);
|
||||
line.append(say, pick);
|
||||
cases.append(line);
|
||||
}
|
||||
r.append(who, cases);
|
||||
after.after(r);
|
||||
after = r;
|
||||
}
|
||||
renderResetLead(s, head.hidden);
|
||||
};
|
||||
|
||||
// renderResetLead: how long before a reset about to run out unused it is
|
||||
// used, under the accounts' switches, one for them all; a pick from the
|
||||
// app's menu (settings/codex-reset-lead). A value set outside the choices
|
||||
// (the CLI takes any minutes in range) is shown and kept.
|
||||
function renderResetLead(s, hidden) {
|
||||
const row = $("#codexResetLeadRow");
|
||||
if (!row) return;
|
||||
row.hidden = hidden;
|
||||
const cur = resetLeadMinutes(s);
|
||||
const leads = RESET_LEADS.includes(cur) ? RESET_LEADS : [...RESET_LEADS, cur].sort((a, b) => a - b);
|
||||
const name = (m) => t("{lead} before", { lead: resetLeadWords(m) });
|
||||
const b = el("button", "sess-pick reset-lead");
|
||||
b.type = "button";
|
||||
b.setAttribute("aria-haspopup", "menu");
|
||||
b.setAttribute("aria-label", t("Codex: how early before one expires") + ": " + name(cur));
|
||||
// every choice in one cell, the current one seen: the button is as wide
|
||||
// as the widest, so a pick doesn't rewrap the row and move the page
|
||||
const say = el("span", "rl-say");
|
||||
for (const m of leads) {
|
||||
const w = el("span", m === cur ? "on" : "", name(m));
|
||||
if (m !== cur) w.setAttribute("aria-hidden", "true");
|
||||
say.append(w);
|
||||
}
|
||||
b.append(say, svg(CHEV, 11, 1.6));
|
||||
b.onclick = (e) => {
|
||||
e.stopPropagation();
|
||||
if (b.classList.contains("open")) return closeProtoMenu();
|
||||
openProtoMenu(b, leads.map((m) => ({ v: String(m), name: name(m), note: m === 30 ? "Default" : "", literalName: true })), String(cur), async (v) => {
|
||||
if (Number(v) === cur) return;
|
||||
try {
|
||||
prefs = await writingPrefs(api("settings/codex-reset-lead", { minutes: Number(v) }));
|
||||
if (state) state.settings = prefs;
|
||||
renderSettings();
|
||||
if (quotas) renderQuotas(); // the cards' titles say it too
|
||||
} catch (err) {
|
||||
statusTErr(err);
|
||||
renderSettings();
|
||||
}
|
||||
}, "Used before it expires", "sess-menu", "right");
|
||||
};
|
||||
$("#codexResetLeadPick").replaceChildren(b);
|
||||
}
|
||||
+32
-16
@@ -2112,6 +2112,10 @@ const I18N = {
|
||||
"Auto-use resets": "自动使用重置卡",
|
||||
"Auto-use resets:": "自动使用重置卡:",
|
||||
"Codex: auto-use resets": "Codex:自动使用重置卡",
|
||||
"Codex: how early before one expires": "Codex:重置卡提前多久使用",
|
||||
"For every account with \"before one expires\" on: the reset about to run out unused is used this long before it does. Earlier loses what the account's windows have left then; the default is half an hour.": "对所有开启了“重置卡到期前”的账号:快到期还没用的重置卡在到期前这么久自动使用。越早用,账号各窗口当时剩下的额度就越多被作废;默认半小时。",
|
||||
"{lead} before": "提前 {lead}",
|
||||
"Used before it expires": "到期前多久使用",
|
||||
"A ChatGPT account uses one of its resets by itself when its week is used up and no other account can answer, or before one expires unused. Off until turned on, account by account; each account's card on the Usage page has the same switch.": "ChatGPT 账号在周额度用完、且没有别的账号能接请求时,或者重置卡快到期还没用时,自动用掉一张。默认关闭,按账号单独打开;用量页每个账号的卡片上也有同一个开关。",
|
||||
"Use credits:": "使用积分:",
|
||||
"when its windows run out, so a task goes on": "额度用尽时继续用积分,任务不中断",
|
||||
@@ -2127,7 +2131,7 @@ const I18N = {
|
||||
"{who} uses a reset by itself only before one expires": "{who} 仅在重置卡到期前自动使用",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most. The five hours running out never uses one. Click to turn it off.": "已开启:周额度用完且无其他账号可接手时自动用一张重置卡,每周最多一张;仅 5 小时额度用完不会动用重置卡。点击关闭。",
|
||||
"Off: a used-up week is waited out, and the vendor may start it again sooner; requests go to your other accounts, or are refused with why. Click to turn it on.": "已关闭:周额度用完时不动用重置卡,等它自行恢复(服务方也可能提前重置);请求改由你的其他账号接手,都无法接手时会被拒绝并说明原因。点击开启。",
|
||||
"On: the reset that runs out first is used about half an hour before it does, if this account's windows have been used, or at once when the account is held up until after then. Click to turn it off.": "已开启:最早到期的重置卡在到期前约半小时自动使用(需账号已用过额度;若限流到那之后才解除,则立即使用)。点击关闭。",
|
||||
"On: the reset that runs out first is used {lead} before it does, if this account's windows have been used, or at once when the account is held up until after then. Click to turn it off.": "已开启:最早到期的重置卡在到期前{lead}自动使用(需账号已用过额度;若限流到那之后才解除,则立即使用)。点击关闭。",
|
||||
"Off: a reset that runs out unused is lost. Click to turn it on.": "已关闭:到期前未用的重置卡将作废。点击开启。",
|
||||
"Auto-use": "自动用卡",
|
||||
"Auto-use: on": "自动用卡:开",
|
||||
@@ -2140,10 +2144,10 @@ const I18N = {
|
||||
"by itself, before it expired": "自动,重置卡到期前",
|
||||
"by hand": "手动",
|
||||
"not auto-used": "不会自动使用",
|
||||
"Auto-use is on: the reset that runs out first is used about half an hour before it does, if this account's windows have been used, so what they have left can be used until then and it isn't lost; at once if the account is held up until after then.": "自动使用已开启:最早到期的重置卡在到期前约半小时自动使用(需账号已用过额度),之前仍可用完剩余额度,卡也不会作废;若限流到那之后才解除,则立即使用。",
|
||||
"Auto-use is on: the reset that runs out first is used {lead} before it does, if this account's windows have been used, so what they have left can be used until then and it isn't lost; at once if the account is held up until after then.": "自动使用已开启:最早到期的重置卡在到期前{lead}自动使用(需账号已用过额度),之前仍可用完剩余额度,卡也不会作废;若限流到那之后才解除,则立即使用。",
|
||||
"Auto-use is off: the reset that runs out first is lost unless it's used by hand before then.": "自动使用已关闭:最早到期的重置卡若未在到期前手动使用,将作废。",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most, and the one about to run out is used about half an hour before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one. Click to turn it off.": "已开启:周额度用完且无其他账号可接手时自动用一张重置卡,每周最多一张;快到期的卡在到期前约半小时自动使用(需账号已用过额度;若限流到那之后才解除,则立即使用)。仅 5 小时额度用完不会动用重置卡。点击关闭。",
|
||||
"Off: this account's resets are used only by hand. Turned on, one is used by itself when its week is used up and no other account can answer, one a week at most, and the one about to run out about half an hour before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one.": "已关闭:重置卡仅手动使用。开启后,周额度用完且无其他账号可接手时自动用一张,每周最多一张;快到期的卡在到期前约半小时自动使用(需账号已用过额度;若限流到那之后才解除,则立即使用)。仅 5 小时额度用完不会动用重置卡。",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most, and the one about to run out is used {lead} before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one. Click to turn it off.": "已开启:周额度用完且无其他账号可接手时自动用一张重置卡,每周最多一张;快到期的卡在到期前{lead}自动使用(需账号已用过额度;若限流到那之后才解除,则立即使用)。仅 5 小时额度用完不会动用重置卡。点击关闭。",
|
||||
"Off: this account's resets are used only by hand. Turned on, one is used by itself when its week is used up and no other account can answer, one a week at most, and the one about to run out {lead} before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one.": "已关闭:重置卡仅手动使用。开启后,周额度用完且无其他账号可接手时自动用一张,每周最多一张;快到期的卡在到期前{lead}自动使用(需账号已用过额度;若限流到那之后才解除,则立即使用)。仅 5 小时额度用完不会动用重置卡。",
|
||||
"{who} uses a reset by itself when its week runs out, or before one expires": "{who} 会在周额度用完时、或重置卡到期前自动使用重置卡",
|
||||
"Uses the reset that runs out first ({when}), never one that lasts longer.": "使用最早到期的一张({when} 到期),不会先用有效期更长的。",
|
||||
"Uses one of its resets; none of them runs out.": "使用一张重置卡;这些重置卡均不会过期。",
|
||||
@@ -6312,6 +6316,10 @@ const I18N = {
|
||||
"Auto-use resets": "自動使用重置卡",
|
||||
"Auto-use resets:": "自動使用重置卡:",
|
||||
"Codex: auto-use resets": "Codex:自動使用重置卡",
|
||||
"Codex: how early before one expires": "Codex:重置卡提前多久使用",
|
||||
"For every account with \"before one expires\" on: the reset about to run out unused is used this long before it does. Earlier loses what the account's windows have left then; the default is half an hour.": "對所有開啟了「重置卡到期前」的帳號:快到期還沒用的重置卡在到期前這麼久自動使用。越早用,帳號各窗口當時剩下的額度就越多被作廢;預設半小時。",
|
||||
"{lead} before": "提前 {lead}",
|
||||
"Used before it expires": "到期前多久使用",
|
||||
"A ChatGPT account uses one of its resets by itself when its week is used up and no other account can answer, or before one expires unused. Off until turned on, account by account; each account's card on the Usage page has the same switch.": "ChatGPT 帳號在週額度用完、且沒有別的帳號能接請求時,或者重置卡快到期還沒用時,自動用掉一張。預設關閉,按帳號單獨開啟;用量頁每個帳號的卡片上也有同一個開關。",
|
||||
"Use credits:": "使用積分:",
|
||||
"when its windows run out, so a task goes on": "額度用盡時繼續用積分,任務不中斷",
|
||||
@@ -6327,7 +6335,7 @@ const I18N = {
|
||||
"{who} uses a reset by itself only before one expires": "{who} 僅在重置卡到期前自動使用",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most. The five hours running out never uses one. Click to turn it off.": "已開啟:週額度用完且無其他帳號可接手時自動用一張重置卡,每週最多一張;僅 5 小時額度用完不會動用重置卡。點擊關閉。",
|
||||
"Off: a used-up week is waited out, and the vendor may start it again sooner; requests go to your other accounts, or are refused with why. Click to turn it on.": "已關閉:週額度用完時不動用重置卡,等它自行恢復(服務方也可能提前重置);請求改由你的其他帳號接手,都無法接手時會被拒絕並說明原因。點擊開啟。",
|
||||
"On: the reset that runs out first is used about half an hour before it does, if this account's windows have been used, or at once when the account is held up until after then. Click to turn it off.": "已開啟:最早到期的重置卡在到期前約半小時自動使用(需帳號已用過額度;若限流到那之後才解除,則立即使用)。點擊關閉。",
|
||||
"On: the reset that runs out first is used {lead} before it does, if this account's windows have been used, or at once when the account is held up until after then. Click to turn it off.": "已開啟:最早到期的重置卡在到期前{lead}自動使用(需帳號已用過額度;若限流到那之後才解除,則立即使用)。點擊關閉。",
|
||||
"Off: a reset that runs out unused is lost. Click to turn it on.": "已關閉:到期前未用的重置卡將作廢。點擊開啟。",
|
||||
"Auto-use": "自動用卡",
|
||||
"Auto-use: on": "自動用卡:開",
|
||||
@@ -6340,10 +6348,10 @@ const I18N = {
|
||||
"by itself, before it expired": "自動,重置卡到期前",
|
||||
"by hand": "手動",
|
||||
"not auto-used": "不會自動使用",
|
||||
"Auto-use is on: the reset that runs out first is used about half an hour before it does, if this account's windows have been used, so what they have left can be used until then and it isn't lost; at once if the account is held up until after then.": "自動使用已開啟:最早到期的重置卡在到期前約半小時自動使用(需帳號已用過額度),之前仍可用完剩餘額度,卡也不會作廢;若限流到那之後才解除,則立即使用。",
|
||||
"Auto-use is on: the reset that runs out first is used {lead} before it does, if this account's windows have been used, so what they have left can be used until then and it isn't lost; at once if the account is held up until after then.": "自動使用已開啟:最早到期的重置卡在到期前{lead}自動使用(需帳號已用過額度),之前仍可用完剩餘額度,卡也不會作廢;若限流到那之後才解除,則立即使用。",
|
||||
"Auto-use is off: the reset that runs out first is lost unless it's used by hand before then.": "自動使用已關閉:最早到期的重置卡若未在到期前手動使用,將作廢。",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most, and the one about to run out is used about half an hour before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one. Click to turn it off.": "已開啟:週額度用完且無其他帳號可接手時自動用一張重置卡,每週最多一張;快到期的卡在到期前約半小時自動使用(需帳號已用過額度;若限流到那之後才解除,則立即使用)。僅 5 小時額度用完不會動用重置卡。點選關閉。",
|
||||
"Off: this account's resets are used only by hand. Turned on, one is used by itself when its week is used up and no other account can answer, one a week at most, and the one about to run out about half an hour before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one.": "已關閉:重置卡僅手動使用。開啟後,週額度用完且無其他帳號可接手時自動用一張,每週最多一張;快到期的卡在到期前約半小時自動使用(需帳號已用過額度;若限流到那之後才解除,則立即使用)。僅 5 小時額度用完不會動用重置卡。",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most, and the one about to run out is used {lead} before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one. Click to turn it off.": "已開啟:週額度用完且無其他帳號可接手時自動用一張重置卡,每週最多一張;快到期的卡在到期前{lead}自動使用(需帳號已用過額度;若限流到那之後才解除,則立即使用)。僅 5 小時額度用完不會動用重置卡。點選關閉。",
|
||||
"Off: this account's resets are used only by hand. Turned on, one is used by itself when its week is used up and no other account can answer, one a week at most, and the one about to run out {lead} before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one.": "已關閉:重置卡僅手動使用。開啟後,週額度用完且無其他帳號可接手時自動用一張,每週最多一張;快到期的卡在到期前{lead}自動使用(需帳號已用過額度;若限流到那之後才解除,則立即使用)。僅 5 小時額度用完不會動用重置卡。",
|
||||
"{who} uses a reset by itself when its week runs out, or before one expires": "{who} 會在週額度用完時、或重置卡到期前自動使用重置卡",
|
||||
"Uses the reset that runs out first ({when}), never one that lasts longer.": "使用最早到期的一張({when} 到期),不會先用有效期更長的。",
|
||||
"Uses one of its resets; none of them runs out.": "使用一張重置卡;這些重置卡均不會過期。",
|
||||
@@ -10489,6 +10497,10 @@ const I18N = {
|
||||
"Auto-use resets": "リセットを自動使用",
|
||||
"Auto-use resets:": "リセットを自動使用:",
|
||||
"Codex: auto-use resets": "Codex:リセットを自動使用",
|
||||
"Codex: how early before one expires": "Codex:期限切れのどれだけ前に使うか",
|
||||
"For every account with \"before one expires\" on: the reset about to run out unused is used this long before it does. Earlier loses what the account's windows have left then; the default is half an hour.": "「期限切れの前」がオンのすべてのアカウントで、未使用のまま期限が近いリセットを、期限のこの時間前に使います。早いほど、その時点で枠に残っている分が失われます。既定は 30 分です。",
|
||||
"{lead} before": "{lead}前",
|
||||
"Used before it expires": "期限切れのどれだけ前に使うか",
|
||||
"A ChatGPT account uses one of its resets by itself when its week is used up and no other account can answer, or before one expires unused. Off until turned on, account by account; each account's card on the Usage page has the same switch.": "ChatGPT アカウントは、週の枠を使い切り、ほかに応答できるアカウントがないとき、または未使用のリセットが期限切れになる前に、リセットを自動で 1 つ使います。オンにするまではオフで、アカウントごとに設定します。使用量ページの各アカウントのカードにも同じスイッチがあります。",
|
||||
"Use credits:": "クレジットを使用:",
|
||||
"when its windows run out, so a task goes on": "枠を使い切ったら使用し、タスクを続行",
|
||||
@@ -10504,7 +10516,7 @@ const I18N = {
|
||||
"{who} uses a reset by itself only before one expires": "{who} は期限切れの前だけリセットを自動使用します",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most. The five hours running out never uses one. Click to turn it off.": "オン:このアカウントの週の枠を使い切り、他のアカウントが応答できないとき、リセットを自動で 1 回使います(週に 1 回まで)。5 時間の枠が尽きただけでは使いません。クリックでオフ。",
|
||||
"Off: a used-up week is waited out, and the vendor may start it again sooner; requests go to your other accounts, or are refused with why. Click to turn it on.": "オフ:週の枠を使い切っても、リセットは使わず枠が戻るのを待ちます(ベンダーが早めにリセットすることもあります)。リクエストは他のアカウントに回り、どこも受けられなければ理由とともに断られます。クリックでオン。",
|
||||
"On: the reset that runs out first is used about half an hour before it does, if this account's windows have been used, or at once when the account is held up until after then. Click to turn it off.": "オン:最初に期限が切れるリセットを、その約 30 分前に自動で使います(このアカウントの枠が使われている場合。それ以降まで制限が続くなら即座に)。クリックでオフ。",
|
||||
"On: the reset that runs out first is used {lead} before it does, if this account's windows have been used, or at once when the account is held up until after then. Click to turn it off.": "オン:最初に期限が切れるリセットを、その{lead}前に自動で使います(このアカウントの枠が使われている場合。それ以降まで制限が続くなら即座に)。クリックでオフ。",
|
||||
"Off: a reset that runs out unused is lost. Click to turn it on.": "オフ:使わずに期限が切れたリセットは失われます。クリックでオン。",
|
||||
"Auto-use": "自動使用",
|
||||
"Auto-use: on": "自動使用:オン",
|
||||
@@ -10517,10 +10529,10 @@ const I18N = {
|
||||
"by itself, before it expired": "自動(期限切れの前)",
|
||||
"by hand": "手動",
|
||||
"not auto-used": "自動使用しない",
|
||||
"Auto-use is on: the reset that runs out first is used about half an hour before it does, if this account's windows have been used, so what they have left can be used until then and it isn't lost; at once if the account is held up until after then.": "自動使用はオンです:最初に期限が切れるリセットは、このアカウントの枠が使われていれば期限の約30分前に使用されるため、それまで残りの枠を使えて無駄になりません。アカウントがそれ以降まで制限されている場合はすぐに使用されます。",
|
||||
"Auto-use is on: the reset that runs out first is used {lead} before it does, if this account's windows have been used, so what they have left can be used until then and it isn't lost; at once if the account is held up until after then.": "自動使用はオンです:最初に期限が切れるリセットは、このアカウントの枠が使われていれば期限の{lead}前に使用されるため、それまで残りの枠を使えて無駄になりません。アカウントがそれ以降まで制限されている場合はすぐに使用されます。",
|
||||
"Auto-use is off: the reset that runs out first is lost unless it's used by hand before then.": "自動使用はオフです:最初に期限が切れるリセットは、それまでに手動で使わないと失われます。",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most, and the one about to run out is used about half an hour before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one. Click to turn it off.": "オン:このアカウントの週の枠を使い切り、他のアカウントが応答できないときにリセットを自動で使用します(最大で週1回)。期限が近いリセットは、アカウントが使われていれば期限の約30分前に、アカウントがそれ以降まで制限されている場合はすぐに使用されます。それ以外では、5時間の枠が切れてもリセットは使われません。クリックでオフにします。",
|
||||
"Off: this account's resets are used only by hand. Turned on, one is used by itself when its week is used up and no other account can answer, one a week at most, and the one about to run out about half an hour before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one.": "オフ:このアカウントのリセットは手動でのみ使用されます。オンにすると、週の枠を使い切り他のアカウントが応答できないときに自動で使用し(最大で週1回)、期限が近いリセットは、アカウントが使われていれば期限の約30分前に、アカウントがそれ以降まで制限されている場合はすぐに使用します。それ以外では、5時間の枠が切れてもリセットは使われません。",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most, and the one about to run out is used {lead} before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one. Click to turn it off.": "オン:このアカウントの週の枠を使い切り、他のアカウントが応答できないときにリセットを自動で使用します(最大で週1回)。期限が近いリセットは、アカウントが使われていれば期限の{lead}前に、アカウントがそれ以降まで制限されている場合はすぐに使用されます。それ以外では、5時間の枠が切れてもリセットは使われません。クリックでオフにします。",
|
||||
"Off: this account's resets are used only by hand. Turned on, one is used by itself when its week is used up and no other account can answer, one a week at most, and the one about to run out {lead} before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one.": "オフ:このアカウントのリセットは手動でのみ使用されます。オンにすると、週の枠を使い切り他のアカウントが応答できないときに自動で使用し(最大で週1回)、期限が近いリセットは、アカウントが使われていれば期限の{lead}前に、アカウントがそれ以降まで制限されている場合はすぐに使用します。それ以外では、5時間の枠が切れてもリセットは使われません。",
|
||||
"{who} uses a reset by itself when its week runs out, or before one expires": "{who} は週の枠を使い切ったとき、または期限切れの前にリセットを自動で使用します",
|
||||
"Uses the reset that runs out first ({when}), never one that lasts longer.": "最初に期限が切れるリセット({when})を使用し、より長く有効なものは使いません。",
|
||||
"Uses one of its resets; none of them runs out.": "リセットを1回使用します。どれも期限切れにはなりません。",
|
||||
@@ -14696,6 +14708,10 @@ const I18N = {
|
||||
"Auto-use resets": "Resets automatisch einlösen",
|
||||
"Auto-use resets:": "Resets automatisch einlösen:",
|
||||
"Codex: auto-use resets": "Codex: Resets automatisch einlösen",
|
||||
"Codex: how early before one expires": "Codex: wie früh vor dem Ablauf",
|
||||
"For every account with \"before one expires\" on: the reset about to run out unused is used this long before it does. Earlier loses what the account's windows have left then; the default is half an hour.": "Für jedes Konto mit „bevor einer abläuft“ an: Der ungenutzt bald ablaufende Reset wird so lange vor Ablauf eingelöst. Früher verfällt, was die Fenster des Kontos dann noch übrig haben; Standard ist eine halbe Stunde.",
|
||||
"{lead} before": "{lead} vorher",
|
||||
"Used before it expires": "Wie lange vor Ablauf eingelöst",
|
||||
"A ChatGPT account uses one of its resets by itself when its week is used up and no other account can answer, or before one expires unused. Off until turned on, account by account; each account's card on the Usage page has the same switch.": "Ein ChatGPT-Konto löst selbst einen seiner Resets ein, wenn seine Woche aufgebraucht ist und kein anderes Konto antworten kann, oder bevor einer ungenutzt abläuft. Aus, bis es eingeschaltet wird, Konto für Konto; die Karte jedes Kontos auf der Nutzungsseite hat denselben Schalter.",
|
||||
"Use credits:": "Credits nutzen:",
|
||||
"when its windows run out, so a task goes on": "wenn die Kontingente aufgebraucht sind, damit eine Aufgabe weiterläuft",
|
||||
@@ -14711,7 +14727,7 @@ const I18N = {
|
||||
"{who} uses a reset by itself only before one expires": "{who} löst einen Reset nur noch automatisch ein, bevor einer abläuft",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most. The five hours running out never uses one. Click to turn it off.": "An: Ist die Woche dieses Kontos aufgebraucht und kann kein anderes Konto antworten, wird automatisch ein Reset eingelöst, höchstens einer pro Woche. Aufgebrauchte fünf Stunden lösen nie einen ein. Klicken zum Ausschalten.",
|
||||
"Off: a used-up week is waited out, and the vendor may start it again sooner; requests go to your other accounts, or are refused with why. Click to turn it on.": "Aus: Eine aufgebrauchte Woche wird abgewartet, der Anbieter setzt sie vielleicht früher zurück; Anfragen gehen an deine anderen Konten oder werden mit Begründung abgelehnt. Klicken zum Einschalten.",
|
||||
"On: the reset that runs out first is used about half an hour before it does, if this account's windows have been used, or at once when the account is held up until after then. Click to turn it off.": "An: Der zuerst ablaufende Reset wird etwa eine halbe Stunde vorher eingelöst, wenn die Fenster dieses Kontos genutzt wurden, oder sofort, wenn das Konto bis danach gesperrt ist. Klicken zum Ausschalten.",
|
||||
"On: the reset that runs out first is used {lead} before it does, if this account's windows have been used, or at once when the account is held up until after then. Click to turn it off.": "An: Der zuerst ablaufende Reset wird {lead} vorher eingelöst, wenn die Fenster dieses Kontos genutzt wurden, oder sofort, wenn das Konto bis danach gesperrt ist. Klicken zum Ausschalten.",
|
||||
"Off: a reset that runs out unused is lost. Click to turn it on.": "Aus: Ein Reset, der ungenutzt abläuft, verfällt. Klicken zum Einschalten.",
|
||||
"Auto-use": "Automatisch",
|
||||
"Auto-use: on": "Automatisch: an",
|
||||
@@ -14724,10 +14740,10 @@ const I18N = {
|
||||
"by itself, before it expired": "automatisch, vor dem Ablauf",
|
||||
"by hand": "von Hand",
|
||||
"not auto-used": "wird nicht automatisch eingelöst",
|
||||
"Auto-use is on: the reset that runs out first is used about half an hour before it does, if this account's windows have been used, so what they have left can be used until then and it isn't lost; at once if the account is held up until after then.": "Automatisches Einlösen ist an: Der zuerst ablaufende Reset wird etwa eine halbe Stunde vor Ablauf eingelöst, sofern die Zeitfenster dieses Kontos genutzt wurden; so lässt sich der Rest bis dahin nutzen, und der Reset verfällt nicht. Ist das Konto bis nach dem Ablauf blockiert, wird er sofort eingelöst.",
|
||||
"Auto-use is on: the reset that runs out first is used {lead} before it does, if this account's windows have been used, so what they have left can be used until then and it isn't lost; at once if the account is held up until after then.": "Automatisches Einlösen ist an: Der zuerst ablaufende Reset wird {lead} vor Ablauf eingelöst, sofern die Zeitfenster dieses Kontos genutzt wurden; so lässt sich der Rest bis dahin nutzen, und der Reset verfällt nicht. Ist das Konto bis nach dem Ablauf blockiert, wird er sofort eingelöst.",
|
||||
"Auto-use is off: the reset that runs out first is lost unless it's used by hand before then.": "Automatisches Einlösen ist aus: Der zuerst ablaufende Reset verfällt, sofern er nicht vorher von Hand eingelöst wird.",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most, and the one about to run out is used about half an hour before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one. Click to turn it off.": "An: Ein Reset wird automatisch eingelöst, wenn die Woche dieses Kontos aufgebraucht ist und kein anderes Konto antworten kann, höchstens einer pro Woche; der bald ablaufende wird etwa eine halbe Stunde vor Ablauf eingelöst, sofern das Konto genutzt wurde, oder sofort, wenn das Konto bis danach blockiert ist. Ein aufgebrauchtes Fünf-Stunden-Fenster allein löst nie einen ein. Zum Ausschalten klicken.",
|
||||
"Off: this account's resets are used only by hand. Turned on, one is used by itself when its week is used up and no other account can answer, one a week at most, and the one about to run out about half an hour before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one.": "Aus: Die Resets dieses Kontos werden nur von Hand eingelöst. Eingeschaltet wird einer automatisch eingelöst, wenn die Woche aufgebraucht ist und kein anderes Konto antworten kann, höchstens einer pro Woche, und der bald ablaufende etwa eine halbe Stunde vor Ablauf, sofern das Konto genutzt wurde, oder sofort, wenn das Konto bis danach blockiert ist. Ein aufgebrauchtes Fünf-Stunden-Fenster allein löst nie einen ein.",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most, and the one about to run out is used {lead} before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one. Click to turn it off.": "An: Ein Reset wird automatisch eingelöst, wenn die Woche dieses Kontos aufgebraucht ist und kein anderes Konto antworten kann, höchstens einer pro Woche; der bald ablaufende wird {lead} vor Ablauf eingelöst, sofern das Konto genutzt wurde, oder sofort, wenn das Konto bis danach blockiert ist. Ein aufgebrauchtes Fünf-Stunden-Fenster allein löst nie einen ein. Zum Ausschalten klicken.",
|
||||
"Off: this account's resets are used only by hand. Turned on, one is used by itself when its week is used up and no other account can answer, one a week at most, and the one about to run out {lead} before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one.": "Aus: Die Resets dieses Kontos werden nur von Hand eingelöst. Eingeschaltet wird einer automatisch eingelöst, wenn die Woche aufgebraucht ist und kein anderes Konto antworten kann, höchstens einer pro Woche, und der bald ablaufende {lead} vor Ablauf, sofern das Konto genutzt wurde, oder sofort, wenn das Konto bis danach blockiert ist. Ein aufgebrauchtes Fünf-Stunden-Fenster allein löst nie einen ein.",
|
||||
"{who} uses a reset by itself when its week runs out, or before one expires": "{who} löst automatisch einen Reset ein, wenn die Woche aufgebraucht ist oder bevor einer abläuft",
|
||||
"Uses the reset that runs out first ({when}), never one that lasts longer.": "Löst den zuerst ablaufenden Reset ein ({when}), nie einen länger gültigen.",
|
||||
"Uses one of its resets; none of them runs out.": "Löst einen der Resets ein; keiner davon läuft ab.",
|
||||
|
||||
@@ -315,6 +315,10 @@
|
||||
<div class="row pref" id="codexAutoResetRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Codex: auto-use resets</div><div class="sub wraps" data-t>A ChatGPT account uses one of its resets by itself when its week is used up and no other account can answer, or before one expires unused. Off until turned on, account by account; each account's card on the Usage page has the same switch.</div></div>
|
||||
</div>
|
||||
<div class="row pref" id="codexResetLeadRow" hidden>
|
||||
<div class="who"><div class="name" data-t>Codex: how early before one expires</div><div class="sub wraps" data-t>For every account with "before one expires" on: the reset about to run out unused is used this long before it does. Earlier loses what the account's windows have left then; the default is half an hour.</div></div>
|
||||
<div id="codexResetLeadPick"></div>
|
||||
</div>
|
||||
<div class="row pref" id="turnDoneRow">
|
||||
<div class="who"><div class="name" data-t>Task done alert</div><div class="sub" id="turnDoneSub"></div></div>
|
||||
<div id="turnDoneSegs"></div>
|
||||
|
||||
@@ -169,6 +169,7 @@ func TestSettingsSaveKeepsWhatItDoesNotSend(t *testing.T) {
|
||||
ChinaMirror: true,
|
||||
CodexAutoReset: []string{"me@example.com"},
|
||||
CodexAutoResetOnly: map[string]string{"me@example.com": "expiring"},
|
||||
CodexResetLead: 180,
|
||||
CodexNoCredits: []string{"me@example.com"},
|
||||
CodexWarmAtOf: map[string]string{"me@example.com": "09:00"},
|
||||
TextSize: 125,
|
||||
|
||||
@@ -112,13 +112,13 @@ const strings = [
|
||||
...Object.values(keys),
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most. The five hours running out never uses one. Click to turn it off.",
|
||||
"Off: a used-up week is waited out, and the vendor may start it again sooner; requests go to your other accounts, or are refused with why. Click to turn it on.",
|
||||
"On: the reset that runs out first is used about half an hour before it does, if this account's windows have been used, or at once when the account is held up until after then. Click to turn it off.",
|
||||
"On: the reset that runs out first is used {lead} before it does, if this account's windows have been used, or at once when the account is held up until after then. Click to turn it off.",
|
||||
"Off: a reset that runs out unused is lost. Click to turn it on.",
|
||||
"Auto-use is on: the reset that runs out first is used about half an hour before it does, if this account's windows have been used, so what they have left can be used until then and it isn't lost; at once if the account is held up until after then.",
|
||||
"Auto-use is on: the reset that runs out first is used {lead} before it does, if this account's windows have been used, so what they have left can be used until then and it isn't lost; at once if the account is held up until after then.",
|
||||
"Auto-use is off: the reset that runs out first is lost unless it's used by hand before then.",
|
||||
"Auto-use is on for a used-up week: a reset is used by itself when this account's week is used up, before its credits are spent. One about to run out is otherwise lost unless it's used by hand or the week runs out before then.",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most, and the one about to run out is used about half an hour before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one. Click to turn it off.",
|
||||
"Off: this account's resets are used only by hand. Turned on, one is used by itself when its week is used up and no other account can answer, one a week at most, and the one about to run out about half an hour before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one.",
|
||||
"On: a reset is used by itself when this account's week is used up and no other account can answer, one a week at most, and the one about to run out is used {lead} before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one. Click to turn it off.",
|
||||
"Off: this account's resets are used only by hand. Turned on, one is used by itself when its week is used up and no other account can answer, one a week at most, and the one about to run out {lead} before it does, if the account has been used, or at once when the account is held up until after then. Otherwise the five hours running out never uses one.",
|
||||
];
|
||||
// wordsOf: a language's words, from its dictionary when not spelled out here
|
||||
async function wordsOf(page, lang) {
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// How long before a Codex reset about to run out unused it is used (the
|
||||
// owner, 10-30: 把提前用卡的时间做成可配置的): one pick under Settings ›
|
||||
// Usage's "Codex: auto-use resets", for every account, from the app's menu
|
||||
// (no native select). Unset it reads half an hour, the default; a pick
|
||||
// posts settings/codex-reset-lead with its minutes and the row, and the
|
||||
// "before one expires" titles, say the new lead. A value set outside the
|
||||
// choices (the CLI's 45m) is shown and kept; one out of range (written by
|
||||
// hand) reads as the half hour, as the gateway reads it. Five languages,
|
||||
// 1100 and 420 wide, both engines; the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
const { watchSettingsReads, settingsDrawn, reach } = require("./reader.cjs");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
|
||||
function server(lang, users, posts, lead) {
|
||||
const fixed = {
|
||||
theme: "light", lang, tray: "panel", quotaLeft: false, currency: "usd", dock: false, dockWindow: false, proxy: "",
|
||||
redact: false, redactPersonal: false, redactWords: [], codexWarmup: "", claudeWarmup: "", codexWarmAt: "", claudeWarmAt: "",
|
||||
trayUsage: "", trayUsageEvery: 3, vision: "", imageGen: "", version: "0.1.900", dir: "~/.config/magpie",
|
||||
gateway: "http://127.0.0.1:3425", proxyNow: "none", proxySource: "none", visionModels: [], imageGenModels: [], lanURLs: [],
|
||||
fx: { rate: 7.2, at: new Date().toISOString(), stale: false },
|
||||
codexUsers: users, codexAutoReset: users.slice(0, 1).map((u) => u.toLowerCase()), codexAutoResetOnly: {},
|
||||
...(lead === undefined ? {} : { codexResetLead: lead }),
|
||||
};
|
||||
let cur = fixed;
|
||||
return async (route) => {
|
||||
const req = route.request(), url = new URL(req.url());
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light" }, fx: fixed.fx });
|
||||
if (url.pathname === "/api/settings/codex-reset-lead") {
|
||||
const body = req.postDataJSON();
|
||||
posts.push(body);
|
||||
cur = { ...cur, codexResetLead: body.minutes };
|
||||
return json(cur);
|
||||
}
|
||||
if (url.pathname === "/api/settings/codex-auto-reset") {
|
||||
const body = req.postDataJSON();
|
||||
posts.push(body);
|
||||
// as the settings keep it: on, and narrowed to one time or not
|
||||
const u = body.user.toLowerCase(), only = { ...cur.codexAutoResetOnly };
|
||||
const was = cur.codexAutoReset.includes(u) ? { week: only[u] !== "expiring", expiring: only[u] !== "week" } : { week: false, expiring: false };
|
||||
const w = body.when ? { ...was, [body.when]: body.on } : { week: body.on, expiring: body.on };
|
||||
const on = cur.codexAutoReset.filter((x) => x !== u);
|
||||
delete only[u];
|
||||
if (w.week || w.expiring) on.push(u);
|
||||
if (w.week !== w.expiring) only[u] = w.week ? "week" : "expiring";
|
||||
cur = { ...cur, codexAutoReset: on, codexAutoResetOnly: only };
|
||||
return json(cur);
|
||||
}
|
||||
if (url.pathname === "/api/settings") {
|
||||
if (req.method() === "POST") cur = { ...cur, ...req.postDataJSON() };
|
||||
return json(cur);
|
||||
}
|
||||
if (url.pathname === "/api/plugins") return json({ plugins: [] });
|
||||
if (url.pathname === "/api/usage/quotas") return json([]);
|
||||
if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
|
||||
if (url.pathname.startsWith("/api/")) return json({});
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
await route.fulfill({ body: await fs.readFile(file), contentType });
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
const langs = ["en", "zh", "zh-TW", "ja", "de"];
|
||||
const users = ["alice@example.com", "a-much-longer-team-seat-address@some-company.example.org"];
|
||||
const launch = (engine) => engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" });
|
||||
|
||||
async function open(t, engine, lang, width, lead, posts) {
|
||||
const browser = await launch(engine);
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 700 }, reducedMotion: "reduce" })).newPage();
|
||||
t.after(async () => {
|
||||
if (process.env.ARTIFACT_DIR) {
|
||||
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
|
||||
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-codex-reset-lead.png`) });
|
||||
}
|
||||
await browser.close();
|
||||
});
|
||||
page.setDefaultTimeout(5000);
|
||||
const errors = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, users, posts, lead));
|
||||
await watchSettingsReads(page);
|
||||
await page.goto("http://magpie.test/?view=settings&tab=usage");
|
||||
await settingsDrawn(page);
|
||||
await page.locator("#codexResetLeadRow").waitFor();
|
||||
return { page, errors };
|
||||
}
|
||||
|
||||
// what the page says a lead of m minutes is, in lang
|
||||
const say = (page, lang, m) => page.evaluate(([lang, m]) => {
|
||||
const n = m < 60 || m % 60 ? I18N[lang]?.["{n} min"] || "{n} min" : I18N[lang]?.["{n} h"] || "{n} h";
|
||||
const lead = n.replace("{n}", m < 60 || m % 60 ? m : m / 60);
|
||||
return (I18N[lang]?.["{lead} before"] || "{lead} before").replace("{lead}", lead);
|
||||
}, [lang, m]);
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of langs) {
|
||||
for (const width of [1100, 420]) {
|
||||
test(`${engine} ${lang} ${width}: Settings › Usage picks how early a reset about to expire is used`, async (t) => {
|
||||
const posts = [];
|
||||
const { page, errors } = await open(t, engine, lang, width, undefined, posts);
|
||||
const row = page.locator("#codexResetLeadRow");
|
||||
assert.equal(await row.isVisible(), true);
|
||||
// translated, its name and its words
|
||||
if (lang !== "en") {
|
||||
const name = (await row.locator(".name").textContent()).trim();
|
||||
assert.notEqual(name, "Codex: how early before one expires", "name translated");
|
||||
assert.notEqual((await row.locator(".sub").textContent()).trim().slice(0, 20), "For every account wi", "words translated");
|
||||
}
|
||||
const pick = row.locator("button.reset-lead");
|
||||
assert.equal((await pick.locator(".rl-say > .on").textContent()).trim(), await say(page, lang, 30), "unset is half an hour");
|
||||
// under the accounts' switches, not between them
|
||||
assert.equal(await page.evaluate(() => {
|
||||
const own = [...document.querySelectorAll(".ar-own")].pop();
|
||||
return !!(own.compareDocumentPosition(document.querySelector("#codexResetLeadRow")) & Node.DOCUMENT_POSITION_FOLLOWING);
|
||||
}), true);
|
||||
// the "before one expires" title says the lead
|
||||
const exp = page.locator(".ar-own").first().locator('.ar-own-case[data-case="expiring"] .ar-own-say');
|
||||
const half = await page.evaluate((lang) => (I18N[lang]?.["{n} min"] || "{n} min").replace("{n}", 30), lang);
|
||||
assert((await exp.getAttribute("title")).includes(half), "the title says half an hour");
|
||||
|
||||
await reach(page, pick);
|
||||
const top = await page.locator("#view-settings").evaluate((v) => v.scrollTop);
|
||||
await pick.click();
|
||||
const items = page.locator(".proto-menu .pm-item");
|
||||
assert.equal(await items.count(), 8, "15 min to 24 h");
|
||||
assert.equal(await page.locator(".proto-menu .pm-item.on .pm-name").textContent(), await say(page, lang, 30));
|
||||
await page.locator(".proto-menu .pm-item", { hasText: await say(page, lang, 180) }).click();
|
||||
for (let i = 0; i < 100 && !posts.length; i++) await page.waitForTimeout(20);
|
||||
assert.deepEqual(posts, [{ minutes: 180 }]);
|
||||
await page.waitForFunction((want) => document.querySelector("#codexResetLeadRow button.reset-lead .rl-say > .on")?.textContent.trim() === want, await say(page, lang, 180));
|
||||
const title = await page.locator(".ar-own").first().locator('.ar-own-case[data-case="expiring"] .ar-own-say').getAttribute("title");
|
||||
const hours = await page.evaluate((lang) => (I18N[lang]?.["{n} h"] || "{n} h").replace("{n}", 3), lang);
|
||||
assert(title.includes(hours), `the title says 3 h: ${title}`);
|
||||
assert.equal(await page.locator("#view-settings").evaluate((v) => v.scrollTop), top, "no click moved the page");
|
||||
|
||||
// fits, no sideways scroll, no native select, no left border
|
||||
const over = await page.evaluate(() => {
|
||||
const view = document.querySelector("#view-settings").getBoundingClientRect();
|
||||
return [...document.querySelectorAll("#codexResetLeadRow, #codexResetLeadRow *")]
|
||||
.filter((e) => { const r = e.getBoundingClientRect(); return r.width && (r.right > view.right + 1 || r.left < view.left - 1); })
|
||||
.map((e) => e.className + " " + e.textContent.slice(0, 30));
|
||||
});
|
||||
assert.deepEqual(over, []);
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth), true, "no sideways scroll");
|
||||
assert.equal(await row.evaluate((e) => getComputedStyle(e).borderLeftWidth), "0px");
|
||||
assert.equal(await page.locator("#view-settings select").count(), 0, "no native select");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test(`${engine}: a lead set outside the choices is shown and kept; one out of range reads as half an hour`, async (t) => {
|
||||
const posts = [];
|
||||
const { page, errors } = await open(t, engine, "en", 900, 45, posts);
|
||||
const pick = page.locator("#codexResetLeadRow button.reset-lead");
|
||||
assert.equal((await pick.locator(".rl-say > .on").textContent()).trim(), "45 min before");
|
||||
await pick.click();
|
||||
assert.equal(await page.locator(".proto-menu .pm-item").count(), 9);
|
||||
assert.equal(await page.locator(".proto-menu .pm-item.on .pm-name").textContent(), "45 min before");
|
||||
await page.keyboard.press("Escape");
|
||||
assert.deepEqual(posts, [], "nothing written by looking");
|
||||
assert.deepEqual(errors, []);
|
||||
const bad = await open(t, engine, "en", 900, 5, []);
|
||||
assert.equal((await bad.page.locator("#codexResetLeadRow button.reset-lead .rl-say > .on").textContent()).trim(), "30 min before");
|
||||
assert.deepEqual(bad.errors, []);
|
||||
});
|
||||
|
||||
test(`${engine}: with no Codex account the lead isn't there`, async (t) => {
|
||||
const browser = await launch(engine);
|
||||
const page = await (await browser.newContext({ viewport: { width: 900, height: 600 }, reducedMotion: "reduce" })).newPage();
|
||||
t.after(() => browser.close());
|
||||
page.setDefaultTimeout(5000);
|
||||
await page.route("**/*", server("en", [], [], undefined));
|
||||
await watchSettingsReads(page);
|
||||
await page.goto("http://magpie.test/?view=settings&tab=usage");
|
||||
await settingsDrawn(page);
|
||||
await page.locator("#resetReminderSegs .opt").first().waitFor();
|
||||
assert.equal(await page.locator("#codexResetLeadRow").isVisible(), false);
|
||||
});
|
||||
}
|
||||
@@ -145,8 +145,9 @@ test("compat.js is the first of the page's own scripts", async () => {
|
||||
// when magpie can't write its folder, signsheets.js when a sign-in asks a
|
||||
// value first, ruleedit.js on a masking rule's Edit, ratewindows.js when
|
||||
// a provider editor draws its rate windows, traywindows.js when the menu
|
||||
// bar shows a card; the checks above still read them
|
||||
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
|
||||
// bar shows a card, autoresetown.js when Settings draws Codex's auto-use
|
||||
// rows; the checks above still read them
|
||||
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
|
||||
});
|
||||
|
||||
test("the styles hold up in Safari 15.0", async () => {
|
||||
|
||||
@@ -142,6 +142,19 @@ func setCodexAutoReset(user string, week, expiring bool) error {
|
||||
return settings.Save(s)
|
||||
}
|
||||
|
||||
// SetCodexResetLead sets how many minutes before a reset about to run out
|
||||
// unused it is spent (resetLead), for every account: from
|
||||
// settings.CodexResetLeadLeast to CodexResetLeadMost, or 0 for the default
|
||||
// half hour.
|
||||
func SetCodexResetLead(minutes int) error {
|
||||
if minutes != 0 && (minutes < settings.CodexResetLeadLeast || minutes > settings.CodexResetLeadMost) {
|
||||
return fmt.Errorf("a reset about to expire is used from %d minutes to %d hours before it does, not %d minutes", settings.CodexResetLeadLeast, settings.CodexResetLeadMost/60, minutes)
|
||||
}
|
||||
s := settings.Load()
|
||||
s.CodexResetLead = minutes
|
||||
return settings.Save(s)
|
||||
}
|
||||
|
||||
var autoReset = autoResets{file: "codex-autoreset.json"}
|
||||
|
||||
type autoResets struct {
|
||||
|
||||
@@ -6,9 +6,11 @@ package provider
|
||||
// nothing again is left to run out, nothing lost. Spending one starts the
|
||||
// windows again, and what they have left then is lost, while the fresh
|
||||
// windows are the same whenever it is spent: so it is spent as late as is
|
||||
// safe, resetExpiryLead before it runs out (#718: spent three hours
|
||||
// early, an account held up for the five hours but freed again in two
|
||||
// lost the 68% of its week it could have used before the reset ran out).
|
||||
// safe, resetLead before it runs out: half an hour unless the user set
|
||||
// another (settings' CodexResetLead). Earlier loses what the windows have
|
||||
// left then (#718: spent three hours early, an account held up for the
|
||||
// five hours but freed again in two lost the 68% of its week it could
|
||||
// have used before the reset ran out).
|
||||
// Only when the account is held up now and won't be free again before
|
||||
// then is it spent at once: nothing more can be used by waiting, and
|
||||
// spending it frees the account. It is the reset that runs out first that
|
||||
@@ -27,14 +29,25 @@ import (
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// resetLead is how long before a reset runs out it is spent: the user's
|
||||
// CodexResetLead, half an hour by default — as late as is safe, with room
|
||||
// for a few looks (resetExpiryClose) missed or failed. A value that can't
|
||||
// be read is the default, never none. Both the spend (expiringResetSpent)
|
||||
// and routing (Allowance.Restarts) read it here, so they can't drift
|
||||
// apart (#717, #718). Shared: routing reads it on every request.
|
||||
func resetLead() time.Duration {
|
||||
return settings.Shared().ResetLead()
|
||||
}
|
||||
|
||||
// resetExpiryNear is how long before a reset runs out its account is
|
||||
// looked at every resetExpiryClose, from then until it is spent: the lead
|
||||
// and half an hour more, an hour at least, so several looks fall inside
|
||||
// the lead however long it is.
|
||||
func resetExpiryNear(lead time.Duration) time.Duration {
|
||||
return max(time.Hour, lead+30*time.Minute)
|
||||
}
|
||||
|
||||
var (
|
||||
// resetExpiryLead is how long before a reset runs out it is spent: as
|
||||
// late as is safe, with room for a few looks (resetExpiryClose) missed
|
||||
// or failed
|
||||
resetExpiryLead = 30 * time.Minute
|
||||
// resetExpiryNear is how long before a reset runs out its account is
|
||||
// looked at every resetExpiryClose, from then until it is spent
|
||||
resetExpiryNear = time.Hour
|
||||
// resetExpiryClose is how often an account is looked at near a reset
|
||||
// running out, after one is spent, and after a failed read or spend
|
||||
// then; and how often the accounts are gone over (each is read only
|
||||
@@ -66,7 +79,7 @@ type expiringResets struct {
|
||||
}
|
||||
|
||||
// check spends one of user's resets, if its windows have been used, when
|
||||
// the soonest of them runs out within resetExpiryLead or the account is
|
||||
// the soonest of them runs out within resetLead or the account is
|
||||
// held up past then (expiringResetSpent); look reads its windows and
|
||||
// resets, spend spends the one that runs out first. Code is "" when none
|
||||
// was tried. now is wall-clock time: a Mac asleep doesn't count it on the
|
||||
@@ -131,10 +144,10 @@ func (e *expiringResets) check(user string, now time.Time, look func() ([]QuotaW
|
||||
// nextResetLook is when an account holding a reset that runs out at until
|
||||
// is looked at next: every resetExpiryClose within resetExpiryNear of
|
||||
// that, every resetExpiryWatch before then but never past its start — so
|
||||
// the reset is looked at several times within resetExpiryLead, a look
|
||||
// missed or failed there still spends it in time.
|
||||
// the reset is looked at several times within resetLead, a look missed
|
||||
// or failed there still spends it in time.
|
||||
func nextResetLook(until, now time.Time) time.Time {
|
||||
if near := until.Add(-resetExpiryNear); near.After(now) {
|
||||
if near := until.Add(-resetExpiryNear(resetLead())); near.After(now) {
|
||||
return minTime(now.Add(resetExpiryWatch), near)
|
||||
}
|
||||
return now.Add(resetExpiryClose)
|
||||
@@ -142,7 +155,7 @@ func nextResetLook(until, now time.Time) time.Time {
|
||||
|
||||
// expiringResetSpent is when a reset that runs out at until is spent by
|
||||
// itself (check, when the account's windows have been used by then):
|
||||
// resetExpiryLead before it runs out, or now once that has passed; now
|
||||
// resetLead before it runs out, or now once that has passed; now
|
||||
// too when the account is stopped (a window that stops it used up) and
|
||||
// back, when it is free again (zero: not known), isn't before then — what
|
||||
// the windows have left can't be used before the reset is spent anyway,
|
||||
@@ -153,7 +166,7 @@ func expiringResetSpent(until, now time.Time, stopped bool, back time.Time) time
|
||||
if !until.After(now) {
|
||||
return time.Time{}
|
||||
}
|
||||
at := until.Add(-resetExpiryLead)
|
||||
at := until.Add(-resetLead())
|
||||
if !at.After(now) || stopped && (back.IsZero() || !back.Before(at)) {
|
||||
return now
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// A reset is spent by itself only within resetExpiryLead of running out,
|
||||
// A reset is spent by itself only within resetLead of running out,
|
||||
// and only when the account's windows have something to start again; an
|
||||
// account is read again when there may be something to do, not before.
|
||||
func TestResetSpentBeforeItRunsOut(t *testing.T) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
// An account that spends a Codex reset about to run out by itself has its
|
||||
// windows started again then, resetExpiryLead before the reset runs out:
|
||||
// windows started again then, resetLead before the reset runs out:
|
||||
// Weekly pace goes by the hours until that, when it is sooner than the week
|
||||
// renews, and Smart's renewals do too (#717, #718). A reset that runs out
|
||||
// after the week renews, or has run out, changes nothing.
|
||||
@@ -116,7 +116,7 @@ func TestResetRunsOutForRouting(t *testing.T) {
|
||||
firstWait = 5 * time.Second
|
||||
t.Cleanup(func() { firstWait = oldWait })
|
||||
all := Allowances("codex")
|
||||
if got := all["me@example.com"].Restarts(now); !got.Equal(until.Add(-resetExpiryLead)) {
|
||||
if got := all["me@example.com"].Restarts(now); !got.Equal(until.Add(-resetLead())) {
|
||||
t.Fatalf("allowance read: restarts %v", got)
|
||||
}
|
||||
if got := all["other@example.com"].Restarts(now); !got.IsZero() {
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/settings"
|
||||
)
|
||||
|
||||
// setResetLead saves the user's lead, in minutes, in a sandbox HOME.
|
||||
func setResetLead(t *testing.T, minutes int) {
|
||||
t.Helper()
|
||||
s := settings.Load()
|
||||
s.CodexResetLead = minutes
|
||||
if err := settings.Save(s); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// The spend and routing go by the lead the user set (the owner, 10-30:
|
||||
// 把提前用卡的时间做成可配置的), the same one, so they can't drift apart
|
||||
// (#717, #718): three hours set, a reset running out in four is spent in
|
||||
// one, and routing takes the windows to start again then.
|
||||
func TestResetLeadFollowsSetting(t *testing.T) {
|
||||
signIn(t)
|
||||
now := time.Now().Round(0)
|
||||
until := now.Add(4 * time.Hour)
|
||||
if got := expiringResetSpent(until, now, false, time.Time{}); !got.Equal(until.Add(-30 * time.Minute)) {
|
||||
t.Fatalf("unset: spent at %v, want half an hour before", until.Sub(got))
|
||||
}
|
||||
setResetLead(t, 180)
|
||||
want := until.Add(-3 * time.Hour)
|
||||
if got := expiringResetSpent(until, now, false, time.Time{}); !got.Equal(want) {
|
||||
t.Fatalf("spent %v before it runs out, want 3h", until.Sub(got))
|
||||
}
|
||||
a := Allowance{{Used: 20, Resets: now.Add(120 * time.Hour), Span: 7 * 24 * time.Hour}}.restartedBy(until)
|
||||
if got := a.Restarts(now); !got.Equal(want) {
|
||||
t.Fatalf("routing: restarts %v before it runs out, want 3h", until.Sub(got))
|
||||
}
|
||||
// within the lead already: at once, for both
|
||||
now2 := until.Add(-2 * time.Hour)
|
||||
if got := expiringResetSpent(until, now2, false, time.Time{}); !got.Equal(now2) {
|
||||
t.Fatalf("within the lead: %v", got)
|
||||
}
|
||||
if got := a.Restarts(now2); !got.Equal(now2) {
|
||||
t.Fatalf("routing within the lead: %v", got)
|
||||
}
|
||||
// and the check spends it then, not before
|
||||
e := expiringResets{next: map[string]time.Time{}}
|
||||
used := []QuotaWindow{{Span: 7 * 24 * time.Hour, Used: 40}}
|
||||
if out, _ := e.check("me@example.com", want.Add(-time.Minute), func() ([]QuotaWindow, *ResetCredits, error) {
|
||||
return used, &ResetCredits{Count: 1, Until: &until}, nil
|
||||
}, func() (ResetOutcome, error) { return ResetOutcome{Code: "reset"}, nil }); out.Code != "" {
|
||||
t.Fatalf("spent a minute before the lead: %+v", out)
|
||||
}
|
||||
e.next = map[string]time.Time{}
|
||||
if out, _ := e.check("me@example.com", want, func() ([]QuotaWindow, *ResetCredits, error) {
|
||||
return used, &ResetCredits{Count: 1, Until: &until}, nil
|
||||
}, func() (ResetOutcome, error) { return ResetOutcome{Code: "reset"}, nil }); out.Code != "reset" {
|
||||
t.Fatalf("not spent at the lead: %+v", out)
|
||||
}
|
||||
}
|
||||
|
||||
// A long lead still has several looks inside it: looks tighten to every
|
||||
// resetExpiryClose half an hour before the lead starts, so a spend that
|
||||
// fails when it is due is tried again five minutes later, not half an
|
||||
// hour, and one missed look doesn't push the spend toward the end.
|
||||
func TestResetLeadLooksInsideLongLead(t *testing.T) {
|
||||
signIn(t)
|
||||
setResetLead(t, 6*60)
|
||||
start := time.Date(2026, 10, 30, 0, 0, 0, 0, time.Local)
|
||||
until := start.Add(12 * time.Hour)
|
||||
due := until.Add(-6 * time.Hour)
|
||||
used := []QuotaWindow{{Span: 7 * 24 * time.Hour, Used: 40}}
|
||||
e := expiringResets{next: map[string]time.Time{}}
|
||||
var spent time.Time
|
||||
var looks []time.Time
|
||||
tries := 0
|
||||
for now := start; now.Before(until); now = now.Add(resetExpiryClose) {
|
||||
e.check("me@example.com", now, func() ([]QuotaWindow, *ResetCredits, error) {
|
||||
looks = append(looks, now)
|
||||
if !spent.IsZero() {
|
||||
return used, nil, nil
|
||||
}
|
||||
return used, &ResetCredits{Count: 1, Until: &until}, nil
|
||||
}, func() (ResetOutcome, error) {
|
||||
// the first try fails (ChatGPT not answering)
|
||||
if tries++; tries == 1 {
|
||||
return ResetOutcome{}, http.ErrHandlerTimeout
|
||||
}
|
||||
spent = now
|
||||
return ResetOutcome{Code: "reset"}, nil
|
||||
})
|
||||
}
|
||||
if want := due.Add(resetExpiryClose); !spent.Equal(want) {
|
||||
t.Fatalf("spent %v before it runs out, want %v (looked at %v)", until.Sub(spent), until.Sub(want), looks)
|
||||
}
|
||||
// looked at every five minutes from half an hour before the lead
|
||||
n := 0
|
||||
for _, l := range looks {
|
||||
if !l.Before(due.Add(-30*time.Minute)) && !l.After(due) {
|
||||
n++
|
||||
}
|
||||
}
|
||||
if n != 7 {
|
||||
t.Fatalf("%d looks in the half hour before the lead, want 7: %v", n, looks)
|
||||
}
|
||||
for _, c := range []struct{ lead, near time.Duration }{
|
||||
{15 * time.Minute, time.Hour},
|
||||
{30 * time.Minute, time.Hour},
|
||||
{2 * time.Hour, 150 * time.Minute},
|
||||
{24 * time.Hour, 24*time.Hour + 30*time.Minute},
|
||||
} {
|
||||
if got := resetExpiryNear(c.lead); got != c.near {
|
||||
t.Errorf("lead %v: near %v, want %v", c.lead, got, c.near)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A lead out of range, written by hand, or a settings file that can't be
|
||||
// read, is the default half hour: never none, which would spend a reset
|
||||
// only as it runs out.
|
||||
func TestResetLeadUnreadIsDefault(t *testing.T) {
|
||||
signIn(t)
|
||||
for _, m := range []int{-5, 1, 14, 24*60 + 1, 1 << 30} {
|
||||
setResetLead(t, m)
|
||||
if got := resetLead(); got != 30*time.Minute {
|
||||
t.Errorf("%d minutes: lead %v", m, got)
|
||||
}
|
||||
}
|
||||
setResetLead(t, 15)
|
||||
if got := resetLead(); got != 15*time.Minute {
|
||||
t.Fatalf("15 minutes: lead %v", got)
|
||||
}
|
||||
if err := os.WriteFile(settings.Path(), []byte(`{"codexResetLead": 15,`), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := resetLead(); got != 30*time.Minute && got != 15*time.Minute {
|
||||
// a half-written file is read as the last good one or the default
|
||||
t.Fatalf("unreadable: lead %v", got)
|
||||
}
|
||||
if err := os.WriteFile(settings.Path(), []byte(`{"codexResetLead": "an hour"}`), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := resetLead(); got != 30*time.Minute && got != 15*time.Minute {
|
||||
t.Fatalf("not a number: lead %v", got)
|
||||
}
|
||||
}
|
||||
@@ -258,7 +258,7 @@ func (a Allowance) WeekUsedUp(now time.Time) bool {
|
||||
|
||||
// Restarts is when an auto-used reset starts the account's windows again,
|
||||
// as the Codex reset about to run out is spent (expiringResetSpent):
|
||||
// resetExpiryLead before it runs out, or now when the account is held up
|
||||
// resetLead before it runs out, or now when the account is held up
|
||||
// past then. What they have left then is lost, as at their own reset, so
|
||||
// Weekly pace and Smart take it for their renewal when it comes sooner
|
||||
// (#717, #718). Zero when none will be.
|
||||
|
||||
@@ -275,7 +275,7 @@ type Settings struct {
|
||||
// of their rate-limit resets by themselves once their weekly window is
|
||||
// used up and no other account can take the request: at most one a
|
||||
// week each (see provider.AutoUseCodexReset); and one about to run out
|
||||
// unused half an hour before it does, or at once when the account is
|
||||
// unused CodexResetLead before it does, or at once when the account is
|
||||
// held up past then (provider.SpendExpiringCodexResets).
|
||||
CodexAutoReset []string `json:"codexAutoReset,omitempty"`
|
||||
// CodexAutoResetOnly narrows an account in CodexAutoReset to one of
|
||||
@@ -285,6 +285,15 @@ type Settings struct {
|
||||
// about to run out only. An account not in it uses one at both, as
|
||||
// every account did before the two were split.
|
||||
CodexAutoResetOnly map[string]string `json:"codexAutoResetOnly,omitempty"`
|
||||
// CodexResetLead is how many minutes before a reset about to run out
|
||||
// unused an account with CodexAutoReset's "expiring" spends it (the
|
||||
// owner, 10-30: 把提前用卡的时间做成可配置的): from CodexResetLeadLeast
|
||||
// to CodexResetLeadMost, 0 for CodexResetLeadDefault. Earlier loses
|
||||
// what the windows have left then (#718), so the default is late.
|
||||
// One for every account: whether an account spends one is its own
|
||||
// say, how early is the same trade for each. Read through
|
||||
// ResetLead, which takes a value out of range for the default.
|
||||
CodexResetLead int `json:"codexResetLead,omitempty"`
|
||||
// CodexNoCredits are the ChatGPT accounts (lower-case) that don't
|
||||
// spend their credits: once a usage window is used up, routing holds
|
||||
// the account as used up and goes on to the user's other accounts,
|
||||
@@ -1026,6 +1035,28 @@ func (s Settings) ImageWait() time.Duration {
|
||||
return time.Duration(min(m, ImageTimeoutMost)) * time.Minute
|
||||
}
|
||||
|
||||
// CodexResetLeadDefault is CodexResetLead's minutes when it is unset, and
|
||||
// CodexResetLeadLeast and CodexResetLeadMost the range it can be set in;
|
||||
// CodexResetLeads the choices the app and the CLI's words offer.
|
||||
const (
|
||||
CodexResetLeadDefault = 30
|
||||
CodexResetLeadLeast = 15
|
||||
CodexResetLeadMost = 24 * 60
|
||||
)
|
||||
|
||||
var CodexResetLeads = []int{15, 30, 60, 120, 180, 360, 720, 1440}
|
||||
|
||||
// ResetLead is how long before a Codex reset about to run out unused it
|
||||
// is spent by itself: CodexResetLead's minutes, CodexResetLeadDefault's
|
||||
// when it is 0 or out of range (written by hand), never none.
|
||||
func (s Settings) ResetLead() time.Duration {
|
||||
m := s.CodexResetLead
|
||||
if m < CodexResetLeadLeast || m > CodexResetLeadMost {
|
||||
m = CodexResetLeadDefault
|
||||
}
|
||||
return time.Duration(m) * time.Minute
|
||||
}
|
||||
|
||||
// ClassifyTimeoutDefault is the seconds a classifier is given when
|
||||
// ClassifyTimeout is 0, and ClassifyTimeoutMost the most it can be set to:
|
||||
// the turn waits on it before it goes anywhere, with nothing sent to its
|
||||
|
||||
Reference in New Issue
Block a user