ac4af582301a4e8a29245dbba767eba31334ddf9
11
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8b902e2879 |
checkin: a ZCode or Qoder captcha stands for the day, not asked again every 30 minutes (plugins#503)
ZCode's check-in is rechecked (pluginRechecks,
|
||
|
|
0ebe6c72c9 |
providers: each account row in the editor has its own Check in now, when the check-in reaches it and it isn't in today (xwoffice_91592 on Discord)
xwoffice_91592 asked for 立即签到 on each account in the provider editor
sheet (Trae CN, a plugin's subscription, one row per account with its
Credits line). The editor's rows read GET /api/login/usage, which carried
no check-in. It now passes those cards through provider.LoginCheckins,
which marks them as the Usage page's cards are (WithCheckins: checkins,
checkinBy, checkin, checkinOff) and adds checkinKey, the account's key
in its vendor's check-in (markCheckins sets it).
The row's button is Settings' Check in now for one account (xiaowu_95660),
not a fork. ciAcctFill in checkinnow.js presses ciNowSend with
{key, user} and checkinBy, so the same POST /api/usage/checkin-account,
the same status-line success and failure, then the row's usage is read
again. When to show it is checkinDue, taken out of checkinRow so the
Usage card's press and the row decide alike: the check-in reaches it, it
isn't off, and it isn't in today (a failed day, an "again" answer, or a
Qoder campaign not open yet still count as due). It sits at the end of
the account's usage line, small (.ci-acct), and wraps whole there rather
than being cut. app.js is 51 bytes smaller (comments cut); checkinnow.js
is lazy and not in the core.
Run (mote, worktree at origin/main
|
||
|
|
4300057264 |
provider: ZCode's check-in is asked again every 30 minutes, as Qoder's is (plugins#503)
ZCode's gift plans open as campaigns, some for under a day (the reporter's ran to 14:00 Beijing). With the check-in settled for the day after a done or inactive answer from noon on, a plan opening in the afternoon could be missed until it had closed. pluginRechecks now includes zcode, so the loop asks again 30 minutes after each answer. Run on mote: go test ./internal/provider/ ok (91s), go vet ok, gofmt clean. Broken by hand: without zcode in pluginRechecks, 4 zcode subtests of TestPluginCheckinQoderRechecksCampaigns are red. Not tried: a real ZCode account with a plan to claim (none open now). |
||
|
|
a05b373538 |
checkin: a plugin's until is when its answer stops holding (Qoder's 10:00 UTC+8)
sdytman on Discord: Qoder's daily credits start at 10:00, can the plugin's check-in follow it? Qoder's /me/campaigns opens each day's CLAIM_BENEFIT campaign at 10:00 and closes it at 09:59 the next day, UTC+8 (startAt and endAt, read with a real account on 10-28; Qoder.app polls the list every 5 minutes). A check-in before 10:00 meets the day before's campaign. Since #2696 the Qoder plugins are asked again every 30 minutes, so today's was claimed somewhere between 10:00 and 10:30; a plain plugin was settled for the Beijing day. auth.checkin may now answer until (RFC 3339 or epoch ms); host.js passes it as RFC 3339 (plugin.Checkin.Until), kept as ValidUntil. settled holds an answer only until then, whatever its outcome; the loop wakes at it instead of its next 30-minute look; an early done that carries it is not provisional (#3326), as the vendor said when its day turns. Instants throughout, so the machine's zone doesn't matter. The Qoder plugins send until from 0.2.43 (plugins fd40b20): the check-in now lands at 10:01. Run (mote): TestPluginCheckinAsksAgainAtUntil, minute by minute from 09:27 Beijing to the next day's 10:30, with time.Local UTC, UTC-8 and Beijing: asks at 09:27, 10:01, 00:00 (the Beijing day), 10:01; a failure in the 09:59 gap asked at 10:01:00 only. GOOS=linux and windows go vet; go test -tags nogui -timeout 45m ./... all ok (76 packages). gofmt -l clean. Broken by hand, each red: settled ignoring ValidUntil (no 10:01 asks); tick not waking at it (10:27 instead); provisional ignoring it (asked every 30 minutes from 00:00 to 10:00); host.js dropping until (ValidUntil zero). Not tried: the Qoder plugin's recheck path with until (the fake plugin is fakeco; the tick and settled it goes through are the same); a GUI change (none: until isn't shown). |
||
|
|
51202cd431 |
plugin: a check-in outcome magpie doesn't know names what the plugin said
A plugin check-in that answered an outcome not in the list, with a message, became failed with the plugin's message alone, so "the daily credits were refreshed" read as magpie's own failure reason. The reason now names the answer first: the plugin answered "yes": <message>. With no message it stays "the plugin answered no outcome" or the answer. Split out of skygunner's fix/usage-absent-used branch (#3650), which carried it beside the usage fix. Run: go test ./internal/provider -run TestPluginCheckinRunsAsTheBuiltinsDo ok. Broken by hand: host.js's old line makes it red (Msg was the message alone). Not tried: a real plugin answering an unknown outcome. Co-authored-by: skygunner <skygunner@users.noreply.github.com> |
||
|
|
45fa29973c |
checkin: an early "already checked in" is asked again, not kept for the day (#3326)
connoryang331 (v0.1.1328, Windows): at 00:00:28 Beijing 14 of 29 plugin
check-ins (AutoClaw CN x5, WorkBuddy x2, CodeArts, Trae x3, MiniMax,
Raccoon x2) answered "already" (done). magpie kept that as the day's
result and never asked again, and Check in now answered from the record
without asking. A real claim at 10:54 paid +200: the vendors' days turn
later than Beijing midnight, so 00:00's "already" was yesterday's.
The class, in the checkiner every check-in shares (built-in and plugin):
- A done, inactive or ineligible answered before noon Beijing
(checkinSureHour) for an account magpie hasn't seen claim that Beijing
day is provisional. The loop asks it again 30 minutes (wbCheckinEvery)
after the answer, until a claim or an answer from noon on: at most 24
more asks a day per such account, none once magpie claims.
- A press (soon) asks again at once for done, inactive and ineligible,
whatever the hour. own-app (Trae 9074) and captcha still stand.
- A claim stamps Claimed, carried over while later answers that day say
done, so a done after magpie's own claim is settled (Qoder's claim then
done case).
- The record goes out with again: true (worked out when shown, never
kept). The card says "{name} says already checked in; its day may not
have turned yet, so magpie asks again later" and keeps Check in now;
Settings, TUI and CLI say the same. en, zh, zh-TW, ja, de.
- Qoder's recheck (#2696, pluginRechecks) is unchanged: its tests pass
as they were.
The plugins repo does not cache "already": autoclaw reads the task list
or calls dailySignin each time, codearts, minimax, raccoon and trae ask
the server each call (read at magpie-community/plugins origin/main
652f06d). No plugin change, publish or mover min.
Tests:
- TestPluginCheckinEarlyDoneAskedAgain (the reporter's 00:00:28: loop at
+29m no ask, +30m asks then claims; a press at 10:54 claims; done all
day is 25 asks and settles at noon; done after magpie's claim settled)
and TestWorkBuddyCheckinEarlyDoneAskedAgain.
- TestPluginCheckinOthersSettledForTheDay now answers at 12:00 Beijing
and checks a press asks again (claimed still settled);
TestPluginCheckinRunsAsTheBuiltinsDo, TestTraeCheckinAnswers and the
WorkBuddy nothing-to-claim/refused tests follow the new rule.
- TestCheckinAgainNotShownAsToday (TUI words and cell).
- checkin-early-done.test.cjs: again card's wording, data-state wait,
Check in now asks plugin-checkin {provider: autoclaw-cn}; a kept done
is "Checked in today +50" with no press. Chromium and WebKit, 5
languages, 900 and 440px, 20/20.
Red on the old code: with the non-test change reverse-applied (fields
kept so it compiles), TestPluginCheckinRunsAsTheBuiltinsDo,
TestPluginCheckinOthersSettledForTheDay (inactive, done, ineligible) and
all 4 subtests of TestPluginCheckinEarlyDoneAskedAgain fail; with
origin/main's app.js, checkin-early-done fails ("Checked in today").
Run at this tree:
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./... clean.
- go test -tags nogui ./internal/provider/ -run 'Checkin|CheckIn',
./internal/tui/ -run 'Checkin|OwnApp': ok.
- GUI: checkin-account, checkin-early-done, i18n-keys, plugin-checkin,
qoder-checkin-recheck, usage-card-refresh, usage-checkin: 177/179. The
2 reds are usage-checkin's "webkit en/zh: Settings has a Qoder check-in
tab", red the same alone on origin/main
|
||
|
|
21f7f9df23 |
checkin: the Qoder plugins' check-in is asked again within the day, as the built-in's was (#2696)
The native Qoder and Qoder CN plugin check-in (pluginCheckinProvider) built
its checkiner without recheck, while the built-in qoderCheckiner set it.
So an inactive or done result was kept for the whole Beijing day, and a
press of "Check in now" was answered from that record too. Qoder CN's
campaign runs 10:00 to 09:59 the next day (mufanmu), so an early read
describes yesterday's campaign and said nothing about today's.
What changed:
- provider: pluginRechecks(id) is true for "qoder" and "qoder-cn" only,
and sets recheck on their checkiner. A press asks at once. The loop asks
again after wbCheckinEvery (30m) for inactive and done. Every other
plugin stays settled for the day.
- GUI (checkinRow): a Qoder account (built-in or plugin) whose check-in
found no campaign today keeps "Check in now". A press reports "Check-in
status refreshed" instead of "Checked in", since it may still find
none. The unused "Checked in" key is replaced in all four languages.
- docs/subsystems/provider-plugins.md names the exception and the tests.
Taken from LoKi's (lokic7123-star) patch on the issue: the recheck on the
Qoder plugin ids, the Check in now button for an inactive Qoder card, and
the neutral press status. Their GUI test was adapted into
qoder-checkin-recheck.test.cjs.
Left out, as the earlier review asked: the blanket 30-minute message, the
UTC timestamps and the client-computed next check. Also left out: the
"Already checked in today" wording and the "· credit" display. That is
not this bug, and the TUI and CLI would need the same change.
Run:
- Red on the old code:
- All 8 subtests of TestPluginCheckinQoderRechecksCampaigns
({qoder,qoder-cn} x {inactive,done} x {loop,press}) fail without
the fix.
- Forcing recheck on for every plugin turns
TestPluginCheckinOthersSettledForTheDay red.
- qoder-checkin-recheck.test.cjs is red on the origin/main assets (no
.ci-now on the card).
- At 91bb01e65 (base
|
||
|
|
a8ecf4020e |
provider: a check-in file that can't be read or parsed stops the check-in
readCheckins, the reader every daily check-in shares (WorkBuddy, Trae CN,
MiniMax Code, Qoder and the plugins' own), took a file it couldn't read
or parse as empty. The next check-in then asked the vendor again for
every account and wrote its answers over the file: an account could be
checked in twice in one day, and the entries it couldn't read were lost.
readCheckins now returns an error for a file that is there but can't be
read, or doesn't parse into entries (cut short, zeroed, empty, `[]`,
`null`). A file not there is still empty. On the error:
- checkiner.checkinNow asks nothing and writes nothing. Each account it
would look at is `failed` with the reason (the path and why), so the
loop tries again after 30 minutes and a press (GUI, TUI, `magpie
accounts checkin`) says why. The error is logged once while it stays
the same.
- The readers that only show results (WithCheckins, *Checkins(),
PluginCheckins) go through shownCheckins, which gives what last read
from the file in this process, so a card keeps its last good data.
- adoptLegacyPluginCheckins' own strict copy of the read now uses
readCheckins too.
Docs: providers-accounts.md no longer lists check-in marks among the
caches written over; provider-plugins.md says the plugin file's case.
Test: TestCheckinUnreadableFileLeftAlone writes a cut-short, zeroed,
empty, `[]` and `null` workbuddy-checkin.json, runs the loop and a press
against a fake WorkBuddy, and checks no status or claim request went out,
the file is byte for byte unchanged, and the result says the path; a
folder in place of plugin-checkin.json does the same through a plugin
checkiner. TestCheckinMissingFileIsEmpty and
TestCheckinUnreadableKeepsLastGood cover the other two sides.
Broken by hand (checkinNow taking the error as an empty map again): the
test went red, every case claimed (Asked true), and green once restored.
Run in a worktree at origin/main
|
||
|
|
62a1df8010 |
provider: a plugin's daily check-in reaches every sign-in, also two that share a display name (plugins#254)
AutoClaw's plugin can hold several sign-ins under one default display name,
which AutoClaw doesn't let the user change. plugin_checkin.go keyed each
account's check-in on "<provider>|<AccountID>", the display name, so
checkinNow's per-key dedupe asked only the first sign-in of each name, by
the loop and by Check in now alike; the others stayed 今日未签 for good,
and Settings showed one row, and one Off switch, per name.
Each sign-in is now keyed on the key plugin-auth.json keeps it under
(pluginCheckinKey: "autoclaw|autoclaw", "autoclaw|autoclaw#x1y2z3").
Two sign-ins never share it; a refresh writes the same key, and signing
in to an account already signed in goes back to its key (host.js
settle). The display name is shown only. Cards, Settings rows,
CheckinOff and Check in now all read the same key, so app.js is
unchanged. An account without an AccountID already had this key.
Upgrade (adoptLegacyPluginCheckins, run when the plugin's accounts are
listed): an entry kept as "<provider>|<display name>" goes
- in plugin-checkin.json, to the first sign-in in use of that name (the
one the old key's check-in asked) and only to it, and the old entry
is dropped: it isn't asked again today, and its namesakes, never asked,
are;
- in settings.CheckinOff, to every sign-in of that name: the user turned
that name off and none of its sign-ins was checked in since, so the
upgrade switches none on (settings.EditCheckinOff edits that field
alone from what the file holds).
A plugin-checkin.json that can't be read or parsed is left as it is and
carried over once it reads; writes go through writePrivate
(temp-and-rename). Known gap: a sign-in made the same day after another
was signed out can take the freed key and that day's result.
The fake plugin's check-in now records a signed-in account as
name@fake/uid so two of one name tell apart in the presses.
Tests:
- TestPluginCheckinTellsSignInsOfOneNameApart: four sign-ins, A/u1, A/u2,
B/u3, B/u4 (the reporter's case). All four pressed once, none again
that day, four entries kept, four Settings rows, every card marked;
with A/u2 off, Check in now the next day presses the other three.
- TestPluginCheckinCarriesOverDisplayNameEntries: a plugin-checkin.json
with fakeco|A@fake and fakeco|B@fake claimed today plus another
plugin's entry, and CheckinOff ["workbuddy|123", "fakeco|B@fake"].
A's check-in goes to its first sign-in only, the old entries go, the
other plugin's stays, both B sign-ins are off and workbuddy|123 is
kept; the loop then presses only A's namesake, and a second look
presses nothing.
- TestPluginCheckinCarriesNothingOverAnUnreadableFile.
Broken by hand, each red:
1. key back on the display name: TellsApart pressed only A@fake/u1 and
B@fake/u3; CarriesOver kept the old entries.
2. adoption not called: CarriesOver ("A's check-in went to ... ok false").
3. record to every heir: CarriesOver ("carried to both") and Unreadable.
4. Off to the first heir only: CarriesOver (CheckinOff lacks one B).
5. old entry kept: CarriesOver and Unreadable.
6. parse error ignored: Unreadable.
Run at
|
||
|
|
2da8fbe488 |
tests: every test that runs plugins on the bun on PATH runs it once first, through testenv.Bun, so a bun that has never run here doesn't time out internal/provider's and internal/plugin's plugin tests (#1306)
|
||
|
|
87487c5ef0 | plugin, provider: a plugin can press its vendor's daily check-in itself (auth.checkin), and magpie runs it as its own check-ins (Lemon on Discord #feedback: provider 每日签到的方法能放到插件里面去做吗; ARNO earlier asked for Qoder's) — the check-ins magpie had (WorkBuddy, Trae CN, MiniMax Code, Qoder) are each written in magpie against the vendor's endpoint, even for a subscription that moved to its plugin, so a plugin author had no way to give their provider one. A plugin's auth hook may now have checkin(getAuth, provider) beside usage: the host lists the provider with checkin: true (plugin.Provider.Checkin) and answers checkin({provider, account}) (plugin.AccountCheckin), refreshing the account as usage does, with {outcome, credit, streak, message}; outcome is claimed, done, ineligible, inactive, captcha or failed, and a throw or an outcome outside these is failed with the reason. internal/provider/plugin_checkin.go runs these through checkin.go's checkiner, as the built-ins are: each signed-in account in use once a Beijing day (first look 2 minutes after start, then every 30), a failure asked again after wbCheckinRetry, every other outcome settled for the day, results kept in plugin-checkin.json by provider|account; a failure is recorded as failed and resets nothing. captcha is new (CheckinCaptcha): the vendor wants a captcha, which magpie never solves, so it is said as "check in in its own app", not as a failure, and not asked again that day. The results mark the account's Usage card (checkinBy "plugin:<provider>", WithCheckins), so the card's check-in row, its Auto check-in and Check in now work for it (POST /api/settings/plugin-checkin {provider, on}, POST /api/usage/plugin-checkin {provider}); Settings → Usage gains a Plugins tab, shown while such a plugin is signed in, a Daily check-in row per provider with Off/On and how each account went; magpie accounts checkin and c on the TUI's Usage page include them (the TUI's "no account" line names check-in plugins). The switch (settings.PluginCheckins, by provider) is off by default; for WorkBuddy, Trae CN, MiniMax Code and Qoder it follows that vendor's existing switch until set on its own, and magpie's own check-in through the plugin's fetch leaves a provider whose plugin checks in to it (pluginChecksIn), so no account is checked in twice. The Settings page's save carries PluginCheckins over (TestSettingsSaveKeepsWhatItDoesNotSend's fixture names it). No plugin declares the hook yet; Qoder's check-in stays magpie's own here. TestPluginCheckinRunsAsTheBuiltinsDo (the fake plugin with FAKE_CHECKIN, five accounts answering claimed, done, captcha, a throw and an unknown outcome: off presses nothing; on, each outcome kept with its vendor; a minute on nothing pressed again; past the retry only the two failures; the next day all five; PluginCheckins and the cards marked; another provider's press asks none) and TestPluginCheckinTakesOverTheVendors (a qoder plugin without the hook leaves magpie's Qoder check-in its account, with it none; PluginCheckinOn's fallbacks) pass -race -count=10, and the latter fails with pluginChecksIn stubbed false; TestTUIChecksPluginsIn passes -race -count=20. plugin-checkin.test.cjs (the card's row with the captcha said, Auto check-in posting {provider, on}, no page move; the Settings Plugins tab at 440px with the row fitting, no sideways scroll, On posting) passes on Chromium and WebKit in en, zh, ja and de; usage-checkin, i18n-keys, gui-ja, gui-de and settings-* pass. go test -tags nogui ./internal/..., go vet, gofmt -l, linux (nogui) and windows builds pass. Not tried with a real plugin or account: no published plugin has the hook yet. docs/subsystems/provider-plugins.md (the hook's contract) and docs/reference.md say it. |