dsh-wtq-pool 1.0.2 → 1.0.4

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。WorkBuddy 被限流时自动换号。三家各有开关,国内与国际各自成组。",
5
- "version": "1.0.2",
5
+ "version": "1.0.4",
6
6
  "license": "MIT",
7
7
  "author": "chengzhi-c",
8
8
  "homepage": "https://github.com/chengzhi-c/dsh-wtq-pool#readme",
@@ -26,7 +26,7 @@
26
26
  "type": "module",
27
27
  "engines": {
28
28
  "node": "^22.19.0 || >=24.0.0",
29
- "dsh": ">=0.1.7-rc.1 <0.3.0"
29
+ "dsh": ">=0.2.0-rc.1 <0.2.1"
30
30
  },
31
31
  "main": "lib/index.js",
32
32
  "types": "lib/index.d.ts",
@@ -50,6 +50,7 @@
50
50
  ],
51
51
  "scripts": {
52
52
  "build": "tsdown",
53
+ "prepare": "pnpm run build",
53
54
  "prepack": "tsdown",
54
55
  "prepublishOnly": "tsdown",
55
56
  "typecheck": "tsc -p tsconfig.json --noEmit",
@@ -73,11 +74,6 @@
73
74
  },
74
75
  "devDependencies": {
75
76
  "@deepseek-ai/cordis": "^4.0.4",
76
- "@deepseek-ai/dsh-client-locale": "0.2.0-rc.2",
77
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.2",
78
- "@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.2",
79
- "@deepseek-ai/dsh-client-ui-settings-plugins": "0.2.0-rc.2",
80
- "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.2",
81
77
  "@deepseek-ai/dsh-host-webserver": "0.2.0-rc.2",
82
78
  "@deepseek-ai/dsh-llm": "0.2.0-rc.2",
83
79
  "@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
@@ -92,30 +88,15 @@
92
88
  },
93
89
  "peerDependencies": {
94
90
  "@deepseek-ai/cordis": ">=4.0.4 <5.0.0",
95
- "@deepseek-ai/dsh-llm": ">=0.2.0-rc.1 <0.3.0",
96
- "@deepseek-ai/dsh-llm-pi-ai": ">=0.2.0-rc.1 <0.3.0",
97
- "@deepseek-ai/dsh-settings": ">=0.2.0-rc.1 <0.3.0",
91
+ "@deepseek-ai/dsh-llm": ">=0.2.0-rc.1 <0.2.1",
92
+ "@deepseek-ai/dsh-llm-pi-ai": ">=0.2.0-rc.1 <0.2.1",
93
+ "@deepseek-ai/dsh-settings": ">=0.2.0-rc.1 <0.2.1",
98
94
  "@deepseek-ai/schemastery": "^3.18.4",
99
- "@earendil-works/pi-ai": ">=0.87.1 <0.88.0"
95
+ "@earendil-works/pi-ai": ">=0.82.1 <0.88.0"
100
96
  },
101
97
  "peerDependenciesMeta": {
102
- "@deepseek-ai/cordis": {
103
- "optional": true
104
- },
105
- "@deepseek-ai/dsh-llm": {
106
- "optional": true
107
- },
108
- "@deepseek-ai/dsh-llm-pi-ai": {
109
- "optional": true
110
- },
111
98
  "@deepseek-ai/dsh-settings": {
112
99
  "optional": true
113
- },
114
- "@deepseek-ai/schemastery": {
115
- "optional": true
116
- },
117
- "@earendil-works/pi-ai": {
118
- "optional": true
119
100
  }
120
101
  }
121
102
  }
package/renderer/panel.js CHANGED
@@ -57,6 +57,7 @@ var EN = {
57
57
  "pool.checkinAllBusy": "Checking in…",
58
58
  "pool.checkinAllDone": "Checked in {count} account(s)",
59
59
  "pool.checkinAllNone": "Every account is already checked in today",
60
+ "pool.checkinAllFailed": "Checked in {count}, {failed} failed",
60
61
  "pool.emptyRegion": "No {region} account is signed in yet.",
61
62
  "pool.emptyHint": "Sign in to that edition in the WorkBuddy desktop app, then press “Detect accounts again”.",
62
63
  "pool.sourceOff": "The WorkBuddy source is switched off in plugin settings.",
@@ -90,6 +91,7 @@ var EN = {
90
91
  "source.checkedIn": "Checked in today",
91
92
  "source.claimable": "Can claim today",
92
93
  "source.noCampaign": "no daily check-in",
94
+ "source.campaignUnknown": "check-in state unavailable",
93
95
  "source.claimableAt": "Can claim after {time}",
94
96
  "source.deviceCheckedIn": "This device checked in today",
95
97
  "qoder.fallback": "using a spare port; the provider row still names {port}",
@@ -237,6 +239,7 @@ var EN = {
237
239
  "foot.docs": "Docs",
238
240
  "foot.license": "License",
239
241
  "err.bridge": "The panel bridge is unavailable.",
242
+ "err.busy": "The panel is busy with another action; try again in a moment.",
240
243
  "tag.free": "free",
241
244
  "tag.rate": "x{rate}",
242
245
  "tag.promoNight": "free until {hour}",
@@ -281,6 +284,7 @@ var ZH = {
281
284
  "pool.checkinAllBusy": "签到中…",
282
285
  "pool.checkinAllDone": "已签到 {count} 个账号",
283
286
  "pool.checkinAllNone": "所有账号今天都已签到",
287
+ "pool.checkinAllFailed": "已签到 {count} 个,{failed} 个失败",
284
288
  "pool.emptyRegion": "{region}这一侧还没有登录的账号。",
285
289
  "pool.emptyHint": "请在该版本的 WorkBuddy 桌面 App 里登录,再点「重新检测账号」。",
286
290
  "pool.sourceOff": "WorkBuddy 来源已在插件设置里关闭。",
@@ -314,6 +318,7 @@ var ZH = {
314
318
  "source.claimable": "今日可签到",
315
319
  "source.noAccounts": "未找到本机登录",
316
320
  "source.noCampaign": "该账号无签到活动",
321
+ "source.campaignUnknown": "签到状态读取失败",
317
322
  "source.deviceCheckedIn": "本机今日已签到",
318
323
  "qoder.fallback": "用的是备用端口;供应商行仍指向 {port}",
319
324
  "badge.next": "下一个",
@@ -461,6 +466,7 @@ var ZH = {
461
466
  "foot.docs": "文档",
462
467
  "foot.license": "许可",
463
468
  "err.bridge": "面板桥不可用。",
469
+ "err.busy": "面板正在处理其他操作,请稍候再试。",
464
470
  "tag.free": "免费",
465
471
  "tag.rate": "x{rate}",
466
472
  "tag.promoNight": "夜间免费 · 到 {hour}",
@@ -589,6 +595,12 @@ function clockHour(hour) {
589
595
  return (value < 10 ? "0" : "") + value + ":00";
590
596
  }
591
597
 
598
+ /**
599
+ * The banner text currently shown, so a later pass can tell its own message
600
+ * from one another action put up (or cleared).
601
+ */
602
+ var bannerText = "";
603
+
592
604
  /**
593
605
  * Show the banner. A failure reaching the panel arrives wrapped in whatever
594
606
  * envelope the bridge used; the reason itself is what the user needs, so the
@@ -596,10 +608,11 @@ function clockHour(hour) {
596
608
  */
597
609
  function note(message, kind) {
598
610
  var banner = $("banner");
599
- if (!message) { show(banner, false); banner.textContent = ""; return; }
611
+ if (!message) { show(banner, false); banner.textContent = ""; bannerText = ""; return; }
600
612
  banner.textContent = String(message)
601
613
  .replace(/^Error invoking remote method '[^']*':\s*/, "")
602
614
  .replace(/^Error:\s*/, "");
615
+ bannerText = banner.textContent;
603
616
  banner.className = kind === "warn" ? "banner warn" : "banner";
604
617
  show(banner, true);
605
618
  }
@@ -644,6 +657,8 @@ var draftSlot = null;
644
657
  var busy = null; // id of the control awaiting a response
645
658
  var checkinBusy = null;
646
659
  var doctorResult = null;
660
+ /** Hours text typed but not yet saved, so a poll cannot overwrite it. */
661
+ var autoHoursDraft = null;
647
662
  /** Account ids whose credit package list the user opened. Absent = collapsed. */
648
663
  var openCredits = {};
649
664
  /** The warning the header banner is currently showing, so it can be cleared. */
@@ -711,7 +726,7 @@ function renderHeader() {
711
726
  // away would keep naming a problem the state document no longer reports. Only
712
727
  // the banner this pass itself last showed is cleared, so a message another
713
728
  // action put up is not wiped by the poll landing behind it.
714
- if (warning !== headerWarning) {
729
+ if (warning !== headerWarning || (warning !== "" && bannerText === "")) {
715
730
  headerWarning = warning;
716
731
  note(warning === "" ? null : warning, "warn");
717
732
  }
@@ -1063,7 +1078,8 @@ function sourceAccountCard(account, kind) {
1063
1078
  ? t("source.checkedIn")
1064
1079
  : deviceDone ? t("source.deviceCheckedIn")
1065
1080
  : opensLabel !== "" ? opensLabel
1066
- : checkin.active ? t("source.claimable") : t("source.noCampaign")));
1081
+ : checkin.campaignsUnavailable === true ? t("source.campaignUnknown")
1082
+ : checkin.active ? t("source.claimable") : t("source.noCampaign")));
1067
1083
  if (!doneToday && checkin.active && checkin.amount > 0) {
1068
1084
  row.appendChild(el("span", "muted", checkin.amount + " "
1069
1085
  + (checkin.unit === undefined || checkin.unit === "credits" ? t("credits.keepUnit") : checkin.unit)));
@@ -1265,7 +1281,15 @@ function claimSourceCheckins(source) {
1265
1281
  }
1266
1282
  var counts = payload ? payload[source] : null;
1267
1283
  var claimed = counts && typeof counts.claimed === "number" ? counts.claimed : 0;
1268
- announce(claimed > 0 ? t("pool.checkinAllDone", { count: claimed }) : t("pool.checkinAllNone"));
1284
+ var failed = counts && typeof counts.failed === "number" ? counts.failed : 0;
1285
+ // A round that failed used to read as "every account is already checked in
1286
+ // today": the counts carry `failed` (and the reason), a source whose round
1287
+ // threw carries none of its own, and the panel read the missing number as
1288
+ // "nothing to collect". The user was told the day was done while nothing
1289
+ // had been collected.
1290
+ announce(failed > 0
1291
+ ? checkinFailureText(claimed, failed, counts && counts.reason)
1292
+ : claimed > 0 ? t("pool.checkinAllDone", { count: claimed }) : t("pool.checkinAllNone"));
1269
1293
  }).catch(function (error) {
1270
1294
  checkinBusy = null;
1271
1295
  note(String(error && error.message ? error.message : error));
@@ -1273,6 +1297,17 @@ function claimSourceCheckins(source) {
1273
1297
  });
1274
1298
  }
1275
1299
 
1300
+ /**
1301
+ * What to say when a check-in round reports failures.
1302
+ *
1303
+ * The counts alone cannot name the cause, and the upstream's own words are
1304
+ * worth more than "failed": the reason is appended when the host has one.
1305
+ */
1306
+ function checkinFailureText(claimed, failed, reason) {
1307
+ var text = t("pool.checkinAllFailed", { count: claimed, failed: failed });
1308
+ return typeof reason === "string" && reason !== "" ? text + " · " + reason : text;
1309
+ }
1310
+
1276
1311
  /** The busy key of one source account row: source, region and label together. */
1277
1312
  function sourceCheckinKey(source, account) {
1278
1313
  return source + ":" + account.region + ":" + account.label;
@@ -1385,7 +1420,9 @@ function renderAutoCheckin() {
1385
1420
  $("autoHoursLabel").textContent = t("auto.hours");
1386
1421
  var input = $("autoHours");
1387
1422
  input.placeholder = t("auto.hoursHint");
1388
- if (document.activeElement !== input) input.value = (auto.hours || []).join(",");
1423
+ if (document.activeElement !== input) {
1424
+ input.value = autoHoursDraft !== null ? autoHoursDraft : (auto.hours || []).join(",");
1425
+ }
1389
1426
  var save = $("autoHoursSave");
1390
1427
  save.textContent = t("auto.hoursSave");
1391
1428
  save.disabled = busy !== null;
@@ -1448,9 +1485,14 @@ function autoNoteRows(auto) {
1448
1485
  if (last.error) return [{ text: t("auto.lastFailedAt", { slot: slot, message: last.error }), tone: "fail" }];
1449
1486
  var rows = [];
1450
1487
  if (last.pending === true) rows.push({ text: t("auto.running"), tone: "" });
1488
+ // The head count is every source's claimed accounts, matching the rows
1489
+ // below; `last.claimed` alone is WorkBuddy's share and read as a total.
1490
+ var claimedTotal = (Number(last.claimed) || 0)
1491
+ + (last.qoder ? Number(last.qoder.claimed) || 0 : 0)
1492
+ + (last.trae ? Number(last.trae.claimed) || 0 : 0);
1451
1493
  rows.push({
1452
1494
  text: t(last.manual === true ? "auto.lastManual" : "auto.lastAuto",
1453
- { slot: slot, count: Number(last.claimed) || 0 }),
1495
+ { slot: slot, count: claimedTotal }),
1454
1496
  tone: last.pending === true ? "" : "ok",
1455
1497
  });
1456
1498
  var push = function (label, counts) {
@@ -1505,6 +1547,11 @@ function autoNoteRows(auto) {
1505
1547
 
1506
1548
  /** Paint the check-in log as rows, so the caller does not build markup inline. */
1507
1549
  function paintAutoNote(host, auto) {
1550
+ // A user who scrolled up to read an older line must not be pulled back to the
1551
+ // bottom by every 2 s poll; only a new pass (row count change) or a box that
1552
+ // was already at the bottom follows the tail.
1553
+ var atBottom = host.scrollTop + host.clientHeight >= host.scrollHeight - 4;
1554
+ var rowCount = host.childElementCount;
1508
1555
  clear(host);
1509
1556
  autoNoteRows(auto).forEach(function (row) {
1510
1557
  var line = el("div", "log-line" + (row.tone ? " " + row.tone : ""));
@@ -1512,10 +1559,7 @@ function paintAutoNote(host, auto) {
1512
1559
  line.appendChild(el("span", "log-text", row.text));
1513
1560
  host.appendChild(line);
1514
1561
  });
1515
- // The log is a scroll region capped at a few rows, so a fresh pass would
1516
- // otherwise leave the newest line - the one the user just waited for - below
1517
- // the fold.
1518
- host.scrollTop = host.scrollHeight;
1562
+ if (host.childElementCount !== rowCount || atBottom) host.scrollTop = host.scrollHeight;
1519
1563
  }
1520
1564
  function renderAccounts() {
1521
1565
  var host = $("accounts");
@@ -2060,8 +2104,18 @@ function renderModels() {
2060
2104
  var key = page.source + "\u0000" + page.key + "\u0000"
2061
2105
  + list.map(function (model) { return model.id; }).sort().join("\u0000");
2062
2106
  var slot = page.source + "\u0000" + page.key;
2063
- if (drafts[slot] === undefined || drafts[slot].key !== key) {
2107
+ if (drafts[slot] === undefined) {
2064
2108
  drafts[slot] = { key: key, draft: draftFor(list, page.selection) };
2109
+ } else if (drafts[slot].key !== key) {
2110
+ // The roster changed under an open draft (a catalog refresh, a fetch): keep
2111
+ // the user's unsaved ticks and overrides for every id that survived, and
2112
+ // start newly listed ids from the saved selection. Replacing the whole
2113
+ // draft silently discarded edits the savebar was still offering to save.
2114
+ var fresh = draftFor(list, page.selection);
2115
+ Object.keys(fresh).forEach(function (id) {
2116
+ if (Object.prototype.hasOwnProperty.call(drafts[slot].draft, id)) fresh[id] = drafts[slot].draft[id];
2117
+ });
2118
+ drafts[slot] = { key: key, draft: fresh };
2065
2119
  }
2066
2120
  draft = drafts[slot].draft;
2067
2121
  draftSlot = slot;
@@ -2509,8 +2563,9 @@ function modelSheetBody(model, entry) {
2509
2563
  body.appendChild(pair);
2510
2564
 
2511
2565
  // Thinking levels: only a model whose catalog offers a reason menu gets the
2512
- // control. Trae and Qoder report no levels at all, so a menu there could
2513
- // never take effect.
2566
+ // control. WorkBuddy reports its own table, and Trae and Qoder advertise
2567
+ // theirs through the gateway, so the menu appears wherever the upstream
2568
+ // actually offers levels and the save reaches the declaration.
2514
2569
  var levels = effectiveLevels(model, entry);
2515
2570
  if (levels.length > 0) {
2516
2571
  var levelsWrap = el("div", "field");
@@ -2780,6 +2835,12 @@ function render() {
2780
2835
  lastPressed = null;
2781
2836
  }
2782
2837
  }
2838
+ // A pending pass whose poll was stopped (or never started) gets its watcher
2839
+ // back here: every state adoption ends in this render, and the log row is the
2840
+ // only thing that reports the pass as running.
2841
+ if (state && state.autoCheckin && state.autoCheckin.last && state.autoCheckin.last.pending === true) {
2842
+ pollCheckinLog(checkinPollAttempts);
2843
+ }
2783
2844
  }
2784
2845
 
2785
2846
  // ---------------------------------------------------------------- actions
@@ -2794,7 +2855,14 @@ function adopt(next) {
2794
2855
  }
2795
2856
 
2796
2857
  function runBusy(id, work) {
2797
- if (busy !== null) return Promise.reject(new Error("panel is busy"));
2858
+ // A second action while one is running used to reject here and nowhere else:
2859
+ // every caller answers with its own `.catch(function () {})`, so the click did
2860
+ // nothing and said nothing. The banner is raised here, once, so a busy panel
2861
+ // answers every control the same way.
2862
+ if (busy !== null) {
2863
+ note(t("err.busy"), "warn");
2864
+ return Promise.reject(new Error("panel is busy"));
2865
+ }
2798
2866
  notePress(document.activeElement);
2799
2867
  busy = id;
2800
2868
  render();
@@ -2840,7 +2908,15 @@ function adoptAndMaybePoll(next, attempts) {
2840
2908
  adopt(next);
2841
2909
  render();
2842
2910
  if (!next || next.refreshing !== true) { stopPolling(); return; }
2843
- if (attempts >= 15) { stopPolling(); return; }
2911
+ if (attempts >= 15) {
2912
+ // Giving up on the pass, not on the document. Leaving `refreshing` set here
2913
+ // left the header saying "detecting…" for good: nothing else comes back for
2914
+ // it, so the flag had to be cleared by the one who stopped watching.
2915
+ stopPolling();
2916
+ adopt(next && typeof next === "object" ? Object.assign({}, next, { refreshing: false }) : next);
2917
+ render();
2918
+ return;
2919
+ }
2844
2920
  stopPolling();
2845
2921
  refreshPoll = window.setTimeout(function () {
2846
2922
  refreshPoll = null;
@@ -2858,6 +2934,9 @@ function adoptAndMaybePoll(next, attempts) {
2858
2934
  var checkinPoll = null;
2859
2935
  var CHECKIN_POLL_MS = 2000;
2860
2936
  var CHECKIN_POLL_LIMIT = 90;
2937
+ var CHECKIN_POLL_SLOW_MS = 10000;
2938
+ var checkinPollAttempts = 0;
2939
+ var checkinPollAt = null;
2861
2940
 
2862
2941
  function stopCheckinPoll() {
2863
2942
  if (checkinPoll !== null) {
@@ -2870,20 +2949,30 @@ function stopCheckinPoll() {
2870
2949
  function pollCheckinLog(attempts) {
2871
2950
  var last = state && state.autoCheckin && state.autoCheckin.last;
2872
2951
  if (!last || last.pending !== true) { stopCheckinPoll(); return; }
2952
+ // Progress is counted per pass: a new `at` starts a fresh fast window.
2953
+ var stamp = typeof last.at === "string" ? last.at : "";
2954
+ if (stamp !== checkinPollAt) { checkinPollAt = stamp; attempts = 0; }
2955
+ checkinPollAttempts = attempts;
2956
+ // A pass running beside another action is not a reason to stop watching it,
2957
+ // but the poll must not run while that action re-renders. `runBusy` calls
2958
+ // back here when it finishes, so dropping the timer now is safe.
2873
2959
  if (busy !== null && busy !== "checkin") { stopCheckinPoll(); return; }
2874
- if (attempts >= CHECKIN_POLL_LIMIT) { stopCheckinPoll(); return; }
2875
2960
  if (checkinPoll !== null) return;
2961
+ // Past the fast window the pass is either long or wedged; keep a slow watch
2962
+ // instead of giving up, or the row reads "running" for the rest of the day.
2963
+ var delay = attempts >= CHECKIN_POLL_LIMIT ? CHECKIN_POLL_SLOW_MS : CHECKIN_POLL_MS;
2876
2964
  checkinPoll = window.setTimeout(function () {
2877
2965
  checkinPoll = null;
2878
2966
  var revision = stateRevision;
2879
2967
  invoke("xd.state").then(function (again) {
2880
2968
  if (revision !== stateRevision) { pollCheckinLog(attempts + 1); return; }
2881
- if (busy !== null && busy !== "checkin") return;
2969
+ // Another action adopted the state; its own render re-arms the watch.
2970
+ if (busy !== null && busy !== "checkin") { stopCheckinPoll(); return; }
2882
2971
  adopt(again);
2883
2972
  render();
2884
2973
  pollCheckinLog(attempts + 1);
2885
- }).catch(function () { stopCheckinPoll(); });
2886
- }, CHECKIN_POLL_MS);
2974
+ }).catch(function () { pollCheckinLog(attempts + 1); });
2975
+ }, delay);
2887
2976
  }
2888
2977
 
2889
2978
  function refresh() {
@@ -2998,6 +3087,11 @@ function setAutoCheckin(enabled, hours) {
2998
3087
  }
2999
3088
  return runBusy("autoCheckin", function () {
3000
3089
  return invoke("xd.setAutoCheckin", { enabled: enabled === true, hours: hours });
3090
+ }).then(function (result) {
3091
+ // Saved: the field now follows the host's value again.
3092
+ autoHoursDraft = null;
3093
+ render();
3094
+ return result;
3001
3095
  }).catch(function () {});
3002
3096
  }
3003
3097
  function claimCheckin(accountId) {
@@ -3036,7 +3130,10 @@ function claimAllCheckins() {
3036
3130
  return;
3037
3131
  }
3038
3132
  var claimed = payload && typeof payload.claimed === "number" ? payload.claimed : 0;
3039
- announce(claimed > 0 ? t("pool.checkinAllDone", { count: claimed }) : t("pool.checkinAllNone"));
3133
+ var failed = payload && typeof payload.failed === "number" ? payload.failed : 0;
3134
+ announce(failed > 0
3135
+ ? checkinFailureText(claimed, failed, payload && payload.reason)
3136
+ : claimed > 0 ? t("pool.checkinAllDone", { count: claimed }) : t("pool.checkinAllNone"));
3040
3137
  }).catch(function (error) {
3041
3138
  checkinBusy = null;
3042
3139
  note(String(error && error.message ? error.message : error));
@@ -3081,6 +3178,29 @@ function toggleAllVisible() {
3081
3178
  function fetchModelList() {
3082
3179
  return runBusy("fetch", function () { return invoke("xd.rescan"); }).catch(function () {});
3083
3180
  }
3181
+
3182
+ /**
3183
+ * Ask the plugin for a live model roster, silently, once per panel.
3184
+ *
3185
+ * Opening the panel is when the list has to be right: a roster read that timed
3186
+ * out while the host was starting leaves the plugin's static fallback in force,
3187
+ * and the model page then listed the fallback's own models and reported the
3188
+ * user's saved choice as retired - on every start, until a manual fetch. The
3189
+ * model page keeps its own "fetch list" button for a deliberate re-read.
3190
+ */
3191
+ var modelRosterRequested = false;
3192
+ function requestModelRoster() {
3193
+ if (modelRosterRequested || bridge === null) return;
3194
+ modelRosterRequested = true;
3195
+ invoke("xd.fetchModels").then(function (next) {
3196
+ adoptAndMaybePoll(next, 0);
3197
+ }).catch(function (error) {
3198
+ // A failed read must not latch the panel onto the static fallback for the
3199
+ // rest of its life: release the guard so the next visit tries again.
3200
+ modelRosterRequested = false;
3201
+ note(String(error && error.message ? error.message : error), "warn");
3202
+ });
3203
+ }
3084
3204
  function discardDraft() {
3085
3205
  // Only the page in view: another page's unsaved edits are not this button's to
3086
3206
  // throw away.
@@ -3202,7 +3322,12 @@ function selectTab(name) {
3202
3322
  tabs[i].className = isActive ? "subtab active" : "subtab";
3203
3323
  tabs[i].setAttribute("aria-selected", isActive ? "true" : "false");
3204
3324
  }
3205
- if (name === "check" && doctorResult === null) runDoctor();
3325
+ // Entering the tab while another action runs would raise the busy banner and
3326
+ // silently skip the doctor; the next entry retries.
3327
+ if (name === "check" && doctorResult === null && busy === null) runDoctor();
3328
+ // The model page shows a roster, so entering it is the moment to make sure
3329
+ // that roster is the vendor's and not this plugin's own fallback.
3330
+ if (name === "models") requestModelRoster();
3206
3331
  }
3207
3332
 
3208
3333
  function labelTabs() {
@@ -3243,6 +3368,9 @@ function bind() {
3243
3368
  }
3244
3369
  // Bound once, with the state read at click time: this is a static node, so the
3245
3370
  // handler cannot live in the render pass that redraws it.
3371
+ $("autoHours").addEventListener("input", function () {
3372
+ autoHoursDraft = $("autoHours").value;
3373
+ });
3246
3374
  $("autoHoursSave").addEventListener("click", function () {
3247
3375
  var auto = (state && state.autoCheckin) || { enabled: false };
3248
3376
  setAutoCheckin(auto.enabled === true, parseCheckinHours($("autoHours").value));
@@ -3323,6 +3451,9 @@ function boot() {
3323
3451
  invoke("xd.state").then(function (next) {
3324
3452
  adoptAndMaybePoll(next, 0);
3325
3453
  pollCheckinLog(0);
3454
+ // After the first document, so a panel opened while the plugin process is
3455
+ // still starting does not burn its one roster request on a dead bridge.
3456
+ requestModelRoster();
3326
3457
  }).catch(function (error) {
3327
3458
  bootAttempts += 1;
3328
3459
  if (bootAttempts < 4) {