dsh-wtq-pool 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-wtq-pool",
3
3
  "displayName": "WTQ Pool",
4
4
  "description": "把本机 WorkBuddy、Trae、Qoder 的桌面登录接入 DeepSeek Harness。限流或额度用尽时自动换号,三家各自开关,国内与国际账号分别成组。",
5
- "version": "1.2.0",
5
+ "version": "1.2.1",
6
6
  "license": "MIT",
7
7
  "author": "chengzhi-c",
8
8
  "homepage": "https://github.com/chengzhi-c/dsh-wtq-pool#readme",
@@ -48,6 +48,16 @@
48
48
  "CHANGELOG.md",
49
49
  "LICENSE"
50
50
  ],
51
+ "scripts": {
52
+ "build": "tsdown",
53
+ "prepare": "pnpm run build",
54
+ "prepack": "tsdown",
55
+ "prepublishOnly": "tsdown",
56
+ "typecheck": "tsc -p tsconfig.json --noEmit",
57
+ "typecheck:client": "tsc -p tsconfig.client.json --noEmit",
58
+ "pretest": "tsdown",
59
+ "test": "node --test --test-timeout=60000 \"tests/*.test.cjs\""
60
+ },
51
61
  "dsh": {
52
62
  "bundle": {
53
63
  "patch": "./cordis.patch.yml"
@@ -89,12 +99,5 @@
89
99
  "@deepseek-ai/dsh-settings": {
90
100
  "optional": true
91
101
  }
92
- },
93
- "scripts": {
94
- "build": "tsdown",
95
- "typecheck": "tsc -p tsconfig.json --noEmit",
96
- "typecheck:client": "tsc -p tsconfig.client.json --noEmit",
97
- "pretest": "tsdown",
98
- "test": "node --test --test-timeout=60000 \"tests/*.test.cjs\""
99
102
  }
100
- }
103
+ }
@@ -1,5 +1,5 @@
1
1
  <!doctype html>
2
- <html lang="zh-CN">
2
+ <html>
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <meta
@@ -578,7 +578,7 @@ button.park:hover:not(:disabled) { filter: brightness(1.08); background: var(--x
578
578
  .acct-delete:hover:not(:disabled) { color: var(--xd-danger); border-color: var(--xd-danger); background: color-mix(in srgb, var(--xd-danger) 10%, transparent); }
579
579
 
580
580
  /* Armed: the next press deletes, so the button stops looking like the idle one. */
581
- .acct-delete.confirming { color: #fff; background: var(--xd-danger); border-color: var(--xd-danger); font-weight: 600; }
581
+ .acct-delete.confirming { color: var(--xd-on-danger); background: var(--xd-danger); border-color: var(--xd-danger); font-weight: 600; }
582
582
  .acct-delete.confirming:hover:not(:disabled) { background: color-mix(in srgb, var(--xd-danger) 85%, #000); border-color: color-mix(in srgb, var(--xd-danger) 85%, #000); }
583
583
 
584
584
  /* Switched off: visibly parked without being hidden. */
package/renderer/panel.js CHANGED
@@ -30,7 +30,7 @@ var EN = {
30
30
  "tab.check": "Connection check",
31
31
  "tab.growth": "Growth centre",
32
32
  "risk.note": "! A ban is possible. Use at your own discretion; no liability accepted !",
33
- "host.missing": "The host has not registered {count} model group(s) from this plugin yet: reload the plugin so it re-reads the declaration.",
33
+ "host.missing": "The host has not registered {count} model group(s) from this plugin yet: reload the plugin.",
34
34
  "btn.rescan": "Detect accounts again",
35
35
  "btn.reset": "Clear all cooldowns",
36
36
  "btn.refresh": "Refresh",
@@ -57,6 +57,7 @@ var EN = {
57
57
  "pool.allRefused": "Every account's sign-in was refused by the upstream; add one with Add account and the pool starts working again.",
58
58
  "pool.restricted": "{count} restricted by the upstream",
59
59
  "pool.allRestricted": "Every account was restricted by the upstream; appeal the restriction in the WorkBuddy console, or add another account.",
60
+ "pool.allSwitchedOff": "Every account is switched off; switch one on to serve requests.",
60
61
  "pool.checkinAll": "Check in every account",
61
62
  "pool.checkinAllHint": "Collect every account's daily check-in. The streak bonus is collected with it.",
62
63
  "pool.checkinAllBusy": "Checking in…",
@@ -102,9 +103,8 @@ var EN = {
102
103
  "source.quotaUnknown": "usage unavailable",
103
104
  "source.checkedIn": "Checked in today",
104
105
  "source.claimable": "Can claim today",
105
- "source.noCampaign": "no daily check-in",
106
106
  "source.campaignUnknown": "check-in state unavailable",
107
- "source.claimableAt": "Can claim after {time}",
107
+ "source.claimableAt": "Can claim after {time} Beijing time",
108
108
  "source.deviceCheckedIn": "This device checked in today",
109
109
  "qoder.fallback": "preferred port {port} is taken; this session serves a spare port, which the provider row follows",
110
110
  "badge.next": "next up",
@@ -173,7 +173,6 @@ var EN = {
173
173
  "checkin.daily": "+{credit} credits/day",
174
174
  "checkin.bonus": "day {days} bonus +{credit}",
175
175
  "checkin.claimed": "claimed +{credit} credits",
176
- "checkin.inactive": "check-in is not available for this account",
177
176
  "checkin.claiming": "Checking in…",
178
177
  "models.serviceModels": "Models for this service",
179
178
  "models.fetchModelList": "Fetch list",
@@ -318,7 +317,7 @@ var ZH = {
318
317
  "tab.check": "连接检查",
319
318
  "tab.growth": "成长中心",
320
319
  "risk.note": "!可能有封号风险,请斟酌使用,概不负责 !",
321
- "host.missing": "宿主还没有注册本插件的 {count} 个模型组:重新加载插件让它重读声明。",
320
+ "host.missing": "宿主还没有注册本插件的 {count} 个模型组:重新加载插件。",
322
321
  "btn.rescan": "重新检测账号",
323
322
  "btn.reset": "清除所有冷却",
324
323
  "btn.refresh": "刷新",
@@ -345,6 +344,7 @@ var ZH = {
345
344
  "pool.allRefused": "所有账号的登录都已被上游拒绝,用「添加账号」重新登录一个,号池就能继续用。",
346
345
  "pool.restricted": "{count} 个被上游限制",
347
346
  "pool.allRestricted": "所有账号都被上游限制了;请到 WorkBuddy 官方后台申诉,或换一个账号。",
347
+ "pool.allSwitchedOff": "所有账号都已停用,重新启用一个即可继续服务。",
348
348
  "pool.checkinAll": "全部签到",
349
349
  "pool.checkinAllHint": "一次领完所有账号今天的签到,连登奖励也随这一轮领取。",
350
350
  "pool.checkinAllBusy": "签到中…",
@@ -390,12 +390,11 @@ var ZH = {
390
390
  "source.checkedIn": "今日已签到",
391
391
  "source.claimable": "今日可签到",
392
392
  "source.noAccounts": "未找到本机登录",
393
- "source.noCampaign": "该账号无签到活动",
394
393
  "source.campaignUnknown": "签到状态读取失败",
395
394
  "source.deviceCheckedIn": "本机今日已签到",
396
395
  "qoder.fallback": "首选端口 {port} 被占用,本次改听备用端口,供应商行跟随本次地址",
397
396
  "badge.next": "下一个",
398
- "source.claimableAt": "{time} 后可签到",
397
+ "source.claimableAt": "北京时间 {time} 后可签到",
399
398
  "badge.cooling": "冷却中",
400
399
  "badge.revoked": "需重新登录",
401
400
  "badge.healthy": "可用",
@@ -461,7 +460,6 @@ var ZH = {
461
460
  "checkin.daily": "每天 +{credit} 积分",
462
461
  "checkin.bonus": "第 {days} 天额外 +{credit}",
463
462
  "checkin.claimed": "已领取 +{credit} 积分",
464
- "checkin.inactive": "该账号没有签到活动",
465
463
  "checkin.claiming": "签到中…",
466
464
  "models.serviceModels": "该服务的模型",
467
465
  "models.fetchModelList": "获取列表",
@@ -824,6 +822,10 @@ var draft = null;
824
822
  var draftSlot = null;
825
823
  var busy = null; // id of the control awaiting a response
826
824
  var checkinBusy = null;
825
+ // Set when the host answers "still running" to a batch claim. The polling loop
826
+ // clears the banner once the pass lands, so it does not say "checking in" for
827
+ // the rest of the session.
828
+ var checkinBusyNote = false;
827
829
  /** Set while a panel login is waiting on the browser, so its button reads as busy. */
828
830
  var loginBusy = false;
829
831
  /** The URL of the login in flight, so the button can offer it again. */
@@ -879,9 +881,12 @@ function renderHeader() {
879
881
  var cooling = accounts.filter(isCooling).length;
880
882
  var refused = accounts.filter(function (a) { return a.hold === "session"; }).length;
881
883
  var restricted = accounts.filter(function (a) { return a.hold === "restricted"; }).length;
882
- // A pool whose every account is refused has nobody to serve a turn, so the
883
- // dot must not read healthy just because a refused sign-in is not cooling.
884
- var healthy = accounts.length > 0 && cooling + refused + restricted < accounts.length;
884
+ // A pool whose every account is refused, restricted or switched off has
885
+ // nobody to serve a turn, so the dot must not read healthy just because none
886
+ // of them is cooling.
887
+ var healthy = accounts.some(function (a) {
888
+ return a.disabled !== true && !isCooling(a) && a.hold !== "session" && a.hold !== "restricted";
889
+ });
885
890
  var refreshing = state !== null && state.refreshing === true;
886
891
  var dot = $("healthDot");
887
892
  dot.className = "dot " + (state === null ? "idle" : (healthy ? "ok" : "idle")) + (refreshing ? " busy" : "");
@@ -1167,18 +1172,24 @@ function renderWorkbuddyHead() {
1167
1172
  host.appendChild(el("span", "muted", t("pool.summary", { count: accounts.length, cooling: cooling })));
1168
1173
 
1169
1174
  // Collecting every reward is the reason a multi-account pool exists, so it is
1170
- // one button rather than a click per account card.
1175
+ // one button rather than a click per account card. It acts on the whole pool,
1176
+ // so it stays while any region still has a campaign and goes when none does.
1177
+ var offerCheckin = accounts.some(function (account) {
1178
+ return account.checkin && (account.checkin.active === true || account.checkin.todayCheckedIn === true);
1179
+ });
1171
1180
  var claimable = accounts.filter(function (account) {
1172
1181
  return account.disabled !== true && account.checkin && account.checkin.active === true
1173
1182
  && account.checkin.todayCheckedIn !== true;
1174
1183
  }).length;
1175
- var allButton = el("button", "ghost small checkin-all ic-calendar" + (checkinBusy === "all" ? " is-busy" : ""),
1176
- checkinBusy === "all" ? t("pool.checkinAllBusy") : t("pool.checkinAll"));
1177
- allButton.type = "button";
1178
- allButton.title = t("pool.checkinAllHint");
1179
- allButton.disabled = busy !== null || checkinBusy !== null || claimable === 0;
1180
- allButton.addEventListener("click", claimAllCheckins);
1181
- host.appendChild(allButton);
1184
+ if (offerCheckin) {
1185
+ var allButton = el("button", "ghost small checkin-all ic-calendar" + (checkinBusy === "all" ? " is-busy" : ""),
1186
+ checkinBusy === "all" ? t("pool.checkinAllBusy") : t("pool.checkinAll"));
1187
+ allButton.type = "button";
1188
+ allButton.title = t("pool.checkinAllHint");
1189
+ allButton.disabled = busy !== null || checkinBusy !== null || claimable === 0;
1190
+ allButton.addEventListener("click", claimAllCheckins);
1191
+ host.appendChild(allButton);
1192
+ }
1182
1193
 
1183
1194
  // Adding an account from here, rather than only from the desktop app: a user
1184
1195
  // with no WorkBuddy install on this machine had no way into the pool at all.
@@ -1215,9 +1226,11 @@ function renderPoolStrip() {
1215
1226
  var usable = accounts.filter(function (a) { return a.disabled !== true && !a.cooling; }).length;
1216
1227
  var noteText = accounts.length === 0
1217
1228
  ? ""
1218
- : usable <= 0
1219
- ? (restricted > 0 && refused === 0 ? t("pool.allRestricted") : refused > 0 ? t("pool.allRefused") : t("pool.allCooling"))
1220
- : t("pool.healthy");
1229
+ : off === accounts.length
1230
+ ? t("pool.allSwitchedOff")
1231
+ : usable <= 0
1232
+ ? (restricted > 0 && refused === 0 ? t("pool.allRestricted") : refused > 0 ? t("pool.allRefused") : t("pool.allCooling"))
1233
+ : t("pool.healthy");
1221
1234
  if (noteText) strip.appendChild(el("span", "muted", noteText));
1222
1235
  if (refused > 0) strip.appendChild(el("span", "finding-fail", t("pool.refused", { count: refused })));
1223
1236
  if (restricted > 0) strip.appendChild(el("span", "finding-fail", t("pool.restricted", { count: restricted })));
@@ -1242,7 +1255,7 @@ function sourceToggle(source, on) {
1242
1255
  }
1243
1256
 
1244
1257
  /** Shared head row for one non-pool source: its name and its own check-in pool. */
1245
- function sourceGroupHead(source, titleKey, count, claimable, busyHere) {
1258
+ function sourceGroupHead(source, titleKey, count, claimable, busyHere, offerCheckin) {
1246
1259
  var head = el("div", "source-head");
1247
1260
  head.appendChild(el("strong", null, t(titleKey)));
1248
1261
  head.appendChild(el("span", "muted", t("source.accountCount", { count: count })));
@@ -1253,10 +1266,24 @@ function sourceGroupHead(source, titleKey, count, claimable, busyHere) {
1253
1266
  allButton.disabled = busy !== null || checkinBusy !== null || claimable === 0
1254
1267
  || (state.sources || {})[source] !== true;
1255
1268
  allButton.addEventListener("click", function () { claimSourceCheckins(source); });
1256
- head.appendChild(allButton);
1269
+ if (offerCheckin !== false) head.appendChild(allButton);
1257
1270
  return head;
1258
1271
  }
1259
1272
 
1273
+ /**
1274
+ * Whether an account has a check-in surface worth drawing.
1275
+ *
1276
+ * Qoder's international service lists promotion campaigns but no daily
1277
+ * CLAIM_BENEFIT round, so its accounts carry `active: false` and no opening
1278
+ * hour. Drawing a disabled button and "no check-in" line for those accounts
1279
+ * reads as a broken control; the card simply has no check-in.
1280
+ */
1281
+ function checkinOffered(checkin) {
1282
+ return checkin !== undefined && checkin !== null
1283
+ && (checkin.active === true || checkin.todayCheckedIn === true
1284
+ || typeof checkin.opensAtHour === "number" || checkin.campaignsUnavailable === true);
1285
+ }
1286
+
1260
1287
  /** One non-pool account card: its own quota figure and today's check-in. */
1261
1288
  function sourceAccountCard(account, kind) {
1262
1289
  var card = el("div", "card account" + (account.expired ? " card-off" : ""));
@@ -1305,7 +1332,7 @@ function sourceAccountCard(account, kind) {
1305
1332
  }
1306
1333
 
1307
1334
  var checkin = account.checkin;
1308
- if (checkin) {
1335
+ if (checkinOffered(checkin)) {
1309
1336
  var row = el("div", "checkin");
1310
1337
  row.appendChild(el("span", "card-title", t("checkin.title")));
1311
1338
  // Trae allows one check-in per device per day, so an account can be unclaimed
@@ -1324,7 +1351,7 @@ function sourceAccountCard(account, kind) {
1324
1351
  : deviceDone ? t("source.deviceCheckedIn")
1325
1352
  : opensLabel !== "" ? opensLabel
1326
1353
  : checkin.campaignsUnavailable === true ? t("source.campaignUnknown")
1327
- : checkin.active ? t("source.claimable") : t("source.noCampaign")));
1354
+ : t("source.claimable")));
1328
1355
  if (!doneToday && checkin.active && checkin.amount > 0) {
1329
1356
  row.appendChild(el("span", "muted", checkin.amount + " "
1330
1357
  + (checkin.unit === undefined || checkin.unit === "credits" ? t("credits.keepUnit") : checkin.unit)));
@@ -1339,8 +1366,10 @@ function sourceAccountCard(account, kind) {
1339
1366
  var claim = el("button", "primary small" + (busyHere ? " is-busy" : ""),
1340
1367
  busyHere ? t("checkin.claiming") : idleLabel);
1341
1368
  claim.type = "button";
1369
+ claim.setAttribute("aria-label", (busyHere ? t("checkin.claiming") : idleLabel) + ": " + account.label);
1342
1370
  claim.disabled = busyHere || checkinBusy !== null || busy !== null
1343
- || checkin.active !== true || doneToday || deviceDone || opensLabel !== "";
1371
+ || checkin.active !== true || doneToday || deviceDone || opensLabel !== ""
1372
+ || account.expired === true;
1344
1373
  claim.addEventListener("click", function () { claimSourceCheckin(kind, account); });
1345
1374
  row.appendChild(claim);
1346
1375
  card.appendChild(row);
@@ -1459,7 +1488,15 @@ function renderSourceStrip(source) {
1459
1488
  // account rows grey their button out for the same reason.
1460
1489
  && account.checkin.deviceCheckedIn !== true;
1461
1490
  }).length;
1462
- host.appendChild(sourceGroupHead(source, section.title, accounts.length, on ? claimable : 0, checkinBusy === source));
1491
+ if (regions.indexOf(activeRegionOf(source)) < 0) setActiveRegion(source, regions[0]);
1492
+ var region = activeRegionOf(source);
1493
+ // An international region has no daily round. Hiding the source-wide button
1494
+ // there keeps it from reading as an action on the accounts below.
1495
+ var offerCheckin = accounts.some(function (account) {
1496
+ return account.region === region && checkinOffered(account.checkin);
1497
+ });
1498
+ host.appendChild(sourceGroupHead(source, section.title, accounts.length, on ? claimable : 0,
1499
+ checkinBusy === source, offerCheckin));
1463
1500
  if (!on) {
1464
1501
  host.appendChild(el("p", "hint", t(section.off)));
1465
1502
  // The switch stays here while the source is off, because that is the only
@@ -1467,12 +1504,14 @@ function renderSourceStrip(source) {
1467
1504
  host.appendChild(sourceFoot(source));
1468
1505
  return;
1469
1506
  }
1470
- if (regions.indexOf(activeRegionOf(source)) < 0) setActiveRegion(source, regions[0]);
1471
- var region = activeRegionOf(source);
1472
1507
  host.appendChild(sourceRegionNav(source, regions, accounts));
1473
1508
  // One short line about this source's own sign-in rules, where the accounts are.
1474
1509
  if (section.note) host.appendChild(el("p", "hint", t(section.note)));
1475
- if (section.checkinNote) host.appendChild(el("p", "hint", t(section.checkinNote)));
1510
+ // The device rule is about the daily check-in; an international region has
1511
+ // none, so the line would describe a button that is not on the page.
1512
+ if (section.checkinNote && section.checkinRegions.indexOf(region) >= 0) {
1513
+ host.appendChild(el("p", "hint", t(section.checkinNote)));
1514
+ }
1476
1515
  if (regionParked(source, region)) {
1477
1516
  host.appendChild(parkedRegionBlock(source, region));
1478
1517
  host.appendChild(sourceFoot(source));
@@ -1519,9 +1558,13 @@ function claimSourceCheckins(source) {
1519
1558
  note(null);
1520
1559
  render();
1521
1560
  if (payload && payload.running === true) {
1522
- // The pass outlived the plugin's answer and is still collecting: the
1523
- // the panel reports it when it lands.
1524
- announce(t("pool.checkinAllBusy"));
1561
+ // The pass outlived the plugin's answer and is still collecting. Say so
1562
+ // on the visible page; the rows follow when it lands. If the pass never
1563
+ // started (another pass owns the accounts), the poll below clears the
1564
+ // banner immediately rather than leaving it up for the session.
1565
+ checkinBusyNote = true;
1566
+ note(t("pool.checkinAllBusy"));
1567
+ pollCheckinLog(0);
1525
1568
  return;
1526
1569
  }
1527
1570
  var counts = payload ? payload[source] : null;
@@ -1531,10 +1574,10 @@ function claimSourceCheckins(source) {
1531
1574
  // today": the counts carry `failed` (and the reason), a source whose round
1532
1575
  // threw carries none of its own, and the panel read the missing number as
1533
1576
  // "nothing to collect". The user was told the day was done while nothing
1534
- // had been collected.
1535
- announce(failed > 0
1536
- ? checkinFailureText(claimed, failed, counts && counts.reason)
1537
- : claimed > 0 ? t("pool.checkinAllDone", { count: claimed }) : t("pool.checkinAllNone"));
1577
+ // had been collected. The same answer has to be visible, not only announced.
1578
+ if (failed > 0) note(checkinFailureText(claimed, failed, counts && counts.reason), "warn");
1579
+ else if (claimed === 0) note(t("pool.checkinAllNone"));
1580
+ else announce(t("pool.checkinAllDone", { count: claimed }));
1538
1581
  }).catch(function (error) {
1539
1582
  checkinBusy = null;
1540
1583
  note(String(error && error.message ? error.message : error));
@@ -1654,12 +1697,20 @@ function claimSourceCheckin(source, account) {
1654
1697
  .then(function (payload) {
1655
1698
  checkinBusy = null;
1656
1699
  if (payload && payload.state) adopt(payload.state);
1700
+ note(null);
1657
1701
  var result = payload && payload.result ? payload.result : {};
1658
1702
  // A skipped claim can carry the upstream's own reason (Trae answers 9095
1659
- // "this device already checked in today"), which is worth reading.
1660
- if (result.outcome === "claimed") announce(t("source.checkinDone"));
1661
- else if (result.deviceCheckedIn === true) announce(t("source.deviceCheckedIn"));
1662
- else announce(result.reason || t("source.checkinSkipped"));
1703
+ // "this device already checked in today"), which is worth reading. A
1704
+ // skipped claim used to reach the screen reader only, so the button looked
1705
+ // inert; the banner now says why on the visible page.
1706
+ //
1707
+ // A click can also land on a row the automatic pass has already collected:
1708
+ // the host answers `skipped` with `todayCheckedIn`. The account is in the
1709
+ // state the click asked for, so that is a success here, not the "already
1710
+ // collected" wording that made the click look like it did nothing.
1711
+ if (result.outcome === "claimed" || result.todayCheckedIn === true) note(t("source.checkinDone"));
1712
+ else if (result.deviceCheckedIn === true) note(t("source.deviceCheckedIn"));
1713
+ else note(result.reason || t("source.checkinSkipped"));
1663
1714
  render();
1664
1715
  }).catch(function (error) {
1665
1716
  checkinBusy = null;
@@ -1760,7 +1811,7 @@ function renderAutoCheckin() {
1760
1811
  var run = $("autoRunNow");
1761
1812
  run.textContent = busy === "checkin" ? t("auto.running") : t("auto.runNow");
1762
1813
  run.title = t("auto.runNowHint");
1763
- run.disabled = busy !== null;
1814
+ run.disabled = busy !== null || checkinBusy !== null;
1764
1815
 
1765
1816
  // The keep-alive row: one button, run by hand. It is a static node, so the
1766
1817
  // handler lives in `bind`. Its own card, its own log: it renews tokens rather
@@ -1981,8 +2032,7 @@ function growthStateText() {
1981
2032
  // A run since the last read leaves the rows holding figures from before it, so
1982
2033
  // the stale wording names what to do rather than claiming nothing was read.
1983
2034
  if (growthState === null) {
1984
- var last = state && state.growth ? state.growth.last : null;
1985
- return t(last ? "growth.stateStale" : "growth.stateNone");
2035
+ return t(growthLastRun() !== null ? "growth.stateStale" : "growth.stateNone");
1986
2036
  }
1987
2037
  // The scheduled pass records its growth half inside the pass it belongs to, so
1988
2038
  // the run time comes from the same place the log line does. Requiring
@@ -2129,14 +2179,17 @@ function paintGrowthAccounts(host) {
2129
2179
  /** The last growth run, whichever entry point started it. */
2130
2180
  function growthLastRun() {
2131
2181
  var growth = (state && state.growth) || {};
2132
- if (growth.last) return growth.last;
2133
2182
  var auto = (state && state.autoCheckin) || {};
2134
- if (auto.last && auto.last.growth) {
2135
- // The scheduled pass records its growth half inside the pass it belongs to,
2136
- // so the time to show is the pass's own.
2137
- return { at: auto.last.at, ...auto.last.growth };
2138
- }
2139
- return null;
2183
+ var scheduled = auto.last && auto.last.growth ? { at: auto.last.at, ...auto.last.growth } : null;
2184
+ if (!growth.last) return scheduled;
2185
+ if (!scheduled) return growth.last;
2186
+ // The scheduled pass and a manual run both leave a record. Taking
2187
+ // `growth.last` unconditionally showed the older one after a pass.
2188
+ var manualAt = Date.parse(growth.last.at);
2189
+ var scheduledAt = Date.parse(scheduled.at);
2190
+ if (!Number.isFinite(scheduledAt)) return growth.last;
2191
+ if (!Number.isFinite(manualAt)) return scheduled;
2192
+ return scheduledAt > manualAt ? scheduled : growth.last;
2140
2193
  }
2141
2194
 
2142
2195
  /** Paint the growth log as rows, the way the check-in log above it is painted. */
@@ -2386,7 +2439,7 @@ function accountCard(account) {
2386
2439
  toggle.setAttribute("aria-checked", off ? "false" : "true");
2387
2440
  // The name a switch carries is the property it controls and does not change
2388
2441
  // with its state; the visible label already says which state it is in.
2389
- toggle.setAttribute("aria-label", t("acct.inPool"));
2442
+ toggle.setAttribute("aria-label", t("acct.inPool") + ": " + account.label);
2390
2443
  toggle.title = off ? t("acct.switchOn") : t("acct.switchOff");
2391
2444
  toggle.disabled = rowBusy;
2392
2445
  toggle.appendChild(el("span", "acct-toggle-dot"));
@@ -2397,6 +2450,7 @@ function accountCard(account) {
2397
2450
  var removeBtn = el("button", "acct-remove", t("acct.remove"));
2398
2451
  removeBtn.id = rowKey + "-remove";
2399
2452
  removeBtn.type = "button";
2453
+ removeBtn.setAttribute("aria-label", t("acct.remove") + ": " + account.label);
2400
2454
  removeBtn.title = t("acct.removeHint");
2401
2455
  removeBtn.disabled = rowBusy;
2402
2456
  removeBtn.addEventListener("click", function () { setAccountState(account.id, "removed"); });
@@ -2418,6 +2472,7 @@ function accountCard(account) {
2418
2472
  var deleteBtn = el("button", armed ? "acct-delete confirming" : "acct-delete", t(armed ? "acct.deleteConfirmAgain" : "acct.delete"));
2419
2473
  deleteBtn.id = rowKey + "-delete";
2420
2474
  deleteBtn.type = "button";
2475
+ deleteBtn.setAttribute("aria-label", t(armed ? "acct.deleteConfirmAgain" : "acct.delete") + ": " + account.label);
2421
2476
  deleteBtn.title = t("acct.deleteHint");
2422
2477
  deleteBtn.disabled = rowBusy;
2423
2478
  deleteBtn.setAttribute("aria-pressed", armed ? "true" : "false");
@@ -2496,7 +2551,8 @@ function accountCard(account) {
2496
2551
  card.appendChild(creditsBlock(account.credits, account.id, { floor: account }));
2497
2552
  }
2498
2553
 
2499
- card.appendChild(checkinBlock(account));
2554
+ var checkinCard = checkinBlock(account);
2555
+ if (checkinCard) card.appendChild(checkinCard);
2500
2556
  return card;
2501
2557
  }
2502
2558
 
@@ -2687,20 +2743,22 @@ function packWhen(pack) {
2687
2743
  }
2688
2744
 
2689
2745
  function checkinBlock(account) {
2690
- var wrap = el("div", "checkin");
2691
- wrap.appendChild(el("span", "card-title", t("checkin.title")));
2692
-
2693
2746
  // A held sign-in is not read at all, so an error here would be the previous
2694
2747
  // read's; the account card already carries the hold and its remedy.
2695
2748
  if (account.checkinError && account.hold !== "session") {
2696
- wrap.appendChild(el("span", "hint finding-fail", account.checkinError));
2697
- return wrap;
2749
+ var failed = el("div", "checkin");
2750
+ failed.appendChild(el("span", "card-title", t("checkin.title")));
2751
+ failed.appendChild(el("span", "hint finding-fail", account.checkinError));
2752
+ return failed;
2698
2753
  }
2699
2754
  var checkin = account.checkin;
2700
- if (!checkin) {
2701
- wrap.appendChild(el("span", "muted", t("checkin.inactive")));
2702
- return wrap;
2703
- }
2755
+ // A region without a daily campaign reports no active check-in. Drawing the
2756
+ // title, a "no check-in" line and a disabled button for it only makes the
2757
+ // card look broken, so the whole block stays away.
2758
+ if (!checkin || (checkin.active !== true && checkin.todayCheckedIn !== true)) return null;
2759
+
2760
+ var wrap = el("div", "checkin");
2761
+ wrap.appendChild(el("span", "card-title", t("checkin.title")));
2704
2762
 
2705
2763
  if (checkin.streakDays > 0) wrap.appendChild(el("span", "muted", t("checkin.streak", { days: checkin.streakDays })));
2706
2764
  if (checkin.dailyCredit > 0) wrap.appendChild(el("span", "muted", t("checkin.daily", { credit: checkin.dailyCredit })));
@@ -2711,16 +2769,12 @@ function checkinBlock(account) {
2711
2769
  wrap.appendChild(el("span", "badge free", t("checkin.bonus", { days: milestone, credit: checkin.streakBonusCredit })));
2712
2770
  }
2713
2771
 
2714
- if (!checkin.active) {
2715
- wrap.appendChild(el("span", "muted", t("checkin.inactive")));
2716
- return wrap;
2717
- }
2718
-
2719
2772
  var busyHere = checkinBusy === account.id;
2720
2773
  // Upstream ships the button's own label when the campaign renames it.
2721
2774
  var idleLabel = checkin.todayCheckedIn ? t("btn.checkinDone") : t("btn.checkin");
2722
2775
  var button = el("button", "primary small" + (busyHere ? " is-busy" : ""), busyHere ? t("checkin.claiming") : idleLabel);
2723
2776
  button.type = "button";
2777
+ button.setAttribute("aria-label", (busyHere ? t("checkin.claiming") : idleLabel) + ": " + account.label);
2724
2778
  // A whole-pool claim is in flight: this account is covered by it, so the
2725
2779
  // per-account button must not fire a second claim.
2726
2780
  button.disabled = checkin.todayCheckedIn || busyHere || busy !== null || checkinBusy !== null;
@@ -2822,6 +2876,20 @@ function restorePlace(host, keep) {
2822
2876
  again.focus({ preventScroll: true });
2823
2877
  }
2824
2878
 
2879
+ /**
2880
+ * The button, input or select an event landed on.
2881
+ *
2882
+ * Both the pointer and the keyboard path need the same answer: most controls are
2883
+ * rebuilt on every render, so the element itself cannot be the memory.
2884
+ */
2885
+ function controlUnder(node) {
2886
+ while (node && node !== document.body) {
2887
+ if (node.tagName === "BUTTON" || node.tagName === "INPUT" || node.tagName === "SELECT") return node;
2888
+ node = node.parentNode;
2889
+ }
2890
+ return null;
2891
+ }
2892
+
2825
2893
  /**
2826
2894
  * The control the user last pressed, so a render pass that disabled it can hand
2827
2895
  * the focus back once it is live again. See `render`.
@@ -3518,6 +3586,9 @@ function field(labelKey, helpKey, control) {
3518
3586
  var wrap = el("div", "field");
3519
3587
  var head = el("div", "field-head");
3520
3588
  head.appendChild(el("span", "field-label", t(labelKey)));
3589
+ // The label is a span beside the control, not a <label>, so the accessible
3590
+ // name has to be carried by the control itself.
3591
+ control.setAttribute("aria-label", t(labelKey));
3521
3592
  if (helpKey) {
3522
3593
  var hint = el("span", "field-help", "?");
3523
3594
  hint.title = t(helpKey);
@@ -3958,9 +4029,13 @@ function render() {
3958
4029
  }
3959
4030
  // A pending pass whose poll was stopped (or never started) gets its watcher
3960
4031
  // back here: every state adoption ends in this render, and the log row is the
3961
- // only thing that reports the pass as running.
4032
+ // only thing that reports the pass as running. Once the pass has landed there
4033
+ // is nothing left to watch, so the banner it set is cleared here as well.
3962
4034
  if (state && state.autoCheckin && state.autoCheckin.last && state.autoCheckin.last.pending === true) {
3963
4035
  pollCheckinLog(checkinPollAttempts);
4036
+ } else if (checkinBusyNote) {
4037
+ checkinBusyNote = false;
4038
+ if (bannerText === t("pool.checkinAllBusy")) note(null);
3964
4039
  }
3965
4040
  }
3966
4041
 
@@ -4138,7 +4213,14 @@ function pageIsVisible() {
4138
4213
  /** Keep reading the log while a check-in pass is still marked pending. */
4139
4214
  function pollCheckinLog(attempts) {
4140
4215
  var last = state && state.autoCheckin && state.autoCheckin.last;
4141
- if (!last || last.pending !== true || !pageIsVisible()) { stopCheckinPoll(); return; }
4216
+ if (!last || last.pending !== true || !pageIsVisible()) {
4217
+ if (checkinBusyNote) {
4218
+ checkinBusyNote = false;
4219
+ if (bannerText === t("pool.checkinAllBusy")) note(null);
4220
+ }
4221
+ stopCheckinPoll();
4222
+ return;
4223
+ }
4142
4224
  // Progress is counted per pass: a new `at` starts a fresh fast window, and a
4143
4225
  // failure count from the previous pass would otherwise cut the new one short.
4144
4226
  var stamp = typeof last.at === "string" ? last.at : "";
@@ -4325,7 +4407,7 @@ function claimCheckin(accountId) {
4325
4407
  note(null);
4326
4408
  render();
4327
4409
  if (payload && payload.result && payload.result.credit > 0) {
4328
- announce(t("checkin.claimed", { credit: payload.result.credit }));
4410
+ note(t("checkin.claimed", { credit: payload.result.credit }));
4329
4411
  }
4330
4412
  }).catch(function (error) {
4331
4413
  checkinBusy = null;
@@ -4345,14 +4427,16 @@ function claimAllCheckins() {
4345
4427
  note(null);
4346
4428
  render();
4347
4429
  if (payload && payload.running === true) {
4348
- announce(t("pool.checkinAllBusy"));
4430
+ checkinBusyNote = true;
4431
+ note(t("pool.checkinAllBusy"));
4432
+ pollCheckinLog(0);
4349
4433
  return;
4350
4434
  }
4351
4435
  var claimed = payload && typeof payload.claimed === "number" ? payload.claimed : 0;
4352
4436
  var failed = payload && typeof payload.failed === "number" ? payload.failed : 0;
4353
- announce(failed > 0
4354
- ? checkinFailureText(claimed, failed, payload && payload.reason)
4355
- : claimed > 0 ? t("pool.checkinAllDone", { count: claimed }) : t("pool.checkinAllNone"));
4437
+ if (failed > 0) note(checkinFailureText(claimed, failed, payload && payload.reason), "warn");
4438
+ else if (claimed === 0) note(t("pool.checkinAllNone"));
4439
+ else announce(t("pool.checkinAllDone", { count: claimed }));
4356
4440
  }).catch(function (error) {
4357
4441
  checkinBusy = null;
4358
4442
  note(String(error && error.message ? error.message : error));
@@ -4669,14 +4753,13 @@ function bind() {
4669
4753
  // re-attached on every pass. Capture phase, so it runs before the button's own
4670
4754
  // handler and records the press even when that handler is about to disable it.
4671
4755
  document.addEventListener("pointerdown", function (event) {
4672
- var node = event.target;
4673
- while (node && node !== document.body) {
4674
- if (node.tagName === "BUTTON" || node.tagName === "INPUT" || node.tagName === "SELECT") {
4675
- notePress(node);
4676
- return;
4677
- }
4678
- node = node.parentNode;
4679
- }
4756
+ notePress(controlUnder(event.target));
4757
+ }, true);
4758
+ // Keyboard activation fires click without a pointerdown, so the same memory
4759
+ // has to be filled here or Enter/Space lost the focus on the next render.
4760
+ document.addEventListener("keydown", function (event) {
4761
+ if (event.key !== "Enter" && event.key !== " ") return;
4762
+ notePress(controlUnder(event.target));
4680
4763
  }, true);
4681
4764
 
4682
4765
  var viewTabs = document.querySelectorAll("#viewTabs .subtab");