diff --git a/docs/subsystems/provider-plugins.md b/docs/subsystems/provider-plugins.md index 083e990ef..7d03d0098 100644 --- a/docs/subsystems/provider-plugins.md +++ b/docs/subsystems/provider-plugins.md @@ -58,7 +58,7 @@ A plugin can press its vendor's daily check-in (签到) itself: its `auth` hook The hook returns `{outcome, credit?, streak?, message?, until?}`. `outcome` is one of `claimed` (checked in now), `done` (already in today), `ineligible`, `inactive` (no check-in event now), `captcha` or `failed`. A throw, or an outcome not in that list, is `failed` with the reason; for an outcome not in the list the reason names what the plugin answered, before its own message (`the plugin answered "yes": …`), so a plugin's wording isn't read as magpie's. `captcha` means the vendor wants a captcha: magpie never solves one, and says "check in in its own app" instead. A plugin must not solve captchas either. An `inactive` or `ineligible` result with a `message` shows it beside the fixed label ("No check-in event now · ") on the card, where it wraps rather than ends in "…", in Settings' check-in line and in `magpie accounts checkin`; the TUI's narrow cell says `c` says why, and `c`'s flash carries it (plugins#304). Without a message the label reads alone. -[`plugin_checkin.go`](../../internal/provider/plugin_checkin.go) runs these through the same `checkiner` as the built-in check-ins ([`checkin.go`](../../internal/provider/checkin.go)): each signed-in, in-use account once a Beijing day, the first look 2 minutes after start and then every 30 minutes, a `failed` asked again after 30 minutes, or at its `until` when that is later (`heldUntil`: a rate-limited claim read, plugins#793), at most 24 hours on and across the Beijing day's turn, a press still asking at once, every other outcome settled for the day. A `done`, `inactive` or `ineligible` answered before noon Beijing (`checkinSureHour`) for an account magpie hasn't seen claim that Beijing day is provisional (`provisional`, #3326): a vendor whose day turns at UTC midnight (08:00 Beijing) or later still answers yesterday's "already" at 00:00, and magpie took it for today's and never asked again. The loop asks it again 30 minutes after the answer, until a claim or an answer from noon on, so at most 24 more asks a day and none once magpie claims; a press (`soon`) asks it again at once, whatever the hour, since the vendor's answer is what the press is for. A claim stamps `Claimed`, carried over while later answers that day say done, so a done after magpie's own claim is settled. Such a record is sent with `again: true` (`shown`, never kept), and the card, Settings, TUI and CLI say the vendor said already checked in and magpie asks again later, not "Checked in today", and the card keeps *Check in now*. A vendor whose day turns after noon Beijing (a US day) is not covered. The Qoder, Qoder CN and ZCode plugins are the exception, as magpie's own Qoder check-in is (`recheck`, `pluginRechecks`, #2696, plugins#503): a campaign or gift plan can open mid-day (Qoder CN's ran 10:00 to 09:59 the next day), so the loop asks again 30 minutes after the last answer, whatever it was but a `captcha` or `own-app`, which waits on the user in the vendor's app and stands for the day (asked again, ZCode's claim only answered 3007 again, plugins#503), and *Check in now* asks at once, and their card keeps *Check in now* for an `inactive` result. Every other plugin keeps the day's result. A plugin whose vendor's day turns at another hour says when in `until` (an RFC 3339 time or epoch milliseconds; `host.js` passes it on as RFC 3339, `plugin.Checkin.Until`), kept as the record's `ValidUntil`: the answer is settled only until then, whatever its outcome (`settled`), the loop wakes then rather than at its next 30-minute look (`wbCheckinLoop.tick`), and an early `done` that says it isn't provisional, since the vendor said when its day turns. Qoder's daily credits open at 10:00 UTC+8 and close at 09:59 the next day (its `/me/campaigns` `startAt`/`endAt`); the Qoder plugins from 0.2.43 answer `until` a minute past the next opening, so a check-in before 10:00, which claims or meets the day before's campaign, is asked again at 10:01, not up to half an hour later (sdytman on Discord). Times are compared as instants, so the machine's zone doesn't matter. Results are kept in `plugin-checkin.json` by `provider|` (`pluginCheckinKey`: the key `plugin-auth.json` keeps the sign-in under, `autoclaw` or `autoclaw#x1y2z3`), never by the display name: two sign-ins can share a name (AutoClaw's default can't be changed), and keyed by it only the first of them was ever checked in, by the loop or *Check in now* (plugins#254). The sign-in key holds over a refresh and over signing in to the same account again (`settle` in `host.js` puts it back under its key); a sign-in made after one was signed out the same day may take the freed key, and with it that day's result. An entry kept by `provider|` before then is carried over once the plugin's accounts are listed (`adoptLegacyPluginCheckins`): a check-in goes to the first sign-in in use of that name, the one the old key asked, and only to it, so its namesakes are asked and none twice; an `Off` in `settings.CheckinOff` goes to every sign-in of that name, since none of them was checked in while it was off. A `plugin-checkin.json` that can't be read or parsed is left as it is and carried over once it reads; until then no plugin account is checked in, and each says why (`readCheckins`, as for every vendor's check-in file). A failure is recorded as failed and never resets an account, a key or a previous day's result. Each account's Usage card has the check-in row (`checkinBy: "plugin:"`), and Settings → Usage has a Plugins tab with a Daily check-in switch per provider (`settings.PluginCheckins`, `POST /api/settings/plugin-checkin {provider, on}`; *Check in now* is `POST /api/usage/plugin-checkin {provider}`). The press says what it came to, a count per kind (`checkinPressSaid`, #3326): claimed now with the credits, already checked in today, not available yet (`inactive`, `ineligible`, or an `again` answer), to check in in the vendor's own app, failed; a result is claimed now only when it carries `asked` (`Asked`, sent but never kept), so an account claimed earlier today counts as already. `magpie accounts checkin` and `c` on the TUI's Usage page include them. Every check-in, built-in or a plugin's, also skips an account listed in `settings.CheckinOff` by its file key (#1902): `checkinNow` asks nothing for it, by the loop or a press, `CheckinAccounts()` lists each account with its own `on` for Settings (`checkinAccounts`, a row each under the vendor's switch when it has two or more, `POST /api/settings/checkin-account {key, on}`), and its card carries `checkinOff`. Under each vendor's switch in Settings, a *Check in now* row checks one account in once (`checkinNowRow`, drawn by [`checkinnow.js`](../../internal/gui/assets/checkinnow.js), loaded when Settings draws a vendor's check-in so it weighs nothing on the core; `POST /api/usage/checkin-account {by, key}`, `provider.CheckInAccount`; xiaowu_95660 on Discord): the same `checkinNow` press, with `only` set to that account's key, so no other account is asked or reported, and the account is asked even while its switch is off, which the press leaves as it is. With two or more accounts the button opens the app menu to pick one. The row says what came of it: checked in with the credit and streak, already checked in today, not eligible or no check-in event with the vendor's message, check in in the vendor's own app, or the failure. It reads the Usage cards again but doesn't draw Settings again under the button. +[`plugin_checkin.go`](../../internal/provider/plugin_checkin.go) runs these through the same `checkiner` as the built-in check-ins ([`checkin.go`](../../internal/provider/checkin.go)): each signed-in, in-use account once a Beijing day, the first look 2 minutes after start and then every 30 minutes, the day's first ask from the time of day the user set (`settings.CheckinAt`, one for every vendor, built-in and plugin; the first such time on the computer's clock at or after the Beijing day's start, `checkinGate`, so every Beijing day holds one; none set asks as the day turns, as before; times_ang on X) while an answer for that day, its `until` and its retries go on as below, a `failed` asked again after 30 minutes, or at its `until` when that is later (`heldUntil`: a rate-limited claim read, plugins#793), at most 24 hours on and across the Beijing day's turn, a press still asking at once, every other outcome settled for the day. A `done`, `inactive` or `ineligible` answered before noon Beijing (`checkinSureHour`) for an account magpie hasn't seen claim that Beijing day is provisional (`provisional`, #3326): a vendor whose day turns at UTC midnight (08:00 Beijing) or later still answers yesterday's "already" at 00:00, and magpie took it for today's and never asked again. The loop asks it again 30 minutes after the answer, until a claim or an answer from noon on, so at most 24 more asks a day and none once magpie claims; a press (`soon`) asks it again at once, whatever the hour, since the vendor's answer is what the press is for. A claim stamps `Claimed`, carried over while later answers that day say done, so a done after magpie's own claim is settled. Such a record is sent with `again: true` (`shown`, never kept), and the card, Settings, TUI and CLI say the vendor said already checked in and magpie asks again later, not "Checked in today", and the card keeps *Check in now*. A vendor whose day turns after noon Beijing (a US day) is not covered. The Qoder, Qoder CN and ZCode plugins are the exception, as magpie's own Qoder check-in is (`recheck`, `pluginRechecks`, #2696, plugins#503): a campaign or gift plan can open mid-day (Qoder CN's ran 10:00 to 09:59 the next day), so the loop asks again 30 minutes after the last answer, whatever it was but a `captcha` or `own-app`, which waits on the user in the vendor's app and stands for the day (asked again, ZCode's claim only answered 3007 again, plugins#503), and *Check in now* asks at once, and their card keeps *Check in now* for an `inactive` result. Every other plugin keeps the day's result. A plugin whose vendor's day turns at another hour says when in `until` (an RFC 3339 time or epoch milliseconds; `host.js` passes it on as RFC 3339, `plugin.Checkin.Until`), kept as the record's `ValidUntil`: the answer is settled only until then, whatever its outcome (`settled`), the loop wakes then rather than at its next 30-minute look (`wbCheckinLoop.tick`), and an early `done` that says it isn't provisional, since the vendor said when its day turns. Qoder's daily credits open at 10:00 UTC+8 and close at 09:59 the next day (its `/me/campaigns` `startAt`/`endAt`); the Qoder plugins from 0.2.43 answer `until` a minute past the next opening, so a check-in before 10:00, which claims or meets the day before's campaign, is asked again at 10:01, not up to half an hour later (sdytman on Discord). Times are compared as instants, so the machine's zone doesn't matter. Results are kept in `plugin-checkin.json` by `provider|` (`pluginCheckinKey`: the key `plugin-auth.json` keeps the sign-in under, `autoclaw` or `autoclaw#x1y2z3`), never by the display name: two sign-ins can share a name (AutoClaw's default can't be changed), and keyed by it only the first of them was ever checked in, by the loop or *Check in now* (plugins#254). The sign-in key holds over a refresh and over signing in to the same account again (`settle` in `host.js` puts it back under its key); a sign-in made after one was signed out the same day may take the freed key, and with it that day's result. An entry kept by `provider|` before then is carried over once the plugin's accounts are listed (`adoptLegacyPluginCheckins`): a check-in goes to the first sign-in in use of that name, the one the old key asked, and only to it, so its namesakes are asked and none twice; an `Off` in `settings.CheckinOff` goes to every sign-in of that name, since none of them was checked in while it was off. A `plugin-checkin.json` that can't be read or parsed is left as it is and carried over once it reads; until then no plugin account is checked in, and each says why (`readCheckins`, as for every vendor's check-in file). A failure is recorded as failed and never resets an account, a key or a previous day's result. Each account's Usage card has the check-in row (`checkinBy: "plugin:"`), and Settings → Usage has a Plugins tab with a Daily check-in switch per provider (`settings.PluginCheckins`, `POST /api/settings/plugin-checkin {provider, on}`; *Check in now* is `POST /api/usage/plugin-checkin {provider}`). The press says what it came to, a count per kind (`checkinPressSaid`, #3326): claimed now with the credits, already checked in today, not available yet (`inactive`, `ineligible`, or an `again` answer), to check in in the vendor's own app, failed; a result is claimed now only when it carries `asked` (`Asked`, sent but never kept), so an account claimed earlier today counts as already. `magpie accounts checkin` and `c` on the TUI's Usage page include them. Every check-in, built-in or a plugin's, also skips an account listed in `settings.CheckinOff` by its file key (#1902): `checkinNow` asks nothing for it, by the loop or a press, `CheckinAccounts()` lists each account with its own `on` for Settings (`checkinAccounts`, a row each under the vendor's switch when it has two or more, `POST /api/settings/checkin-account {key, on}`), and its card carries `checkinOff`. Under each vendor's switch in Settings, a *Check in now* row checks one account in once (`checkinNowRow`, drawn by [`checkinnow.js`](../../internal/gui/assets/checkinnow.js), loaded when Settings draws a vendor's check-in so it weighs nothing on the core; `POST /api/usage/checkin-account {by, key}`, `provider.CheckInAccount`; xiaowu_95660 on Discord): the same `checkinNow` press, with `only` set to that account's key, so no other account is asked or reported, and the account is asked even while its switch is off, which the press leaves as it is. With two or more accounts the button opens the app menu to pick one. The row says what came of it: checked in with the credit and streak, already checked in today, not eligible or no check-in event with the vendor's message, check in in the vendor's own app, or the failure. It reads the Usage cards again but doesn't draw Settings again under the button. The switch is off by default. For a provider whose vendor magpie checked in through the plugin's fetch before (WorkBuddy, Trae CN, MiniMax Code, Qoder), it follows that vendor's existing switch until set on its own, and magpie's own check-in leaves that provider's accounts to the plugin (`pluginChecksIn`), so an account is never checked in twice. diff --git a/internal/cli/settings_cli_test.go b/internal/cli/settings_cli_test.go index 053e99a7d..4480e32ea 100644 --- a/internal/cli/settings_cli_test.go +++ b/internal/cli/settings_cli_test.go @@ -55,6 +55,9 @@ func TestSettingsSetGetReset(t *testing.T) { {"redactWords", `["a","b"]`, "a,b"}, {"redactWords", "", "[]"}, {"codexWarmup", "off", `""`}, + // the check-in's time of day (times_ang on X), as 09:00 + {"checkinAt", "9:30", "09:30"}, + {"checkinAt", "", `""`}, {"refusalRetries", "2", "2"}, {"otel", `{"enabled":true,"endpoint":"http://127.0.0.1:4318"}`, ""}, } { @@ -92,6 +95,7 @@ func TestSettingsRefusesAndWritesNothing(t *testing.T) { {"settings", "set", "usageAlert", "lots"}, {"settings", "set", "usageAlert", "200"}, // the save's own range {"settings", "set", "trayUsageEvery", "4"}, + {"settings", "set", "checkinAt", "25:00"}, {"settings", "set", "vision", "nobody/nothing"}, {"settings", "set", "otel", `{"bogus":1}`}, {"settings", "set", "theme", "--help-me"}, diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index 990c1d30e..1eae5305c 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -18233,7 +18233,9 @@ function checkinRow(q, first, subs) { text = [t("Auto check-in is off for this account"), last].filter(Boolean).join(" · "); } else { kind = on ? "wait" : ""; - text = [t(on ? "Not checked in yet today" : "Auto check-in is off"), last].filter(Boolean).join(" · "); + // and when it will be, with a time of day set (times_ang on X) + const at = on && state.settings?.checkinAt ? t("checks in from {at}", { at: state.settings.checkinAt }) : ""; + text = [t(on ? "Not checked in yet today" : "Auto check-in is off"), at, last].filter(Boolean).join(" · "); } row.dataset.state = kind || "none"; const say = el("span", "ci-say"); @@ -20051,8 +20053,8 @@ function renderSettings() { $(`#${id}CheckinSegs`).replaceChildren(segs([["off", t("Off")], ["on", t("On")]], s[on] ? "on" : "off", (v) => savePrefs({ ...keep, [on]: v === "on" }))); sub.textContent = [say, ...ciLines(s[on + "s"])].filter(Boolean).join(" · "); sub.title = as; - list.querySelectorAll(".ci-acct, .ci-now-row").forEach((x) => x.remove()); - list.append(...checkinAccountRows(s, id === "wb" ? "" : id), ...checkinNowRow(s, id === "wb" ? "" : id)); + list.querySelectorAll(".ci-acct, .ci-now-row, .ci-at-row").forEach((x) => x.remove()); + list.append(...checkinAtRow(s, s[on]), ...checkinAccountRows(s, id === "wb" ? "" : id), ...checkinNowRow(s, id === "wb" ? "" : id)); } // and the plugins that check in themselves, a group each renderPluginCheckins(s); @@ -22580,7 +22582,7 @@ function renderPluginCheckins(s) { const g = el("div", "list prefs ci-plugin"); g.dataset.provider = p.id; g.dataset.feature = "warmups"; - g.append(row, ...checkinAccountRows(s, "plugin:" + p.id), ...checkinNowRow(s, "plugin:" + p.id)); + g.append(row, ...checkinAtRow(s, p.on), ...checkinAccountRows(s, "plugin:" + p.id), ...checkinNowRow(s, "plugin:" + p.id)); return g; })); // the replaced groups stay gone @@ -22588,6 +22590,15 @@ function renderPluginCheckins(s) { remountProvPrefs(); } +// the time of day every daily check-in asks from (times_ang on X), drawn by checkinnow.js +function checkinAtRow(s, on) { + if (!on) return []; + const row = el("div", "row pref ci-at-row"); + if (window.ciAtFill) ciAtFill(row, s); + else { row.hidden = true; import("./checkinnow.js").then(() => ciAtFill(row, s), () => {}); } + return [row]; +} + // one account's Check in now (xiaowu_95660), drawn by checkinnow.js function checkinNowRow(s, by) { if (!(s.checkinAccounts || []).some((a) => (a.by || "") === by)) return []; @@ -22672,7 +22683,7 @@ function prefsKeep(s) { trayUsages: s.trayUsages || [], redact: !!s.redact, redactPersonal: !!s.redactPersonal, redactKinds: s.redactKinds || {}, redactWords: s.redactWords || [], redactWordsAnyCase: !!s.redactWordsAnyCase, redactWordsWhole: !!s.redactWordsWhole, redactShape: !!s.redactShape, codexWarmup: s.codexWarmup || "", claudeWarmup: s.claudeWarmup || "", codexWarmAt: s.codexWarmAt || "", claudeWarmAt: s.claudeWarmAt || "", - codexWarmAts: warmTimes(s.codexWarmAts, s.codexWarmAt), claudeWarmAts: warmTimes(s.claudeWarmAts, s.claudeWarmAt), workbuddyCheckin: !!s.workbuddyCheckin, traeCheckin: !!s.traeCheckin, minimaxCheckin: !!s.minimaxCheckin, qoderCheckin: !!s.qoderCheckin, noStats: !!s.noStats, noUsageStats: !!s.noUsageStats, signInLinkOnly: !!s.signInLinkOnly, + codexWarmAts: warmTimes(s.codexWarmAts, s.codexWarmAt), claudeWarmAts: warmTimes(s.claudeWarmAts, s.claudeWarmAt), workbuddyCheckin: !!s.workbuddyCheckin, traeCheckin: !!s.traeCheckin, minimaxCheckin: !!s.minimaxCheckin, qoderCheckin: !!s.qoderCheckin, checkinAt: s.checkinAt || "", noStats: !!s.noStats, noUsageStats: !!s.noUsageStats, signInLinkOnly: !!s.signInLinkOnly, replyModel: s.replyModel || "", noLoopGuard: !!s.noLoopGuard, claudeLeanPrompt: !!s.claudeLeanPrompt, claudePrintMode: !!s.claudePrintMode, refusalRetries: s.refusalRetries ?? null, retryAfterCap: s.retryAfterCap ?? null, noUpdatePill: !!s.noUpdatePill, noAutoUpdate: !!s.noAutoUpdate, updateEvery: s.updateEvery || 360, autoRestart: !!s.autoRestart, noAutoDownload: !!s.noAutoDownload, updateChannel: s.updateChannel || "", trayUsage: s.trayUsage || "", trayUsageEvery: s.trayUsageEvery || 3, trayNoLogos: !!s.trayNoLogos, trayNoBird: !!s.trayNoBird, trayNoNumber: !!s.trayNoNumber, trayPace: !!s.trayPace, trayNoCost: !!s.trayNoCost, trayWindows: s.trayWindows || {}, vision: s.vision || "", visionEffort: s.visionEffort || "", searcherEffort: s.searcherEffort || "", imageGen: s.imageGen || "", videoGen: s.videoGen || "", imageTimeout: s.imageTimeout || 0, classifyTimeout: s.classifyTimeout || 0, searcher: s.searcher || "", searchFirst: s.searchFirst || "", currency: s.currency || "usd", diff --git a/internal/gui/assets/checkinnow.js b/internal/gui/assets/checkinnow.js index 1f6a6d058..05c91d9ea 100644 --- a/internal/gui/assets/checkinnow.js +++ b/internal/gui/assets/checkinnow.js @@ -109,3 +109,30 @@ function checkinNowLine(r, who) { return { bad: true, text: t("Couldn't check in {who}: {why}", { who, why: r?.msg || t("Check-in failed") }) }; } } + +// ciAtFill draws the check-in's time of day into row (checkinAt; times_ang +// on X): Off asks as each vendor's day starts, On at 09:00 or the time typed. +window.ciAtFill = function (row, s) { + const at = s.checkinAt || ""; + const save = (v) => savePrefs({ ...prefsKeep(s), checkinAt: v }); + const who = el("div", "who"); + const sub = el("div", "sub", at ? t("From {at} each day, for every vendor's check-in", { at }) : t("As soon as each vendor's day starts")); + sub.title = t("A computer asleep then checks in when it wakes."); + who.append(el("div", "name", t("Check-in time")), sub); + const box = el("div", "warm-at" + (at ? " times" : "")); + if (at) { + const i = input(at, "09:00", "time"); + i.className = "at"; + i.setAttribute("aria-label", t("Time of day")); + blurOnEnter(i); + i.onchange = () => { if (i.value && i.value !== at) save(i.value); }; + const one = el("span", "warm-time"); + one.append(i); + const list = el("span", "warm-times"); + list.append(one); + box.append(list); + } + box.append(segs([["off", t("Off")], ["on", t("On")]], at ? "on" : "off", (v) => save(v === "on" ? at || "09:00" : ""))); + row.hidden = false; + row.append(who, box); +}; diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index 385ef6139..f355a6653 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -4,6 +4,11 @@ // works. {name} slots are filled by t(str, vars). const I18N = { zh: { + "Check-in time": "签到时间", + "From {at} each day, for every vendor's check-in": "每天 {at} 起签到,所有服务商的签到都按这个时间", + "As soon as each vendor's day starts": "每个服务商的新一天一开始就签到", + "A computer asleep then checks in when it wakes.": "到点时电脑在睡眠的话,醒来后再签到。", + "checks in from {at}": "{at} 起签到", "Archived": "已归档", "Everywhere": "所有地方", "Preference": "偏好", @@ -4841,6 +4846,11 @@ const I18N = { "This report is no longer kept: magpie keeps the last 5.": "这份报告已经不在了:magpie 只保留最近 5 份。", }, "zh-TW": { + "Check-in time": "簽到時間", + "From {at} each day, for every vendor's check-in": "每天 {at} 起簽到,所有服務商的簽到都按這個時間", + "As soon as each vendor's day starts": "每個服務商的新一天一開始就簽到", + "A computer asleep then checks in when it wakes.": "到點時電腦在睡眠的話,醒來後再簽到。", + "checks in from {at}": "{at} 起簽到", "Archived": "已封存", "Everywhere": "所有地方", "Preference": "偏好", @@ -9663,6 +9673,11 @@ const I18N = { "This report is no longer kept: magpie keeps the last 5.": "這份報告已經不在了:magpie 只保留最近 5 份。", }, ja: { + "Check-in time": "チェックインの時刻", + "From {at} each day, for every vendor's check-in": "毎日 {at} からチェックイン(すべてのサービスのチェックインに共通)", + "As soon as each vendor's day starts": "各サービスの日付が変わったらすぐにチェックイン", + "A computer asleep then checks in when it wakes.": "その時刻にスリープ中なら、復帰後にチェックインします。", + "checks in from {at}": "{at} からチェックイン", "Archived": "アーカイブ済み", "Everywhere": "どこでも", "Preference": "好み", @@ -14487,6 +14502,11 @@ const I18N = { "This report is no longer kept: magpie keeps the last 5.": "このレポートはもう残っていません。magpie は最新の 5 件だけを保存します。", }, de: { + "Check-in time": "Check-in-Zeit", + "From {at} each day, for every vendor's check-in": "Täglich ab {at}, für den Check-in jedes Anbieters", + "As soon as each vendor's day starts": "Sobald der Tag des jeweiligen Anbieters beginnt", + "A computer asleep then checks in when it wakes.": "Schläft der Computer dann, wird beim Aufwachen eingecheckt.", + "checks in from {at}": "Check-in ab {at}", "Archived": "Archiviert", "Everywhere": "Überall", "Preference": "Vorliebe", diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.go index 5fc39423a..0909fd18b 100644 --- a/internal/gui/core_budget_test.go +++ b/internal/gui/core_budget_test.go @@ -16,7 +16,7 @@ import ( // raises them and says why in its commit. const ( appScriptBudget = 1_316_874 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added; 1,337,735 with the provider editor's link naming a partner's page by its own host (siteHost) instead of usemagpie.ai's /go link, the core's own editor, with no room added (10-23); 1,338,084 with Check in now saying what the press came to (claimed +credits, already today, not available yet) where it said "refreshed" (#3326), the check-in row the tray panel draws too, the core's own, with no room added (10-23); 1,338,929 with a new partner's tile keeping a small dot until it is opened, in the add sheet, the core's own, with no room added (10-23); 1,343,324 with the sidebar's open-page row marked by one shape that moves on a spring (navTopGo), the window's own shell, which every page sits beside, with no room added (10-23); 1,343,465 with a dialog kept centred while its content comes in, until it is pressed (holdModal, every page's dialogs), the core's own, with no room added (10-24); 1,317,486 with what masking did moved out to Insights › Masking (plugins/redact), the budget lowered to it (10-24); 1,321,336 with Codex's one subagent model, its card's square saying plainly what each choice does and a row with a name in its sheet, where two squares read alike (the owner), the Agents page's, which the tray panel draws too, the core's own, with no room added (10-24); 1,321,424 with Settings › Models' Image generation MCP server row beside Image recognition's (JonahFu on X), the two drawn by one helper (mcpRow), Settings' own, with no room added (10-25); 1,321,994 with a provider of the user's set never to rest for a limit (zoecats), the provider editor's Advanced row, the core's own editor, with no room added (10-25); 1,322,289 with Settings › Privacy's Keep a key's form under Mask secrets (Charles Cao on X), Settings' own row, with no room added (10-25); 1,322,537 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,323,401 with the tray panel drawing its last allowances at once and asking for them beside the state (#3160, #3134), the tray panel's, the core's own, and the 4 bytes 84c50f032 added, with no room added (10-25); 1,326,105 with many releases' notes merged into one list by kind, each line with its version (the owner), in the update sheet and What's new, with no room added (10-25); 1,321,319 with Settings › Observability moved out to its plugin (plugins/otel/page.js) and its Langfuse setup there (an X user), the budget lowered to it (10-26); a quota card whose window is used but names no reset no longer saying "Not used yet" (windy on Discord) raised it to 1,321,347, and back to 1,321,319 with Settings' model pickers sharing one row helper (modelOpt) where six kept their own copy, no raise (10-26); 1,325,845 with every slow page's skeletons getting magpie's bird hopping bar to bar (skelBird, the owner after the Plugins page's README), one bird for the window over whatever page or dialog is loading, the core's own, with no room added (10-26); 1,310,129 with Settings › Network and sharing's gateway rows (its port, bare ids, local network, allowed addresses, web pages) moved out to the gateway plugin (plugins/gateway/settings.js), the budget lowered to it (10-27); 1,310,269 with Test models naming the first model that failed and its error in the status line, where it said only how many (ysm119 on Discord), the provider editor's, the core's own, with no room added (10-27); 1,310,460 with Settings › About's Website row linking usemagpie.ai (the owner), Settings' own row, with no room added (10-27); 1,309,669 with a pool's Stop at the caps and Check usage near a cap ticks under a provider's accounts (plugins#349), the core's own editor, its account rows' Remove and add rows each drawn by one helper (forgetOf, addRow), with no room added (10-28); 1,311,681 with Install another agent on the Agents page naming the agents Plugins has (More in Plugins) and opening Plugins at its Agents (the owner), the Agents page's, the core's own, with no room added (10-28); 1,311,735 with More in Plugins in sight while Install another agent is folded (the owner), with no room added (10-29); 1,313,704 with a window whose WebKit scrolls under wheels it never tells of (macOS 13) remembered once seen, a scroll at rest then waiting 120ms for a second the same way within 80ms before it is put back, kept for a late wheel to give back (waitsBack), and a load landing under the wheel keeping the reader's way (backAfterLoad, issennknight), the window's own scroll guard, with no room added (10-29); back to 1,311,735 with Settings › Models › Web search's rows (renderSearch, renderSearcher, the search APIs' keys) moved out to the search plugin (plugins/search/settings.js), app.js 1,292,527 after it, not lowered further since what is left plus 1.5% is over it (#4133, 10-29); 1,315,316 with the Agents row of a Claude Code or Codex not connected saying the account it is signed in to and switching it to another (Switch accounts only, the owner on X), in place of the failover line's ChatGPT accounts button, the Agents page's, the core's own, its comments cut down, with no room added (10-30); 1,317,705 with a Claude account added from a setup-token (sfss5362 on X): the sign-in's Use a setup-token instead…, its sheet, and its account row's magpie only, the provider editor's account rows, the core's own editor, its comments cut down, with no room added (10-30); back to 1,315,316 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, loaded when one is asked for (signAsk, 10-30); 1,315,479 with the provider editor lining its Advanced up with its fields (the owner: 高级这个折叠按钮为什么在一个前不着村后不着店的位置?) and a refresh on each of its accounts (在这里也要加上手动刷新用量的按钮), the core's own editor, with no room added (10-31); 1,315,603 with About's Log row, the path of the log the app writes and an Open for its folder (rayem1w on X), in app.js, its comment cut to one line, with no room added (10-31); 1,316,781 with a provider's model listed by an id of the user's (zeewell on X), the provider editor's Names & levels Listed as box beside Same as, the core's own editor, with no room added (10-31); 1,316,874 with a package manager's magpie (the AUR's magpie-bin) naming the command that updates it in Settings' Version row and lighting no Update pill (shuhai on Discord), the core's own update row, which the tray panel reads too, its comments cut to one line, with no room added (10-31); Settings › Sync's Kept on this computer row (hayden4608 on Discord) raised it to 1,317,497, which is no bound; the 1,316,874 it had came back once later trims left app.js at 1,308,363 (10-31) - coreScriptBudget = 1_533_802 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25); 1,534,312 with the tray panel's last allowances drawn at once (#3160, #3134), with no room added (10-25); 1,537,016 with many releases' notes merged into one list by kind (the owner), in app.js, with no room added (10-25); 1,542,244 with a plugin's README loading under magpie's bird bouncing down its lines instead of pulsing bars (the owner), the Plugins page's, in plugins.js, with no room added (10-26); 1,542,418 with a page plugin's sidebar tab coming and going as it is installed, switched on or off, or removed, instead of on the Plugins page's next load (the owner), in plugins.js, with no room added (10-26); 1,537,645 with Settings › Observability moved out to plugins/otel, lowered to it (10-26); 1,537,673 with a used window with no reset not "Not used yet" (windy on Discord), and back to 1,537,645 with Settings' model pickers sharing modelOpt (10-26); 1,541,967 with every slow page's skeletons getting magpie's bird (skelBird, the owner), in app.js, the README's bird sharing its drawing and styles, with no room added (10-26); 1,526,251 with Settings' gateway rows moved out to plugins/gateway/settings.js, lowered to it (10-27); 1,526,391 with Test models naming the first failed model and its error (ysm119 on Discord), in app.js, with no room added (10-27); 1,526,556 with About's Website row (the owner), in app.js, with no room added (10-27); 1,526,500 with a pool's cap ticks (plugins#349), in app.js, with no room added (10-28); 1,527,245 with About's Open-source licenses row and dialog (the owner), in app.js, with no room added (10-28); 1,528,076 with the Partners heading's light (the owner), in app.js, with no room added (10-28); 1,530,449 with Install another agent's More in Plugins row (the owner), in app.js, and Plugins opening at its Agents, in plugins.js, with no room added (10-28); 1,530,807 with layout.js measuring the scrollbar into --bar, which every page's right padding takes off so its sides match (the owner), the window's own shell, with no room added (10-28); 1,530,861 with More in Plugins in sight while Install another agent is folded (the owner), in app.js, with no room added (10-29); 1,532,830 with waitsBack and backAfterLoad (issennknight, macOS 13), the window's own scroll guard, in app.js, with no room added (10-29); the context map's tile wording (a4e929212) and Cindy's Add magpie (628ac36fc) had taken the core over it, and Web search's rows moved out to plugins/search/settings.js brought it back to 1,530,861 (#4133, 10-29); 1,532,459 with a provider editor's account rows on one line each, First or Make first at its right end and the settings that aren't set under ⋯ (the owner), the core's own editor, in app.js, which stays in its budget with its comments cut down, with no room added (10-29); 1,532,602 with a plugin's README waiting for its bird to land on three lines before it goes in, however soon it came (the owner, 10-30), in plugins.js, with no room added; 1,536,357 with Switch accounts only on the Agents row (the owner on X), in app.js, with no room added (10-30); 1,537,034 with a plugin's README read once shown at once, with no bird, when its page opens again and read again behind it, the last 20 kept (the owner), in plugins.js, with no room added (10-30); 1,539,423 with a Claude account added from a setup-token (sfss5362 on X), in app.js, with no room added (10-30); 1,538,975 with purposes.js written as compact JSON by genpurposes and the MCP tool purpose in it, 448 bytes less in all (ferock on Discord), lowered to it (10-30); 1,536,586 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, lowered by the 2,389 the setup-token raised it (10-30); 1,536,631 with the 45 bytes b62fa332f added to app.js (Send requests unmasked for subscriptions and plugin providers too) without a raise, with no room added (10-31); 1,537,356 with Settings › Models › Replies › Claude Code's interactive mode, a row beside Short Claude system prompt (the owner), in app.js, with no room added (10-31); Long conversations in Codex's row naming the config.toml keys Codex reads before it, with Take it out, and the window magpie tells Codex for the model it runs (zgjfjfl on Discord) raised it to 1,537,669, and it is back under 1,537,356 with the key list and the window's size written by the server (codexKeysText, tokensSize) and the row's words cut, no raise (10-31); 1,538,554 with the same two, with no room added (10-31); 1,538,678 with About's Log row (rayem1w on X), with no room added (10-31); 1,539,856 with a model's Listed as id (zeewell on X), in app.js, with no room added (10-31); Tuned for you's Codex row offering the advice to background compaction (herman_hong on Discord) and a package manager's magpie naming its command (shuhai on Discord) took it to 1,541,798, and the release notes' dialogs (What's new, the update's ask) moved out to whatsnew.js, loaded when one opens, brought it back under 1,539,856, no raise (10-31); 1,540,479 for Settings › Sync's Kept on this computer row (hayden4608 on Discord) was taken back to 1,539,856 once the core weighed 1,533,355, no raise (10-31); 1,532,958 with the context window card's head naming the agent and the model's lab (the owner), in context.js, after the card's part text viewer moved out to ctxtext.js (7,005 bytes), lowered to it (10-31); 1,533,105 with the provider editor's Claude Code runs as row moved above the accounts, its pill and hover card in claudemode.js, and Settings found at the row that draws anew (the owner), in app.js and i18n.js, with no room added (11-01); a Codex account's credits spent only after every other account, key and fallback (gokoshiki on Discord) fit in it with the Codex options' comments in app.js cut down, no raise (11-01); a plugin option's words in the window's language and the filtered-models note (plugins#590, anewuser6937 on Discord) fit in it with three of the provider editor's comments in app.js cut down, no raise (11-01); 1,533,802 with a closed Mac window telling its page it is out of sight (#4293, pipi-1997), in app.js, which every page needs, its comments cut to one line, with no room added (11-01); Warm up on a Codex or Claude account's Usage card (01huadalang on Discord), in plugins/usage/page.js, its one call in app.js paid for by two comments cut, no raise (11-01); Settings' Check in now for one account (xiaowu_95660), its row and press in checkinnow.js, loaded when Settings draws a check-in, its one call in app.js paid for by three check-in comments cut, no raise (11-02); a ChatGPT account's plan end under its row on Providers (danzi002 on Discord), its line in app.js paid for by two account-row comments cut, no raise (11-02); Scroll to top and Scroll to bottom (#1090, emo172), in scrollends.js, imported on the window's first scroll, its one line in app.js paid for by two comments cut, no raise (11-02); a new-api relay's User ID beside the balance token (zxc56823), in app.js, paid for by four comments cut, no raise (11-03); Air's opened rows saying whether Air's own Codex and Claude Agent go through magpie (jumy_18634 on Discord), in app.js, paid for by six Agents-page comments cut, no raise (11-03); a key's spend cap on its row (sparkling_lemur_62868 on Discord), its pill and held line in keyspend.js, loaded when the provider editor draws a key, its one call in app.js, no raise (11-03); Claude Code's status line square beside ultracode (steven_4422 on Discord), in app.js, paid for by foldSame's comment cut, no raise (11-03); Codex's Restart the app when magpie switches its account tick (atom0964 on Discord), in app.js, paid for by five account-row comments cut, no raise (11-03); over it at 1,534,154 (#5139), 1,533,125 at e928b57f0, 677 bytes under it, and 1,525,207 with Settings › Sync's server form (davForm: WebDAV, S3 and GitHub) moved out to syncfiles.js, loaded when it opens, not lowered since what is left plus 1.5% is over it (11-04); a Mac window's page letting go of its layers after 30s out of sight (#5530, Matrix on Discord), in app.js, paid for by four comments cut, no raise (11-06); a plugin's tools hidden from every agent from its Plugins row (chengming0v0 on Discord), in plugins.js, paid for by two comments cut, no raise (11-07); a key's balance typed by hand (tenacious_eagle on Discord), its pill in keybalance.js, loaded by keyspend.js when the provider editor draws a key of a provider that takes one, nothing in app.js, no raise (11-08); a key's provider's model list off (axelburks on Discord), its tick in app.js, paid for by four Models-section comments cut, no raise (11-08); a model's own headers in Model settings (axelburks on Discord), the core's own editor, paid for by sixteen of its comments cut, no raise (11-08); a model asked on System One (axelburks on Discord), in app.js, paid for by three of the editor's comments cut, no raise (11-08); a typed balance's part that expires (tenacious_eagle_96548 on Discord), its days on the Usage page and the panel in app.js (expiresIn), paid for by five balance comments cut, no raise (11-08); a model's context window and max output in its Model settings row (sayagoodbyeplz on Discord), the row's boxes in modellimits.js, loaded when the provider editor draws a model, its one call in app.js paid for by nine comments cut, no raise (11-08); Make first under Smart saying the order only settles ties (CryptoSarom on X, 4436b7d98, 1,080 bytes in app.js) took it to 1,534,166 (#5720), and About's Open-source licenses dialog moved out to notices.js and Sync's Restore and Upload asks to syncfiles.js, each loaded when it opens, brought it back to 1,530,548, no raise (11-09); a subscription's warm-ups, check-ins and resets moved from Settings into its provider's editor (the owner, 11-07), in app.js, paid for by comments cut, no raise (11-09); Settings › Models › Images' Video generation (a custom provider's video model, Discord #feedback), its row in videogen.js, loaded when Settings draws Image generation, its one call in app.js, no raise (11-09); a window's cap at an amount of its unit (9won_25273 on Discord, 40cbdaa7e) took it to 1,535,556 (#5795), and the account-cap rows' comments cut brought it back to 1,533,547, no raise (11-09); Claude Desktop's Claude Magpie switch (#5671, baranwang on X), in app.js, one switch helper shared with the largest-window one and four comments cut, no raise (11-09); a plugin's page sharing a picture it drew (the day card, JungleyYeh on X), its copy and save in pageshare.js, loaded the first time a page shares one, its one call in pluginpages.js paid for by two of its comments cut, no raise (11-09); the quick panel wording unpriced calls as the Usage page does (tenacious_eagle on Discord), in app.js, paid for by four of the panel's comments cut, no raise (11-10); the Codex reset note naming its ChatGPT projects and chats (b3a57b3d8), paid for by appBackSaid's comment cut, no raise (11-10) + coreScriptBudget = 1_533_802 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it; 1,528,525 with Codex's one subagent model, with no room added (10-24); 1,528,972 with the Image generation MCP server row (JonahFu on X), with no room added (10-25); 1,529,542 with the limit-rest row (zoecats), with no room added (10-25); 1,529,837 with Keep a key's form (Charles Cao on X), with no room added (10-25); 1,530,050 with no Codex squares beside its named settings rows (the owner), with no room added (10-25); 1,530,631 with a plugin's page growing to its README on the dialog's spring instead of in one jump (the owner), the Plugins page's, in plugins.js, with no room added (10-25); 1,533,445 with the context map counting its tokens on as a live request grows, a tile pointed at keeping its tip, a tool's gathered results saying how many and the small files their folder (the owner, after flohoeller's map on X), in context.js, which the Routing page draws as well as Usage, and the 4 bytes 84c50f032 added to app.js (Settings' Version row) without a raise, with no room added (10-25); 1,534,312 with the tray panel's last allowances drawn at once (#3160, #3134), with no room added (10-25); 1,537,016 with many releases' notes merged into one list by kind (the owner), in app.js, with no room added (10-25); 1,542,244 with a plugin's README loading under magpie's bird bouncing down its lines instead of pulsing bars (the owner), the Plugins page's, in plugins.js, with no room added (10-26); 1,542,418 with a page plugin's sidebar tab coming and going as it is installed, switched on or off, or removed, instead of on the Plugins page's next load (the owner), in plugins.js, with no room added (10-26); 1,537,645 with Settings › Observability moved out to plugins/otel, lowered to it (10-26); 1,537,673 with a used window with no reset not "Not used yet" (windy on Discord), and back to 1,537,645 with Settings' model pickers sharing modelOpt (10-26); 1,541,967 with every slow page's skeletons getting magpie's bird (skelBird, the owner), in app.js, the README's bird sharing its drawing and styles, with no room added (10-26); 1,526,251 with Settings' gateway rows moved out to plugins/gateway/settings.js, lowered to it (10-27); 1,526,391 with Test models naming the first failed model and its error (ysm119 on Discord), in app.js, with no room added (10-27); 1,526,556 with About's Website row (the owner), in app.js, with no room added (10-27); 1,526,500 with a pool's cap ticks (plugins#349), in app.js, with no room added (10-28); 1,527,245 with About's Open-source licenses row and dialog (the owner), in app.js, with no room added (10-28); 1,528,076 with the Partners heading's light (the owner), in app.js, with no room added (10-28); 1,530,449 with Install another agent's More in Plugins row (the owner), in app.js, and Plugins opening at its Agents, in plugins.js, with no room added (10-28); 1,530,807 with layout.js measuring the scrollbar into --bar, which every page's right padding takes off so its sides match (the owner), the window's own shell, with no room added (10-28); 1,530,861 with More in Plugins in sight while Install another agent is folded (the owner), in app.js, with no room added (10-29); 1,532,830 with waitsBack and backAfterLoad (issennknight, macOS 13), the window's own scroll guard, in app.js, with no room added (10-29); the context map's tile wording (a4e929212) and Cindy's Add magpie (628ac36fc) had taken the core over it, and Web search's rows moved out to plugins/search/settings.js brought it back to 1,530,861 (#4133, 10-29); 1,532,459 with a provider editor's account rows on one line each, First or Make first at its right end and the settings that aren't set under ⋯ (the owner), the core's own editor, in app.js, which stays in its budget with its comments cut down, with no room added (10-29); 1,532,602 with a plugin's README waiting for its bird to land on three lines before it goes in, however soon it came (the owner, 10-30), in plugins.js, with no room added; 1,536,357 with Switch accounts only on the Agents row (the owner on X), in app.js, with no room added (10-30); 1,537,034 with a plugin's README read once shown at once, with no bird, when its page opens again and read again behind it, the last 20 kept (the owner), in plugins.js, with no room added (10-30); 1,539,423 with a Claude account added from a setup-token (sfss5362 on X), in app.js, with no room added (10-30); 1,538,975 with purposes.js written as compact JSON by genpurposes and the MCP tool purpose in it, 448 bytes less in all (ferock on Discord), lowered to it (10-30); 1,536,586 with the setup-token sheet and Copilot's GHE.com one moved out to signsheets.js, lowered by the 2,389 the setup-token raised it (10-30); 1,536,631 with the 45 bytes b62fa332f added to app.js (Send requests unmasked for subscriptions and plugin providers too) without a raise, with no room added (10-31); 1,537,356 with Settings › Models › Replies › Claude Code's interactive mode, a row beside Short Claude system prompt (the owner), in app.js, with no room added (10-31); Long conversations in Codex's row naming the config.toml keys Codex reads before it, with Take it out, and the window magpie tells Codex for the model it runs (zgjfjfl on Discord) raised it to 1,537,669, and it is back under 1,537,356 with the key list and the window's size written by the server (codexKeysText, tokensSize) and the row's words cut, no raise (10-31); 1,538,554 with the same two, with no room added (10-31); 1,538,678 with About's Log row (rayem1w on X), with no room added (10-31); 1,539,856 with a model's Listed as id (zeewell on X), in app.js, with no room added (10-31); Tuned for you's Codex row offering the advice to background compaction (herman_hong on Discord) and a package manager's magpie naming its command (shuhai on Discord) took it to 1,541,798, and the release notes' dialogs (What's new, the update's ask) moved out to whatsnew.js, loaded when one opens, brought it back under 1,539,856, no raise (10-31); 1,540,479 for Settings › Sync's Kept on this computer row (hayden4608 on Discord) was taken back to 1,539,856 once the core weighed 1,533,355, no raise (10-31); 1,532,958 with the context window card's head naming the agent and the model's lab (the owner), in context.js, after the card's part text viewer moved out to ctxtext.js (7,005 bytes), lowered to it (10-31); 1,533,105 with the provider editor's Claude Code runs as row moved above the accounts, its pill and hover card in claudemode.js, and Settings found at the row that draws anew (the owner), in app.js and i18n.js, with no room added (11-01); a Codex account's credits spent only after every other account, key and fallback (gokoshiki on Discord) fit in it with the Codex options' comments in app.js cut down, no raise (11-01); a plugin option's words in the window's language and the filtered-models note (plugins#590, anewuser6937 on Discord) fit in it with three of the provider editor's comments in app.js cut down, no raise (11-01); 1,533,802 with a closed Mac window telling its page it is out of sight (#4293, pipi-1997), in app.js, which every page needs, its comments cut to one line, with no room added (11-01); Warm up on a Codex or Claude account's Usage card (01huadalang on Discord), in plugins/usage/page.js, its one call in app.js paid for by two comments cut, no raise (11-01); Settings' Check in now for one account (xiaowu_95660), its row and press in checkinnow.js, loaded when Settings draws a check-in, its one call in app.js paid for by three check-in comments cut, no raise (11-02); a ChatGPT account's plan end under its row on Providers (danzi002 on Discord), its line in app.js paid for by two account-row comments cut, no raise (11-02); Scroll to top and Scroll to bottom (#1090, emo172), in scrollends.js, imported on the window's first scroll, its one line in app.js paid for by two comments cut, no raise (11-02); a new-api relay's User ID beside the balance token (zxc56823), in app.js, paid for by four comments cut, no raise (11-03); Air's opened rows saying whether Air's own Codex and Claude Agent go through magpie (jumy_18634 on Discord), in app.js, paid for by six Agents-page comments cut, no raise (11-03); a key's spend cap on its row (sparkling_lemur_62868 on Discord), its pill and held line in keyspend.js, loaded when the provider editor draws a key, its one call in app.js, no raise (11-03); Claude Code's status line square beside ultracode (steven_4422 on Discord), in app.js, paid for by foldSame's comment cut, no raise (11-03); Codex's Restart the app when magpie switches its account tick (atom0964 on Discord), in app.js, paid for by five account-row comments cut, no raise (11-03); over it at 1,534,154 (#5139), 1,533,125 at e928b57f0, 677 bytes under it, and 1,525,207 with Settings › Sync's server form (davForm: WebDAV, S3 and GitHub) moved out to syncfiles.js, loaded when it opens, not lowered since what is left plus 1.5% is over it (11-04); a Mac window's page letting go of its layers after 30s out of sight (#5530, Matrix on Discord), in app.js, paid for by four comments cut, no raise (11-06); a plugin's tools hidden from every agent from its Plugins row (chengming0v0 on Discord), in plugins.js, paid for by two comments cut, no raise (11-07); a key's balance typed by hand (tenacious_eagle on Discord), its pill in keybalance.js, loaded by keyspend.js when the provider editor draws a key of a provider that takes one, nothing in app.js, no raise (11-08); a key's provider's model list off (axelburks on Discord), its tick in app.js, paid for by four Models-section comments cut, no raise (11-08); a model's own headers in Model settings (axelburks on Discord), the core's own editor, paid for by sixteen of its comments cut, no raise (11-08); a model asked on System One (axelburks on Discord), in app.js, paid for by three of the editor's comments cut, no raise (11-08); a typed balance's part that expires (tenacious_eagle_96548 on Discord), its days on the Usage page and the panel in app.js (expiresIn), paid for by five balance comments cut, no raise (11-08); a model's context window and max output in its Model settings row (sayagoodbyeplz on Discord), the row's boxes in modellimits.js, loaded when the provider editor draws a model, its one call in app.js paid for by nine comments cut, no raise (11-08); Make first under Smart saying the order only settles ties (CryptoSarom on X, 4436b7d98, 1,080 bytes in app.js) took it to 1,534,166 (#5720), and About's Open-source licenses dialog moved out to notices.js and Sync's Restore and Upload asks to syncfiles.js, each loaded when it opens, brought it back to 1,530,548, no raise (11-09); a subscription's warm-ups, check-ins and resets moved from Settings into its provider's editor (the owner, 11-07), in app.js, paid for by comments cut, no raise (11-09); Settings › Models › Images' Video generation (a custom provider's video model, Discord #feedback), its row in videogen.js, loaded when Settings draws Image generation, its one call in app.js, no raise (11-09); a window's cap at an amount of its unit (9won_25273 on Discord, 40cbdaa7e) took it to 1,535,556 (#5795), and the account-cap rows' comments cut brought it back to 1,533,547, no raise (11-09); Claude Desktop's Claude Magpie switch (#5671, baranwang on X), in app.js, one switch helper shared with the largest-window one and four comments cut, no raise (11-09); a plugin's page sharing a picture it drew (the day card, JungleyYeh on X), its copy and save in pageshare.js, loaded the first time a page shares one, its one call in pluginpages.js paid for by two of its comments cut, no raise (11-09); the quick panel wording unpriced calls as the Usage page does (tenacious_eagle on Discord), in app.js, paid for by four of the panel's comments cut, no raise (11-10); the Codex reset note naming its ChatGPT projects and chats (b3a57b3d8), paid for by appBackSaid's comment cut, no raise (11-10); the daily check-in's time of day (times_ang on X), its row in checkinnow.js, its one call in app.js, no raise (11-10) ) func TestCoreScriptBudget(t *testing.T) { diff --git a/internal/gui/tests/checkin-at.test.cjs b/internal/gui/tests/checkin-at.test.cjs new file mode 100644 index 000000000..74220bd35 --- /dev/null +++ b/internal/gui/tests/checkin-at.test.cjs @@ -0,0 +1,133 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// times_ang on X: "magpie 可以调整自动签到的时间吗". Under a daily check-in +// that is on, a Check-in time row: Off (as each vendor's day starts) or +// On at 09:00, a time typed then saved as settings.checkinAt through +// POST /api/settings, and Off again saves ""; a plugin's check-in group +// has the same row, a check-in turned off none. An account not checked in +// yet says the time on its Usage card. Chromium and WebKit, the window at +// 1100 and 420, in English, Chinese, Traditional Chinese, Japanese and +// German; 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, provPrefsProviders, openProvPrefs, inEditor } = require("./reader.cjs"); + +const assets = path.resolve(__dirname, "../assets"); +const yesterday = new Date(Date.now() + 8 * 3600e3 - 86400e3).toISOString().slice(0, 10); + +function serve(lang, saved, at) { + const settings = { theme: "light", lang, quotaLeft: false, currency: "usd", workbuddy: true, workbuddyCheckin: true, checkinAt: at, + trae: true, traeCheckin: false, + checkinPlugins: [{ id: "autoclaw", name: "AutoClaw", on: true, checkins: [] }], + checkinAccounts: [{ key: "workbuddy|u1", by: "", user: "Ann", on: true }] }; + const quotas = () => [ + { provider: "workbuddy", name: "WorkBuddy", plan: "Pro", user: "Ann", windows: [{ name: "Credits", used: 12 }], checkins: true, + checkin: { user: "Ann", day: yesterday, outcome: "claimed", credit: 50 } }, + ]; + return async (route) => { + const url = new URL(route.request().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:true};` }); + 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 }); + if (url.pathname === "/api/settings") { + if (route.request().method() === "POST") { + const b = route.request().postDataJSON(); + saved.push(b.checkinAt); + settings.checkinAt = b.checkinAt; + } + return json(settings); + } + if (url.pathname === "/api/providers") return json(provPrefsProviders(["workbuddy", "autoclaw"], { workbuddy: "WorkBuddy", autoclaw: "AutoClaw" })); + if (url.pathname === "/api/usage/quotas") return json(quotas()); + if (url.pathname === "/api/groups") return json({ groups: [], models: [] }); + if (url.pathname === "/api/plugins") return json({ plugins: [] }); + 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)]; + try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); } + }; +} + +const words = { + en: { name: "Check-in time", off: "As soon as each vendor's day starts", on: "From 21:30 each day, for every vendor's check-in", card: "Not checked in yet today · checks in from 21:30" }, + zh: { name: "签到时间", off: "每个服务商的新一天一开始就签到", on: "每天 21:30 起签到,所有服务商的签到都按这个时间", card: "今日尚未签到 · 21:30 起签到" }, + "zh-TW": { name: "簽到時間", off: "每個服務商的新一天一開始就簽到", on: "每天 21:30 起簽到,所有服務商的簽到都按這個時間", card: "今日尚未簽到 · 21:30 起簽到" }, + ja: { name: "チェックインの時刻", off: "各サービスの日付が変わったらすぐにチェックイン", on: "毎日 21:30 からチェックイン(すべてのサービスのチェックインに共通)", card: "今日はまだチェックインしていません · 21:30 からチェックイン" }, + de: { name: "Check-in-Zeit", off: "Sobald der Tag des jeweiligen Anbieters beginnt", on: "Täglich ab 21:30, für den Check-in jedes Anbieters", card: "Heute noch nicht eingecheckt · Check-in ab 21:30" }, +}; + +function launch(engine) { + return engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }); +} + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + for (const width of [1100, 420]) { + for (const lang of Object.keys(words)) { + const w = words[lang]; + test(`${engine} ${width} ${lang}: the check-in's time of day is set under Daily check-in`, async (t) => { + const browser = await launch(engine); + t.after(() => browser.close()); + const page = await (await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" })).newPage(); + page.setDefaultTimeout(5000); + page.setDefaultNavigationTimeout(60000); + const errors = [], saved = []; + page.on("pageerror", (e) => { if (engine === "webkit" && /due to access control checks/.test(e.message)) return; errors.push(e.message); }); + await page.route("**/*", serve(lang, saved, "")); + await watchSettingsReads(page); + await openProvPrefs(page, "workbuddy"); + await settingsDrawn(page); + const row = page.locator(".editor .prov-prefs #wbList .ci-at-row"); + await row.waitFor(); + assert.equal((await row.locator(".name").innerText()).trim(), w.name); + assert.equal((await row.locator(".sub").innerText()).trim(), w.off); + assert.equal(await row.locator("input.at").count(), 0, "no time while Off"); + assert.equal(await page.locator("#traeList .ci-at-row").count(), 0, "a check-in turned off has none"); + assert.equal(await page.locator('.ci-plugin[data-provider="autoclaw"] .ci-at-row').count(), 1, "a plugin's check-in has one"); + + const on = row.locator(".segs .opt").nth(1); + await inEditor(page, on); + await on.click(); + await page.waitForFunction(() => document.querySelector(".editor #wbList .ci-at-row input.at")?.value === "09:00"); + assert.deepEqual(saved, ["09:00"]); + const time = page.locator(".editor #wbList .ci-at-row input.at"); + await time.fill("21:30"); + await time.press("Enter"); + await page.waitForFunction((want) => document.querySelector(".editor #wbList .ci-at-row .sub")?.textContent.trim() === want, w.on); + assert.deepEqual(saved, ["09:00", "21:30"]); + for (const box of [await page.locator(".editor #wbList .ci-at-row").boundingBox(), await time.boundingBox()]) { + assert(box.width > 0 && box.x + box.width <= width, "the row fits"); + } + assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, "no sideways scroll"); + if (process.env.ARTIFACT_DIR) await page.locator(".editor #wbList").screenshot({ path: path.join(process.env.ARTIFACT_DIR, `checkin-at-${engine}-${width}-${lang}.png`) }); + + await page.locator(".editor #wbList .ci-at-row .segs .opt").nth(0).click(); + await page.waitForFunction((want) => document.querySelector(".editor #wbList .ci-at-row .sub")?.textContent.trim() === want, w.off); + assert.deepEqual(saved, ["09:00", "21:30", ""]); + assert.equal(await page.locator("select").count(), 0); + assert.deepEqual(errors, []); + }); + + test(`${engine} ${width} ${lang}: a card not checked in yet says the time`, async (t) => { + const browser = await launch(engine); + t.after(() => browser.close()); + const page = await (await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" })).newPage(); + page.setDefaultTimeout(5000); + page.setDefaultNavigationTimeout(60000); + const errors = []; + page.on("pageerror", (e) => { if (engine === "webkit" && /due to access control checks/.test(e.message)) return; errors.push(e.message); }); + await page.route("**/*", serve(lang, [], "21:30")); + await watchSettingsReads(page); + await page.goto("http://magpie.test/?view=usage"); + await settingsDrawn(page); + const say = page.locator(".subscription-card", { hasText: "WorkBuddy" }).locator(".wb-checkin .ci-say"); + await say.first().waitFor(); + assert.equal((await say.first().innerText()).trim().split(" · ").slice(0, 2).join(" · "), w.card); + assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, "no sideways scroll"); + assert.deepEqual(errors, []); + }); + } + } +} diff --git a/internal/provider/checkin.go b/internal/provider/checkin.go index 8133311c4..774f484df 100644 --- a/internal/provider/checkin.go +++ b/internal/provider/checkin.go @@ -6,6 +6,8 @@ package provider // rechecked every 30 minutes but for a captcha or own-app answer, which // waits on the user, and an answer that may be the vendor's day before // (provisional, #3326), asked again every 30 minutes until a claim or an answer from noon on. +// The loop asks for a day from the time of day the user set on +// (settings.CheckinAt, checkinGate), else as the day turns. // A press asks the vendor again for a done, inactive or ineligible one. // What came of it is kept in the vendor's file by its key for reuse // (see workbuddy_checkin.go for when a failure is tried again). @@ -82,6 +84,7 @@ func (c checkiner) checkinNow(ctx context.Context, soon bool) []WorkBuddyCheckin // and an account the user left out is not asked at all, by the loop // or a press (#1902) off := checkinOff() + gate := checkinGate(now) for _, a := range c.accounts() { if !a.On || a.key == "" || asked[a.key] || !c.reaches(a.key, off) { continue @@ -93,6 +96,15 @@ func (c checkiner) checkinNow(ctx context.Context, soon bool) []WorkBuddyCheckin } asked[a.key] = true prev, seen := st[a.key] + // the loop asks for a day not yet asked from the user's time of + // day on (checkinGate); a press asks at once + if !soon && (!seen || prev.Day != day) && now.Before(gate) { + if seen { + prev.User, prev.By = a.User, c.by + out = append(out, prev.shown()) + } + continue + } settled := prev.settled(day, now, soon) // a press asks the vendor again for a done, inactive or // ineligible magpie saw no claim for: answered from the record, @@ -157,6 +169,30 @@ func (c checkiner) checkinNow(ctx context.Context, soon bool) []WorkBuddyCheckin return out } +// checkinGate is when the loop first asks for the Beijing day now is on: +// the first time of day settings.CheckinAt names, on now's clock (the +// computer's zone), at or after the day's start; the start when none is +// set (as before: as the day turns). Every Beijing day holds one, so a +// time set never skips one; on a day a clock change leaves without it, +// the start. +func checkinGate(now time.Time) time.Time { + t := now.In(beijing) + start := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, beijing) + h, m, ok := settings.Clock(settings.Load().CheckinAt) + if !ok { + return start + } + l := start.In(now.Location()) + at := time.Date(l.Year(), l.Month(), l.Day(), h, m, 0, 0, l.Location()) + if at.Before(start) { + at = time.Date(l.Year(), l.Month(), l.Day()+1, h, m, 0, 0, l.Location()) + } + if !at.Before(start.AddDate(0, 0, 1)) { + return start + } + return at +} + // unread is how the accounts checkinNow would look at stand while its file // can't be read (err, logged by readCheckins): each failed with err, at // now, so the loop tries again after wbCheckinRetry and a press says why; diff --git a/internal/provider/checkin_at_test.go b/internal/provider/checkin_at_test.go new file mode 100644 index 000000000..13c3afbff --- /dev/null +++ b/internal/provider/checkin_at_test.go @@ -0,0 +1,194 @@ +package provider + +import ( + "context" + "slices" + "testing" + "time" + + "github.com/yetone/magpie/internal/settings" +) + +// checkinAtSet saves at as the check-in's time of day. +func checkinAtSet(t *testing.T, at string) { + t.Helper() + s := settings.Load() + s.CheckinAt = at + if err := settings.Save(s); err != nil { + t.Fatal(err) + } +} + +// pluginCheckinClaims is a plugin provider whose one account's check-in +// claims at each ask, with until (none when nil) after it, counting asks. +func pluginCheckinClaims(id string, until func(time.Time) time.Time, now *time.Time, calls *int) pluginCheckinProvider { + return pluginCheckinProvider{ID: id, accounts: []pluginCheckinAcct{{User: "ann", On: true, key: id + "|ann", card: id, do: func(context.Context) WorkBuddyCheckin { + *calls++ + r := WorkBuddyCheckin{Outcome: CheckinClaimed, Credit: 1} + if until != nil { + r.ValidUntil = until(*now) + } + return r + }}}} +} + +// loopAsks runs the daily loop a minute at a time for days from start and +// says when it asked, as the held clock read then. +func loopAsks(t *testing.T, c checkiner, now *time.Time, start time.Time, days int) []time.Time { + t.Helper() + var l wbCheckinLoop + var asked []time.Time + for m := time.Duration(0); m < time.Duration(days)*24*time.Hour; m += time.Minute { + *now = start.Add(m) + for _, r := range l.tick(context.Background(), c) { + if r.Asked { + asked = append(asked, *now) + } + } + } + return asked +} + +// times_ang on X: 可以调整自动签到的时间吗. With a time of day set, the +// loop asks for each Beijing day at that time on the computer's clock, +// once, every day, in a zone ahead of Beijing's day and one behind it; a +// press asks before it; none set asks as the Beijing day turns. +func TestCheckinAtTimeOfDay(t *testing.T) { + for _, tc := range []struct { + name string + zone *time.Location + at string + want string // the Beijing time of each ask + // catchUp: the first look asks, its Beijing day's time gone by + catchUp bool + }{ + {"Beijing at 09:00", time.FixedZone("UTC+8", 8*3600), "09:00", "09:00", false}, + // 23:30 New York (winter) is 12:30 the next Beijing day; at 03:00 + // New York, Beijing's 11-05 is past its 23:30 (11-04 New York) + {"New York at 23:30", time.FixedZone("UTC-5", -5*3600), "23:30", "12:30", true}, + {"New York unset", time.FixedZone("UTC-5", -5*3600), "", "00:00", true}, + } { + t.Run(tc.name, func(t *testing.T) { + claudeHome(t) + checkinAtSet(t, tc.at) + // 03:00 local on 11-05, the loop's first look + start := time.Date(2026, 11, 5, 3, 0, 0, 0, tc.zone) + now, calls := start, 0 + c := pluginCheckinClaims("fakeco", nil, &now, &calls).checkiner(func() time.Time { return now }) + asked := loopAsks(t, c, &now, start, 4) + if len(asked) == 0 || asked[0].Equal(start) != tc.catchUp { + t.Fatalf("asked at %v; at the first look, want %v", asked, tc.catchUp) + } + days := map[string]bool{} + for i, a := range asked { + if i == 0 && tc.catchUp { + days[wbCheckinDay(a)] = true + continue + } + if got := a.In(beijing).Format("15:04"); got != tc.want { + t.Fatalf("asked at %s (Beijing %s), want Beijing %s; all: %v", a.Format(time.RFC3339), got, tc.want, asked) + } + if tc.at != "" && a.Format("15:04") != tc.at { + t.Fatalf("asked at %s on the computer's clock, want %s", a.Format("15:04"), tc.at) + } + day := wbCheckinDay(a) + if days[day] { + t.Fatalf("asked twice on Beijing %s: %v", day, asked) + } + days[day] = true + } + // every Beijing day from the first ask's to the last's + first, last := asked[0].In(beijing), asked[len(asked)-1].In(beijing) + for d := first; !d.After(last); d = d.AddDate(0, 0, 1) { + if !days[wbCheckinDay(d)] { + t.Fatalf("Beijing %s skipped: %v", wbCheckinDay(d), asked) + } + } + if len(days) < 3 { + t.Fatalf("asked on %d days in 4: %v", len(days), asked) + } + }) + } + + t.Run("a press before it", func(t *testing.T) { + claudeHome(t) + checkinAtSet(t, "21:00") + now := time.Date(2026, 11, 5, 8, 0, 0, 0, beijing) + calls := 0 + c := pluginCheckinClaims("fakeco", nil, &now, &calls).checkiner(func() time.Time { return now }) + if rs := c.checkinNow(context.Background(), false); len(rs) != 0 || calls != 0 { + t.Fatalf("the loop at 08:00 asked for 21:00: %+v", rs) + } + if rs := c.checkinNow(context.Background(), true); len(rs) != 1 || !rs[0].Asked || calls != 1 { + t.Fatalf("a press at 08:00 didn't ask: %+v", rs) + } + // asked today, the loop leaves the claim be at 21:00 + now = now.Add(13 * time.Hour) + if c.checkinNow(context.Background(), false); calls != 1 { + t.Fatalf("asked again after a press's claim") + } + }) +} + +// A vendor whose day turns at 10:00 Beijing (a plugin's until, Qoder's) +// gets one ask in each of its days with the time set at 20:00: its turn +// falls before the time, and the claim at 20:00 is that day's. +func TestCheckinAtKeepsVendorDays(t *testing.T) { + claudeHome(t) + checkinAtSet(t, "20:00") + tenNext := func(at time.Time) time.Time { + b := at.In(beijing) + u := time.Date(b.Year(), b.Month(), b.Day(), 10, 0, 0, 0, beijing) + if !u.After(at) { + u = u.AddDate(0, 0, 1) + } + return u + } + start := time.Date(2026, 11, 5, 3, 0, 0, 0, beijing) + now, calls := start, 0 + c := pluginCheckinClaims("fakeco", tenNext, &now, &calls).checkiner(func() time.Time { return now }) + asked := loopAsks(t, c, &now, start, 4) + var want []time.Time + for d := range 4 { + want = append(want, time.Date(2026, 11, 5+d, 20, 0, 0, 0, beijing)) + } + if !slices.EqualFunc(asked, want, time.Time.Equal) { + t.Fatalf("asked at %v, want %v", asked, want) + } + // each vendor day [10:00, 10:00) holds one + for i := 1; i < len(asked); i++ { + if asked[i].Sub(asked[i-1]) != 24*time.Hour { + t.Fatalf("asks %v apart", asked[i].Sub(asked[i-1])) + } + } +} + +// checkinGate is the time on the Beijing day, wherever the computer's +// clock is, and the day's start when none is set or a bad one is. +func TestCheckinGate(t *testing.T) { + claudeHome(t) + ny := time.FixedZone("UTC-5", -5*3600) + now := time.Date(2026, 11, 5, 1, 0, 0, 0, beijing) // 12:00 11-04 in New York + for _, tc := range []struct { + at string + now time.Time + want time.Time + }{ + {"", now, time.Date(2026, 11, 5, 0, 0, 0, 0, beijing)}, + {"07:30", now, time.Date(2026, 11, 5, 7, 30, 0, 0, beijing)}, + {"7:30", now, time.Date(2026, 11, 5, 7, 30, 0, 0, beijing)}, + // the Beijing day 11-05 runs 11:00 11-04 to 11:00 11-05 in New York + {"10:59", now.In(ny), time.Date(2026, 11, 5, 10, 59, 0, 0, ny)}, + {"11:00", now.In(ny), time.Date(2026, 11, 4, 11, 0, 0, 0, ny)}, + } { + checkinAtSet(t, tc.at) + if got := checkinGate(tc.now); !got.Equal(tc.want) { + t.Errorf("%q at %v: %v, want %v", tc.at, tc.now, got, tc.want) + } + } + s := settings.Load() + s.CheckinAt = "25:00" + if err := settings.Save(s); err == nil { + t.Fatal("saved 25:00") + } +} diff --git a/internal/provider/workbuddy_checkin.go b/internal/provider/workbuddy_checkin.go index db1c86fc3..7f944dea2 100644 --- a/internal/provider/workbuddy_checkin.go +++ b/internal/provider/workbuddy_checkin.go @@ -665,6 +665,10 @@ func (l *wbCheckinLoop) tick(ctx context.Context, c checkinRunner) []WorkBuddyCh cx, cancel := context.WithTimeout(ctx, 2*time.Minute) defer cancel() rs := c.checkinNow(cx, false) + // and at the user's time of day, when the day's first ask waits for it + if g := checkinGate(now); g.After(now) && (l.again.IsZero() || g.Before(l.again)) { + l.again = g + } for _, r := range rs { due := time.Time{} if r.Outcome == CheckinFailed { diff --git a/internal/settings/settings.go b/internal/settings/settings.go index 776e18273..52be6a7ce 100644 --- a/internal/settings/settings.go +++ b/internal/settings/settings.go @@ -366,6 +366,13 @@ type Settings struct { // "|", which provider.adoptLegacyPluginCheckins // carries over). CheckinOff []string `json:"checkinOff,omitempty"` + // CheckinAt is the local time of day ("15:04") every daily check-in, + // built-in and plugin, waits for before it asks for the vendor's day + // (times_ang on X: 可以调整自动签到的时间吗); "" asks as the day turns, + // as before. It holds the day's first ask only: the vendor's own turn + // (a plugin's until) and the tries after it are kept, so no day is + // skipped (provider.checkinGate). + CheckinAt string `json:"checkinAt,omitempty"` // ReplyModel is what a reply's model name says when the request went // out under another name than the one asked for (a group's member, a // model's own id, a provider/model id): "" the model the agent asked @@ -2214,6 +2221,9 @@ func saveOwn(s Settings, recording, reads bool) error { return fmt.Errorf("%s's warm-up time of day must look like 06:00 or be off, not %q", user, at) } } + if _, _, ok := Clock(s.CheckinAt); s.CheckinAt != "" && !ok { + return fmt.Errorf("the check-in's time of day must look like 09:00, not %q", s.CheckinAt) + } if !slices.Contains(TrayEvery, s.TrayUsageEvery) { return fmt.Errorf("the menu bar's usage is refreshed every %v minutes, not %d", TrayEvery, s.TrayUsageEvery) } @@ -2518,6 +2528,11 @@ func (s Settings) normal() Settings { *w.at = (*w.ats)[0] } } + // the check-in's time of day, as 09:00 whichever way it came + s.CheckinAt = strings.TrimSpace(s.CheckinAt) + if h, m, ok := Clock(s.CheckinAt); ok { + s.CheckinAt = fmt.Sprintf("%02d:%02d", h, m) + } // a reply's model name: memberModel, as a magpie before replyModel // kept it, when replyModel isn't set, and kept beside it for that // magpie diff --git a/internal/settingsapi/settingsapi.go b/internal/settingsapi/settingsapi.go index fafb96c2b..78a4555a5 100644 --- a/internal/settingsapi/settingsapi.go +++ b/internal/settingsapi/settingsapi.go @@ -43,7 +43,7 @@ var Keys = []string{ "noStats", "noUsageStats", "otel", // warm-ups and check-ins "codexWarmup", "claudeWarmup", "codexWarmAt", "claudeWarmAt", "codexWarmAts", "claudeWarmAts", - "workbuddyCheckin", "traeCheckin", "minimaxCheckin", "qoderCheckin", + "workbuddyCheckin", "traeCheckin", "minimaxCheckin", "qoderCheckin", "checkinAt", // models: replies, vision, images, search "replyModel", "noLoopGuard", "claudeLeanPrompt", "claudePrintMode", "refusalRetries", "retryAfterCap", "vision", "visionEffort", "imageGen", "videoGen", "imageTimeout", "classifyTimeout",