dsh-wtq-pool 1.1.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/CHANGELOG.md +23 -0
- package/README.en.md +21 -17
- package/README.md +21 -17
- package/lib/client.js +1 -2
- package/lib/index.d.ts +0 -2
- package/lib/index.js +1291 -556
- package/package.json +1 -1
- package/renderer/index.html +2 -15
- package/renderer/panel.css +1 -1
- package/renderer/panel.js +189 -134
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
|
|
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",
|
|
@@ -287,13 +286,6 @@ var EN = {
|
|
|
287
286
|
"composer.hint": "When the selected model belongs to this plugin, its account's credits appear on the left of the composer. Click to switch accounts.",
|
|
288
287
|
"composer.show": "Show credits",
|
|
289
288
|
"composer.hide": "Hide credits",
|
|
290
|
-
"rewrite.title": "Client name",
|
|
291
|
-
"rewrite.on": "On",
|
|
292
|
-
"rewrite.off": "Off",
|
|
293
|
-
"rewrite.label": "Rename the client in the prompt the domestic host receives",
|
|
294
|
-
"rewrite.hint": "The domestic WorkBuddy host refuses a request whose prompt names DeepSeek Harness as the client (channel check 11128). Turned on, every occurrence of that name is sent as DeepSeek; turned off, the original wording is sent.",
|
|
295
|
-
"rewrite.show": "Rename client",
|
|
296
|
-
"rewrite.hide": "Stop renaming",
|
|
297
289
|
"check.title": "Connection check",
|
|
298
290
|
"check.empty": "Run the check to see whether a chat can reach WorkBuddy, Trae or Qoder.",
|
|
299
291
|
"check.pass": "PASS",
|
|
@@ -325,7 +317,7 @@ var ZH = {
|
|
|
325
317
|
"tab.check": "连接检查",
|
|
326
318
|
"tab.growth": "成长中心",
|
|
327
319
|
"risk.note": "!可能有封号风险,请斟酌使用,概不负责 !",
|
|
328
|
-
"host.missing": "宿主还没有注册本插件的 {count}
|
|
320
|
+
"host.missing": "宿主还没有注册本插件的 {count} 个模型组:重新加载插件。",
|
|
329
321
|
"btn.rescan": "重新检测账号",
|
|
330
322
|
"btn.reset": "清除所有冷却",
|
|
331
323
|
"btn.refresh": "刷新",
|
|
@@ -352,6 +344,7 @@ var ZH = {
|
|
|
352
344
|
"pool.allRefused": "所有账号的登录都已被上游拒绝,用「添加账号」重新登录一个,号池就能继续用。",
|
|
353
345
|
"pool.restricted": "{count} 个被上游限制",
|
|
354
346
|
"pool.allRestricted": "所有账号都被上游限制了;请到 WorkBuddy 官方后台申诉,或换一个账号。",
|
|
347
|
+
"pool.allSwitchedOff": "所有账号都已停用,重新启用一个即可继续服务。",
|
|
355
348
|
"pool.checkinAll": "全部签到",
|
|
356
349
|
"pool.checkinAllHint": "一次领完所有账号今天的签到,连登奖励也随这一轮领取。",
|
|
357
350
|
"pool.checkinAllBusy": "签到中…",
|
|
@@ -397,12 +390,11 @@ var ZH = {
|
|
|
397
390
|
"source.checkedIn": "今日已签到",
|
|
398
391
|
"source.claimable": "今日可签到",
|
|
399
392
|
"source.noAccounts": "未找到本机登录",
|
|
400
|
-
"source.noCampaign": "该账号无签到活动",
|
|
401
393
|
"source.campaignUnknown": "签到状态读取失败",
|
|
402
394
|
"source.deviceCheckedIn": "本机今日已签到",
|
|
403
395
|
"qoder.fallback": "首选端口 {port} 被占用,本次改听备用端口,供应商行跟随本次地址",
|
|
404
396
|
"badge.next": "下一个",
|
|
405
|
-
"source.claimableAt": "{time} 后可签到",
|
|
397
|
+
"source.claimableAt": "北京时间 {time} 后可签到",
|
|
406
398
|
"badge.cooling": "冷却中",
|
|
407
399
|
"badge.revoked": "需重新登录",
|
|
408
400
|
"badge.healthy": "可用",
|
|
@@ -468,7 +460,6 @@ var ZH = {
|
|
|
468
460
|
"checkin.daily": "每天 +{credit} 积分",
|
|
469
461
|
"checkin.bonus": "第 {days} 天额外 +{credit}",
|
|
470
462
|
"checkin.claimed": "已领取 +{credit} 积分",
|
|
471
|
-
"checkin.inactive": "该账号没有签到活动",
|
|
472
463
|
"checkin.claiming": "签到中…",
|
|
473
464
|
"models.serviceModels": "该服务的模型",
|
|
474
465
|
"models.fetchModelList": "获取列表",
|
|
@@ -527,13 +518,6 @@ var ZH = {
|
|
|
527
518
|
"composer.hint": "开启后,选中本插件的模型时,输入框左侧显示正在使用的账号积分。点开可以换号。",
|
|
528
519
|
"composer.show": "显示积分",
|
|
529
520
|
"composer.hide": "隐藏积分",
|
|
530
|
-
"rewrite.title": "客户端名称",
|
|
531
|
-
"rewrite.on": "已开启",
|
|
532
|
-
"rewrite.off": "已关闭",
|
|
533
|
-
"rewrite.label": "改写发往国内版的提示词里的客户端名称",
|
|
534
|
-
"rewrite.hint": "WorkBuddy 国内版会拒绝提示词里把客户端名称写成 DeepSeek Harness 的对话请求(渠道校验 11128)。开启后,提示词里这个名称的每一处都改为 DeepSeek;关闭后恢复原名。",
|
|
535
|
-
"rewrite.show": "改写名称",
|
|
536
|
-
"rewrite.hide": "恢复原名",
|
|
537
521
|
"growth.title": "成长中心",
|
|
538
522
|
"growth.ready": "WorkBuddy",
|
|
539
523
|
"growth.running": "运行中…",
|
|
@@ -838,6 +822,10 @@ var draft = null;
|
|
|
838
822
|
var draftSlot = null;
|
|
839
823
|
var busy = null; // id of the control awaiting a response
|
|
840
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;
|
|
841
829
|
/** Set while a panel login is waiting on the browser, so its button reads as busy. */
|
|
842
830
|
var loginBusy = false;
|
|
843
831
|
/** The URL of the login in flight, so the button can offer it again. */
|
|
@@ -893,9 +881,12 @@ function renderHeader() {
|
|
|
893
881
|
var cooling = accounts.filter(isCooling).length;
|
|
894
882
|
var refused = accounts.filter(function (a) { return a.hold === "session"; }).length;
|
|
895
883
|
var restricted = accounts.filter(function (a) { return a.hold === "restricted"; }).length;
|
|
896
|
-
// A pool whose every account is refused
|
|
897
|
-
// dot must not read healthy just because
|
|
898
|
-
|
|
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
|
+
});
|
|
899
890
|
var refreshing = state !== null && state.refreshing === true;
|
|
900
891
|
var dot = $("healthDot");
|
|
901
892
|
dot.className = "dot " + (state === null ? "idle" : (healthy ? "ok" : "idle")) + (refreshing ? " busy" : "");
|
|
@@ -969,6 +960,10 @@ function renderSourceTabs() {
|
|
|
969
960
|
for (var j = 0; j < groups.length; j += 1) {
|
|
970
961
|
groups[j].hidden = groups[j].getAttribute("data-source") !== activeSource;
|
|
971
962
|
}
|
|
963
|
+
// The keep-alive renews WorkBuddy sign-ins only; leaving the card on Trae or
|
|
964
|
+
// Qoder made it look as if "Refresh now" would touch that source's tokens.
|
|
965
|
+
var keepAliveCard = $("keepAliveCard");
|
|
966
|
+
if (keepAliveCard) keepAliveCard.hidden = activeSource !== "workbuddy";
|
|
972
967
|
// The source tab owns the models view too, and a source tab click does not
|
|
973
968
|
// run the whole render, so the model page and the footer - which names the
|
|
974
969
|
// endpoint of the source on screen - are repainted from here.
|
|
@@ -1177,18 +1172,24 @@ function renderWorkbuddyHead() {
|
|
|
1177
1172
|
host.appendChild(el("span", "muted", t("pool.summary", { count: accounts.length, cooling: cooling })));
|
|
1178
1173
|
|
|
1179
1174
|
// Collecting every reward is the reason a multi-account pool exists, so it is
|
|
1180
|
-
// 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
|
+
});
|
|
1181
1180
|
var claimable = accounts.filter(function (account) {
|
|
1182
1181
|
return account.disabled !== true && account.checkin && account.checkin.active === true
|
|
1183
1182
|
&& account.checkin.todayCheckedIn !== true;
|
|
1184
1183
|
}).length;
|
|
1185
|
-
|
|
1186
|
-
checkinBusy === "all" ?
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
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
|
+
}
|
|
1192
1193
|
|
|
1193
1194
|
// Adding an account from here, rather than only from the desktop app: a user
|
|
1194
1195
|
// with no WorkBuddy install on this machine had no way into the pool at all.
|
|
@@ -1225,9 +1226,11 @@ function renderPoolStrip() {
|
|
|
1225
1226
|
var usable = accounts.filter(function (a) { return a.disabled !== true && !a.cooling; }).length;
|
|
1226
1227
|
var noteText = accounts.length === 0
|
|
1227
1228
|
? ""
|
|
1228
|
-
:
|
|
1229
|
-
?
|
|
1230
|
-
:
|
|
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");
|
|
1231
1234
|
if (noteText) strip.appendChild(el("span", "muted", noteText));
|
|
1232
1235
|
if (refused > 0) strip.appendChild(el("span", "finding-fail", t("pool.refused", { count: refused })));
|
|
1233
1236
|
if (restricted > 0) strip.appendChild(el("span", "finding-fail", t("pool.restricted", { count: restricted })));
|
|
@@ -1252,7 +1255,7 @@ function sourceToggle(source, on) {
|
|
|
1252
1255
|
}
|
|
1253
1256
|
|
|
1254
1257
|
/** Shared head row for one non-pool source: its name and its own check-in pool. */
|
|
1255
|
-
function sourceGroupHead(source, titleKey, count, claimable, busyHere) {
|
|
1258
|
+
function sourceGroupHead(source, titleKey, count, claimable, busyHere, offerCheckin) {
|
|
1256
1259
|
var head = el("div", "source-head");
|
|
1257
1260
|
head.appendChild(el("strong", null, t(titleKey)));
|
|
1258
1261
|
head.appendChild(el("span", "muted", t("source.accountCount", { count: count })));
|
|
@@ -1263,10 +1266,24 @@ function sourceGroupHead(source, titleKey, count, claimable, busyHere) {
|
|
|
1263
1266
|
allButton.disabled = busy !== null || checkinBusy !== null || claimable === 0
|
|
1264
1267
|
|| (state.sources || {})[source] !== true;
|
|
1265
1268
|
allButton.addEventListener("click", function () { claimSourceCheckins(source); });
|
|
1266
|
-
head.appendChild(allButton);
|
|
1269
|
+
if (offerCheckin !== false) head.appendChild(allButton);
|
|
1267
1270
|
return head;
|
|
1268
1271
|
}
|
|
1269
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
|
+
|
|
1270
1287
|
/** One non-pool account card: its own quota figure and today's check-in. */
|
|
1271
1288
|
function sourceAccountCard(account, kind) {
|
|
1272
1289
|
var card = el("div", "card account" + (account.expired ? " card-off" : ""));
|
|
@@ -1315,7 +1332,7 @@ function sourceAccountCard(account, kind) {
|
|
|
1315
1332
|
}
|
|
1316
1333
|
|
|
1317
1334
|
var checkin = account.checkin;
|
|
1318
|
-
if (checkin) {
|
|
1335
|
+
if (checkinOffered(checkin)) {
|
|
1319
1336
|
var row = el("div", "checkin");
|
|
1320
1337
|
row.appendChild(el("span", "card-title", t("checkin.title")));
|
|
1321
1338
|
// Trae allows one check-in per device per day, so an account can be unclaimed
|
|
@@ -1334,7 +1351,7 @@ function sourceAccountCard(account, kind) {
|
|
|
1334
1351
|
: deviceDone ? t("source.deviceCheckedIn")
|
|
1335
1352
|
: opensLabel !== "" ? opensLabel
|
|
1336
1353
|
: checkin.campaignsUnavailable === true ? t("source.campaignUnknown")
|
|
1337
|
-
:
|
|
1354
|
+
: t("source.claimable")));
|
|
1338
1355
|
if (!doneToday && checkin.active && checkin.amount > 0) {
|
|
1339
1356
|
row.appendChild(el("span", "muted", checkin.amount + " "
|
|
1340
1357
|
+ (checkin.unit === undefined || checkin.unit === "credits" ? t("credits.keepUnit") : checkin.unit)));
|
|
@@ -1349,8 +1366,10 @@ function sourceAccountCard(account, kind) {
|
|
|
1349
1366
|
var claim = el("button", "primary small" + (busyHere ? " is-busy" : ""),
|
|
1350
1367
|
busyHere ? t("checkin.claiming") : idleLabel);
|
|
1351
1368
|
claim.type = "button";
|
|
1369
|
+
claim.setAttribute("aria-label", (busyHere ? t("checkin.claiming") : idleLabel) + ": " + account.label);
|
|
1352
1370
|
claim.disabled = busyHere || checkinBusy !== null || busy !== null
|
|
1353
|
-
|| checkin.active !== true || doneToday || deviceDone || opensLabel !== ""
|
|
1371
|
+
|| checkin.active !== true || doneToday || deviceDone || opensLabel !== ""
|
|
1372
|
+
|| account.expired === true;
|
|
1354
1373
|
claim.addEventListener("click", function () { claimSourceCheckin(kind, account); });
|
|
1355
1374
|
row.appendChild(claim);
|
|
1356
1375
|
card.appendChild(row);
|
|
@@ -1469,7 +1488,15 @@ function renderSourceStrip(source) {
|
|
|
1469
1488
|
// account rows grey their button out for the same reason.
|
|
1470
1489
|
&& account.checkin.deviceCheckedIn !== true;
|
|
1471
1490
|
}).length;
|
|
1472
|
-
|
|
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));
|
|
1473
1500
|
if (!on) {
|
|
1474
1501
|
host.appendChild(el("p", "hint", t(section.off)));
|
|
1475
1502
|
// The switch stays here while the source is off, because that is the only
|
|
@@ -1477,12 +1504,14 @@ function renderSourceStrip(source) {
|
|
|
1477
1504
|
host.appendChild(sourceFoot(source));
|
|
1478
1505
|
return;
|
|
1479
1506
|
}
|
|
1480
|
-
if (regions.indexOf(activeRegionOf(source)) < 0) setActiveRegion(source, regions[0]);
|
|
1481
|
-
var region = activeRegionOf(source);
|
|
1482
1507
|
host.appendChild(sourceRegionNav(source, regions, accounts));
|
|
1483
1508
|
// One short line about this source's own sign-in rules, where the accounts are.
|
|
1484
1509
|
if (section.note) host.appendChild(el("p", "hint", t(section.note)));
|
|
1485
|
-
|
|
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
|
+
}
|
|
1486
1515
|
if (regionParked(source, region)) {
|
|
1487
1516
|
host.appendChild(parkedRegionBlock(source, region));
|
|
1488
1517
|
host.appendChild(sourceFoot(source));
|
|
@@ -1529,9 +1558,13 @@ function claimSourceCheckins(source) {
|
|
|
1529
1558
|
note(null);
|
|
1530
1559
|
render();
|
|
1531
1560
|
if (payload && payload.running === true) {
|
|
1532
|
-
// The pass outlived the plugin's answer and is still collecting
|
|
1533
|
-
// the
|
|
1534
|
-
|
|
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);
|
|
1535
1568
|
return;
|
|
1536
1569
|
}
|
|
1537
1570
|
var counts = payload ? payload[source] : null;
|
|
@@ -1541,10 +1574,10 @@ function claimSourceCheckins(source) {
|
|
|
1541
1574
|
// today": the counts carry `failed` (and the reason), a source whose round
|
|
1542
1575
|
// threw carries none of its own, and the panel read the missing number as
|
|
1543
1576
|
// "nothing to collect". The user was told the day was done while nothing
|
|
1544
|
-
// had been collected.
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
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 }));
|
|
1548
1581
|
}).catch(function (error) {
|
|
1549
1582
|
checkinBusy = null;
|
|
1550
1583
|
note(String(error && error.message ? error.message : error));
|
|
@@ -1664,12 +1697,20 @@ function claimSourceCheckin(source, account) {
|
|
|
1664
1697
|
.then(function (payload) {
|
|
1665
1698
|
checkinBusy = null;
|
|
1666
1699
|
if (payload && payload.state) adopt(payload.state);
|
|
1700
|
+
note(null);
|
|
1667
1701
|
var result = payload && payload.result ? payload.result : {};
|
|
1668
1702
|
// A skipped claim can carry the upstream's own reason (Trae answers 9095
|
|
1669
|
-
// "this device already checked in today"), which is worth reading.
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
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"));
|
|
1673
1714
|
render();
|
|
1674
1715
|
}).catch(function (error) {
|
|
1675
1716
|
checkinBusy = null;
|
|
@@ -1770,7 +1811,7 @@ function renderAutoCheckin() {
|
|
|
1770
1811
|
var run = $("autoRunNow");
|
|
1771
1812
|
run.textContent = busy === "checkin" ? t("auto.running") : t("auto.runNow");
|
|
1772
1813
|
run.title = t("auto.runNowHint");
|
|
1773
|
-
run.disabled = busy !== null;
|
|
1814
|
+
run.disabled = busy !== null || checkinBusy !== null;
|
|
1774
1815
|
|
|
1775
1816
|
// The keep-alive row: one button, run by hand. It is a static node, so the
|
|
1776
1817
|
// handler lives in `bind`. Its own card, its own log: it renews tokens rather
|
|
@@ -1812,26 +1853,6 @@ function renderComposerPoints() {
|
|
|
1812
1853
|
$("composerPointsHint").textContent = t("composer.hint");
|
|
1813
1854
|
}
|
|
1814
1855
|
|
|
1815
|
-
/**
|
|
1816
|
-
* The client-name switch.
|
|
1817
|
-
*
|
|
1818
|
-
* Same shape as the credits switch above, and for the same reason: the label says
|
|
1819
|
-
* what pressing it will do and which way it currently stands. Off by default -
|
|
1820
|
-
* turning it on is the user's decision, because it changes what the prompt tells
|
|
1821
|
-
* the upstream about the client.
|
|
1822
|
-
*/
|
|
1823
|
-
function renderRewriteClientName() {
|
|
1824
|
-
var renamed = state !== null && typeof state.replacedClientName === "string";
|
|
1825
|
-
$("rewriteTitle").textContent = t("rewrite.title");
|
|
1826
|
-
$("rewriteState").textContent = renamed ? t("rewrite.on") : t("rewrite.off");
|
|
1827
|
-
var button = $("rewriteClientName");
|
|
1828
|
-
button.textContent = t(renamed ? "rewrite.hide" : "rewrite.show");
|
|
1829
|
-
button.className = "small" + (renamed ? " on" : "");
|
|
1830
|
-
button.disabled = busy !== null;
|
|
1831
|
-
$("rewriteText").textContent = t("rewrite.label");
|
|
1832
|
-
$("rewriteHint").textContent = t("rewrite.hint");
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
1856
|
/**
|
|
1836
1857
|
* The check-in log: one row per source, each with a state dot.
|
|
1837
1858
|
*
|
|
@@ -1894,7 +1915,10 @@ function autoNoteRows(auto) {
|
|
|
1894
1915
|
tone: claimed > 0 || adopted > 0 ? "ok" : "",
|
|
1895
1916
|
});
|
|
1896
1917
|
};
|
|
1897
|
-
|
|
1918
|
+
if (last.workbuddy !== false
|
|
1919
|
+
&& (last.claimed !== undefined || last.skipped !== undefined || last.failed !== undefined)) {
|
|
1920
|
+
push(t("auto.rowWorkbuddy"), { claimed: last.claimed, skipped: last.skipped, failed: last.failed });
|
|
1921
|
+
}
|
|
1898
1922
|
pushTravel(last.travel);
|
|
1899
1923
|
if (last.growth) {
|
|
1900
1924
|
var growth = last.growth;
|
|
@@ -2008,8 +2032,7 @@ function growthStateText() {
|
|
|
2008
2032
|
// A run since the last read leaves the rows holding figures from before it, so
|
|
2009
2033
|
// the stale wording names what to do rather than claiming nothing was read.
|
|
2010
2034
|
if (growthState === null) {
|
|
2011
|
-
|
|
2012
|
-
return t(last ? "growth.stateStale" : "growth.stateNone");
|
|
2035
|
+
return t(growthLastRun() !== null ? "growth.stateStale" : "growth.stateNone");
|
|
2013
2036
|
}
|
|
2014
2037
|
// The scheduled pass records its growth half inside the pass it belongs to, so
|
|
2015
2038
|
// the run time comes from the same place the log line does. Requiring
|
|
@@ -2156,14 +2179,17 @@ function paintGrowthAccounts(host) {
|
|
|
2156
2179
|
/** The last growth run, whichever entry point started it. */
|
|
2157
2180
|
function growthLastRun() {
|
|
2158
2181
|
var growth = (state && state.growth) || {};
|
|
2159
|
-
if (growth.last) return growth.last;
|
|
2160
2182
|
var auto = (state && state.autoCheckin) || {};
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
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;
|
|
2167
2193
|
}
|
|
2168
2194
|
|
|
2169
2195
|
/** Paint the growth log as rows, the way the check-in log above it is painted. */
|
|
@@ -2413,7 +2439,7 @@ function accountCard(account) {
|
|
|
2413
2439
|
toggle.setAttribute("aria-checked", off ? "false" : "true");
|
|
2414
2440
|
// The name a switch carries is the property it controls and does not change
|
|
2415
2441
|
// with its state; the visible label already says which state it is in.
|
|
2416
|
-
toggle.setAttribute("aria-label", t("acct.inPool"));
|
|
2442
|
+
toggle.setAttribute("aria-label", t("acct.inPool") + ": " + account.label);
|
|
2417
2443
|
toggle.title = off ? t("acct.switchOn") : t("acct.switchOff");
|
|
2418
2444
|
toggle.disabled = rowBusy;
|
|
2419
2445
|
toggle.appendChild(el("span", "acct-toggle-dot"));
|
|
@@ -2424,6 +2450,7 @@ function accountCard(account) {
|
|
|
2424
2450
|
var removeBtn = el("button", "acct-remove", t("acct.remove"));
|
|
2425
2451
|
removeBtn.id = rowKey + "-remove";
|
|
2426
2452
|
removeBtn.type = "button";
|
|
2453
|
+
removeBtn.setAttribute("aria-label", t("acct.remove") + ": " + account.label);
|
|
2427
2454
|
removeBtn.title = t("acct.removeHint");
|
|
2428
2455
|
removeBtn.disabled = rowBusy;
|
|
2429
2456
|
removeBtn.addEventListener("click", function () { setAccountState(account.id, "removed"); });
|
|
@@ -2445,6 +2472,7 @@ function accountCard(account) {
|
|
|
2445
2472
|
var deleteBtn = el("button", armed ? "acct-delete confirming" : "acct-delete", t(armed ? "acct.deleteConfirmAgain" : "acct.delete"));
|
|
2446
2473
|
deleteBtn.id = rowKey + "-delete";
|
|
2447
2474
|
deleteBtn.type = "button";
|
|
2475
|
+
deleteBtn.setAttribute("aria-label", t(armed ? "acct.deleteConfirmAgain" : "acct.delete") + ": " + account.label);
|
|
2448
2476
|
deleteBtn.title = t("acct.deleteHint");
|
|
2449
2477
|
deleteBtn.disabled = rowBusy;
|
|
2450
2478
|
deleteBtn.setAttribute("aria-pressed", armed ? "true" : "false");
|
|
@@ -2523,7 +2551,8 @@ function accountCard(account) {
|
|
|
2523
2551
|
card.appendChild(creditsBlock(account.credits, account.id, { floor: account }));
|
|
2524
2552
|
}
|
|
2525
2553
|
|
|
2526
|
-
|
|
2554
|
+
var checkinCard = checkinBlock(account);
|
|
2555
|
+
if (checkinCard) card.appendChild(checkinCard);
|
|
2527
2556
|
return card;
|
|
2528
2557
|
}
|
|
2529
2558
|
|
|
@@ -2714,20 +2743,22 @@ function packWhen(pack) {
|
|
|
2714
2743
|
}
|
|
2715
2744
|
|
|
2716
2745
|
function checkinBlock(account) {
|
|
2717
|
-
var wrap = el("div", "checkin");
|
|
2718
|
-
wrap.appendChild(el("span", "card-title", t("checkin.title")));
|
|
2719
|
-
|
|
2720
2746
|
// A held sign-in is not read at all, so an error here would be the previous
|
|
2721
2747
|
// read's; the account card already carries the hold and its remedy.
|
|
2722
2748
|
if (account.checkinError && account.hold !== "session") {
|
|
2723
|
-
|
|
2724
|
-
|
|
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;
|
|
2725
2753
|
}
|
|
2726
2754
|
var checkin = account.checkin;
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
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")));
|
|
2731
2762
|
|
|
2732
2763
|
if (checkin.streakDays > 0) wrap.appendChild(el("span", "muted", t("checkin.streak", { days: checkin.streakDays })));
|
|
2733
2764
|
if (checkin.dailyCredit > 0) wrap.appendChild(el("span", "muted", t("checkin.daily", { credit: checkin.dailyCredit })));
|
|
@@ -2738,16 +2769,12 @@ function checkinBlock(account) {
|
|
|
2738
2769
|
wrap.appendChild(el("span", "badge free", t("checkin.bonus", { days: milestone, credit: checkin.streakBonusCredit })));
|
|
2739
2770
|
}
|
|
2740
2771
|
|
|
2741
|
-
if (!checkin.active) {
|
|
2742
|
-
wrap.appendChild(el("span", "muted", t("checkin.inactive")));
|
|
2743
|
-
return wrap;
|
|
2744
|
-
}
|
|
2745
|
-
|
|
2746
2772
|
var busyHere = checkinBusy === account.id;
|
|
2747
2773
|
// Upstream ships the button's own label when the campaign renames it.
|
|
2748
2774
|
var idleLabel = checkin.todayCheckedIn ? t("btn.checkinDone") : t("btn.checkin");
|
|
2749
2775
|
var button = el("button", "primary small" + (busyHere ? " is-busy" : ""), busyHere ? t("checkin.claiming") : idleLabel);
|
|
2750
2776
|
button.type = "button";
|
|
2777
|
+
button.setAttribute("aria-label", (busyHere ? t("checkin.claiming") : idleLabel) + ": " + account.label);
|
|
2751
2778
|
// A whole-pool claim is in flight: this account is covered by it, so the
|
|
2752
2779
|
// per-account button must not fire a second claim.
|
|
2753
2780
|
button.disabled = checkin.todayCheckedIn || busyHere || busy !== null || checkinBusy !== null;
|
|
@@ -2849,6 +2876,20 @@ function restorePlace(host, keep) {
|
|
|
2849
2876
|
again.focus({ preventScroll: true });
|
|
2850
2877
|
}
|
|
2851
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
|
+
|
|
2852
2893
|
/**
|
|
2853
2894
|
* The control the user last pressed, so a render pass that disabled it can hand
|
|
2854
2895
|
* the focus back once it is live again. See `render`.
|
|
@@ -3545,6 +3586,9 @@ function field(labelKey, helpKey, control) {
|
|
|
3545
3586
|
var wrap = el("div", "field");
|
|
3546
3587
|
var head = el("div", "field-head");
|
|
3547
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));
|
|
3548
3592
|
if (helpKey) {
|
|
3549
3593
|
var hint = el("span", "field-help", "?");
|
|
3550
3594
|
hint.title = t(helpKey);
|
|
@@ -3957,7 +4001,6 @@ function render() {
|
|
|
3957
4001
|
renderAutoCheckin();
|
|
3958
4002
|
renderGrowth();
|
|
3959
4003
|
renderComposerPoints();
|
|
3960
|
-
renderRewriteClientName();
|
|
3961
4004
|
renderHostHint();
|
|
3962
4005
|
renderRegionTabs();
|
|
3963
4006
|
renderModelRegionTabs();
|
|
@@ -3986,9 +4029,13 @@ function render() {
|
|
|
3986
4029
|
}
|
|
3987
4030
|
// A pending pass whose poll was stopped (or never started) gets its watcher
|
|
3988
4031
|
// back here: every state adoption ends in this render, and the log row is the
|
|
3989
|
-
// 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.
|
|
3990
4034
|
if (state && state.autoCheckin && state.autoCheckin.last && state.autoCheckin.last.pending === true) {
|
|
3991
4035
|
pollCheckinLog(checkinPollAttempts);
|
|
4036
|
+
} else if (checkinBusyNote) {
|
|
4037
|
+
checkinBusyNote = false;
|
|
4038
|
+
if (bannerText === t("pool.checkinAllBusy")) note(null);
|
|
3992
4039
|
}
|
|
3993
4040
|
}
|
|
3994
4041
|
|
|
@@ -4043,7 +4090,15 @@ function runBusy(id, work) {
|
|
|
4043
4090
|
render();
|
|
4044
4091
|
return work().then(function (result) {
|
|
4045
4092
|
busy = null;
|
|
4046
|
-
|
|
4093
|
+
// A host answer may still be detecting behind the click. Adopt it through
|
|
4094
|
+
// the same polling path the initial open uses, but only when it actually
|
|
4095
|
+
// reports that state: most settings/reset answers omit `refreshing`, and
|
|
4096
|
+
// adopting those here must not cancel a poll already running.
|
|
4097
|
+
if (result && result.accounts && typeof result.refreshing === "boolean") {
|
|
4098
|
+
adoptAndMaybePoll(result, 0);
|
|
4099
|
+
} else if (result && result.accounts) {
|
|
4100
|
+
adopt(result);
|
|
4101
|
+
}
|
|
4047
4102
|
if (result && result.stale === true) note(t("err.stale"), "warn");
|
|
4048
4103
|
else note(null);
|
|
4049
4104
|
render();
|
|
@@ -4158,7 +4213,14 @@ function pageIsVisible() {
|
|
|
4158
4213
|
/** Keep reading the log while a check-in pass is still marked pending. */
|
|
4159
4214
|
function pollCheckinLog(attempts) {
|
|
4160
4215
|
var last = state && state.autoCheckin && state.autoCheckin.last;
|
|
4161
|
-
if (!last || last.pending !== true || !pageIsVisible()) {
|
|
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
|
+
}
|
|
4162
4224
|
// Progress is counted per pass: a new `at` starts a fresh fast window, and a
|
|
4163
4225
|
// failure count from the previous pass would otherwise cut the new one short.
|
|
4164
4226
|
var stamp = typeof last.at === "string" ? last.at : "";
|
|
@@ -4277,12 +4339,6 @@ function setComposerPoints(enabled) {
|
|
|
4277
4339
|
}).catch(function () {});
|
|
4278
4340
|
}
|
|
4279
4341
|
|
|
4280
|
-
function setRewriteClientName(enabled) {
|
|
4281
|
-
return runBusy("rewrite", function () {
|
|
4282
|
-
return invoke("xd.setRewriteClientName", { enabled: enabled === true });
|
|
4283
|
-
}).catch(function () {});
|
|
4284
|
-
}
|
|
4285
|
-
|
|
4286
4342
|
/** Switch one source (workbuddy / trae / qoder) on or off; the answer is the refreshed document. */
|
|
4287
4343
|
function setSource(source, enabled) {
|
|
4288
4344
|
return runBusy("source", function () {
|
|
@@ -4351,7 +4407,7 @@ function claimCheckin(accountId) {
|
|
|
4351
4407
|
note(null);
|
|
4352
4408
|
render();
|
|
4353
4409
|
if (payload && payload.result && payload.result.credit > 0) {
|
|
4354
|
-
|
|
4410
|
+
note(t("checkin.claimed", { credit: payload.result.credit }));
|
|
4355
4411
|
}
|
|
4356
4412
|
}).catch(function (error) {
|
|
4357
4413
|
checkinBusy = null;
|
|
@@ -4371,14 +4427,16 @@ function claimAllCheckins() {
|
|
|
4371
4427
|
note(null);
|
|
4372
4428
|
render();
|
|
4373
4429
|
if (payload && payload.running === true) {
|
|
4374
|
-
|
|
4430
|
+
checkinBusyNote = true;
|
|
4431
|
+
note(t("pool.checkinAllBusy"));
|
|
4432
|
+
pollCheckinLog(0);
|
|
4375
4433
|
return;
|
|
4376
4434
|
}
|
|
4377
4435
|
var claimed = payload && typeof payload.claimed === "number" ? payload.claimed : 0;
|
|
4378
4436
|
var failed = payload && typeof payload.failed === "number" ? payload.failed : 0;
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
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 }));
|
|
4382
4440
|
}).catch(function (error) {
|
|
4383
4441
|
checkinBusy = null;
|
|
4384
4442
|
note(String(error && error.message ? error.message : error));
|
|
@@ -4496,6 +4554,12 @@ function saveModels() {
|
|
|
4496
4554
|
invoke("xd.saveModels", {
|
|
4497
4555
|
gateway: page.key,
|
|
4498
4556
|
selection: { enabledModelIds: enabledModelIds, overrides: overrides },
|
|
4557
|
+
// The models this page actually showed. A roster read can be partial (the
|
|
4558
|
+
// static fallback while the live list is still unread, or a directory that
|
|
4559
|
+
// answered with fewer rows), and the host keeps the stored entries for the
|
|
4560
|
+
// ids this page could not display instead of reading their absence as a
|
|
4561
|
+
// deliberate removal.
|
|
4562
|
+
knownModelIds: page.list.map(function (model) { return model.id; }),
|
|
4499
4563
|
}).then(function (next) {
|
|
4500
4564
|
busy = null;
|
|
4501
4565
|
adopt(next);
|
|
@@ -4650,14 +4714,6 @@ function bind() {
|
|
|
4650
4714
|
setComposerPoints(state === null || state.showComposerPoints !== true);
|
|
4651
4715
|
});
|
|
4652
4716
|
}
|
|
4653
|
-
// Same shape: a static node, so the listener is bound once and the state is
|
|
4654
|
-
// read at click time rather than captured from the render that drew the label.
|
|
4655
|
-
var rewriteToggle = $("rewriteClientName");
|
|
4656
|
-
if (rewriteToggle) {
|
|
4657
|
-
rewriteToggle.addEventListener("click", function () {
|
|
4658
|
-
setRewriteClientName(state === null || typeof state.replacedClientName !== "string");
|
|
4659
|
-
});
|
|
4660
|
-
}
|
|
4661
4717
|
// Bound once, with the state read at click time: this is a static node, so the
|
|
4662
4718
|
// handler cannot live in the render pass that redraws it.
|
|
4663
4719
|
$("autoHours").addEventListener("input", function () {
|
|
@@ -4697,14 +4753,13 @@ function bind() {
|
|
|
4697
4753
|
// re-attached on every pass. Capture phase, so it runs before the button's own
|
|
4698
4754
|
// handler and records the press even when that handler is about to disable it.
|
|
4699
4755
|
document.addEventListener("pointerdown", function (event) {
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
}
|
|
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));
|
|
4708
4763
|
}, true);
|
|
4709
4764
|
|
|
4710
4765
|
var viewTabs = document.querySelectorAll("#viewTabs .subtab");
|