dsh-connect-workbuddy 5.17.0 → 5.18.2

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/lib/client.js CHANGED
@@ -980,6 +980,57 @@ window.__ModuleLoader__.load({
980
980
  throw hostError instanceof Error ? hostError : new WorkBuddySettingsWriteError("cliBridge", "neither the Host save endpoint nor the settings scope persisted the value");
981
981
  }
982
982
  /**
983
+ * Read the opt-in DSH sidebar panel switch out of a settings snapshot.
984
+ *
985
+ * Only an explicit `true` is ON, matching the schema's `default(false)` and
986
+ * every other switch in this file: the row claims a GLOBAL sidebar seat shared
987
+ * by every installed bundle, so an absent or malformed value must read as
988
+ * "did not ask for this", never as consent.
989
+ *
990
+ * @param configured - the whole settings snapshot.
991
+ * @returns whether the panel row should exist.
992
+ */
993
+ function sidebarPanelEnabledOf(configured) {
994
+ const value = configured?.["sidebarPanel"];
995
+ return unwrapVolatileDeep(value) === true;
996
+ }
997
+ /**
998
+ * Write the opt-in DSH sidebar panel switch, verifying it landed.
999
+ *
1000
+ * Same two writers and same reasoning as {@link writeCliBridgeEnabled}: the
1001
+ * Host endpoint first (it is the authoritative merge and reports its own
1002
+ * refusal), the settings scope second, because this namespace's browser mirror
1003
+ * is documented as stale on the affected 0.1.7 deployments — and a sidebar row
1004
+ * that merely *looks* present while the Host disagrees is worse than no row.
1005
+ *
1006
+ * A plain top-level boolean, so it is set on its own path; there is no sibling
1007
+ * state inside the field to preserve.
1008
+ *
1009
+ * @param scope - the bound settings scope for this plugin's namespace.
1010
+ * @param enabled - the desired state.
1011
+ * @throws {WorkBuddySettingsWriteError} when neither writer persists the value.
1012
+ */
1013
+ async function writeSidebarPanelEnabled(scope, enabled) {
1014
+ let hostError;
1015
+ try {
1016
+ const authoritative = await saveViaHostEndpoint("sidebarPanel", void 0, enabled);
1017
+ if (authoritative !== void 0) try {
1018
+ await scope.set("sidebarPanel", authoritative["sidebarPanel"]);
1019
+ } catch {}
1020
+ return;
1021
+ } catch (error) {
1022
+ hostError = error;
1023
+ }
1024
+ let delivered = false;
1025
+ try {
1026
+ delivered = await scope.set("sidebarPanel", enabled) !== false;
1027
+ } catch {
1028
+ delivered = false;
1029
+ }
1030
+ if (delivered && sidebarPanelEnabledOf(scope.getSnapshot().value)) return;
1031
+ throw hostError instanceof Error ? hostError : new WorkBuddySettingsWriteError("sidebarPanel", "neither the Host save endpoint nor the settings scope persisted the value");
1032
+ }
1033
+ /**
983
1034
  * Read the CodeBuddy-CLI route's PINNED model out of a settings snapshot.
984
1035
  *
985
1036
  * `''` is a real answer here, not a missing one: it means "nothing is pinned,
@@ -1345,6 +1396,7 @@ window.__ModuleLoader__.load({
1345
1396
  orderAccountIds: preferences.orderAccountIds
1346
1397
  };
1347
1398
  if (preferences.probeInputTokens !== void 0) slot["probeInputTokens"] = preferences.probeInputTokens;
1399
+ if (preferences.autoCheckin !== void 0) slot["autoCheckin"] = preferences.autoCheckin;
1348
1400
  const next = nextRegionPool(scope.getSnapshot().value, region, slot)[region];
1349
1401
  await writeField(scope, "regions", region, next, (readBack) => {
1350
1402
  const pool = readBack?.pool;
@@ -1363,6 +1415,84 @@ window.__ModuleLoader__.load({
1363
1415
  });
1364
1416
  }
1365
1417
  //#endregion
1418
+ //#region src/client/panel-switch.ts
1419
+ /**
1420
+ * Whether the OPTIONAL sidebar panel is switched on, as the browser half sees
1421
+ * it, plus the tiny subscription the registration controller needs.
1422
+ *
1423
+ * ## Why this is a module-level store and not component state
1424
+ *
1425
+ * The `sidebar.panellist` row is built from ENTRY METADATA, not from the
1426
+ * component: `ui-sidebar`'s `SidebarRoot` maps `usePanels(...)` (the slot's
1427
+ * entries) into a `PanelRow` button whose label comes from `options.label` and
1428
+ * whose glyph is `renderSlot(...)`. A component that returns `null` therefore
1429
+ * does not hide the row — it renders a BLANK, still-clickable nav button. That
1430
+ * is why the panel cannot use the `ComposerCreditsGate` trick the composer
1431
+ * readout uses (that seat renders a list of components, so `null` means
1432
+ * absent). The row has to be registered only while the switch is on, and
1433
+ * unregistered when it goes off.
1434
+ *
1435
+ * Registering conditionally in turn means something must OWN the re-register on
1436
+ * a settings change, and that something lives in the entry (`apply`), not in a
1437
+ * component. This module is the seam between the two: the card writes a value
1438
+ * here after it has verified a write landed, and the entry subscribes to
1439
+ * register or dispose.
1440
+ *
1441
+ * ## Why the Host is the seed
1442
+ *
1443
+ * The value is DELIVERED by the Host on the status document
1444
+ * (`sidebarPanelEnabled`), for the reason every other switch in this plugin is
1445
+ * Host-carried: this namespace's browser mirror is documented as stale on the
1446
+ * affected 0.1.7 deployments. Reading only the settings scope at startup would
1447
+ * let a stale `false` hide a row the Host believes it is serving — with nothing
1448
+ * to re-evaluate it afterwards, the panel would then be gone for the session.
1449
+ *
1450
+ * Turning the panel OFF while the page is open needs no special handling here:
1451
+ * `ui-layout`'s `retainMainPanels` drops an `activePanelId` whose `main` key no
1452
+ * longer exists, so the centre column returns to the conversation by itself.
1453
+ */
1454
+ /** Listeners waiting for a change to the opt-in state. */
1455
+ const listeners = /* @__PURE__ */ new Set();
1456
+ /**
1457
+ * The current answer, defaulting to OFF.
1458
+ *
1459
+ * OFF is the whole point of this switch: an absent or unreadable value must
1460
+ * never turn the row on. See `Config.sidebarPanel` in `src/index.ts`.
1461
+ */
1462
+ let wanted = false;
1463
+ /** Whether the sidebar panel should currently be registered. */
1464
+ function sidebarPanelWanted() {
1465
+ return wanted;
1466
+ }
1467
+ /**
1468
+ * Set the opt-in state and notify the registration controller.
1469
+ *
1470
+ * Idempotent: the controller re-registers on every call, and a settings
1471
+ * subscription can legitimately report the same value twice. Callers that
1472
+ * cannot tell whether the value changed need not check first.
1473
+ *
1474
+ * @param next - the desired state.
1475
+ */
1476
+ function setSidebarPanelWanted(next) {
1477
+ if (wanted === next) return;
1478
+ wanted = next;
1479
+ for (const listener of [...listeners]) try {
1480
+ listener();
1481
+ } catch {}
1482
+ }
1483
+ /**
1484
+ * Observe changes to the opt-in state.
1485
+ *
1486
+ * @param listener - invoked after each change.
1487
+ * @returns the disposer removing this listener.
1488
+ */
1489
+ function subscribeSidebarPanelWanted(listener) {
1490
+ listeners.add(listener);
1491
+ return () => {
1492
+ listeners.delete(listener);
1493
+ };
1494
+ }
1495
+ //#endregion
1366
1496
  //#region src/client/manual-order.ts
1367
1497
  /**
1368
1498
  * Manual priority order, shared by every surface that lists member accounts.
@@ -2089,12 +2219,25 @@ window.__ModuleLoader__.load({
2089
2219
  sessionId
2090
2220
  };
2091
2221
  }
2222
+ const realTier = normalizeRealTier(body.realTier);
2092
2223
  return {
2093
2224
  mode: body.mode === "real" ? "real" : "virtual",
2094
2225
  accounts,
2095
2226
  ...body.derived === void 0 ? {} : { derived },
2096
2227
  sdkDir: typeof body.sdkDir === "string" ? body.sdkDir : "",
2097
- sdkFallbackToVirtual: body.sdkFallbackToVirtual !== false
2228
+ sdkFallbackToVirtual: body.sdkFallbackToVirtual !== false,
2229
+ ...realTier === void 0 ? {} : { realTier }
2230
+ };
2231
+ }
2232
+ /** 只接受三种已知状态;其它一律当"没这一项",不去猜。 */
2233
+ function normalizeRealTier(value) {
2234
+ if (typeof value !== "object" || value === null) return void 0;
2235
+ const record = value;
2236
+ const state = record["state"];
2237
+ if (state !== "available" && state !== "broken" && state !== "unavailable") return void 0;
2238
+ return {
2239
+ state,
2240
+ platform: typeof record["platform"] === "string" ? record["platform"] : ""
2098
2241
  };
2099
2242
  }
2100
2243
  /**
@@ -3094,7 +3237,14 @@ window.__ModuleLoader__.load({
3094
3237
  */
3095
3238
  function AccountPool(props) {
3096
3239
  const { t, region, pool, settingsScope, siblingBusy, onBusyChange, onSaved, onRefresh, onRescan, rescanning, onSelectAccount, selectingAccount, accountTools } = props;
3097
- const { deviceMode, deviceProfiles, deviceDerived, onDeviceModeChange, onSaveDeviceProfile } = props;
3240
+ const { deviceMode, deviceProfiles, deviceDerived, onDeviceModeChange, onSaveDeviceProfile, realTier } = props;
3241
+ /**
3242
+ * 「真实值」能不能用。`undefined`(老 Host 没这一项)必须落到 `true`——读不到就
3243
+ * 禁用等于替用户取消一个可能可用的功能。
3244
+ */
3245
+ const realTierUsable = realTier === void 0 ? true : realTier.state === "available";
3246
+ /** 当前正停在「真实值」但它已经不可用:把说明换成"用不了",而不是宣传语。 */
3247
+ const modeHintBlocked = realTierUsable === false && deviceMode === "real";
3098
3248
  const [draft, setDraft] = (0, react.useState)(null);
3099
3249
  const [saving, setSaving] = (0, react.useState)(false);
3100
3250
  const [saveError, setSaveError] = (0, react.useState)(void 0);
@@ -3131,7 +3281,8 @@ window.__ModuleLoader__.load({
3131
3281
  targetModelId: pool?.targetModelId || pool?.staleTargetModelId || "",
3132
3282
  probeInputTokens: pool?.probeInputTokens ?? 0,
3133
3283
  memberAccountIds: pool?.memberAccountIds ?? [],
3134
- orderAccountIds: pool?.orderAccountIds ?? []
3284
+ orderAccountIds: pool?.orderAccountIds ?? [],
3285
+ autoCheckin: pool?.autoCheckin === true
3135
3286
  };
3136
3287
  const active = draftRegion === region && draft !== null ? draft : saved;
3137
3288
  /**
@@ -3152,7 +3303,24 @@ window.__ModuleLoader__.load({
3152
3303
  * the pending edit.
3153
3304
  */
3154
3305
  const poolRunning = saved.enabled;
3155
- const dirty = draftRegion === region && draft !== null && (draft.enabled !== saved.enabled || draft.targetModelId !== saved.targetModelId || draft.probeInputTokens !== saved.probeInputTokens || !sameIds(draft.memberAccountIds, saved.memberAccountIds) || !sameOrder(draft.orderAccountIds, saved.orderAccountIds));
3306
+ const dirty = draftRegion === region && draft !== null && (draft.enabled !== saved.enabled || draft.targetModelId !== saved.targetModelId || draft.probeInputTokens !== saved.probeInputTokens || !sameIds(draft.memberAccountIds, saved.memberAccountIds) || !sameOrder(draft.orderAccountIds, saved.orderAccountIds) || draft.autoCheckin !== saved.autoCheckin);
3307
+ /**
3308
+ * The automatic check-in's progress line, or nothing.
3309
+ *
3310
+ * Read from the SAVED switch, not the draft: this describes what the runner is
3311
+ * doing, and a draft that says "on" has not started anything yet. Showing
3312
+ * progress for a switch that is not saved would claim a job was running.
3313
+ */
3314
+ const autoCheckinStatus = (() => {
3315
+ if (!saved.autoCheckin) return null;
3316
+ const today = pool?.autoCheckinToday;
3317
+ if (today === void 0) return null;
3318
+ const headline = today.pending === 0 && today.done === today.total ? t("row.poolAutoCheckinDone", { total: String(today.total) }) : t("row.poolAutoCheckinToday", {
3319
+ done: String(today.done),
3320
+ total: String(today.total)
3321
+ });
3322
+ return (0, react.createElement)("div", { className: "dsm-workbuddy-pool-auto-checkin-status" }, (0, react.createElement)("span", { className: "dsm-workbuddy-pool-auto-checkin-line" }, headline), today.pending === 0 ? null : (0, react.createElement)("span", { className: "dsm-workbuddy-pool-auto-checkin-pending" }, t("row.poolAutoCheckinPending", { count: String(today.pending) })), today.lastError === void 0 ? null : (0, react.createElement)("span", { className: "dsm-workbuddy-pool-auto-checkin-error" }, t("row.poolAutoCheckinFailed", { message: today.lastError })));
3323
+ })();
3156
3324
  /**
3157
3325
  * Membership that actually resolves to a local sign-in — what a batch runs on.
3158
3326
  *
@@ -3766,7 +3934,18 @@ window.__ModuleLoader__.load({
3766
3934
  enabled: next
3767
3935
  }));
3768
3936
  }
3769
- }), (0, react.createElement)("span", { className: "sw-track" })), (0, react.createElement)("b", { className: "dsm-workbuddy-pool-modebar-label" }, t("row.poolEnabled")), (0, react.createElement)("span", { className: "dsm-workbuddy-pool-modebar-state" }, poolRunning ? t("row.poolModeAuto") : t("row.poolModeManual")), dirty ? (0, react.createElement)("span", { className: "dsm-workbuddy-pool-dirty" }, t("row.poolDirty")) : null), (0, react.createElement)("p", { className: "dsm-workbuddy-pool-note" }, t("row.poolEnabledHint"))), poolRunning && currentAccount !== void 0 && !effectiveMembers.includes(currentAccount.accountId) ? (0, react.createElement)("p", { className: "dsm-workbuddy-pool-note dsm-workbuddy-pool-serving-note" }, t("row.poolServingOutside", { account: currentName ?? "" })) : null, poolRunning && effectiveMembers.length > 0 && usable.length === 0 ? allMembersBlockedByModel(pool?.accounts ?? [], effectiveMembers, active.memberAccountIds) ? (0, react.createElement)("p", {
3937
+ }), (0, react.createElement)("span", { className: "sw-track" })), (0, react.createElement)("b", { className: "dsm-workbuddy-pool-modebar-label" }, t("row.poolEnabled")), (0, react.createElement)("span", { className: "dsm-workbuddy-pool-modebar-state" }, poolRunning ? t("row.poolModeAuto") : t("row.poolModeManual")), dirty ? (0, react.createElement)("span", { className: "dsm-workbuddy-pool-dirty" }, t("row.poolDirty")) : null), (0, react.createElement)("p", { className: "dsm-workbuddy-pool-note" }, t("row.poolEnabledHint")), pool.checkinSupported ? (0, react.createElement)("div", { className: "dsm-workbuddy-pool-auto-checkin" }, (0, react.createElement)("div", { className: "dsm-workbuddy-pool-switchrow" }, (0, react.createElement)("label", { className: "sw" }, (0, react.createElement)("input", {
3938
+ type: "checkbox",
3939
+ checked: active.autoCheckin,
3940
+ disabled: !canEditPool,
3941
+ onChange: (event) => {
3942
+ const next = event.currentTarget.checked;
3943
+ editDraft((current) => ({
3944
+ ...current,
3945
+ autoCheckin: next
3946
+ }));
3947
+ }
3948
+ }), (0, react.createElement)("span", { className: "sw-track" })), (0, react.createElement)("b", { className: "dsm-workbuddy-pool-modebar-label" }, t("row.poolAutoCheckin"))), (0, react.createElement)("p", { className: "dsm-workbuddy-pool-note" }, t("row.poolAutoCheckinHint")), autoCheckinStatus) : null), poolRunning && currentAccount !== void 0 && !effectiveMembers.includes(currentAccount.accountId) ? (0, react.createElement)("p", { className: "dsm-workbuddy-pool-note dsm-workbuddy-pool-serving-note" }, t("row.poolServingOutside", { account: currentName ?? "" })) : null, poolRunning && effectiveMembers.length > 0 && usable.length === 0 ? allMembersBlockedByModel(pool?.accounts ?? [], effectiveMembers, active.memberAccountIds) ? (0, react.createElement)("p", {
3770
3949
  className: "dsm-workbuddy-pool-warn",
3771
3950
  role: "status"
3772
3951
  }, `${t("row.poolModelWideBusy")} ${t("row.poolModelWideBusyHint")}`) : (0, react.createElement)("p", {
@@ -3809,16 +3988,20 @@ window.__ModuleLoader__.load({
3809
3988
  className: "dsm-workbuddy-device-mode-seg",
3810
3989
  role: "group",
3811
3990
  "aria-label": t("row.deviceModeTitle")
3812
- }, ...["virtual", "real"].map((mode) => (0, react.createElement)("button", {
3813
- key: mode,
3814
- type: "button",
3815
- className: `dsm-workbuddy-device-seg-btn${deviceMode === mode ? " dsm-workbuddy-device-seg-on" : ""}`,
3816
- "aria-pressed": deviceMode === mode,
3817
- disabled: deviceModeBusy,
3818
- onClick: () => {
3819
- changeDeviceMode(mode);
3820
- }
3821
- }, t(mode === "virtual" ? "row.deviceModeVirtual" : "row.deviceModeReal")))), (0, react.createElement)("span", { className: "dsm-workbuddy-hint" }, deviceMode === "real" ? t("row.deviceModeHintReal") : t("row.deviceModeHintVirtual"))), (0, react.createElement)("div", { className: `dsm-workbuddy-pool-table${pool.checkinSupported ? " dsm-workbuddy-pool-table-checkin" : ""}` }, (0, react.createElement)("div", { className: "dsm-workbuddy-pool-row dsm-workbuddy-pool-row-head" }, (0, react.createElement)("span", null, t("row.poolColumnAccount")), (0, react.createElement)("span", null, t("row.poolColumnCredits")), (0, react.createElement)("span", null, t("row.poolColumnProbe")), pool.checkinSupported ? (0, react.createElement)("span", null, t("row.poolColumnCheckin")) : null, (0, react.createElement)("span", null)), ...(() => {
3991
+ }, ...["virtual", "real"].map((mode) => {
3992
+ const blocked = mode === "real" && realTierUsable === false;
3993
+ return (0, react.createElement)("button", {
3994
+ key: mode,
3995
+ type: "button",
3996
+ className: `dsm-workbuddy-device-seg-btn${deviceMode === mode ? " dsm-workbuddy-device-seg-on" : ""}`,
3997
+ "aria-pressed": deviceMode === mode,
3998
+ disabled: deviceModeBusy || blocked,
3999
+ title: blocked ? t("row.deviceModeRealUnsupported") : void 0,
4000
+ onClick: () => {
4001
+ changeDeviceMode(mode);
4002
+ }
4003
+ }, t(mode === "virtual" ? "row.deviceModeVirtual" : "row.deviceModeReal"));
4004
+ })), (0, react.createElement)("span", { className: "dsm-workbuddy-hint" }, modeHintBlocked ? t("row.deviceModeRealUnsupported") : deviceMode === "real" ? t("row.deviceModeHintReal") : t("row.deviceModeHintVirtual"))), (0, react.createElement)("div", { className: `dsm-workbuddy-pool-table${pool.checkinSupported ? " dsm-workbuddy-pool-table-checkin" : ""}` }, (0, react.createElement)("div", { className: "dsm-workbuddy-pool-row dsm-workbuddy-pool-row-head" }, (0, react.createElement)("span", null, t("row.poolColumnAccount")), (0, react.createElement)("span", null, t("row.poolColumnCredits")), (0, react.createElement)("span", null, t("row.poolColumnProbe")), pool.checkinSupported ? (0, react.createElement)("span", null, t("row.poolColumnCheckin")) : null, (0, react.createElement)("span", null)), ...(() => {
3822
4005
  const ordered = sortAccountsByOrder(pool.accounts, orderIds);
3823
4006
  let memberSeen = 0;
3824
4007
  let memberTotal = 0;
@@ -4208,7 +4391,7 @@ window.__ModuleLoader__.load({
4208
4391
  return {
4209
4392
  tier: record["tier"] === "real" ? "real" : "virtual",
4210
4393
  sdk: {
4211
- state: sdkState === "ready" || sdkState === "unsupported" || sdkState === "missing" || sdkState === "error" ? sdkState : "error",
4394
+ state: sdkState === "ready" || sdkState === "unsupported" || sdkState === "missing" || sdkState === "error" || sdkState === "disabled" ? sdkState : "error",
4212
4395
  bundle: typeof sdkRecord["bundle"] === "string" ? sdkRecord["bundle"] : "",
4213
4396
  path: typeof sdkRecord["path"] === "string" ? sdkRecord["path"] : "",
4214
4397
  platform: typeof sdkRecord["platform"] === "string" ? sdkRecord["platform"] : "",
@@ -4223,7 +4406,8 @@ window.__ModuleLoader__.load({
4223
4406
  ...typeof tokenRecord["fetchedAtMs"] === "number" ? { fetchedAtMs: tokenRecord["fetchedAtMs"] } : {},
4224
4407
  ...typeof tokenRecord["lastAttemptMs"] === "number" ? { lastAttemptMs: tokenRecord["lastAttemptMs"] } : {},
4225
4408
  ...typeof tokenRecord["reason"] === "string" ? { reason: tokenRecord["reason"] } : {}
4226
- }
4409
+ },
4410
+ ...typeof record["sdkEnabled"] === "boolean" ? { sdkEnabled: record["sdkEnabled"] } : {}
4227
4411
  };
4228
4412
  }
4229
4413
  /** 读状态。`undefined` = 这个 Host 没有这条路由(404/503),面板该整块隐藏。 */
@@ -4250,6 +4434,21 @@ window.__ModuleLoader__.load({
4250
4434
  async function refreshDeviceSdk(path) {
4251
4435
  return normalize(await post(path, "refresh"));
4252
4436
  }
4437
+ /**
4438
+ * 写 SDK 总开关(`Config.deviceSdkEnabled`)。
4439
+ *
4440
+ * 501 = 这个宿主没有 settings 写入路径。抛出去而不是静默吞掉:卡片要把开关置灰,
4441
+ * 而那需要知道"做不到",不是"做失败了"。
4442
+ */
4443
+ async function setDeviceSdkEnabled(path, enabled) {
4444
+ const response = await fetch(`${path}?action=${enabled ? "enable" : "disable"}`, {
4445
+ method: "POST",
4446
+ headers: { accept: "application/json" },
4447
+ credentials: "same-origin"
4448
+ });
4449
+ if (response.status === 501) throw new Error("this host has no settings write path");
4450
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
4451
+ }
4253
4452
  /** 取完整值。只在用户点「显示」或「复制」时调用。 */
4254
4453
  async function revealDeviceSdk(path) {
4255
4454
  const body = await post(path, "reveal");
@@ -4322,6 +4521,16 @@ window.__ModuleLoader__.load({
4322
4521
  const [savingDir, setSavingDir] = (0, react.useState)(false);
4323
4522
  const [savingFallback, setSavingFallback] = (0, react.useState)(false);
4324
4523
  const [savedNote, setSavedNote] = (0, react.useState)(false);
4524
+ /**
4525
+ * SDK 总开关(`Config.deviceSdkEnabled`)。
4526
+ *
4527
+ * 与上面那几项**不是同一份文档**:这个落在插件配置(`cordis.patch.yml`),
4528
+ * 而目录/回退落在设备设置文件。分两次读的理由与 `settingsPath` 分开一样——
4529
+ * 两者可以各自缺席。`undefined` = 这个 Host 还不认识这一项(或没有 settings
4530
+ * 服务),此时开关置灰并显示「不可用」,而不是假装它是关的。
4531
+ */
4532
+ const [sdkMasterEnabled, setSdkMasterEnabled] = (0, react.useState)(void 0);
4533
+ const [savingMaster, setSavingMaster] = (0, react.useState)(false);
4325
4534
  const load = (0, react.useCallback)(async (refresh) => {
4326
4535
  if (path === "") return;
4327
4536
  setBusy(true);
@@ -4329,6 +4538,7 @@ window.__ModuleLoader__.load({
4329
4538
  try {
4330
4539
  const next = refresh ? await refreshDeviceSdk(path) : await fetchDeviceSdk(path);
4331
4540
  setReport(next);
4541
+ if (next?.sdkEnabled !== void 0) setSdkMasterEnabled(next.sdkEnabled);
4332
4542
  if (refresh) {
4333
4543
  setValue(void 0);
4334
4544
  setCopied(false);
@@ -4458,11 +4668,49 @@ window.__ModuleLoader__.load({
4458
4668
  setSavingFallback(false);
4459
4669
  }
4460
4670
  };
4671
+ /**
4672
+ * 切换 SDK 总开关。
4673
+ *
4674
+ * 写完之后**重读一次快照**:关掉之后状态行必须立刻变成 `disabled`,而那一条是
4675
+ * 从 `GET /device-sdk` 算出来的——只改本地 state 会让"已关"与下面那行"正常"
4676
+ * 并存,正是这一页最不该出现的自相矛盾。
4677
+ */
4678
+ const saveMaster = async (value) => {
4679
+ if (path === "") return;
4680
+ setSavingMaster(true);
4681
+ setError(void 0);
4682
+ try {
4683
+ await setDeviceSdkEnabled(path, value);
4684
+ setSdkMasterEnabled(value);
4685
+ await load(false);
4686
+ } catch (cause) {
4687
+ setError(cause instanceof Error ? cause.message : String(cause));
4688
+ } finally {
4689
+ setSavingMaster(false);
4690
+ }
4691
+ };
4461
4692
  const sdk = report?.sdk;
4462
4693
  const token = report?.token;
4463
- const stateKey = sdk?.state === "ready" ? token?.state === "ok" ? "sdk.statusReady" : token?.state === "stale" ? "sdk.statusStale" : "sdk.statusNoToken" : sdk?.state === "missing" ? "sdk.statusMissing" : sdk?.state === "unsupported" ? "sdk.statusUnsupported" : "sdk.statusError";
4694
+ const stateKey = sdk?.state === "disabled" ? "sdk.statusDisabled" : sdk?.state === "ready" ? token?.state === "ok" ? "sdk.statusReady" : token?.state === "stale" ? "sdk.statusStale" : "sdk.statusNoToken" : sdk?.state === "missing" ? "sdk.statusMissing" : sdk?.state === "unsupported" ? "sdk.statusUnsupported" : "sdk.statusError";
4464
4695
  const stateOk = sdk?.state === "ready" && token?.state === "ok";
4465
4696
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
4697
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4698
+ className: "dsm-workbuddy-sdk-master",
4699
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
4700
+ className: "dsm-workbuddy-sdk-switch",
4701
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
4702
+ type: "checkbox",
4703
+ checked: sdkMasterEnabled ?? true,
4704
+ disabled: savingMaster || sdkMasterEnabled === void 0,
4705
+ onChange: (event) => {
4706
+ saveMaster(event.target.checked);
4707
+ }
4708
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("sdk.masterLabel") })]
4709
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4710
+ className: "dsm-workbuddy-hint",
4711
+ children: t("sdk.masterHint")
4712
+ })]
4713
+ }),
4466
4714
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4467
4715
  className: "dsm-workbuddy-panel-note",
4468
4716
  children: t("sdk.hint")
@@ -5437,6 +5685,30 @@ window.__ModuleLoader__.load({
5437
5685
  });
5438
5686
  }
5439
5687
  //#endregion
5688
+ //#region src/catalog.ts
5689
+ /**
5690
+ * The tier one model currently RESOLVES TO, given the saved budgets.
5691
+ *
5692
+ * This is the rule the card's radio group has to agree with, so it lives next
5693
+ * to {@link applyContextBudgets} rather than being re-derived in the browser —
5694
+ * ONE definition, so the UI cannot drift from the backend again (issue #215).
5695
+ *
5696
+ * `undefined` means "no explicit budget" and answers the NATIVE window, which
5697
+ * is exactly what {@link applyContextBudgets} does with an absent entry. The
5698
+ * card used to default the 200K radio with `?? 200_000` instead, so a model
5699
+ * with no stored budget showed "200K" selected while DSH was told 1,000,000 —
5700
+ * the reporter's case. The radio was right there in the UI and wrong in the
5701
+ * only place that matters.
5702
+ *
5703
+ * A budget ABOVE the native window answers the native window, because
5704
+ * {@link applyContextBudgets} clamps with `Math.min`: a stored 1048576 for a 1M
5705
+ * model genuinely resolves to the native tier, and that radio is the one that
5706
+ * should be lit.
5707
+ */
5708
+ function effectiveContextBudget(nativeContextWindow, savedBudget) {
5709
+ return savedBudget === void 0 ? nativeContextWindow : Math.min(nativeContextWindow, savedBudget);
5710
+ }
5711
+ //#endregion
5440
5712
  //#region src/default-effort.ts
5441
5713
  /** The tiers DSH/pi-ai speak. Mirrors `THINKING_LEVELS` in `./adapter.ts`. */
5442
5714
  const THINKING_LEVELS = [
@@ -5460,6 +5732,26 @@ window.__ModuleLoader__.load({
5460
5732
  return THINKING_LEVELS.filter((level) => supported.includes(level));
5461
5733
  }
5462
5734
  /**
5735
+ * The one tier a model should dispatch at when a caller names none.
5736
+ *
5737
+ * @param model - the catalog entry, carrying the upstream's own declaration.
5738
+ * @param saved - the user's per-model choice, keyed by model id; an absent (or
5739
+ * unsupported, or stale) entry falls through to the upstream default, then to
5740
+ * this model's own MIDDLE tier (never its weakest one).
5741
+ * @returns a tier the model declares, or `undefined` when it declares none — in
5742
+ * which case the adapter's existing `off` normalization (issue #90) is still
5743
+ * the right answer and this module must not invent one.
5744
+ */
5745
+ function defaultEffortFor(model, saved = {}) {
5746
+ const declared = declaredEfforts(model.reasoning);
5747
+ if (declared.length === 0) return void 0;
5748
+ const asked = saved[model.id];
5749
+ if (typeof asked === "string" && declared.includes(asked)) return asked;
5750
+ const upstreamDefault = model.reasoning?.defaultEffort;
5751
+ if (typeof upstreamDefault === "string" && declared.includes(upstreamDefault)) return upstreamDefault;
5752
+ return declared[Math.floor(declared.length / 2)];
5753
+ }
5754
+ /**
5463
5755
  * The tier list the card offers for one model.
5464
5756
  *
5465
5757
  * Exactly the model's own declared tiers — no localising, no cross-model
@@ -5998,7 +6290,7 @@ window.__ModuleLoader__.load({
5998
6290
  CONTRAST colour, so a ticked box painted itself as a heavy black pill — the
5999
6291
  loudest object in a section made of plain 13px text. */
6000
6292
  .dsm-workbuddy-pref input{flex:none;cursor:pointer;accent-color:var(--dsw-alias-brand-primary,#5686fe)}
6001
- .dsm-workbuddy-pref-check,.dsm-workbuddy-image-tool-check,.dsm-workbuddy-video-tool-check,.dsm-workbuddy-cli-bridge-check,.dsm-workbuddy-upstream-check,.dsm-workbuddy-channel-continue-check{inline-size:15px;block-size:15px;margin:3px 0 0}
6293
+ .dsm-workbuddy-pref-check,.dsm-workbuddy-image-tool-check,.dsm-workbuddy-video-tool-check,.dsm-workbuddy-cli-bridge-check,.dsm-workbuddy-sidebar-panel-check,.dsm-workbuddy-upstream-check,.dsm-workbuddy-channel-continue-check{inline-size:15px;block-size:15px;margin:3px 0 0}
6002
6294
  /* The upstream-identity switches are their own group, so they get a divider
6003
6295
  above them instead of relying on spacing alone: they change the request the
6004
6296
  whole plugin sends, not a per-region display choice, and reading them as the
@@ -6168,7 +6460,21 @@ window.__ModuleLoader__.load({
6168
6460
  .dsm-workbuddy-model{display:grid;grid-template-columns:minmax(0,1fr);gap:7px;padding:10px 12px;background:var(--dsw-alias-bg-layer-2,#232529);transition:opacity .16s}
6169
6461
  .dsm-workbuddy-model-disabled{opacity:.55}
6170
6462
  .dsm-workbuddy-model+.dsm-workbuddy-model{border-top:1px solid var(--dsw-alias-border-l2,#36373b)}
6171
- .dsm-workbuddy-model-head{display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0}
6463
+ /* ISSUE #198 — the model row's controls MUST WRAP.
6464
+
6465
+ The row carries four groups on one line: the name, the two checkboxes, the
6466
+ context-budget radio group, and the test/measure buttons. The budget group had
6467
+ flex:none and the row had no flex-wrap, so on a narrow card (dsh-go on a
6468
+ phone, a ~360 px settings panel) the row's intrinsic width exceeded the
6469
+ container and the model list's overflow:hidden CLIPPED THE REST — the third
6470
+ radio (「模型原生窗口」, e.g. 1M) was neither visible nor clickable, and the
6471
+ largest budget a user could pick looked like 500K. A control that is clipped is
6472
+ worse than one that is missing: the README promises three tiers and the screen
6473
+ silently contradicts it. Both halves are needed — the row wraps, AND the group
6474
+ itself wraps, because its three labels can exceed even a whole narrow line —
6475
+ hence the media query below as well, which gives the group the full width on a
6476
+ phone so it reads as one deliberate line rather than a scramble. */
6477
+ .dsm-workbuddy-model-head{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;row-gap:8px;min-width:0}
6172
6478
  .dsm-workbuddy-model-enabled{display:flex;align-items:center;gap:8px;min-width:0;cursor:pointer;flex:1}
6173
6479
  .dsm-workbuddy-model-enabled input{margin:0;accent-color:var(--dsw-alias-brand-primary,#5686fe);flex:none}
6174
6480
  .dsm-workbuddy-model-image{display:inline-flex;align-items:center;gap:5px;flex:none;cursor:pointer;color:var(--dsw-alias-label-secondary,#c6c9d0);font-size:11px;line-height:16px}
@@ -6216,8 +6522,14 @@ window.__ModuleLoader__.load({
6216
6522
  .dsm-workbuddy-model-effort-select:hover:not(:disabled){border-color:var(--dsw-alias-border-l2,#3a3d45)}
6217
6523
  .dsm-workbuddy-model-effort-select:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}
6218
6524
  .dsm-workbuddy-model-effort-select:disabled{opacity:.55;cursor:default}
6219
- .dsm-workbuddy-context-budget{display:flex;align-items:center;justify-content:flex-end;gap:12px;flex:none;margin:0;padding:0;border:0;color:var(--dsw-alias-label-secondary,#c6c9d0);font-size:11px;line-height:16px}
6220
- .dsm-workbuddy-context-budget label{display:inline-flex;align-items:center;gap:4px;cursor:pointer}
6525
+ /* The three tiers plus the two probe buttons plus the two checkboxes are MORE
6526
+ than one narrow line can hold, so this group must be allowed to break between
6527
+ its own labels too (issue #199's sibling, #198): flex:none alone was half of
6528
+ the clipping bug, and flex-wrap is the other half — a 1.048M label is wider
6529
+ than 200K. Left-aligning the group under the media query makes the group
6530
+ own its line on a phone instead of dangling at the right edge. */
6531
+ .dsm-workbuddy-context-budget{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:12px;row-gap:6px;flex:none;margin:0;padding:0;border:0;color:var(--dsw-alias-label-secondary,#c6c9d0);font-size:11px;line-height:16px}
6532
+ .dsm-workbuddy-context-budget label{display:inline-flex;align-items:center;gap:4px;cursor:pointer;white-space:nowrap}
6221
6533
  .dsm-workbuddy-context-budget input{margin:0;accent-color:var(--dsw-alias-brand-primary,#5686fe)}
6222
6534
  .dsm-workbuddy-model-capability-note{margin:0;color:var(--dsw-alias-label-tertiary,#999);font-size:12px;line-height:18px}
6223
6535
  /* Model probe (test button + result). The result line is its own row under the
@@ -6241,7 +6553,7 @@ window.__ModuleLoader__.load({
6241
6553
  .dsm-workbuddy-model-probe-result-ok{color:var(--dsw-alias-state-success-primary,#22a06b)}
6242
6554
  .dsm-workbuddy-model-probe-result-warn{color:var(--dsw-alias-state-warn-primary,#f59e0b)}
6243
6555
  .dsm-workbuddy-model-probe-result-bad{color:var(--dsw-alias-state-error-primary,#ef4444)}
6244
- .dsm-workbuddy-model-actions{display:flex;align-items:center;justify-content:space-between;gap:12px;border-top:1px solid var(--dsw-alias-border-l2,#36373b);padding-top:12px}
6556
+ .dsm-workbuddy-model-actions{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;row-gap:8px;border-top:1px solid var(--dsw-alias-border-l2,#36373b);padding-top:12px}
6245
6557
  .dsm-workbuddy-model-save-error{flex:1;min-width:0;color:var(--dsw-alias-state-error-primary,#ef4444);font-size:12px;line-height:16px;text-align:right}
6246
6558
  .dsm-workbuddy-model-actions-buttons{display:flex;align-items:center;justify-content:flex-end;gap:8px}
6247
6559
  .dsm-workbuddy-usage-cheer{display:inline-flex;align-items:center;gap:4px;flex:none;text-decoration:underline;text-underline-offset:2px;color:var(--dsw-alias-label-tertiary,#999);font-size:13px;line-height:1.5;transition:color .16s}
@@ -6538,12 +6850,40 @@ window.__ModuleLoader__.load({
6538
6850
  */
6539
6851
  .dsm-workbuddy-pool-modebar{padding:12px 14px;gap:8px;border-color:rgba(86,134,254,.36);background:linear-gradient(180deg,rgba(86,134,254,.10),rgba(86,134,254,.02)),var(--dsw-alias-bg-layer-2,#24262c)}
6540
6852
  .dsm-workbuddy-pool-modebar-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
6853
+ /* A ROW that holds one switch and its label — NOT a card.
6854
+ *
6855
+ * Split out from .dsm-workbuddy-pool-modebar (which is the tinted CARD) because
6856
+ * the automatic check-in switch used to carry the card class by mistake: it was
6857
+ * drawn as a second, nested card inside the mode bar, so the two switches came
6858
+ * out at different sizes with a deep dark gap between them (issue #191
6859
+ * follow-up).
6860
+ *
6861
+ * Keeping the row shape in its own class is what stops that from coming back: a
6862
+ * switch row can never inherit a card's padding, border or background, because
6863
+ * those live on a class this one does not share. Rendered geometry matches
6864
+ * .dsm-workbuddy-pool-modebar-row exactly, so switches stacked in one bar line
6865
+ * up on both axes. */
6866
+ .dsm-workbuddy-pool-switchrow{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
6541
6867
  .dsm-workbuddy-pool-modebar-label{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary,#e6e6e6)}
6542
6868
  /* The mode in words. A switch's position is a 20px shape to decode; this says
6543
6869
  which of the two modes is in force, and therefore how to read the table. */
6544
6870
  .dsm-workbuddy-pool-modebar-state{flex:none;padding:1px 9px;border-radius:999px;font-size:12px;line-height:18px;font-weight:500;color:var(--dsw-alias-brand-primary,#5686fe);background:rgba(86,134,254,.14);border:1px solid rgba(86,134,254,.3)}
6545
6871
  .dsm-workbuddy-pool-modebar .dsm-workbuddy-pool-dirty{margin-left:auto}
6546
6872
  .dsm-workbuddy-pool-modebar .dsm-workbuddy-pool-note{line-height:18px;color:var(--dsw-alias-label-secondary,#c6c9d0)}
6873
+ /* The automatic check-in block (issue #191): a switch, its hint, and — once it
6874
+ has run — a one-line progress readout. Indented under the pool switch because
6875
+ it is a second, narrower consent: the pool switch says "pick my account", this
6876
+ one says "write to it every day". */
6877
+ .dsm-workbuddy-pool-auto-checkin{margin-top:10px;padding-left:2px;display:flex;flex-direction:column;gap:6px}
6878
+ .dsm-workbuddy-pool-auto-checkin-status{display:flex;flex-wrap:wrap;gap:10px;font-size:12px;line-height:17px;color:var(--dsw-alias-label-secondary,#c6c9d0)}
6879
+ /* The progress figure is the ANSWER to "did it work?", so it is the one part
6880
+ that carries primary text colour rather than the muted note colour. */
6881
+ .dsm-workbuddy-pool-auto-checkin-line{color:var(--dsw-alias-label-primary,CanvasText);font-weight:500}
6882
+ .dsm-workbuddy-pool-auto-checkin-pending{color:var(--dsw-alias-label-secondary,#c6c9d0)}
6883
+ /* A failed attempt is a real condition the user may need to act on, so it is
6884
+ not muted — but it is also not an error the plugin can fix, hence warn, not
6885
+ the error red reserved for "this broke". */
6886
+ .dsm-workbuddy-pool-auto-checkin-error{color:var(--dsw-alias-label-warning,#d9822b)}
6547
6887
  /* Orthogonal concepts in one sentence when they collide ("in use" vs "in the
6548
6888
  pool"). A left rule marks it as an aside about the row above, not a warning. */
6549
6889
  .dsm-workbuddy-pool-serving-note{padding-left:10px;border-left:2px solid rgba(86,134,254,.5);color:var(--dsw-alias-label-secondary,#c6c9d0)}
@@ -6614,6 +6954,12 @@ window.__ModuleLoader__.load({
6614
6954
  /* This account's own test model (issue #61). Narrower than the section-level
6615
6955
  picker so a long model name cannot push the two buttons out of the row. */
6616
6956
  @media (max-width:760px){.dsm-workbuddy-pool-row{grid-template-columns:1fr 1fr;row-gap:6px}.dsm-workbuddy-pool-select{max-width:180px}}
6957
+ /* ISSUE #198, the same breakpoint the pool row already uses. On a phone the model
6958
+ row's budget group takes the WHOLE line and left-aligns: right-justified, a
6959
+ wrapped two-tier group reads as a stray fragment under the buttons, and the tier
6960
+ the user is trying to find — the native window — is the last label in the group,
6961
+ so the line has to start at the left to have room to end at all. */
6962
+ @media (max-width:760px){.dsm-workbuddy-context-budget{flex:1 1 100%;justify-content:flex-start}}
6617
6963
  /* Pool switch, namespaced under .dsm-workbuddy-pool so it cannot collide with host styles. */
6618
6964
  .dsm-workbuddy-pool .sw{position:relative;display:inline-block;width:38px;height:22px;flex:none;cursor:pointer}
6619
6965
  .dsm-workbuddy-pool .sw input{position:absolute;opacity:0;width:0;height:0}
@@ -6644,7 +6990,11 @@ window.__ModuleLoader__.load({
6644
6990
  /* Secondary text inside the transfer DIALOG (not a bar): the privacy note
6645
6991
  shown when credentials leave the machine. Kept independent of the bar
6646
6992
  classes so the dialog does not depend on the bar's layout to be readable. */
6647
- .dsm-workbuddy-hint{color:var(--dsw-alias-label-tertiary,#999)}
6993
+ /* 辅助说明文字的**唯一**入口。字号与行高必须写死在这里,不能靠继承:
6994
+ 这个类同时被用在 <p> 与 <span> 上,而 <p> 在宿主里带默认段落样式,于是
6995
+ 同一句说明在两处会长成两种大小(实测截图里 SDK 那两段比周围 12px 的辅助
6996
+ 文字大了一圈,正是这个原因)。全仓其它 hint 类都写了 12px/18px,这里补齐。 */
6997
+ .dsm-workbuddy-hint{color:var(--dsw-alias-label-tertiary,#999);font-size:12px;line-height:18px}
6648
6998
  /* The transfer dialog is deliberately a block: it holds a scrollable account
6649
6999
  list and per-entry checkboxes, which cannot live in a one-row bar. */
6650
7000
  .dsm-workbuddy-transfer-dialog{margin-top:8px;padding:10px 12px;border:1px solid var(--dsw-alias-border-l2,#3a3d45);border-radius:10px;background:var(--dsw-alias-bg-secondary,transparent)}
@@ -6714,7 +7064,17 @@ window.__ModuleLoader__.load({
6714
7064
  @keyframes dsm-workbuddy-veil-spin{to{transform:rotate(360deg)}}
6715
7065
  @keyframes dsm-workbuddy-veil-dash{0%{stroke-dasharray:12 150;stroke-dashoffset:0}50%{stroke-dasharray:24 150;stroke-dashoffset:-6}to{stroke-dasharray:12 150;stroke-dashoffset:0}}
6716
7066
  @media (prefers-reduced-motion: reduce){.dsm-workbuddy-veil-spinner{animation:none}.dsm-workbuddy-veil-spinner-arc{animation:none;stroke-dasharray:18 150;stroke-dashoffset:-3}}
6717
-
7067
+ .dsm-workbuddy-page{box-sizing:border-box;height:100%;display:flex;flex-direction:column;align-items:center;gap:20px;padding:28px clamp(24px,4vw,48px) 48px;overflow:auto;color:var(--dsw-alias-label-primary,#e6e6e6)}
7068
+ .dsm-workbuddy-page>*{width:100%;max-width:860px}
7069
+ .dsm-workbuddy-page-head{display:flex;flex-direction:column;gap:6px}
7070
+ .dsm-workbuddy-page-back{appearance:none;font:inherit;cursor:pointer;border:1px solid var(--dsw-alias-border-l2,#36373b);background:var(--dsw-alias-bg-layer-1,#17181b);color:var(--dsw-alias-label-secondary,#c7c7c7);border-radius:8px;padding:5px 12px;display:inline-flex;align-items:center;gap:6px;align-self:flex-start;font-size:13px;line-height:20px}
7071
+ .dsm-workbuddy-page-back:hover{color:var(--dsw-alias-label-primary,#e6e6e6);border-color:var(--dsw-alias-label-dimmed,#777)}
7072
+ .dsm-workbuddy-page-back svg{flex:none}
7073
+ .dsm-workbuddy-page-icon{width:40px;height:40px;border-radius:9px;align-self:flex-start;margin-top:14px}
7074
+ .dsm-workbuddy-page-title{margin:0;font-size:20px;font-weight:600;line-height:1.4}
7075
+ .dsm-workbuddy-page-desc{margin:0;font-size:13px;line-height:1.5;color:var(--dsw-alias-label-tertiary,#999)}
7076
+ .dsm-workbuddy-page-body .dsm-workbuddy-usage{padding:20px 20px 8px;border:1px solid var(--dsw-alias-border-l2,#36373b);background:var(--dsw-alias-bg-layer-3,#202126);border-radius:12px}
7077
+ .dsm-workbuddy-panel-icon{display:block;border-radius:4px;flex:none}
6718
7078
  /* ---- 设备头档位与逐账号参数弹窗 ------------------------------------------
6719
7079
  档位那一行贴着账号表:它同时决定"这台机器对外声称自己是谁"和"每行的齿轮能
6720
7080
  不能用",埋进「更多设置」会让齿轮看起来时好时坏。
@@ -6793,6 +7153,17 @@ window.__ModuleLoader__.load({
6793
7153
  /* 回退开关:勾选框交回平台(accent-color),方框尺寸/圆角/勾形不由我们画。 */
6794
7154
  .dsm-workbuddy-sdk-switch{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--dsw-alias-label-primary,#e8e9ed);cursor:pointer}
6795
7155
  .dsm-workbuddy-sdk-switch input{accent-color:var(--dsw-alias-brand-primary,#5686fe)}
7156
+ /* 总开关区块:它在面板最上面,与下面那组诊断之间要有一道肉眼可见的分界——
7157
+ 否则"关掉它"和"看它现在的状态"会被读成同一件事。 */
7158
+ .dsm-workbuddy-sdk-master{
7159
+ display:flex;flex-direction:column;gap:4px;
7160
+ margin:0 0 10px;padding:10px 12px;
7161
+ border:1px solid var(--dsw-alias-border-l2,#3a3d45);border-radius:10px;
7162
+ background:var(--dsw-alias-bg-layer-2,#232529);
7163
+ }
7164
+ .dsm-workbuddy-sdk-master .dsm-workbuddy-hint{margin:0}
7165
+ /* 关掉时整块诊断降饱和度:它仍然是事实("现在没在跑"),但不再是当前动作的重点。 */
7166
+ .dsm-workbuddy-sdk-master-off + .dsm-workbuddy-panel-note{opacity:.75}
6796
7167
  .dsm-workbuddy-device-input:focus{outline:none;border-color:var(--dsw-alias-brand-primary,#5686fe)}
6797
7168
  .dsm-workbuddy-device-input-bad{border-color:var(--dsw-alias-label-error,#e5534b)}
6798
7169
  .dsm-workbuddy-device-error{color:var(--dsw-alias-label-error,#e5534b);font-size:12px;margin:4px 0 0}
@@ -6904,19 +7275,104 @@ window.__ModuleLoader__.load({
6904
7275
  font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary,#444);
6905
7276
  }
6906
7277
  .dsm-workbuddy-composer-panel-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
6907
- .dsm-workbuddy-composer-panel-title{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary,CanvasText)}
6908
- /* Self-contained: the dsm-btn primitive lives in TRAE_CARD_CSS, which the
6909
- composer never loads, so the refresh button must style itself. */
7278
+ /* nowrap: the header is a title plus an 11px control in a ~250px popover, and
7279
+ without it the TITLE broke across two lines ("WB AI" / "积分") the moment the
7280
+ settings control joined the row — measured on the live Desktop host. The
7281
+ title is the one thing that must stay on one line; what follows it is short by
7282
+ construction. */
7283
+ .dsm-workbuddy-composer-panel-title{flex:none;white-space:nowrap;font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary,CanvasText)}
7284
+ /* The header's TEST control, left of settings.
7285
+ A quiet pill like its neighbour, but WITHOUT the brand fill: re-testing is a
7286
+ local, repeatable action on the table right below it, while the settings pill
7287
+ is the one control that leaves the panel. Two equally loud pills would make
7288
+ the header read as a toolbar; this one stays a step quieter and earns its
7289
+ colour only on hover. */
6910
7290
  .dsm-workbuddy-composer-panel-refresh{
6911
- appearance:none;flex:none;margin-left:auto;padding:3px 10px;
6912
- border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.34));
6913
- border-radius:7px;background:transparent;
7291
+ appearance:none;flex:none;
7292
+ display:inline-flex;align-items:center;gap:4px;
7293
+ padding:3px 8px 3px 6px;margin-right:6px;
7294
+ border:1px solid transparent;border-radius:999px;
7295
+ background:transparent;
6914
7296
  color:var(--dsw-alias-label-secondary,#444);
6915
- font:inherit;font-size:11px;line-height:16px;cursor:pointer;
7297
+ font:inherit;font-size:11px;line-height:16px;font-weight:500;
7298
+ cursor:pointer;
7299
+ transition:background-color .12s ease,border-color .12s ease,color .12s ease;
7300
+ }
7301
+ .dsm-workbuddy-composer-panel-refresh:hover:not(:disabled){
7302
+ background:rgba(127,127,127,.10);
7303
+ border-color:var(--dsw-alias-border-l2,rgba(127,127,127,.34));
7304
+ color:var(--dsw-alias-label-primary,CanvasText);
6916
7305
  }
6917
- .dsm-workbuddy-composer-panel-refresh:hover:not(:disabled){border-color:var(--dsw-alias-label-dimmed,rgba(127,127,127,.6));color:var(--dsw-alias-label-primary,CanvasText)}
7306
+ .dsm-workbuddy-composer-panel-refresh:active:not(:disabled){background:rgba(127,127,127,.16)}
6918
7307
  .dsm-workbuddy-composer-panel-refresh:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}
6919
- .dsm-workbuddy-composer-panel-refresh:disabled{opacity:.5;cursor:default}
7308
+ /* A running batch keeps the label readable but stops the hover: the button is
7309
+ disabled, and a disabled control that still lights up on hover invites a
7310
+ second press that will be ignored. */
7311
+ .dsm-workbuddy-composer-panel-refresh:disabled{cursor:default;opacity:.6}
7312
+ /* The circular arrow does not shrink (a flex item defaults to it) and never
7313
+ wraps away from the label. */
7314
+ .dsm-workbuddy-composer-panel-refresh-icon{flex:none;display:block}
7315
+ /* While the batch runs the arrow TURNS. A disabled button with a static icon
7316
+ reads as broken, and a serial batch is long enough that "did my press land?"
7317
+ is a real question. One turn per 900ms: fast enough to read as motion, slow
7318
+ enough not to look like a rendering fault. */
7319
+ .dsm-workbuddy-composer-panel-refresh-icon-spin{animation:dsm-workbuddy-panel-refresh-spin .9s linear infinite}
7320
+ @keyframes dsm-workbuddy-panel-refresh-spin{to{transform:rotate(360deg)}}
7321
+ .dsm-workbuddy-composer-panel-refresh-label{flex:none;white-space:nowrap}
7322
+ /* The spinner is the ONLY indication the batch is alive, so under reduced
7323
+ motion it must not disappear: the animation is dropped and the icon keeps a
7324
+ distinct look (dimmed) plus the label says 「正在测试…」. */
7325
+ @media (prefers-reduced-motion:reduce){
7326
+ .dsm-workbuddy-composer-panel-refresh{transition:none}
7327
+ .dsm-workbuddy-composer-panel-refresh-icon-spin{animation:none;opacity:.55}
7328
+ }
7329
+
7330
+ /* The header's right-hand control: the link to this plugin's settings.
7331
+ A wrapper rather than an auto margin on the button, because the button is NOT
7332
+ always rendered (a host with no route renders none) and a wrapper that is
7333
+ always present keeps the header layout identical either way. */
7334
+ .dsm-workbuddy-composer-panel-actions{flex:none;margin-left:auto;display:flex;align-items:center}
7335
+ /* Styled as a quiet text link rather than a bordered button: navigating away is
7336
+ not the header's primary action, and a loud button beside a 13px title reads as
7337
+ a toolbar. The border appears only on hover/focus, which is where the
7338
+ affordance is needed. */
7339
+ /* A quiet PILL, not an underlined link. The underline made a one-word label
7340
+ read as body text that happened to be clickable — in a 13px header the eye
7341
+ does not register it as a control at all. The tinted fill plus the gear give
7342
+ it a shape at rest, which is where the affordance is actually needed; the
7343
+ underline only appeared on hover, i.e. after the user already knew.
7344
+ The fill is the brand colour at 10%, so it reads as "secondary action in this
7345
+ product" rather than as a fourth grey chip beside the title. */
7346
+ .dsm-workbuddy-composer-panel-settings{
7347
+ appearance:none;flex:none;
7348
+ display:inline-flex;align-items:center;gap:4px;
7349
+ padding:3px 8px 3px 6px;
7350
+ border:1px solid transparent;border-radius:999px;
7351
+ background:rgba(86,134,254,.10);
7352
+ color:var(--dsw-alias-brand-primary,#5686fe);
7353
+ font:inherit;font-size:11px;line-height:16px;font-weight:500;
7354
+ cursor:pointer;
7355
+ transition:background-color .12s ease,border-color .12s ease,color .12s ease;
7356
+ }
7357
+ .dsm-workbuddy-composer-panel-settings:hover{
7358
+ background:rgba(86,134,254,.18);
7359
+ border-color:rgba(86,134,254,.34);
7360
+ color:var(--dsw-alias-brand-primary,#5686fe);
7361
+ }
7362
+ .dsm-workbuddy-composer-panel-settings:active{background:rgba(86,134,254,.26)}
7363
+ .dsm-workbuddy-composer-panel-settings:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#5686fe);outline-offset:1px}
7364
+ /* The gear does not shrink when the label is a longer word ("Settings" vs
7365
+ "设置"): a flex item defaults to shrinking, which would squash the icon into
7366
+ an oval on a narrow popover. */
7367
+ .dsm-workbuddy-composer-panel-settings-icon{flex:none;display:block}
7368
+ /* The label never wraps. Two lines in a 16px-tall pill would push the header
7369
+ taller and unstick the table below it. */
7370
+ .dsm-workbuddy-composer-panel-settings-label{flex:none;white-space:nowrap}
7371
+ /* Reduced motion: the colour transition is decoration, and the hover state is
7372
+ still fully visible without it. */
7373
+ @media (prefers-reduced-motion:reduce){
7374
+ .dsm-workbuddy-composer-panel-settings{transition:none}
7375
+ }
6920
7376
  /* The panel is a TABLE: one row per account in the region, one figure (the
6921
7377
  general balance) per row, and a row click switches accounts.
6922
7378
 
@@ -7645,9 +8101,11 @@ window.__ModuleLoader__.load({
7645
8101
  if (props.t === void 0) throw new Error("WorkBuddy plugin card requires its translation function");
7646
8102
  return (0, react.createElement)(WorkBuddyCardBody, props);
7647
8103
  }
7648
- function WorkBuddyCardBody({ t, settingsScope, view }) {
8104
+ function WorkBuddyCardBody({ t, settingsScope, view, surface, backToConversation }) {
7649
8105
  if (t === void 0) throw new Error("WorkBuddy plugin card requires its translation function");
7650
- const [open, setOpen] = (0, react.useState)(view === "page");
8106
+ const pageSurface = surface === "page";
8107
+ const [cardOpen, setCardOpen] = (0, react.useState)(view === "page");
8108
+ const open = pageSurface || cardOpen;
7651
8109
  /** The region whose tab is on screen; each tab is its own provider stack. */
7652
8110
  const [activeRegion, setActiveRegion] = (0, react.useState)("cn");
7653
8111
  /**
@@ -7743,6 +8201,14 @@ window.__ModuleLoader__.load({
7743
8201
  const [cliBridgeOn, setCliBridgeOn] = (0, react.useState)(void 0);
7744
8202
  const [cliBridgeBusy, setCliBridgeBusy] = (0, react.useState)(false);
7745
8203
  /**
8204
+ * The OPTIONAL sidebar-row switch (PR #188).
8205
+ *
8206
+ * `undefined` until the first Host answer arrives, so the box renders the
8207
+ * committed value instead of guessing — the same rule as `cliBridgeOn`.
8208
+ */
8209
+ const [sidebarPanelOn, setSidebarPanelOn] = (0, react.useState)(void 0);
8210
+ const [sidebarPanelBusy, setSidebarPanelBusy] = (0, react.useState)(false);
8211
+ /**
7746
8212
  * The quick-adjust pins of the CLI route (model, effort, region order) made
7747
8213
  * by THIS card instance.
7748
8214
  *
@@ -8326,6 +8792,42 @@ window.__ModuleLoader__.load({
8326
8792
  }
8327
8793
  };
8328
8794
  /**
8795
+ * Whether the OPTIONAL sidebar row is switched on (PR #188).
8796
+ *
8797
+ * Read Host-first, mirror-second, for the same measured reason as
8798
+ * `cliBridgeSwitchedOn`: the browser's settings mirror is stale for this
8799
+ * namespace on the affected 0.1.7 deployments. `=== true` on both — absent is
8800
+ * not consent, and this switch claims a global sidebar seat.
8801
+ */
8802
+ const sidebarPanelSwitchedOn = () => {
8803
+ if (sidebarPanelOn !== void 0) return sidebarPanelOn;
8804
+ const fromHost = statusByRegion[activeRegion]?.sidebarPanelEnabled;
8805
+ if (typeof fromHost === "boolean") return fromHost;
8806
+ return sidebarPanelEnabledOf(settingsScope?.getSnapshot().value);
8807
+ };
8808
+ /**
8809
+ * Flip the sidebar-row switch.
8810
+ *
8811
+ * Published to the entry's opt-in store on success, because the row is built
8812
+ * from slot ENTRY METADATA and therefore cannot decide its own visibility —
8813
+ * see `panel-switch.ts`. Publishing only AFTER the write is verified keeps the
8814
+ * two from disagreeing: the row never appears for a value the Host refused.
8815
+ */
8816
+ const toggleSidebarPanel = async (enabled) => {
8817
+ if (settingsScope === void 0) return;
8818
+ setSidebarPanelBusy(true);
8819
+ try {
8820
+ await writeSidebarPanelEnabled(settingsScope, enabled);
8821
+ if (mounted.current) setSidebarPanelOn(enabled);
8822
+ setSidebarPanelWanted(enabled);
8823
+ await refreshUsage(activeRegion);
8824
+ } catch (error) {
8825
+ if (mounted.current) setAccountError(error instanceof Error ? error.message : t("row.requestFailed"));
8826
+ } finally {
8827
+ if (mounted.current) setSidebarPanelBusy(false);
8828
+ }
8829
+ };
8830
+ /**
8329
8831
  * The three upstream-identity switches, read the same three-level way the CLI
8330
8832
  * switch is: this card's own successful write, then the settings snapshot.
8331
8833
  *
@@ -8731,14 +9233,33 @@ window.__ModuleLoader__.load({
8731
9233
  };
8732
9234
  });
8733
9235
  };
9236
+ /**
9237
+ * Set one model's DSH context budget, or CLEAR it.
9238
+ *
9239
+ * `undefined` means "no cap — use the model's native window", and it is
9240
+ * written as the ABSENCE of the key rather than as a stored number equal to
9241
+ * the window. That distinction is the whole of issue #215: a stored
9242
+ * `{ id: 1000000 }` and an absent entry both resolve to 1,000,000 today, but
9243
+ * only the absent one keeps following the model if the upstream ever raises
9244
+ * its window. It is also what makes the "native" radio mean one thing —
9245
+ * "no budget" — instead of sometimes meaning "a budget that happens to equal
9246
+ * the window".
9247
+ *
9248
+ * The key is DELETED rather than assigned `undefined`: an explicit
9249
+ * `undefined` survives `structuredClone` and the settings write path's strict
9250
+ * JSON codec rejects the whole save (see `setDefaultThinkingEffort`, which
9251
+ * follows the same rule for the same reason).
9252
+ */
8734
9253
  const setContextBudget = (modelId, budget) => {
8735
- editDraft((current) => ({
8736
- ...current,
8737
- contextBudgets: {
8738
- ...current.contextBudgets,
8739
- [modelId]: budget
8740
- }
8741
- }));
9254
+ editDraft((current) => {
9255
+ const next = { ...current.contextBudgets };
9256
+ if (budget === void 0) delete next[modelId];
9257
+ else next[modelId] = budget;
9258
+ return {
9259
+ ...current,
9260
+ contextBudgets: next
9261
+ };
9262
+ });
8742
9263
  };
8743
9264
  /**
8744
9265
  * Choose one model's default thinking tier (issue #179).
@@ -9036,6 +9557,16 @@ window.__ModuleLoader__.load({
9036
9557
  /** The saved choice no longer matches a local sign-in (tokens are fine). */
9037
9558
  const selectionLost = status.status === "signed-out" && status.selectionLost === true;
9038
9559
  /**
9560
+ * The vault directory could not be READ at all (issue #199).
9561
+ *
9562
+ * A permissions failure masquerades as "the account is gone": `syncVault`
9563
+ * skips the vault when its readdir fails, so the saved OAuth-only account
9564
+ * drops out of the list while the desktop scan's accounts remain. Without
9565
+ * this the card tells the user to re-sign-in, which cannot repair a DACL.
9566
+ * The raw error is shown because it names the actual failing operation.
9567
+ */
9568
+ const vaultUnreadable = status.status === "signed-out" ? status.vaultUnreadable : void 0;
9569
+ /**
9039
9570
  * The paths the Host probed, on the branch where nothing was found at all.
9040
9571
  * Absent on the legacy card payload (an older Host), so it defaults empty
9041
9572
  * rather than rendering an empty diagnostic.
@@ -9329,6 +9860,38 @@ window.__ModuleLoader__.load({
9329
9860
  })]
9330
9861
  });
9331
9862
  /**
9863
+ * The sidebar-row switch (PR #188).
9864
+ *
9865
+ * Its own class for the reason the CLI box has one: the credit-switch suite's
9866
+ * "exactly one switch" selector (`.dsm-workbuddy-pref-check`) must keep
9867
+ * resolving to the credit box alone.
9868
+ *
9869
+ * NOT gated on the active tab's provider: the row is a property of the whole
9870
+ * plugin, not of one region, and a signed-out card can still turn it on.
9871
+ */
9872
+ const sidebarPanelPreference = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
9873
+ className: "dsm-workbuddy-pref",
9874
+ title: t("row.sidebarPanelHint"),
9875
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
9876
+ type: "checkbox",
9877
+ className: "dsm-workbuddy-sidebar-panel-check",
9878
+ checked: sidebarPanelSwitchedOn(),
9879
+ disabled: !canWrite || saving || poolBusy || sidebarPanelBusy,
9880
+ onChange: (event) => {
9881
+ toggleSidebarPanel(event.target.checked);
9882
+ }
9883
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
9884
+ className: "dsm-workbuddy-pref-copy",
9885
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9886
+ className: "dsm-workbuddy-pref-label",
9887
+ children: t("row.sidebarPanelLabel")
9888
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9889
+ className: "dsm-workbuddy-pref-hint",
9890
+ children: t("row.sidebarPanelHint")
9891
+ })]
9892
+ })]
9893
+ });
9894
+ /**
9332
9895
  * The two quick-adjust pins of the CLI route, rendered under its switch the
9333
9896
  * way the seat picker sits under its switch: indented, and only while the
9334
9897
  * switch is ON — the pickers configure the route the switch turned on, and
@@ -9638,738 +10201,796 @@ window.__ModuleLoader__.load({
9638
10201
  })
9639
10202
  ]
9640
10203
  });
9641
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
9642
- className: `dsm-plugin-card${open ? " dsm-plugin-card-open" : ""}`,
9643
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
9644
- type: "button",
9645
- className: "dsm-plugin-card-header",
9646
- "aria-expanded": open,
9647
- "aria-label": `${t(open ? "row.collapse" : "row.expand")}: ${title}`,
9648
- onClick: () => {
9649
- setOpen(!open);
9650
- },
10204
+ const pageHead = pageSurface ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10205
+ className: "dsm-workbuddy-page-head",
10206
+ children: [
10207
+ backToConversation !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
10208
+ type: "button",
10209
+ className: "dsm-workbuddy-page-back",
10210
+ onClick: backToConversation,
10211
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
10212
+ width: "14",
10213
+ height: "14",
10214
+ viewBox: "0 0 16 16",
10215
+ fill: "none",
10216
+ "aria-hidden": "true",
10217
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
10218
+ d: "M10 3.5 5.5 8l4.5 4.5",
10219
+ stroke: "currentColor",
10220
+ strokeWidth: "1.6",
10221
+ strokeLinecap: "round",
10222
+ strokeLinejoin: "round"
10223
+ })
10224
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("nav.back") })]
10225
+ }) : null,
10226
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
10227
+ className: "dsm-workbuddy-page-icon",
10228
+ src: WORKBUDDY_PLUGIN_ICON,
10229
+ alt: ""
10230
+ }),
10231
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10232
+ className: "dsm-workbuddy-page-title",
10233
+ children: title
10234
+ }),
10235
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10236
+ className: "dsm-workbuddy-page-desc",
10237
+ children: t("row.desc")
10238
+ })
10239
+ ]
10240
+ }) : null;
10241
+ const cardBody = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CardBodyBoundary, {
10242
+ t,
10243
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10244
+ className: "dsm-workbuddy-usage",
9651
10245
  children: [
9652
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
9653
- className: "dsm-plugin-card-icon",
9654
- src: WORKBUDDY_PLUGIN_ICON,
9655
- alt: ""
9656
- }),
9657
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
9658
- className: "dsm-plugin-card-head",
9659
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9660
- className: "dsm-plugin-card-title",
9661
- children: title
9662
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9663
- className: "dsm-plugin-card-description",
9664
- children: t("row.desc")
9665
- })]
10246
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10247
+ className: "dsm-workbuddy-tabs",
10248
+ role: "tablist",
10249
+ "aria-label": title,
10250
+ children: WORKBUDDY_REGIONS.map((region) => {
10251
+ const regionStatus = statusByRegion[region];
10252
+ const regionOnState = regionOn(region);
10253
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10254
+ className: "dsm-workbuddy-tab-cell",
10255
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
10256
+ type: "button",
10257
+ role: "tab",
10258
+ "aria-selected": region === activeRegion,
10259
+ className: `dsm-workbuddy-tab${region === activeRegion ? " dsm-workbuddy-tab-active" : ""}${regionOnState ? "" : " dsm-workbuddy-tab-off"}`,
10260
+ onClick: () => {
10261
+ setActiveRegion(region);
10262
+ setAccountError(void 0);
10263
+ },
10264
+ children: [regionStatus === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10265
+ "aria-hidden": "true",
10266
+ className: "dsm-workbuddy-tab-dot",
10267
+ style: dotStyle(regionStatus.status)
10268
+ }), region === "cn" ? t("row.tabCn") : t("row.tabGlobal")]
10269
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
10270
+ className: "dsm-workbuddy-tab-switch",
10271
+ title: t("row.tabSwitchHint"),
10272
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10273
+ type: "checkbox",
10274
+ checked: regionOnState,
10275
+ disabled: togglingRegion === region || !canWrite || saving || poolBusy,
10276
+ "aria-label": t("row.tabSwitchAria", { region: region === "cn" ? t("row.tabCn") : t("row.tabGlobal") }),
10277
+ onChange: (event) => {
10278
+ toggleRegion(region, event.target.checked);
10279
+ }
10280
+ })
10281
+ })]
10282
+ }, region);
10283
+ })
9666
10284
  }),
9667
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9668
- "aria-hidden": "true",
9669
- className: `dsm-plugin-card-chevron${open ? " dsm-plugin-card-chevron-open" : ""}`
9670
- })
9671
- ]
9672
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
9673
- className: "dsm-plugin-card-body",
9674
- hidden: !open,
9675
- children: open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CardBodyBoundary, {
9676
- t,
9677
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9678
- className: "dsm-workbuddy-usage",
10285
+ signedIn ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10286
+ className: "dsm-workbuddy-panels",
10287
+ role: "tablist",
10288
+ "aria-label": t("row.panelAria"),
9679
10289
  children: [
9680
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
9681
- className: "dsm-workbuddy-tabs",
9682
- role: "tablist",
9683
- "aria-label": title,
9684
- children: WORKBUDDY_REGIONS.map((region) => {
9685
- const regionStatus = statusByRegion[region];
9686
- const regionOnState = regionOn(region);
9687
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9688
- className: "dsm-workbuddy-tab-cell",
9689
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
9690
- type: "button",
9691
- role: "tab",
9692
- "aria-selected": region === activeRegion,
9693
- className: `dsm-workbuddy-tab${region === activeRegion ? " dsm-workbuddy-tab-active" : ""}${regionOnState ? "" : " dsm-workbuddy-tab-off"}`,
9694
- onClick: () => {
9695
- setActiveRegion(region);
9696
- setAccountError(void 0);
9697
- },
9698
- children: [regionStatus === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9699
- "aria-hidden": "true",
9700
- className: "dsm-workbuddy-tab-dot",
9701
- style: dotStyle(regionStatus.status)
9702
- }), region === "cn" ? t("row.tabCn") : t("row.tabGlobal")]
9703
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
9704
- className: "dsm-workbuddy-tab-switch",
9705
- title: t("row.tabSwitchHint"),
9706
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
9707
- type: "checkbox",
9708
- checked: regionOnState,
9709
- disabled: togglingRegion === region || !canWrite || saving || poolBusy,
9710
- "aria-label": t("row.tabSwitchAria", { region: region === "cn" ? t("row.tabCn") : t("row.tabGlobal") }),
9711
- onChange: (event) => {
9712
- toggleRegion(region, event.target.checked);
9713
- }
9714
- })
9715
- })]
9716
- }, region);
9717
- })
10290
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10291
+ type: "button",
10292
+ role: "tab",
10293
+ id: "dsm-workbuddy-tab-accounts",
10294
+ "aria-controls": "dsm-workbuddy-panel-accounts",
10295
+ "aria-selected": panel === "accounts",
10296
+ className: `dsm-workbuddy-panel-tab${panel === "accounts" ? " dsm-workbuddy-panel-tab-active" : ""}`,
10297
+ onClick: () => {
10298
+ setPanel("accounts");
10299
+ },
10300
+ children: t("row.panelAccounts")
9718
10301
  }),
9719
- signedIn ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9720
- className: "dsm-workbuddy-panels",
9721
- role: "tablist",
9722
- "aria-label": t("row.panelAria"),
9723
- children: [
9724
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
9725
- type: "button",
9726
- role: "tab",
9727
- id: "dsm-workbuddy-tab-accounts",
9728
- "aria-controls": "dsm-workbuddy-panel-accounts",
9729
- "aria-selected": panel === "accounts",
9730
- className: `dsm-workbuddy-panel-tab${panel === "accounts" ? " dsm-workbuddy-panel-tab-active" : ""}`,
9731
- onClick: () => {
9732
- setPanel("accounts");
9733
- },
9734
- children: t("row.panelAccounts")
9735
- }),
9736
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
9737
- type: "button",
9738
- role: "tab",
9739
- id: "dsm-workbuddy-tab-models",
9740
- "aria-controls": "dsm-workbuddy-panel-models",
9741
- "aria-selected": panel === "models",
9742
- className: `dsm-workbuddy-panel-tab${panel === "models" ? " dsm-workbuddy-panel-tab-active" : ""}`,
9743
- onClick: () => {
9744
- setPanel("models");
9745
- },
9746
- children: t("row.panelModels")
9747
- }),
9748
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
9749
- type: "button",
9750
- role: "tab",
9751
- id: "dsm-workbuddy-tab-capabilities",
9752
- "aria-controls": "dsm-workbuddy-panel-capabilities",
9753
- "aria-selected": panel === "capabilities",
9754
- className: `dsm-workbuddy-panel-tab${panel === "capabilities" ? " dsm-workbuddy-panel-tab-active" : ""}`,
9755
- onClick: () => {
9756
- setPanel("capabilities");
9757
- },
9758
- children: t("row.panelCapabilities")
9759
- }),
9760
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
9761
- type: "button",
9762
- role: "tab",
9763
- id: "dsm-workbuddy-tab-diag",
9764
- "aria-controls": "dsm-workbuddy-panel-diag",
9765
- "aria-selected": panel === "diag",
9766
- className: `dsm-workbuddy-panel-tab${panel === "diag" ? " dsm-workbuddy-panel-tab-active" : ""}`,
9767
- onClick: () => {
9768
- setPanel("diag");
9769
- },
9770
- children: t("row.panelDiag")
9771
- }),
9772
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
9773
- type: "button",
9774
- role: "tab",
9775
- id: "dsm-workbuddy-tab-sdk",
9776
- "aria-controls": "dsm-workbuddy-panel-sdk",
9777
- "aria-selected": panel === "sdk",
9778
- className: `dsm-workbuddy-panel-tab${panel === "sdk" ? " dsm-workbuddy-panel-tab-active" : ""}`,
9779
- onClick: () => {
9780
- setPanel("sdk");
9781
- },
9782
- children: t("row.panelSdk")
9783
- })
9784
- ]
10302
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10303
+ type: "button",
10304
+ role: "tab",
10305
+ id: "dsm-workbuddy-tab-models",
10306
+ "aria-controls": "dsm-workbuddy-panel-models",
10307
+ "aria-selected": panel === "models",
10308
+ className: `dsm-workbuddy-panel-tab${panel === "models" ? " dsm-workbuddy-panel-tab-active" : ""}`,
10309
+ onClick: () => {
10310
+ setPanel("models");
10311
+ },
10312
+ children: t("row.panelModels")
10313
+ }),
10314
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10315
+ type: "button",
10316
+ role: "tab",
10317
+ id: "dsm-workbuddy-tab-capabilities",
10318
+ "aria-controls": "dsm-workbuddy-panel-capabilities",
10319
+ "aria-selected": panel === "capabilities",
10320
+ className: `dsm-workbuddy-panel-tab${panel === "capabilities" ? " dsm-workbuddy-panel-tab-active" : ""}`,
10321
+ onClick: () => {
10322
+ setPanel("capabilities");
10323
+ },
10324
+ children: t("row.panelCapabilities")
10325
+ }),
10326
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10327
+ type: "button",
10328
+ role: "tab",
10329
+ id: "dsm-workbuddy-tab-diag",
10330
+ "aria-controls": "dsm-workbuddy-panel-diag",
10331
+ "aria-selected": panel === "diag",
10332
+ className: `dsm-workbuddy-panel-tab${panel === "diag" ? " dsm-workbuddy-panel-tab-active" : ""}`,
10333
+ onClick: () => {
10334
+ setPanel("diag");
10335
+ },
10336
+ children: t("row.panelDiag")
10337
+ }),
10338
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10339
+ type: "button",
10340
+ role: "tab",
10341
+ id: "dsm-workbuddy-tab-sdk",
10342
+ "aria-controls": "dsm-workbuddy-panel-sdk",
10343
+ "aria-selected": panel === "sdk",
10344
+ className: `dsm-workbuddy-panel-tab${panel === "sdk" ? " dsm-workbuddy-panel-tab-active" : ""}`,
10345
+ onClick: () => {
10346
+ setPanel("sdk");
10347
+ },
10348
+ children: t("row.panelSdk")
10349
+ })
10350
+ ]
10351
+ }) : null,
10352
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10353
+ className: "dsm-workbuddy-panel",
10354
+ role: "tabpanel",
10355
+ id: "dsm-workbuddy-panel-accounts",
10356
+ "aria-labelledby": "dsm-workbuddy-tab-accounts",
10357
+ hidden: signedIn && panel !== "accounts",
10358
+ children: [
10359
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10360
+ className: "dsm-workbuddy-models-summary",
10361
+ children: t("row.tabHint")
10362
+ }),
10363
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10364
+ className: "dsm-workbuddy-models-summary dsm-workbuddy-free-quota-warn",
10365
+ children: t("row.tabFreeQuotaWarn")
10366
+ }),
10367
+ !activeRegionOn ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10368
+ className: "dsm-workbuddy-tab-off-notice",
10369
+ children: t("row.tabOffNotice")
10370
+ }) : null,
10371
+ status.status === "error" || status.status === "signed-in" && status.creditsError !== void 0 ? status.status === "signed-in" && status.credentialRejected === true ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10372
+ className: "dsm-workbuddy-usage-hint",
10373
+ children: t("row.reloginHint")
10374
+ }) : null,
10375
+ accountError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10376
+ className: "dsm-workbuddy-account-error",
10377
+ role: "alert",
10378
+ children: accountError
10379
+ }),
10380
+ selectionLost ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10381
+ className: "dsm-workbuddy-usage-hint",
10382
+ children: t("row.selectionLostHint")
10383
+ }) : null,
10384
+ vaultUnreadable !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10385
+ className: "dsm-workbuddy-account-error",
10386
+ role: "alert",
10387
+ children: t("row.vaultUnreadableHint", { message: vaultUnreadable })
9785
10388
  }) : null,
9786
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9787
- className: "dsm-workbuddy-panel",
9788
- role: "tabpanel",
9789
- id: "dsm-workbuddy-panel-accounts",
9790
- "aria-labelledby": "dsm-workbuddy-tab-accounts",
9791
- hidden: signedIn && panel !== "accounts",
10389
+ status.status === "signed-in" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
10390
+ status.credentialRejected === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
10391
+ className: "dsm-workbuddy-usage-error",
10392
+ role: "alert",
10393
+ children: [
10394
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: t("row.credentialRejectedTitle") }),
10395
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("row.credentialRejectedIntro", { accountName: nameOf(status.accountName) }) }),
10396
+ status.recovery?.usableAccount !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("row.credentialRejectedSwitch", { accountName: nameOf(status.recovery.usableAccount.accountName) }) }) : status.recovery?.reloginRequired === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("row.credentialRejectedRelogin") }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("row.credentialRejectedChoose") }),
10397
+ status.recovery?.usableAccount === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10398
+ type: "button",
10399
+ className: "dsm-btn dsm-btn-outline",
10400
+ disabled: switchingAccount || !canWrite,
10401
+ onClick: () => {
10402
+ const target = status.recovery?.usableAccount;
10403
+ if (target !== void 0) switchAccount(target.accountId);
10404
+ },
10405
+ children: switchingAccount ? t("row.accountsScanning") : t("row.credentialRejectedSwitchAction", { accountName: nameOf(status.recovery.usableAccount.accountName) })
10406
+ })
10407
+ ]
10408
+ }) : null,
10409
+ status.creditsError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10410
+ className: "dsm-workbuddy-usage-error",
10411
+ children: t("row.creditsError", { message: status.creditsError })
10412
+ }),
10413
+ status.refreshError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10414
+ className: "dsm-workbuddy-usage-error",
10415
+ role: "alert",
10416
+ children: t("row.requestFailedHint", { message: status.refreshError })
10417
+ }),
10418
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccountPool, {
10419
+ t,
10420
+ region: activeRegion,
10421
+ ...status.pool === void 0 ? {} : { pool: status.pool },
10422
+ ...settingsScope === void 0 ? {} : { settingsScope },
10423
+ onRescan: () => {
10424
+ rescanAccounts();
10425
+ },
10426
+ rescanning: busy,
10427
+ onSelectAccount: (accountId) => {
10428
+ switchAccount(accountId);
10429
+ },
10430
+ selectingAccount: switchingAccount,
10431
+ accountTools,
10432
+ siblingBusy: saving || togglingRegion !== void 0,
10433
+ onBusyChange: setPoolBusy,
10434
+ onSaved: async () => await refreshUsage(activeRegion) !== void 0,
10435
+ onRefresh: () => refreshUsage(activeRegion),
10436
+ ...deviceSettings === void 0 ? {} : {
10437
+ deviceMode: deviceSettings.mode,
10438
+ deviceProfiles: deviceSettings.accounts,
10439
+ ...deviceSettings.derived === void 0 ? {} : { deviceDerived: deviceSettings.derived },
10440
+ onDeviceModeChange: changeDeviceMode,
10441
+ onSaveDeviceProfile: saveDeviceProfile,
10442
+ ...deviceSettings.realTier === void 0 ? {} : { realTier: deviceSettings.realTier }
10443
+ }
10444
+ })
10445
+ ] }) : null
10446
+ ]
10447
+ }),
10448
+ signedIn ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10449
+ className: "dsm-workbuddy-panel",
10450
+ role: "tabpanel",
10451
+ id: "dsm-workbuddy-panel-models",
10452
+ "aria-labelledby": "dsm-workbuddy-tab-models",
10453
+ hidden: panel !== "models",
10454
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
10455
+ className: "dsm-workbuddy-models",
10456
+ "aria-label": t("row.modelsTitle"),
10457
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10458
+ className: "dsm-workbuddy-models-fold",
9792
10459
  children: [
9793
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
9794
- className: "dsm-workbuddy-models-summary",
9795
- children: t("row.tabHint")
9796
- }),
9797
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
9798
- className: "dsm-workbuddy-models-summary dsm-workbuddy-free-quota-warn",
9799
- children: t("row.tabFreeQuotaWarn")
9800
- }),
9801
- !activeRegionOn ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
9802
- className: "dsm-workbuddy-tab-off-notice",
9803
- children: t("row.tabOffNotice")
9804
- }) : null,
9805
- status.status === "error" || status.status === "signed-in" && status.creditsError !== void 0 ? status.status === "signed-in" && status.credentialRejected === true ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
9806
- className: "dsm-workbuddy-usage-hint",
9807
- children: t("row.reloginHint")
9808
- }) : null,
9809
- accountError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
9810
- className: "dsm-workbuddy-account-error",
9811
- role: "alert",
9812
- children: accountError
9813
- }),
9814
- selectionLost ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
9815
- className: "dsm-workbuddy-usage-hint",
9816
- children: t("row.selectionLostHint")
9817
- }) : null,
9818
- status.status === "signed-in" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
9819
- status.credentialRejected === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
9820
- className: "dsm-workbuddy-usage-error",
9821
- role: "alert",
10460
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10461
+ className: "dsm-workbuddy-models-head",
10462
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10463
+ className: "dsm-workbuddy-models-title-row",
10464
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
10465
+ className: "dsm-workbuddy-models-title",
10466
+ children: [t("row.modelsTitle"), dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10467
+ className: "dsm-workbuddy-models-dirty",
10468
+ children: t("row.modelsDirty")
10469
+ }) : null]
10470
+ })
10471
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10472
+ className: "dsm-workbuddy-models-summary",
10473
+ children: t("row.modelsSummary", { count: activeEnabledIds.size })
10474
+ })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10475
+ className: "dsm-workbuddy-models-head-actions",
9822
10476
  children: [
9823
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: t("row.credentialRejectedTitle") }),
9824
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("row.credentialRejectedIntro", { accountName: nameOf(status.accountName) }) }),
9825
- status.recovery?.usableAccount !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("row.credentialRejectedSwitch", { accountName: nameOf(status.recovery.usableAccount.accountName) }) }) : status.recovery?.reloginRequired === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("row.credentialRejectedRelogin") }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: t("row.credentialRejectedChoose") }),
9826
- status.recovery?.usableAccount === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10477
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
9827
10478
  type: "button",
9828
10479
  className: "dsm-btn dsm-btn-outline",
9829
- disabled: switchingAccount || !canWrite,
10480
+ disabled: busy,
9830
10481
  onClick: () => {
9831
- const target = status.recovery?.usableAccount;
9832
- if (target !== void 0) switchAccount(target.accountId);
10482
+ refreshModels();
9833
10483
  },
9834
- children: switchingAccount ? t("row.accountsScanning") : t("row.credentialRejectedSwitchAction", { accountName: nameOf(status.recovery.usableAccount.accountName) })
10484
+ children: busy ? t("row.modelsRefreshing") : t("row.modelsRefresh")
10485
+ }),
10486
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10487
+ type: "button",
10488
+ className: "dsm-btn dsm-btn-outline dsm-workbuddy-models-sweep",
10489
+ disabled: busy || sweeping !== void 0 || activeEnabledIds.size === 0,
10490
+ title: t("row.modelsTestEnabledHint"),
10491
+ onClick: sweepEnabledModels,
10492
+ children: sweeping === void 0 ? t("row.modelsTestEnabled") : t("row.modelsTesting", {
10493
+ done: sweeping.done,
10494
+ total: sweeping.total
10495
+ })
10496
+ }),
10497
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10498
+ type: "button",
10499
+ className: "dsm-btn dsm-btn-outline dsm-workbuddy-models-sweep",
10500
+ disabled: busy || sweeping !== void 0 || visibleModels.length === 0,
10501
+ title: t("row.modelsTestAllHint"),
10502
+ onClick: sweepAllModels,
10503
+ children: sweeping === void 0 ? t("row.modelsTestAll") : t("row.modelsTesting", {
10504
+ done: sweeping.done,
10505
+ total: sweeping.total
10506
+ })
10507
+ }),
10508
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10509
+ type: "button",
10510
+ className: "dsm-btn dsm-btn-outline dsm-workbuddy-models-sweep",
10511
+ disabled: busy || tpsSweeping !== void 0 || tpsBusy || activeEnabledIds.size === 0,
10512
+ title: t("row.tpsSweepEnabledHint"),
10513
+ onClick: sweepTpsEnabledModels,
10514
+ children: tpsSweeping === void 0 ? t("row.tpsSweepEnabled") : t("row.tpsTesting", {
10515
+ done: tpsSweeping.done,
10516
+ total: tpsSweeping.total
10517
+ })
9835
10518
  })
9836
10519
  ]
9837
- }) : null,
9838
- status.creditsError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
9839
- className: "dsm-workbuddy-usage-error",
9840
- children: t("row.creditsError", { message: status.creditsError })
9841
- }),
9842
- status.refreshError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
9843
- className: "dsm-workbuddy-usage-error",
9844
- role: "alert",
9845
- children: t("row.requestFailedHint", { message: status.refreshError })
9846
- }),
9847
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AccountPool, {
9848
- t,
9849
- region: activeRegion,
9850
- ...status.pool === void 0 ? {} : { pool: status.pool },
9851
- ...settingsScope === void 0 ? {} : { settingsScope },
9852
- onRescan: () => {
9853
- rescanAccounts();
9854
- },
9855
- rescanning: busy,
9856
- onSelectAccount: (accountId) => {
9857
- switchAccount(accountId);
9858
- },
9859
- selectingAccount: switchingAccount,
9860
- accountTools,
9861
- siblingBusy: saving || togglingRegion !== void 0,
9862
- onBusyChange: setPoolBusy,
9863
- onSaved: async () => await refreshUsage(activeRegion) !== void 0,
9864
- onRefresh: () => refreshUsage(activeRegion),
9865
- ...deviceSettings === void 0 ? {} : {
9866
- deviceMode: deviceSettings.mode,
9867
- deviceProfiles: deviceSettings.accounts,
9868
- ...deviceSettings.derived === void 0 ? {} : { deviceDerived: deviceSettings.derived },
9869
- onDeviceModeChange: changeDeviceMode,
9870
- onSaveDeviceProfile: saveDeviceProfile
9871
- }
9872
- })
9873
- ] }) : null
9874
- ]
9875
- }),
9876
- signedIn ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
9877
- className: "dsm-workbuddy-panel",
9878
- role: "tabpanel",
9879
- id: "dsm-workbuddy-panel-models",
9880
- "aria-labelledby": "dsm-workbuddy-tab-models",
9881
- hidden: panel !== "models",
9882
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
9883
- className: "dsm-workbuddy-models",
9884
- "aria-label": t("row.modelsTitle"),
9885
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9886
- className: "dsm-workbuddy-models-fold",
9887
- children: [
9888
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9889
- className: "dsm-workbuddy-models-head",
9890
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
9891
- className: "dsm-workbuddy-models-title-row",
9892
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
9893
- className: "dsm-workbuddy-models-title",
9894
- children: [t("row.modelsTitle"), dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
9895
- className: "dsm-workbuddy-models-dirty",
9896
- children: t("row.modelsDirty")
9897
- }) : null]
9898
- })
9899
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
9900
- className: "dsm-workbuddy-models-summary",
9901
- children: t("row.modelsSummary", { count: activeEnabledIds.size })
9902
- })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9903
- className: "dsm-workbuddy-models-head-actions",
10520
+ })]
10521
+ }),
10522
+ probeError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10523
+ className: "dsm-workbuddy-model-probe-result dsm-workbuddy-model-probe-result-bad",
10524
+ role: "alert",
10525
+ children: t("row.probeError", { message: probeError })
10526
+ }),
10527
+ sweepSummary === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10528
+ className: "dsm-workbuddy-models-sweep-summary",
10529
+ role: "status",
10530
+ children: sweepSummary
10531
+ }),
10532
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10533
+ className: "dsm-workbuddy-model-list",
10534
+ children: visibleModels.map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10535
+ className: `dsm-workbuddy-model${activeEnabledIds.has(model.id) ? "" : " dsm-workbuddy-model-disabled"}`,
10536
+ children: [
10537
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10538
+ className: "dsm-workbuddy-model-head",
9904
10539
  children: [
9905
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
9906
- type: "button",
9907
- className: "dsm-btn dsm-btn-outline",
9908
- disabled: busy,
9909
- onClick: () => {
9910
- refreshModels();
9911
- },
9912
- children: busy ? t("row.modelsRefreshing") : t("row.modelsRefresh")
9913
- }),
9914
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
9915
- type: "button",
9916
- className: "dsm-btn dsm-btn-outline dsm-workbuddy-models-sweep",
9917
- disabled: busy || sweeping !== void 0 || activeEnabledIds.size === 0,
9918
- title: t("row.modelsTestEnabledHint"),
9919
- onClick: sweepEnabledModels,
9920
- children: sweeping === void 0 ? t("row.modelsTestEnabled") : t("row.modelsTesting", {
9921
- done: sweeping.done,
9922
- total: sweeping.total
9923
- })
10540
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
10541
+ className: "dsm-workbuddy-model-enabled",
10542
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10543
+ type: "checkbox",
10544
+ checked: activeEnabledIds.has(model.id),
10545
+ disabled: !canWrite || saving,
10546
+ onChange: () => {
10547
+ toggleModel(model.id);
10548
+ }
10549
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
10550
+ className: "dsm-workbuddy-model-copy",
10551
+ children: [
10552
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
10553
+ className: "dsm-workbuddy-model-name",
10554
+ children: [model.name, effectiveRate(model) === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
10555
+ className: "dsm-workbuddy-model-name-rate",
10556
+ children: ["x", effectiveRate(model).toFixed(2)]
10557
+ })]
10558
+ }),
10559
+ promoChip(model),
10560
+ busyIcon(busyLevels[model.id], uiLanguage())
10561
+ ]
10562
+ })]
9924
10563
  }),
9925
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
9926
- type: "button",
9927
- className: "dsm-btn dsm-btn-outline dsm-workbuddy-models-sweep",
9928
- disabled: busy || sweeping !== void 0 || visibleModels.length === 0,
9929
- title: t("row.modelsTestAllHint"),
9930
- onClick: sweepAllModels,
9931
- children: sweeping === void 0 ? t("row.modelsTestAll") : t("row.modelsTesting", {
9932
- done: sweeping.done,
9933
- total: sweeping.total
9934
- })
10564
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
10565
+ className: "dsm-workbuddy-model-image",
10566
+ title: imageCheckboxHint(model, t),
10567
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10568
+ type: "checkbox",
10569
+ checked: activeImageIds.has(model.id),
10570
+ disabled: !canWrite || saving,
10571
+ onChange: () => {
10572
+ toggleImage(model.id);
10573
+ }
10574
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("row.modelImage") })]
9935
10575
  }),
9936
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
9937
- type: "button",
9938
- className: "dsm-btn dsm-btn-outline dsm-workbuddy-models-sweep",
9939
- disabled: busy || tpsSweeping !== void 0 || tpsBusy || activeEnabledIds.size === 0,
9940
- title: t("row.tpsSweepEnabledHint"),
9941
- onClick: sweepTpsEnabledModels,
9942
- children: tpsSweeping === void 0 ? t("row.tpsSweepEnabled") : t("row.tpsTesting", {
9943
- done: tpsSweeping.done,
9944
- total: tpsSweeping.total
9945
- })
9946
- })
9947
- ]
9948
- })]
9949
- }),
9950
- probeError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
9951
- className: "dsm-workbuddy-model-probe-result dsm-workbuddy-model-probe-result-bad",
9952
- role: "alert",
9953
- children: t("row.probeError", { message: probeError })
9954
- }),
9955
- sweepSummary === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
9956
- className: "dsm-workbuddy-models-sweep-summary",
9957
- role: "status",
9958
- children: sweepSummary
9959
- }),
9960
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
9961
- className: "dsm-workbuddy-model-list",
9962
- children: visibleModels.map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9963
- className: `dsm-workbuddy-model${activeEnabledIds.has(model.id) ? "" : " dsm-workbuddy-model-disabled"}`,
9964
- children: [
9965
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
9966
- className: "dsm-workbuddy-model-head",
10576
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
10577
+ className: `dsm-workbuddy-model-off${offBlocked(model) ? " dsm-workbuddy-model-off-blocked" : ""}`,
10578
+ title: offBlocked(model) ? t("row.modelOffRefusedHint") : t("row.modelOffHint"),
9967
10579
  children: [
9968
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
9969
- className: "dsm-workbuddy-model-enabled",
9970
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
9971
- type: "checkbox",
9972
- checked: activeEnabledIds.has(model.id),
9973
- disabled: !canWrite || saving,
9974
- onChange: () => {
9975
- toggleModel(model.id);
9976
- }
9977
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
9978
- className: "dsm-workbuddy-model-copy",
9979
- children: [
9980
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
9981
- className: "dsm-workbuddy-model-name",
9982
- children: [model.name, effectiveRate(model) === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
9983
- className: "dsm-workbuddy-model-name-rate",
9984
- children: ["x", effectiveRate(model).toFixed(2)]
9985
- })]
9986
- }),
9987
- promoChip(model),
9988
- busyIcon(busyLevels[model.id], uiLanguage())
9989
- ]
9990
- })]
9991
- }),
9992
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
9993
- className: "dsm-workbuddy-model-image",
9994
- title: imageCheckboxHint(model, t),
9995
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
9996
- type: "checkbox",
9997
- checked: activeImageIds.has(model.id),
9998
- disabled: !canWrite || saving,
9999
- onChange: () => {
10000
- toggleImage(model.id);
10001
- }
10002
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("row.modelImage") })]
10580
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10581
+ type: "checkbox",
10582
+ checked: activeOffIds.has(model.id),
10583
+ disabled: !canWrite || saving || offBlocked(model),
10584
+ onChange: () => {
10585
+ toggleOff(model.id);
10586
+ }
10003
10587
  }),
10004
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
10005
- className: `dsm-workbuddy-model-off${offBlocked(model) ? " dsm-workbuddy-model-off-blocked" : ""}`,
10006
- title: offBlocked(model) ? t("row.modelOffRefusedHint") : t("row.modelOffHint"),
10007
- children: [
10008
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10009
- type: "checkbox",
10010
- checked: activeOffIds.has(model.id),
10011
- disabled: !canWrite || saving || offBlocked(model),
10012
- onChange: () => {
10013
- toggleOff(model.id);
10014
- }
10015
- }),
10016
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("row.modelOff") }),
10017
- offBlocked(model) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10018
- className: "dsm-workbuddy-model-off-flag",
10019
- children: t("row.modelOffRefused")
10020
- }) : null
10021
- ]
10022
- }),
10023
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
10024
- className: "dsm-workbuddy-context-budget",
10025
- "aria-label": t("row.contextBudget"),
10026
- children: [
10027
- model.nativeContextWindow > 2e5 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10028
- type: "radio",
10029
- name: `context-${model.id}`,
10030
- checked: (activeContextBudgets[model.id] ?? 2e5) === 2e5,
10031
- disabled: !canWrite || saving,
10032
- onChange: () => {
10033
- setContextBudget(model.id, 2e5);
10034
- }
10035
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "200K" })] }) : null,
10036
- model.nativeContextWindow > 5e5 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10037
- type: "radio",
10038
- name: `context-${model.id}`,
10039
- checked: activeContextBudgets[model.id] === 5e5,
10040
- disabled: !canWrite || saving,
10041
- onChange: () => {
10042
- setContextBudget(model.id, 5e5);
10043
- }
10044
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "500K" })] }) : null,
10045
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10046
- type: "radio",
10047
- name: `context-${model.id}`,
10048
- checked: model.nativeContextWindow <= 2e5 || activeContextBudgets[model.id] === model.nativeContextWindow,
10049
- disabled: model.nativeContextWindow <= 2e5 || !canWrite || saving,
10050
- onChange: () => {
10051
- setContextBudget(model.id, model.nativeContextWindow);
10052
- }
10053
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: formatCapacity(model.nativeContextWindow, t("row.modelUnknown")) })] })
10054
- ]
10055
- }),
10056
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10057
- className: "dsm-workbuddy-model-actions-buttons",
10058
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10059
- type: "button",
10060
- className: "dsm-btn dsm-btn-outline dsm-workbuddy-model-probe",
10061
- disabled: probing[model.id] === true || status.status !== "signed-in",
10062
- title: t("row.probeHint"),
10063
- onClick: () => {
10064
- probeModels([model.id]);
10065
- },
10066
- children: probing[model.id] === true ? t("row.probing") : t("row.probe")
10067
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10068
- type: "button",
10069
- className: "dsm-btn dsm-btn-outline dsm-workbuddy-model-probe",
10070
- disabled: tpsProbing[model.id] === true || status.status !== "signed-in",
10071
- title: t("row.tpsHint"),
10072
- onClick: () => {
10073
- measureTpsFor([model.id]);
10074
- },
10075
- children: tpsProbing[model.id] === true ? t("row.tpsMeasuring") : t("row.tpsMeasure")
10076
- })]
10077
- })
10588
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("row.modelOff") }),
10589
+ offBlocked(model) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10590
+ className: "dsm-workbuddy-model-off-flag",
10591
+ children: t("row.modelOffRefused")
10592
+ }) : null
10078
10593
  ]
10079
10594
  }),
10080
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10081
- className: "dsm-workbuddy-model-details",
10082
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10083
- className: "dsm-workbuddy-model-meta",
10084
- children: [
10085
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("row.modelContext", { context: formatCapacity(model.nativeContextWindow, t("row.modelUnknown")) }) }),
10086
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("row.modelOutput", { output: formatCapacity(model.maxTokens, t("row.modelUnknown")) }) }),
10087
- (() => {
10088
- const efforts = selectableEfforts(model.reasoning);
10089
- if (efforts.length === 0) return null;
10090
- const saved = activeDefaultEfforts[model.id];
10091
- const chosen = typeof saved === "string" && efforts.includes(saved) ? saved : "";
10092
- const upstream = model.reasoning?.defaultEffort;
10093
- const followLabel = upstream !== void 0 && efforts.includes(upstream) ? t("row.modelEffortFollowNamed", { effort: upstream }) : t("row.modelEffortFollow");
10094
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
10095
- className: "dsm-workbuddy-model-effort",
10096
- title: t("row.modelEffortHint"),
10097
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("row.modelEffortLabel") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
10098
- className: "dsm-workbuddy-model-effort-select",
10099
- value: chosen,
10100
- disabled: !canWrite || saving,
10101
- "aria-label": t("row.modelEffortAria", { model: model.name }),
10102
- onChange: (event) => {
10103
- setDefaultThinkingEffort(model.id, event.currentTarget.value);
10104
- },
10105
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
10106
- value: "",
10107
- children: followLabel
10108
- }), efforts.map((level) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
10109
- value: level,
10110
- children: level
10111
- }, level))]
10112
- })]
10113
- });
10114
- })()
10115
- ]
10116
- })
10595
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
10596
+ className: "dsm-workbuddy-context-budget",
10597
+ "aria-label": t("row.contextBudget"),
10598
+ children: [
10599
+ model.nativeContextWindow > 2e5 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10600
+ type: "radio",
10601
+ name: `context-${model.id}`,
10602
+ checked: effectiveContextBudget(model.nativeContextWindow, activeContextBudgets[model.id]) === 2e5,
10603
+ disabled: !canWrite || saving,
10604
+ onChange: () => {
10605
+ setContextBudget(model.id, 2e5);
10606
+ }
10607
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "200K" })] }) : null,
10608
+ model.nativeContextWindow > 5e5 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10609
+ type: "radio",
10610
+ name: `context-${model.id}`,
10611
+ checked: effectiveContextBudget(model.nativeContextWindow, activeContextBudgets[model.id]) === 5e5,
10612
+ disabled: !canWrite || saving,
10613
+ onChange: () => {
10614
+ setContextBudget(model.id, 5e5);
10615
+ }
10616
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "500K" })] }) : null,
10617
+ model.nativeContextWindow > 2e5 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10618
+ type: "radio",
10619
+ name: `context-${model.id}`,
10620
+ checked: effectiveContextBudget(model.nativeContextWindow, activeContextBudgets[model.id]) === model.nativeContextWindow,
10621
+ disabled: !canWrite || saving,
10622
+ onChange: () => {
10623
+ setContextBudget(model.id, void 0);
10624
+ }
10625
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: formatCapacity(model.nativeContextWindow, t("row.modelUnknown")) })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
10626
+ type: "radio",
10627
+ name: `context-${model.id}`,
10628
+ checked: true,
10629
+ disabled: true,
10630
+ onChange: () => {}
10631
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: formatCapacity(model.nativeContextWindow, t("row.modelUnknown")) })] })
10632
+ ]
10117
10633
  }),
10118
- (() => {
10119
- const result = probes[activeRegion]?.[model.id];
10120
- if (result === void 0) return null;
10121
- const view = probeResultView(result, t);
10122
- const reason = inlineProbeReason(result.outcome, result.message);
10123
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
10124
- className: `dsm-workbuddy-model-probe-result dsm-workbuddy-model-probe-result-${view.tone}`,
10125
- role: "status",
10126
- ...result.message === void 0 ? {} : { title: result.message },
10127
- children: [view.text, reason === void 0 ? null : " · " + reason]
10128
- });
10129
- })(),
10130
- (() => {
10131
- const measured = tpsResults[model.id];
10132
- if (measured === void 0) return null;
10133
- const view = tpsResultView(measured, t, tpsMeasuredAt[model.id]);
10134
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10135
- className: `dsm-workbuddy-model-probe-result dsm-workbuddy-model-probe-result-${view.tone}`,
10136
- role: "status",
10137
- children: view.text
10138
- });
10139
- })()
10634
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10635
+ className: "dsm-workbuddy-model-actions-buttons",
10636
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10637
+ type: "button",
10638
+ className: "dsm-btn dsm-btn-outline dsm-workbuddy-model-probe",
10639
+ disabled: probing[model.id] === true || status.status !== "signed-in",
10640
+ title: t("row.probeHint"),
10641
+ onClick: () => {
10642
+ probeModels([model.id]);
10643
+ },
10644
+ children: probing[model.id] === true ? t("row.probing") : t("row.probe")
10645
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10646
+ type: "button",
10647
+ className: "dsm-btn dsm-btn-outline dsm-workbuddy-model-probe",
10648
+ disabled: tpsProbing[model.id] === true || status.status !== "signed-in",
10649
+ title: t("row.tpsHint"),
10650
+ onClick: () => {
10651
+ measureTpsFor([model.id]);
10652
+ },
10653
+ children: tpsProbing[model.id] === true ? t("row.tpsMeasuring") : t("row.tpsMeasure")
10654
+ })]
10655
+ })
10140
10656
  ]
10141
- }, model.id))
10657
+ }),
10658
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10659
+ className: "dsm-workbuddy-model-details",
10660
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10661
+ className: "dsm-workbuddy-model-meta",
10662
+ children: [
10663
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("row.modelContext", { context: formatCapacity(model.nativeContextWindow, t("row.modelUnknown")) }) }),
10664
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("row.modelOutput", { output: formatCapacity(model.maxTokens, t("row.modelUnknown")) }) }),
10665
+ (() => {
10666
+ const efforts = selectableEfforts(model.reasoning);
10667
+ if (efforts.length === 0) return null;
10668
+ const saved = activeDefaultEfforts[model.id];
10669
+ const chosen = typeof saved === "string" && efforts.includes(saved) ? saved : "";
10670
+ const follow = defaultEffortFor(model);
10671
+ const followLabel = follow !== void 0 ? t("row.modelEffortFollowNamed", { effort: follow }) : t("row.modelEffortFollow");
10672
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
10673
+ className: "dsm-workbuddy-model-effort",
10674
+ title: t("row.modelEffortHint"),
10675
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("row.modelEffortLabel") }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
10676
+ className: "dsm-workbuddy-model-effort-select",
10677
+ value: chosen,
10678
+ disabled: !canWrite || saving,
10679
+ "aria-label": t("row.modelEffortAria", { model: model.name }),
10680
+ onChange: (event) => {
10681
+ setDefaultThinkingEffort(model.id, event.currentTarget.value);
10682
+ },
10683
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
10684
+ value: "",
10685
+ children: followLabel
10686
+ }), efforts.map((level) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
10687
+ value: level,
10688
+ children: level
10689
+ }, level))]
10690
+ })]
10691
+ });
10692
+ })()
10693
+ ]
10694
+ })
10695
+ }),
10696
+ (() => {
10697
+ const result = probes[activeRegion]?.[model.id];
10698
+ if (result === void 0) return null;
10699
+ const view = probeResultView(result, t);
10700
+ const reason = inlineProbeReason(result.outcome, result.message);
10701
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
10702
+ className: `dsm-workbuddy-model-probe-result dsm-workbuddy-model-probe-result-${view.tone}`,
10703
+ role: "status",
10704
+ ...result.message === void 0 ? {} : { title: result.message },
10705
+ children: [view.text, reason === void 0 ? null : " · " + reason]
10706
+ });
10707
+ })(),
10708
+ (() => {
10709
+ const measured = tpsResults[model.id];
10710
+ if (measured === void 0) return null;
10711
+ const view = tpsResultView(measured, t, tpsMeasuredAt[model.id]);
10712
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10713
+ className: `dsm-workbuddy-model-probe-result dsm-workbuddy-model-probe-result-${view.tone}`,
10714
+ role: "status",
10715
+ children: view.text
10716
+ });
10717
+ })()
10718
+ ]
10719
+ }, model.id))
10720
+ }),
10721
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10722
+ className: "dsm-workbuddy-model-capability-note",
10723
+ children: t("row.modelCapabilityPending")
10724
+ }),
10725
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10726
+ className: "dsm-workbuddy-model-actions",
10727
+ children: [
10728
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
10729
+ className: "dsm-workbuddy-usage-cheer",
10730
+ href: WORKBUDDY_GITHUB_URL,
10731
+ target: "_blank",
10732
+ rel: "noopener noreferrer",
10733
+ children: [t("row.cheer"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10734
+ className: "dsm-workbuddy-usage-cheer-star",
10735
+ "aria-hidden": "true",
10736
+ children: "★"
10737
+ })]
10142
10738
  }),
10143
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10144
- className: "dsm-workbuddy-model-capability-note",
10145
- children: t("row.modelCapabilityPending")
10739
+ saveError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10740
+ className: "dsm-workbuddy-model-save-error",
10741
+ children: t("row.saveError", { message: saveError })
10146
10742
  }),
10147
10743
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10148
- className: "dsm-workbuddy-model-actions",
10149
- children: [
10150
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
10151
- className: "dsm-workbuddy-usage-cheer",
10152
- href: WORKBUDDY_GITHUB_URL,
10153
- target: "_blank",
10154
- rel: "noopener noreferrer",
10155
- children: [t("row.cheer"), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10156
- className: "dsm-workbuddy-usage-cheer-star",
10157
- "aria-hidden": "true",
10158
- children: "★"
10159
- })]
10160
- }),
10161
- saveError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10162
- className: "dsm-workbuddy-model-save-error",
10163
- children: t("row.saveError", { message: saveError })
10164
- }),
10165
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10166
- className: "dsm-workbuddy-model-actions-buttons",
10167
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10168
- type: "button",
10169
- className: "dsm-btn dsm-btn-outline",
10170
- disabled: !dirty || saving || poolBusy || togglingRegion !== void 0,
10171
- onClick: discardModels,
10172
- children: t("row.discard")
10173
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10174
- type: "button",
10175
- className: "dsm-btn dsm-btn-primary",
10176
- disabled: !dirty || saving || poolBusy || togglingRegion !== void 0 || activeEnabledIds.size === 0,
10177
- onClick: () => {
10178
- saveModels();
10179
- },
10180
- children: saving ? t("row.saving") : t("row.save")
10181
- })]
10182
- })
10183
- ]
10744
+ className: "dsm-workbuddy-model-actions-buttons",
10745
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10746
+ type: "button",
10747
+ className: "dsm-btn dsm-btn-outline",
10748
+ disabled: !dirty || saving || poolBusy || togglingRegion !== void 0,
10749
+ onClick: discardModels,
10750
+ children: t("row.discard")
10751
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10752
+ type: "button",
10753
+ className: "dsm-btn dsm-btn-primary",
10754
+ disabled: !dirty || saving || poolBusy || togglingRegion !== void 0 || activeEnabledIds.size === 0,
10755
+ onClick: () => {
10756
+ saveModels();
10757
+ },
10758
+ children: saving ? t("row.saving") : t("row.save")
10759
+ })]
10184
10760
  })
10185
10761
  ]
10186
10762
  })
10187
- })
10188
- }) : null,
10189
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10190
- className: "dsm-workbuddy-panel",
10191
- role: "tabpanel",
10192
- id: "dsm-workbuddy-panel-capabilities",
10193
- "aria-labelledby": "dsm-workbuddy-tab-capabilities",
10194
- hidden: signedIn && panel !== "capabilities",
10195
- children: [
10196
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10197
- className: "dsm-workbuddy-panel-note",
10198
- children: t("row.panelCapabilitiesHint")
10199
- }),
10200
- creditPreferences,
10201
- upstreamSwitches,
10202
- channelRejectContinuePreference
10203
10763
  ]
10764
+ })
10765
+ })
10766
+ }) : null,
10767
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10768
+ className: "dsm-workbuddy-panel",
10769
+ role: "tabpanel",
10770
+ id: "dsm-workbuddy-panel-capabilities",
10771
+ "aria-labelledby": "dsm-workbuddy-tab-capabilities",
10772
+ hidden: signedIn && panel !== "capabilities",
10773
+ children: [
10774
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10775
+ className: "dsm-workbuddy-panel-note",
10776
+ children: t("row.panelCapabilitiesHint")
10204
10777
  }),
10205
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10206
- className: "dsm-workbuddy-panel",
10207
- role: "tabpanel",
10208
- id: "dsm-workbuddy-panel-diag",
10209
- "aria-labelledby": "dsm-workbuddy-tab-diag",
10210
- hidden: !signedIn || panel !== "diag",
10211
- children: status.status !== "signed-in" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10212
- className: "dsm-workbuddy-diag",
10213
- children: [
10214
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10215
- className: "dsm-workbuddy-diag-row",
10216
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10217
- className: "dsm-workbuddy-diag-label",
10218
- children: t("row.diagRegion")
10219
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10220
- className: "dsm-workbuddy-diag-value",
10221
- children: status.region === "cn" ? t("row.tabCn") : t("row.tabGlobal")
10222
- })]
10223
- }),
10224
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10225
- className: "dsm-workbuddy-diag-row",
10226
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10227
- className: "dsm-workbuddy-diag-label",
10228
- children: t("row.diagDomain")
10229
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10230
- className: "dsm-workbuddy-diag-value dsm-workbuddy-diag-mono",
10231
- children: status.domain === void 0 || status.domain === "" ? t("row.modelUnknown") : status.domain
10232
- })]
10233
- }),
10234
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10235
- className: "dsm-workbuddy-diag-row",
10236
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10237
- className: "dsm-workbuddy-diag-label",
10238
- children: t("row.diagAccount")
10239
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10240
- className: "dsm-workbuddy-diag-value",
10241
- children: nameOf(status.accountName)
10242
- })]
10243
- }),
10244
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10245
- className: "dsm-workbuddy-diag-row",
10246
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10247
- className: "dsm-workbuddy-diag-label",
10248
- children: t("row.diagToken")
10249
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10250
- className: "dsm-workbuddy-diag-value dsm-workbuddy-diag-mono",
10251
- children: formatDate(status.tokenExpiresAtMs)
10252
- })]
10253
- }),
10254
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10255
- className: "dsm-workbuddy-diag-row",
10256
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10257
- className: "dsm-workbuddy-diag-label",
10258
- children: t("row.diagCatalog")
10259
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10260
- className: "dsm-workbuddy-diag-value",
10261
- children: formatNumber(status.models.length)
10262
- })]
10263
- }),
10264
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10265
- className: "dsm-workbuddy-diag-row",
10266
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10267
- className: "dsm-workbuddy-diag-label",
10268
- children: t("row.diagEnabled")
10269
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10270
- className: "dsm-workbuddy-diag-value",
10271
- children: formatNumber(status.enabledModelIds.length)
10272
- })]
10273
- }),
10274
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10275
- className: "dsm-workbuddy-diag-row",
10276
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10277
- className: "dsm-workbuddy-diag-label",
10278
- children: t("row.diagPool")
10279
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10280
- className: "dsm-workbuddy-diag-value",
10281
- children: status.pool?.enabled === true ? t("row.diagPoolOn", { count: status.pool.accounts.length }) : t("row.diagPoolOff")
10282
- })]
10283
- }),
10284
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10285
- className: "dsm-workbuddy-diag-row",
10286
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10287
- className: "dsm-workbuddy-diag-label",
10288
- children: t("row.diagFailures")
10289
- }), (() => {
10290
- const failures = [];
10291
- if (status.credentialRejected === true) failures.push(t("row.credentialRejectedTitle"));
10292
- if (status.refreshError !== void 0) failures.push(status.refreshError);
10293
- if (status.creditsError !== void 0) failures.push(status.creditsError);
10294
- const unreadable = status.models.reduce((count, model) => count + (model.promos ?? []).filter((promo) => promo.schedule?.dailyUnusable === true).length, 0);
10295
- if (unreadable > 0) failures.push(t("row.diagPromoUnreadable", { count: unreadable }));
10296
- return failures.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10297
- className: "dsm-workbuddy-diag-value",
10298
- children: t("row.diagNoFailures")
10299
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10300
- className: "dsm-workbuddy-diag-value dsm-workbuddy-diag-bad dsm-workbuddy-diag-mono",
10301
- children: failures.join(" · ")
10302
- });
10303
- })()]
10304
- })
10305
- ]
10306
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10307
- className: "dsm-workbuddy-diag-hint",
10308
- children: t("row.diagHint")
10309
- })] })
10310
- }),
10311
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10312
- className: "dsm-workbuddy-panel",
10313
- role: "tabpanel",
10314
- id: "dsm-workbuddy-panel-sdk",
10315
- "aria-labelledby": "dsm-workbuddy-tab-sdk",
10316
- hidden: !signedIn || panel !== "sdk",
10317
- children: panel === "sdk" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DeviceSdkPanel, {
10318
- t,
10319
- path: WORKBUDDY_DEVICE_SDK_PATH,
10320
- settingsPath: WORKBUDDY_DEVICE_PROFILE_PATH
10321
- }) : null
10322
- }),
10323
- status.status === "signed-out" && loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10324
- className: "dsm-workbuddy-usage-text",
10325
- role: "status",
10326
- children: t("row.accountsLoading")
10327
- }) : null,
10328
- status.status === "signed-out" && !loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
10329
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10330
- className: "dsm-workbuddy-usage-text",
10331
- children: signedOutText(notice, t)
10778
+ creditPreferences,
10779
+ upstreamSwitches,
10780
+ channelRejectContinuePreference,
10781
+ sidebarPanelPreference
10782
+ ]
10783
+ }),
10784
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10785
+ className: "dsm-workbuddy-panel",
10786
+ role: "tabpanel",
10787
+ id: "dsm-workbuddy-panel-diag",
10788
+ "aria-labelledby": "dsm-workbuddy-tab-diag",
10789
+ hidden: !signedIn || panel !== "diag",
10790
+ children: status.status !== "signed-in" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10791
+ className: "dsm-workbuddy-diag",
10792
+ children: [
10793
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10794
+ className: "dsm-workbuddy-diag-row",
10795
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10796
+ className: "dsm-workbuddy-diag-label",
10797
+ children: t("row.diagRegion")
10798
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10799
+ className: "dsm-workbuddy-diag-value",
10800
+ children: status.region === "cn" ? t("row.tabCn") : t("row.tabGlobal")
10801
+ })]
10332
10802
  }),
10333
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10334
- className: "dsm-workbuddy-usage-account-actions",
10335
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10336
- type: "button",
10337
- className: "dsm-btn dsm-btn-outline",
10338
- disabled: busy,
10339
- onClick: () => {
10340
- rescanAccounts();
10341
- },
10342
- children: busy ? t("row.accountsScanning") : t("row.accountsRescan")
10343
- })
10803
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10804
+ className: "dsm-workbuddy-diag-row",
10805
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10806
+ className: "dsm-workbuddy-diag-label",
10807
+ children: t("row.diagDomain")
10808
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10809
+ className: "dsm-workbuddy-diag-value dsm-workbuddy-diag-mono",
10810
+ children: status.domain === void 0 || status.domain === "" ? t("row.modelUnknown") : status.domain
10811
+ })]
10344
10812
  }),
10345
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10346
- className: "dsm-workbuddy-pool-tools",
10347
- children: accountTools
10813
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10814
+ className: "dsm-workbuddy-diag-row",
10815
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10816
+ className: "dsm-workbuddy-diag-label",
10817
+ children: t("row.diagAccount")
10818
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10819
+ className: "dsm-workbuddy-diag-value",
10820
+ children: nameOf(status.accountName)
10821
+ })]
10348
10822
  }),
10349
- searched.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SearchedPaths, {
10350
- items: searched,
10351
- t
10352
- }) : null
10353
- ] }) : null,
10354
- status.status === "error" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10355
- className: "dsm-workbuddy-usage-error-block",
10356
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10357
- className: "dsm-workbuddy-usage-error",
10358
- role: "alert",
10359
- children: t("row.usageErrorHint", { message: status.message === "" ? t("row.requestFailed") : status.message })
10360
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10361
- type: "button",
10362
- className: "dsm-btn dsm-btn-outline",
10363
- onClick: () => {
10364
- statusRetries.current = 0;
10365
- refreshUsage(activeRegion);
10366
- },
10367
- children: t("row.usageRetry")
10368
- })]
10369
- }) : null
10370
- ]
10823
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10824
+ className: "dsm-workbuddy-diag-row",
10825
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10826
+ className: "dsm-workbuddy-diag-label",
10827
+ children: t("row.diagToken")
10828
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10829
+ className: "dsm-workbuddy-diag-value dsm-workbuddy-diag-mono",
10830
+ children: formatDate(status.tokenExpiresAtMs)
10831
+ })]
10832
+ }),
10833
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10834
+ className: "dsm-workbuddy-diag-row",
10835
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10836
+ className: "dsm-workbuddy-diag-label",
10837
+ children: t("row.diagCatalog")
10838
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10839
+ className: "dsm-workbuddy-diag-value",
10840
+ children: formatNumber(status.models.length)
10841
+ })]
10842
+ }),
10843
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10844
+ className: "dsm-workbuddy-diag-row",
10845
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10846
+ className: "dsm-workbuddy-diag-label",
10847
+ children: t("row.diagEnabled")
10848
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10849
+ className: "dsm-workbuddy-diag-value",
10850
+ children: formatNumber(status.enabledModelIds.length)
10851
+ })]
10852
+ }),
10853
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10854
+ className: "dsm-workbuddy-diag-row",
10855
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10856
+ className: "dsm-workbuddy-diag-label",
10857
+ children: t("row.diagPool")
10858
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10859
+ className: "dsm-workbuddy-diag-value",
10860
+ children: status.pool?.enabled === true ? t("row.diagPoolOn", { count: status.pool.accounts.length }) : t("row.diagPoolOff")
10861
+ })]
10862
+ }),
10863
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10864
+ className: "dsm-workbuddy-diag-row",
10865
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10866
+ className: "dsm-workbuddy-diag-label",
10867
+ children: t("row.diagFailures")
10868
+ }), (() => {
10869
+ const failures = [];
10870
+ if (status.credentialRejected === true) failures.push(t("row.credentialRejectedTitle"));
10871
+ if (status.refreshError !== void 0) failures.push(status.refreshError);
10872
+ if (status.creditsError !== void 0) failures.push(status.creditsError);
10873
+ const unreadable = status.models.reduce((count, model) => count + (model.promos ?? []).filter((promo) => promo.schedule?.dailyUnusable === true).length, 0);
10874
+ if (unreadable > 0) failures.push(t("row.diagPromoUnreadable", { count: unreadable }));
10875
+ return failures.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10876
+ className: "dsm-workbuddy-diag-value",
10877
+ children: t("row.diagNoFailures")
10878
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10879
+ className: "dsm-workbuddy-diag-value dsm-workbuddy-diag-bad dsm-workbuddy-diag-mono",
10880
+ children: failures.join(" · ")
10881
+ });
10882
+ })()]
10883
+ })
10884
+ ]
10885
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10886
+ className: "dsm-workbuddy-diag-hint",
10887
+ children: t("row.diagHint")
10888
+ })] })
10889
+ }),
10890
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10891
+ className: "dsm-workbuddy-panel",
10892
+ role: "tabpanel",
10893
+ id: "dsm-workbuddy-panel-sdk",
10894
+ "aria-labelledby": "dsm-workbuddy-tab-sdk",
10895
+ hidden: !signedIn || panel !== "sdk",
10896
+ children: panel === "sdk" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DeviceSdkPanel, {
10897
+ t,
10898
+ path: WORKBUDDY_DEVICE_SDK_PATH,
10899
+ settingsPath: WORKBUDDY_DEVICE_PROFILE_PATH
10900
+ }) : null
10901
+ }),
10902
+ status.status === "signed-out" && loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10903
+ className: "dsm-workbuddy-usage-text",
10904
+ role: "status",
10905
+ children: t("row.accountsLoading")
10906
+ }) : null,
10907
+ status.status === "signed-out" && !loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
10908
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10909
+ className: "dsm-workbuddy-usage-text",
10910
+ children: signedOutText(notice, t)
10911
+ }),
10912
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10913
+ className: "dsm-workbuddy-usage-account-actions",
10914
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10915
+ type: "button",
10916
+ className: "dsm-btn dsm-btn-outline",
10917
+ disabled: busy,
10918
+ onClick: () => {
10919
+ rescanAccounts();
10920
+ },
10921
+ children: busy ? t("row.accountsScanning") : t("row.accountsRescan")
10922
+ })
10923
+ }),
10924
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10925
+ className: "dsm-workbuddy-pool-tools",
10926
+ children: accountTools
10927
+ }),
10928
+ searched.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SearchedPaths, {
10929
+ items: searched,
10930
+ t
10931
+ }) : null
10932
+ ] }) : null,
10933
+ status.status === "error" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10934
+ className: "dsm-workbuddy-usage-error-block",
10935
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
10936
+ className: "dsm-workbuddy-usage-error",
10937
+ role: "alert",
10938
+ children: t("row.usageErrorHint", { message: status.message === "" ? t("row.requestFailed") : status.message })
10939
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
10940
+ type: "button",
10941
+ className: "dsm-btn dsm-btn-outline",
10942
+ onClick: () => {
10943
+ statusRetries.current = 0;
10944
+ refreshUsage(activeRegion);
10945
+ },
10946
+ children: t("row.usageRetry")
10947
+ })]
10948
+ }) : null
10949
+ ]
10950
+ })
10951
+ });
10952
+ if (pageSurface) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
10953
+ className: "dsm-workbuddy-page",
10954
+ children: [pageHead, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10955
+ className: "dsm-workbuddy-page-body",
10956
+ children: cardBody
10957
+ })]
10958
+ });
10959
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
10960
+ className: `dsm-plugin-card${open ? " dsm-plugin-card-open" : ""}`,
10961
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
10962
+ type: "button",
10963
+ className: "dsm-plugin-card-header",
10964
+ "aria-expanded": open,
10965
+ "aria-label": `${t(open ? "row.collapse" : "row.expand")}: ${title}`,
10966
+ onClick: () => {
10967
+ setCardOpen(!cardOpen);
10968
+ },
10969
+ children: [
10970
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
10971
+ className: "dsm-plugin-card-icon",
10972
+ src: WORKBUDDY_PLUGIN_ICON,
10973
+ alt: ""
10974
+ }),
10975
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
10976
+ className: "dsm-plugin-card-head",
10977
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10978
+ className: "dsm-plugin-card-title",
10979
+ children: title
10980
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10981
+ className: "dsm-plugin-card-description",
10982
+ children: t("row.desc")
10983
+ })]
10984
+ }),
10985
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
10986
+ "aria-hidden": "true",
10987
+ className: `dsm-plugin-card-chevron${open ? " dsm-plugin-card-chevron-open" : ""}`
10371
10988
  })
10372
- }) : null
10989
+ ]
10990
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
10991
+ className: "dsm-plugin-card-body",
10992
+ hidden: !open,
10993
+ children: open ? cardBody : null
10373
10994
  })]
10374
10995
  });
10375
10996
  }
@@ -10736,26 +11357,34 @@ window.__ModuleLoader__.load({
10736
11357
  return kept.length === 0 ? void 0 : kept.join(" · ");
10737
11358
  }
10738
11359
  function ComposerCredits(props) {
10739
- const { t, provider, region, settingsScope } = props;
11360
+ const { t, provider, region, settingsScope, onOpenSettings } = props;
10740
11361
  if (t === void 0) throw new Error("Composer credits readout requires its translation function");
10741
11362
  const owned = provider === void 0 ? void 0 : WORKBUDDY_COMPOSER_PROVIDERS[provider];
10742
11363
  const activeRegion = region ?? owned;
10743
11364
  const [usage, setUsage] = (0, react.useState)(void 0);
10744
11365
  const [accountCredits, setAccountCredits] = (0, react.useState)(void 0);
10745
- const [busy, setBusy] = (0, react.useState)(false);
11366
+ const [switchingId, setSwitchingId] = (0, react.useState)(void 0);
10746
11367
  /**
10747
11368
  * A test batch is running.
10748
11369
  *
10749
- * Separate from `busy`, which tracks a credits READ: the two take wildly
10750
- * different times (one round trip against one probe per account, serial with
10751
- * a gap), and sharing a flag would either freeze the readout for a minute or
11370
+ * Its OWN flag, not shared with `failed`/`inFlight`: a batch is one serial
11371
+ * probe per account (a minute for a big pool) while a credits read is one
11372
+ * round trip. Sharing a flag would either freeze the readout for a minute or
10752
11373
  * let a press be swallowed as "already refreshing".
10753
11374
  */
10754
11375
  const [testing, setTesting] = (0, react.useState)(false);
10755
11376
  /** The batch's failure, in the user's language; `failed` is for reads. */
10756
11377
  const [testError, setTestError] = (0, react.useState)(void 0);
10757
- const [switchingId, setSwitchingId] = (0, react.useState)(void 0);
10758
11378
  const [failed, setFailed] = (0, react.useState)(false);
11379
+ /**
11380
+ * The settings button could not reach a page on this host.
11381
+ *
11382
+ * Its own flag, not `failed`, because the two render DIFFERENT sentences: this
11383
+ * one says the host offers no route to the settings page, which is not the same
11384
+ * claim as "the credits read failed", and sharing a flag would print one over
11385
+ * the other.
11386
+ */
11387
+ const [settingsFailed, setSettingsFailed] = (0, react.useState)(false);
10759
11388
  const [lastRefresh, setLastRefresh] = (0, react.useState)(void 0);
10760
11389
  const [open, setOpen] = (0, react.useState)(false);
10761
11390
  const inFlight = (0, react.useRef)(false);
@@ -10816,7 +11445,6 @@ window.__ModuleLoader__.load({
10816
11445
  const fetchUsage = (0, react.useCallback)(async (signal) => {
10817
11446
  if (inFlight.current || activeRegion === void 0) return;
10818
11447
  inFlight.current = true;
10819
- if (mounted.current) setBusy(true);
10820
11448
  try {
10821
11449
  const response = await fetch(withWorkBuddyRegion(WORKBUDDY_USAGE_PATH, activeRegion), {
10822
11450
  headers: { accept: "application/json" },
@@ -10833,7 +11461,6 @@ window.__ModuleLoader__.load({
10833
11461
  if (mounted.current && signal?.aborted !== true) setFailed(true);
10834
11462
  } finally {
10835
11463
  inFlight.current = false;
10836
- if (mounted.current) setBusy(false);
10837
11464
  }
10838
11465
  }, [activeRegion]);
10839
11466
  /**
@@ -10978,31 +11605,28 @@ window.__ModuleLoader__.load({
10978
11605
  }
10979
11606
  };
10980
11607
  /**
10981
- * The header button: test EVERY account in this region, then re-read what the
10982
- * batch changed.
10983
- *
10984
- * It used to be a plain refresh. The owner asked for the other thing this
10985
- * panel's readers actually want — the same "一键测试所有账号" the pool card
10986
- * runs (`src/account-pool-run.ts testAllAccounts`, one account at a time with
10987
- * a gap, because hitting the whole pool at once is how the upstream's volume
10988
- * limit gets tripped).
10989
- *
10990
- * Two reasons the batch, not a read, is the right control HERE. A mark in this
10991
- * table is a MEASUREMENT (`被限流 · 约 6 小时后` is a probe result), and
10992
- * re-reading the usage document cannot improve a stale measurement — only
10993
- * running it again can. And the rows are the pool's members, so the question
10994
- * "which of these can serve?" is answered by testing them, not by asking the
10995
- * credits endpoint again.
10996
- *
10997
- * The re-read afterwards is not a courtesy: the probes live in the USAGE
10998
- * document (`usage.pool.accounts[].probe`), so the dots and marks only move
10999
- * once that document is fetched again. Without it the button would leave the
11000
- * table showing the state it just measured away.
11001
- *
11002
- * The batch answers NDJSON (one line per account, streamed) on a current Host
11003
- * and one document on an older one, so both shapes are read; the stream is
11004
- * drained even after unmount, because dropping the reader leaves the Host
11005
- * writing into a socket nobody reads.
11608
+ * The header's REFRESH control: probe every account in this region.
11609
+ *
11610
+ * Named for the reader's outcome (this table, brought up to date) while the
11611
+ * work underneath is a probe batch. The distinction is not cosmetic: "refresh"
11612
+ * sounds like a free re-read of what the Host already knows, and what the Host
11613
+ * already knows is exactly the stale measurement we are trying to replace. The
11614
+ * hint says "probes each account" so the cost is not a surprise.
11615
+ *
11616
+ * THE ROW COLOURS ARE WHAT THIS PRODUCES. The dots and the "被限流 · 约 N 小时后"
11617
+ * lines in the table are not read from the upstream on every poll — they are
11618
+ * the last MEASUREMENT the Host persisted. Until something probes an account,
11619
+ * there is nothing to report and every row looks usable. That is why this
11620
+ * lives beside the settings control rather than in the pool card alone: this
11621
+ * table is where the reader sees the state, so this is where the question "is
11622
+ * this still true?" gets asked.
11623
+ *
11624
+ * The batch is SERIAL on the Host (one probe per account, with a gap), so it
11625
+ * streams NDJSON and each row is folded in the moment it lands. Waiting for
11626
+ * the whole stream would leave the row the user is watching wrong for as long
11627
+ * as the SLOWEST account takes — the dead-looking panel the streamed shape
11628
+ * exists to avoid. The re-read in `finally` then confirms the same facts from
11629
+ * the Host's own store, so the fold is a shortcut, never the record.
11006
11630
  */
11007
11631
  const testEveryAccount = (0, react.useCallback)(async () => {
11008
11632
  if (activeRegion === void 0 || testingRef.current) return;
@@ -11045,7 +11669,7 @@ window.__ModuleLoader__.load({
11045
11669
  }
11046
11670
  if (mounted.current && failure !== void 0) setTestError(failure);
11047
11671
  } catch {
11048
- if (mounted.current) setTestError(t("composer.testFailed"));
11672
+ if (mounted.current) setTestError(t("composer.refreshAccountsFailed"));
11049
11673
  } finally {
11050
11674
  testingRef.current = false;
11051
11675
  if (mounted.current) setTesting(false);
@@ -11057,6 +11681,29 @@ window.__ModuleLoader__.load({
11057
11681
  fetchAccountCredits,
11058
11682
  t
11059
11683
  ]);
11684
+ /**
11685
+ * The header's settings control: open this plugin's page, then close.
11686
+ *
11687
+ * CLOSING IS PART OF THE JOB. The panel is portaled to `document.body` and
11688
+ * floats over the composer; navigating the centre column does not remove it, so
11689
+ * leaving it open would park a credits table on top of the page the user just
11690
+ * asked for. It is not reopened on return — a popover that comes back by itself
11691
+ * after navigation is a popover the user cannot get rid of.
11692
+ *
11693
+ * `false` (no route on this host) sets the panel's own error line rather than
11694
+ * doing nothing: a press that changes nothing on screen is indistinguishable
11695
+ * from a broken button, and the honest answer here is "this host has no way
11696
+ * there".
11697
+ */
11698
+ const openSettings = () => {
11699
+ if (!(onOpenSettings === void 0 ? false : onOpenSettings())) {
11700
+ setFailed(false);
11701
+ setSettingsFailed(true);
11702
+ return;
11703
+ }
11704
+ setSettingsFailed(false);
11705
+ setOpen(false);
11706
+ };
11060
11707
  if (owned === void 0) return null;
11061
11708
  /**
11062
11709
  * The Host's own answer for this region, when the document carries one.
@@ -11157,15 +11804,70 @@ window.__ModuleLoader__.load({
11157
11804
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11158
11805
  className: "dsm-workbuddy-composer-panel-title",
11159
11806
  children: t(activeRegion === "cn" ? "composer.panelTitleCn" : "composer.panelTitleGlobal")
11160
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
11161
- type: "button",
11162
- className: "dsm-workbuddy-composer-panel-refresh",
11163
- disabled: busy || testing || switchingId !== void 0,
11164
- title: t("composer.testAllHint"),
11165
- onClick: () => {
11166
- testEveryAccount();
11167
- },
11168
- children: testing ? t("composer.testing") : t("composer.testAll")
11807
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
11808
+ className: "dsm-workbuddy-composer-panel-actions",
11809
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
11810
+ type: "button",
11811
+ className: "dsm-workbuddy-composer-panel-refresh",
11812
+ disabled: testing || switchingId !== void 0,
11813
+ title: t("composer.refreshHint"),
11814
+ "aria-label": t("composer.refreshHint"),
11815
+ onClick: () => {
11816
+ testEveryAccount();
11817
+ },
11818
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
11819
+ className: testing ? "dsm-workbuddy-composer-panel-refresh-icon dsm-workbuddy-composer-panel-refresh-icon-spin" : "dsm-workbuddy-composer-panel-refresh-icon",
11820
+ viewBox: "0 0 16 16",
11821
+ width: "12",
11822
+ height: "12",
11823
+ fill: "none",
11824
+ "aria-hidden": "true",
11825
+ focusable: "false",
11826
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
11827
+ d: "M13.3 8a5.3 5.3 0 1 1-1.55-3.75",
11828
+ stroke: "currentColor",
11829
+ strokeWidth: "1.5",
11830
+ strokeLinecap: "round"
11831
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
11832
+ d: "M13.4 2.2v2.9h-2.9",
11833
+ stroke: "currentColor",
11834
+ strokeWidth: "1.5",
11835
+ strokeLinecap: "round",
11836
+ strokeLinejoin: "round"
11837
+ })]
11838
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11839
+ className: "dsm-workbuddy-composer-panel-refresh-label",
11840
+ children: testing ? t("composer.refreshing") : t("composer.refresh")
11841
+ })]
11842
+ }), onOpenSettings === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
11843
+ type: "button",
11844
+ className: "dsm-workbuddy-composer-panel-settings",
11845
+ title: t("composer.openSettingsHint"),
11846
+ onClick: openSettings,
11847
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
11848
+ className: "dsm-workbuddy-composer-panel-settings-icon",
11849
+ viewBox: "0 0 16 16",
11850
+ width: "12",
11851
+ height: "12",
11852
+ fill: "none",
11853
+ "aria-hidden": "true",
11854
+ focusable: "false",
11855
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
11856
+ d: "M8 10.2a2.2 2.2 0 1 0 0-4.4 2.2 2.2 0 0 0 0 4.4Z",
11857
+ stroke: "currentColor",
11858
+ strokeWidth: "1.5"
11859
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
11860
+ d: "M12.9 9.6a1.2 1.2 0 0 0 .24 1.32l.04.04a1.4 1.4 0 1 1-1.98 1.98l-.04-.04a1.2 1.2 0 0 0-1.32-.24 1.2 1.2 0 0 0-.72 1.1v.12a1.4 1.4 0 1 1-2.8 0v-.07a1.2 1.2 0 0 0-.78-1.1 1.2 1.2 0 0 0-1.32.24l-.04.04a1.4 1.4 0 1 1-1.98-1.98l.04-.04a1.2 1.2 0 0 0 .24-1.32 1.2 1.2 0 0 0-1.1-.72h-.12a1.4 1.4 0 1 1 0-2.8h.07a1.2 1.2 0 0 0 1.1-.78 1.2 1.2 0 0 0-.24-1.32l-.04-.04a1.4 1.4 0 1 1 1.98-1.98l.04.04a1.2 1.2 0 0 0 1.32.24h.05a1.2 1.2 0 0 0 .72-1.1v-.12a1.4 1.4 0 1 1 2.8 0v.07a1.2 1.2 0 0 0 .72 1.1 1.2 1.2 0 0 0 1.32-.24l.04-.04a1.4 1.4 0 1 1 1.98 1.98l-.04.04a1.2 1.2 0 0 0-.24 1.32v.05a1.2 1.2 0 0 0 1.1.72h.12a1.4 1.4 0 1 1 0 2.8h-.07a1.2 1.2 0 0 0-1.1.72Z",
11861
+ stroke: "currentColor",
11862
+ strokeWidth: "1.5",
11863
+ strokeLinecap: "round",
11864
+ strokeLinejoin: "round"
11865
+ })]
11866
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11867
+ className: "dsm-workbuddy-composer-panel-settings-label",
11868
+ children: t("composer.openSettings")
11869
+ })]
11870
+ })]
11169
11871
  })]
11170
11872
  }),
11171
11873
  signedOut ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
@@ -11276,7 +11978,12 @@ window.__ModuleLoader__.load({
11276
11978
  className: "dsm-workbuddy-composer-panel-error",
11277
11979
  role: "status",
11278
11980
  children: testError
11279
- })
11981
+ }),
11982
+ settingsFailed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
11983
+ className: "dsm-workbuddy-composer-panel-error",
11984
+ role: "status",
11985
+ children: t("composer.openSettingsFailed")
11986
+ }) : null
11280
11987
  ]
11281
11988
  }), document.body)
11282
11989
  ]
@@ -11375,7 +12082,7 @@ window.__ModuleLoader__.load({
11375
12082
  return region;
11376
12083
  }
11377
12084
  function ComposerCreditsGate(props) {
11378
- const { t, position, settingsScope, useProjection } = props;
12085
+ const { t, position, settingsScope, useProjection, onOpenSettings } = props;
11379
12086
  const [, setRevision] = (0, react.useState)(0);
11380
12087
  (0, react.useEffect)(() => settingsScope?.subscribe(() => {
11381
12088
  setRevision((value) => value + 1);
@@ -11389,7 +12096,8 @@ window.__ModuleLoader__.load({
11389
12096
  t,
11390
12097
  provider,
11391
12098
  region,
11392
- ...settingsScope === void 0 ? {} : { settingsScope }
12099
+ ...settingsScope === void 0 ? {} : { settingsScope },
12100
+ ...onOpenSettings === void 0 ? {} : { onOpenSettings }
11393
12101
  });
11394
12102
  }
11395
12103
  //#endregion
@@ -12066,6 +12774,8 @@ window.__ModuleLoader__.load({
12066
12774
  * @module dsh-connect-workbuddy/client/locales
12067
12775
  */
12068
12776
  const en = {
12777
+ "nav.panel": "WorkBuddy",
12778
+ "nav.back": "Back to conversation",
12069
12779
  "row.title": "WorkBuddy credits & models (dsh-connect-workbuddy)",
12070
12780
  "row.desc": "Use WorkBuddy models in DSH: each refresh reads every model's credit multiplier from the upstream catalog, image input is toggled per model, several accounts can be switched or failed over automatically, and daily check-in plus your remaining credits are one click away. The domestic and international sides are two independent providers, each with its own account — use both at the same time.",
12071
12781
  "row.expand": "Expand",
@@ -12122,6 +12832,7 @@ window.__ModuleLoader__.load({
12122
12832
  "row.accountsWriteFailed": "The account change was not saved: {message} — the active profile's configuration file could not be updated (on Windows it may be locked by an antivirus scanner or a sync client). Your previous choice is still in effect; close whatever holds that file and try again (see docs/WINDOWS.md in the plugin repo for the exact path).",
12123
12833
  "row.selectionLostHint": "The saved account no longer exists locally.",
12124
12834
  "row.selectionLostMessage": "The account saved for this region is no longer among the local sign-ins (WorkBuddy replaced its login or cleaned up backups). Your other sign-ins are fine — pick a current one from the list above. Signing in again in the desktop app will not fix this.",
12835
+ "row.vaultUnreadableHint": "The credential vault directory could not be read ({message}). This is usually a permissions problem, not a lost account: the saved accounts are still on disk. Run as administrator: takeown /F \"<vault dir>\" /R /D Y && icacls \"<vault dir>\" /reset /T, then restart DSH. The directory path is documented in docs/WINDOWS.md of the plugin repo.",
12125
12836
  "row.panelAccounts": "Accounts",
12126
12837
  "row.panelModels": "Models",
12127
12838
  "row.panelCapabilities": "Capabilities",
@@ -12167,7 +12878,7 @@ window.__ModuleLoader__.load({
12167
12878
  "row.modelOffRefusedHint": "Measured to reject the “off” level with HTTP 400 (code 11133) on both gateways. With this ticked, every request that carries no reasoning tier — compaction summaries above all — would fail, so it cannot be enabled here.",
12168
12879
  "row.modelEffortLabel": "Default reasoning",
12169
12880
  "row.modelEffortAria": "Default reasoning level for {model}",
12170
- "row.modelEffortHint": "The reasoning level this model uses when a request names none — new conversations, compaction summaries and session titles. Only the levels WorkBuddy itself declares for this model are offered; “Default (x)” means WorkBuddy’s own declared default for it.",
12881
+ "row.modelEffortHint": "The reasoning level this model uses when a request names none — new conversations, compaction summaries and session titles. Only the levels WorkBuddy itself declares for this model are offered; “Default (x)” names the level that will actually be used: your pick if you made one, otherwise the level WorkBuddy declares for this model, otherwise that model’s own middle tier (never its weakest one).",
12171
12882
  "row.modelEffortFollow": "Default",
12172
12883
  "row.modelEffortFollowNamed": "Default ({effort})",
12173
12884
  "row.modelUnknown": "Unknown",
@@ -12343,6 +13054,12 @@ window.__ModuleLoader__.load({
12343
13054
  "row.poolSavedStaleRefresh": "Saved, but the panel could not re-read it. The value is stored; the next refresh will show it.",
12344
13055
  "row.poolDiscard": "Discard changes",
12345
13056
  "row.poolDirty": "● Unsaved changes",
13057
+ "row.poolAutoCheckin": "Check in automatically each day",
13058
+ "row.poolAutoCheckinHint": "On: the plugin claims the daily check-in for the accounts checked into this pool, once a day, in the background. It reads first and never re-claims an account already checked in, so a restart cannot double-claim. Off: nothing runs until you press the button. A missed day resets the streak.",
13059
+ "row.poolAutoCheckinToday": "Today: {done} of {total} checked in",
13060
+ "row.poolAutoCheckinDone": "Today: all {total} checked in",
13061
+ "row.poolAutoCheckinPending": "{count} still to retry",
13062
+ "row.poolAutoCheckinFailed": "Last attempt failed: {message}",
12346
13063
  "row.poolManualUnlock": "Turn off rotation",
12347
13064
  "row.poolLogTitle": "Activity",
12348
13065
  "row.poolLogClear": "Clear",
@@ -12410,6 +13127,7 @@ window.__ModuleLoader__.load({
12410
13127
  "row.deviceModeReal": "Real",
12411
13128
  "row.deviceModeHintVirtual": "Every account presents a virtual device id derived from this machine. Use the gear on a row to set one by hand.",
12412
13129
  "row.deviceModeHintReal": "Every account presents this machine's real device, signed by the WorkBuddy desktop SDK installed here. The gear is off — one real machine cannot be given two different ids. If the SDK is unavailable, no device header is sent at all (see 「SDK」).",
13130
+ "row.deviceModeRealUnsupported": "Not available on this platform: the desktop SDK cannot hand out a device token here — on macOS it blocks on the main dispatch queue, which a background process never drains. Switching to Real would only fall back to Virtual, so the option is disabled. See the SDK section for the current reading.",
12413
13131
  "row.deviceGearHint": "Edit this account's device id (X-Machine-ID / X-Session-ID)",
12414
13132
  "row.deviceGearBlockedHint": "Only available in the Virtual tier",
12415
13133
  "row.deviceGearAria": "Edit device parameters for {accountName}",
@@ -12442,6 +13160,9 @@ window.__ModuleLoader__.load({
12442
13160
  "sdk.statusMissing": "No installed WorkBuddy desktop SDK found on this machine",
12443
13161
  "sdk.statusUnsupported": "The SDK refused this platform",
12444
13162
  "sdk.statusError": "The SDK could not be loaded",
13163
+ "sdk.statusDisabled": "Turned off in settings",
13164
+ "sdk.masterLabel": "Use the real-device SDK",
13165
+ "sdk.masterHint": "On: discover the installed desktop SDK, fetch its device token in a background child process and keep it fresh every 10 minutes. Off: none of that happens — no discovery, no child process, no prewarming — so the Real tier has no token to send. The Virtual tier is unaffected (its ids come from the local salt), so turning this off is safe if you only want virtual devices.",
12445
13166
  "sdk.bundle": "SDK",
12446
13167
  "sdk.runtime": "Runtime",
12447
13168
  "sdk.fetched": "Last fetched",
@@ -12486,6 +13207,8 @@ window.__ModuleLoader__.load({
12486
13207
  "row.channelRejectContinueText": "Text sent:",
12487
13208
  "row.cliBridgeLabel": "Let the local CodeBuddy CLI do the work",
12488
13209
  "row.cliBridgeHint": "Adds the codebuddy_ask tool and the /codebuddy command. Each call spends CodeBuddy quota. injectResult only affects /codebuddy — its result is injected back into the session, costing one DSH turn when the session is idle; tool calls never read it. Rate-limited: 6 turns per session per hour, 20 per process per hour, one turn at a time. Off by default.",
13210
+ "row.sidebarPanelLabel": "Show WorkBuddy in the sidebar",
13211
+ "row.sidebarPanelHint": "Adds a WorkBuddy row to the DSH sidebar that opens this card as a full page. Off by default: the row takes a global sidebar slot shared by every installed plugin, and the Plugins page already reaches the same content. Takes effect on the click — no Save needed — and switching it off while the page is open returns you to the conversation.",
12489
13212
  "row.cliBridgeModelLabel": "CLI model",
12490
13213
  "row.cliBridgeModelDefault": "CLI default",
12491
13214
  "row.cliBridgeModelAria": "Model the local CodeBuddy CLI runs on",
@@ -12543,10 +13266,13 @@ window.__ModuleLoader__.load({
12543
13266
  "composer.current": "In use",
12544
13267
  "composer.noAccounts": "No account in this region",
12545
13268
  "composer.signedOut": "Not signed in",
12546
- "composer.testAll": "Test all",
12547
- "composer.testing": "Testing…",
12548
- "composer.testAllHint": "Test every account in this region, one at a time",
12549
- "composer.testFailed": "Could not test the accounts",
13269
+ "composer.openSettings": "Settings",
13270
+ "composer.openSettingsHint": "Open this plugin's settings page (accounts, models, switches)",
13271
+ "composer.openSettingsFailed": "This host offers no route to the plugin settings page",
13272
+ "composer.refresh": "Refresh",
13273
+ "composer.refreshing": "Refreshing…",
13274
+ "composer.refreshHint": "Refresh every account status in this region — probes each account once, one at a time (spends a small amount of credits, takes up to a minute)",
13275
+ "composer.refreshAccountsFailed": "Could not refresh the account status",
12550
13276
  "composer.refreshFailed": "Could not refresh credits",
12551
13277
  "composer.lastRefresh": "Last refreshed",
12552
13278
  "composer.panelTitle": "WorkBuddy credits",
@@ -12572,6 +13298,8 @@ window.__ModuleLoader__.load({
12572
13298
  "cliLive.aria": "A CodeBuddy turn is running: {detail}"
12573
13299
  };
12574
13300
  const zh = {
13301
+ "nav.panel": "WorkBuddy",
13302
+ "nav.back": "返回会话",
12575
13303
  "row.title": "接入使用 WorkBuddy 积分与模型(dsh-connect-workbuddy)",
12576
13304
  "row.desc": "在 DSH 中使用 WorkBuddy 模型:每次刷新都按上游目录读取每个模型的积分倍率,图片输入可逐模型开关,多个账号可切换或由账号池自动换号,每日签到与剩余积分一键可查。国内版与国际版是两个独立供应商,各有自己的账号,可同时使用。",
12577
13305
  "row.expand": "展开",
@@ -12628,6 +13356,7 @@ window.__ModuleLoader__.load({
12628
13356
  "row.accountsWriteFailed": "账号改动未保存:{message} —— 当前 profile 的配置文件写入失败(Windows 上可能被杀毒软件或同步盘占用)。当前仍是原来保存的选择,请先关闭占用该文件的程序再重试(文件的确切路径见插件仓库的 docs/WINDOWS.md)。",
12629
13357
  "row.selectionLostHint": "已保存的账号在本机已不存在。",
12630
13358
  "row.selectionLostMessage": "该区域保存的账号已不在本机登录列表中(WorkBuddy 更换了登录或清理了备份文件)。本机其他登录仍然可用——请在上方列表中重新选择一个当前账号。重新登录桌面端 App 无法修复此问题。",
13359
+ "row.vaultUnreadableHint": "凭据保险库目录无法读取({message})。这通常是权限问题而不是账号丢失:已保存的账号其实还在磁盘上。请以管理员身份运行:takeown /F \"<vault 目录>\" /R /D Y && icacls \"<vault 目录>\" /reset /T,然后重启 DSH。目录路径见插件仓库 docs/WINDOWS.md 的 vault 说明。",
12631
13360
  "row.panelAccounts": "账号",
12632
13361
  "row.panelModels": "模型",
12633
13362
  "row.panelCapabilities": "能力",
@@ -12673,7 +13402,7 @@ window.__ModuleLoader__.load({
12673
13402
  "row.modelOffRefusedHint": "实测在两个网关上都拒绝「关闭思考」档位(HTTP 400 / code 11133)。勾选后,所有未指定推理档位的请求(尤其是压缩摘要)都会失败,因此这里不能启用。",
12674
13403
  "row.modelEffortLabel": "默认推理强度",
12675
13404
  "row.modelEffortAria": "{model} 的默认推理强度",
12676
- "row.modelEffortHint": "请求未指定档位时这个模型使用的推理强度——新对话、压缩摘要、会话标题都属于这类请求。这里只列出 WorkBuddy 为该模型声明的档位;「默认(x)」里的 x 就是 WorkBuddy 自己声明的默认档位。",
13405
+ "row.modelEffortHint": "请求未指定档位时这个模型使用的推理强度——新对话、压缩摘要、会话标题都属于这类请求。这里只列出 WorkBuddy 为该模型声明的档位;「默认(x)」里的 x 就是真正会用的那一档:你选过就是你的选择,否则是 WorkBuddy 为这个模型声明的默认档,再否则是这个模型自己声明的**中档**(永远不是最弱的那一档)。",
12677
13406
  "row.modelEffortFollow": "默认",
12678
13407
  "row.modelEffortFollowNamed": "默认({effort})",
12679
13408
  "row.modelUnknown": "未知",
@@ -12849,6 +13578,12 @@ window.__ModuleLoader__.load({
12849
13578
  "row.poolSavedStaleRefresh": "已保存,但面板未能重新读取。设置已写入;下次刷新后会显示。",
12850
13579
  "row.poolDiscard": "放弃修改",
12851
13580
  "row.poolDirty": "● 有未保存的修改",
13581
+ "row.poolAutoCheckin": "每天自动签到",
13582
+ "row.poolAutoCheckinHint": "开启:插件在后台为勾选进池的账号领取每日签到,一天一次。它先读状态、已签到的不重复领取,所以重启也不会多领。关闭:不点按钮就什么都不会发生。漏一天会断连签。",
13583
+ "row.poolAutoCheckinToday": "今日:已签 {done} / {total}",
13584
+ "row.poolAutoCheckinDone": "今日:{total} 个全部已签",
13585
+ "row.poolAutoCheckinPending": "待重试 {count} 个",
13586
+ "row.poolAutoCheckinFailed": "上次尝试失败:{message}",
12852
13587
  "row.poolManualUnlock": "关闭自动轮换",
12853
13588
  "row.poolLogTitle": "活动记录",
12854
13589
  "row.poolLogClear": "清空",
@@ -12916,6 +13651,7 @@ window.__ModuleLoader__.load({
12916
13651
  "row.deviceModeReal": "真实值",
12917
13652
  "row.deviceModeHintVirtual": "每个账号使用一台按本机盐派生的虚拟设备。点某行右侧的齿轮可以手工指定它的值。",
12918
13653
  "row.deviceModeHintReal": "所有账号共用这台机器真实的设备,由本机安装的 WorkBuddy 桌面端 SDK 签发。齿轮已关闭——一台真机不能有两个不同的 id。SDK 不可用时一个设备头都不发(见「SDK」分区)。",
13654
+ "row.deviceModeRealUnsupported": "本平台用不了:桌面端 SDK 在这里取不到设备 token——macOS 上它会阻塞在 dispatch 主队列,而后台进程永不排空那个队列。切过去也只会降级回虚拟值,所以这一档已禁用。当前读数见「SDK」分区。",
12919
13655
  "row.deviceGearHint": "编辑这个账号的设备标识(X-Machine-ID / X-Session-ID)",
12920
13656
  "row.deviceGearBlockedHint": "只在「虚拟值」档下可用",
12921
13657
  "row.deviceGearAria": "编辑 {accountName} 的设备参数",
@@ -12948,6 +13684,9 @@ window.__ModuleLoader__.load({
12948
13684
  "sdk.statusMissing": "未在本机找到已安装的 WorkBuddy 桌面端 SDK",
12949
13685
  "sdk.statusUnsupported": "SDK 拒绝了这个平台",
12950
13686
  "sdk.statusError": "SDK 加载失败",
13687
+ "sdk.statusDisabled": "已在设置里关闭",
13688
+ "sdk.masterLabel": "启用真实设备 SDK",
13689
+ "sdk.masterHint": "开启时:查找本机安装的桌面端 SDK、在后台子进程里取设备 token,并每 10 分钟换新一次。关闭时这些事一件都不做——不查找、不起子进程、不预热——「真实值」档因此没有 token 可发。「虚拟值」档不受影响(它的 id 由本机盐派生),只想用虚拟设备的话关掉是安全的。",
12951
13690
  "sdk.bundle": "SDK",
12952
13691
  "sdk.runtime": "运行时",
12953
13692
  "sdk.fetched": "最近取到",
@@ -12992,6 +13731,8 @@ window.__ModuleLoader__.load({
12992
13731
  "row.channelRejectContinueText": "发送的文本:",
12993
13732
  "row.cliBridgeLabel": "允许调用本机 CodeBuddy CLI 干活",
12994
13733
  "row.cliBridgeHint": "开启后多出 codebuddy_ask 工具与 /codebuddy 指令;每次调用花 CodeBuddy 配额。injectResult 只影响 /codebuddy:其结果回注会话,会话空闲时多花一次 DSH 回合;工具调用不读它。限流:每会话每小时 6 回合、每进程每小时 20 回合、同时只跑一个回合。默认关闭。",
13734
+ "row.sidebarPanelLabel": "在侧边栏显示 WorkBuddy",
13735
+ "row.sidebarPanelHint": "在 DSH 侧边栏加一个 WorkBuddy 行,点开就是这张卡片的整页版。默认关闭:这一行占的是所有插件共用的全局侧边栏座位,而「插件」页本来就能看到同样的内容。点一下即生效,不用保存;页面开着时关掉它,会直接回到对话。",
12995
13736
  "row.cliBridgeModelLabel": "CLI 模型",
12996
13737
  "row.cliBridgeModelDefault": "CLI 默认",
12997
13738
  "row.cliBridgeModelAria": "本地 CodeBuddy CLI 运行所用的模型",
@@ -13049,10 +13790,13 @@ window.__ModuleLoader__.load({
13049
13790
  "composer.current": "当前选用",
13050
13791
  "composer.noAccounts": "该区域暂无账号",
13051
13792
  "composer.signedOut": "未登录",
13052
- "composer.testAll": "一键测试",
13053
- "composer.testing": "正在测试…",
13054
- "composer.testAllHint": "逐个测试本区所有账号(一次一个,避免触发上游限流)",
13055
- "composer.testFailed": "测试失败",
13793
+ "composer.openSettings": "设置",
13794
+ "composer.openSettingsHint": "打开本插件的设置页(账号、模型、各项开关)",
13795
+ "composer.openSettingsFailed": "这台宿主没有通往插件设置页的入口",
13796
+ "composer.refresh": "刷新",
13797
+ "composer.refreshing": "正在刷新…",
13798
+ "composer.refreshHint": "刷新本区所有账号的状态——逐个探测每个账号(会消耗少量积分,最长约一分钟)",
13799
+ "composer.refreshAccountsFailed": "账号状态刷新失败",
13056
13800
  "composer.refreshFailed": "积分刷新失败",
13057
13801
  "composer.lastRefresh": "最近刷新",
13058
13802
  "composer.panelTitle": "WorkBuddy 积分",
@@ -13078,6 +13822,91 @@ window.__ModuleLoader__.load({
13078
13822
  "cliLive.aria": "有一个 CodeBuddy 回合正在跑:{detail}"
13079
13823
  };
13080
13824
  //#endregion
13825
+ //#region src/client/settings-route.ts
13826
+ /**
13827
+ * The route from a readout to THIS plugin's settings page.
13828
+ *
13829
+ * ## Why this is a module and not three lines inside `apply`
13830
+ *
13831
+ * The entry (`src/client/index.tsx`) imports browser-only DSH packages that the
13832
+ * Node test environment cannot load, so anything worth asserting on has to live
13833
+ * outside it — the same seam `panel-switch.ts` provides for the opt-in switch and
13834
+ * `ComposerCreditsGate.tsx` provides for the readout's own visibility rule. This
13835
+ * module holds the whole decision, so the spec exercises the REAL chain instead
13836
+ * of a mirror of it.
13837
+ *
13838
+ * ## Why two routes
13839
+ *
13840
+ * On this host line a plugin's settings are not a "page in Settings" at all:
13841
+ * the Plugins page owns them, and each bundle's page (`plugins.bundle.config` /
13842
+ * `plugins.row.config`) IS the configuration surface — Settings keeps only the
13843
+ * read-only built-in inventory. So "open the plugin's settings" means "open the
13844
+ * Plugins page on this bundle", and the supported way to ask for that is the
13845
+ * `pluginNavigation` service the Plugins page provides:
13846
+ * `openBundle(packageName)` selects that page without changing the Session.
13847
+ *
13848
+ * `pluginNavigation` is provided by `@deepseek-ai/dsh-client-ui-plugin-manager`,
13849
+ * NOT by the shell. A profile can be composed without it, and plugin load order
13850
+ * is not something a contributor may assume — so the probe happens at CALL time
13851
+ * rather than at registration time. Probing once in `apply` would capture
13852
+ * `undefined` on a page whose Plugins bundle simply applied after ours, and the
13853
+ * button would be dead for the rest of the session with nothing to re-evaluate
13854
+ * it.
13855
+ *
13856
+ * The fallback reaches the SAME page through the lower-level `layout` service.
13857
+ * `selectPanel('plugins')` is the shipped main key of the Plugins page (the
13858
+ * plugin-manager bundle registers `sidebar.panellist` id / `main` key
13859
+ * `'plugins'`), so a host that predates `pluginNavigation` still lands the user
13860
+ * where the settings are, one click from the row. It is a fallback and not the
13861
+ * primary route deliberately: `'plugins'` is another package's private key,
13862
+ * while `openBundle` is that package's published seam. `selectPanel` THROWS when
13863
+ * the key is not registered (the Plugins page disabled, a trimmed profile), so
13864
+ * the call is guarded rather than trusted.
13865
+ *
13866
+ * ## Why `false` rather than an exception
13867
+ *
13868
+ * A caller here is a popover button. There is no host line this plugin supports
13869
+ * that lacks both routes, but "cannot" must not become a thrown error inside a
13870
+ * click handler on a user's machine; it becomes a `false` the caller reports and
13871
+ * a button that stays honest.
13872
+ */
13873
+ /**
13874
+ * The package name the Plugins page knows this plugin by.
13875
+ *
13876
+ * `openBundle` matches the inventory's `pkg.name` by EXACT equality, and that
13877
+ * name is the profile's package name — the npm package name — not the Loader
13878
+ * entry id (`include:dsh-connect-workbuddy` on the live Desktop profile). This is
13879
+ * the same reason `WORKBUDDY_CARD_KEYS` registers the card under every spelling:
13880
+ * the comparison is exact and the deployment picks the spelling. The inventory
13881
+ * side of that comparison is the package name in every composition observed, so
13882
+ * that is what `openBundle` is asked for.
13883
+ */
13884
+ const WORKBUDDY_PACKAGE_NAME = "dsh-connect-workbuddy";
13885
+ /** The shipped `main` / `sidebar.panellist` key of the Plugins page. */
13886
+ const PLUGINS_PANEL_ID = "plugins";
13887
+ /**
13888
+ * Open this plugin's settings page.
13889
+ *
13890
+ * @param get - the entry's soft service probe (`ctx.get`), which returns
13891
+ * `undefined` for an absent service instead of throwing. Called HERE, on every
13892
+ * invocation, so a service that appears after `apply` is still found.
13893
+ * @returns whether a route was taken. `false` means the caller's control should
13894
+ * not have been offered; see the module note.
13895
+ */
13896
+ function openPluginSettingsPage(get) {
13897
+ const navigation = get("pluginNavigation");
13898
+ if (navigation !== void 0 && typeof navigation.openBundle === "function") try {
13899
+ navigation.openBundle(WORKBUDDY_PACKAGE_NAME);
13900
+ return true;
13901
+ } catch {}
13902
+ const layout = get("layout");
13903
+ if (layout !== void 0 && typeof layout.selectPanel === "function") try {
13904
+ layout.selectPanel(PLUGINS_PANEL_ID);
13905
+ return true;
13906
+ } catch {}
13907
+ return false;
13908
+ }
13909
+ //#endregion
13081
13910
  //#region src/client/index.tsx
13082
13911
  /**
13083
13912
  * Browser half: WorkBuddy credits and model management inside Plugin
@@ -13125,6 +13954,16 @@ window.__ModuleLoader__.load({
13125
13954
  }), "dsh-connect-workbuddy: settings copy");
13126
13955
  const t = ctx.locale.bind(namespace);
13127
13956
  const softGet = (name) => ctx.get(name);
13957
+ /**
13958
+ * Open this plugin's settings page, as the credits panel's header control
13959
+ * asks for it.
13960
+ *
13961
+ * Defined here because this is the only place with a service probe into the
13962
+ * Host; the whole route lives in `settings-route.ts` so it has one home and
13963
+ * its own test. The probe runs per press, which is why this is a function
13964
+ * and not a captured answer.
13965
+ */
13966
+ const onOpenSettings = () => openPluginSettingsPage(softGet);
13128
13967
  let settingsScope;
13129
13968
  const forms = softGet("configForms");
13130
13969
  /**
@@ -13190,11 +14029,13 @@ window.__ModuleLoader__.load({
13190
14029
  locale: namespace,
13191
14030
  inject: () => settingsScope === void 0 ? {
13192
14031
  t,
13193
- position: "composer"
14032
+ position: "composer",
14033
+ onOpenSettings
13194
14034
  } : {
13195
14035
  t,
13196
14036
  position: "composer",
13197
- settingsScope
14037
+ settingsScope,
14038
+ onOpenSettings
13198
14039
  }
13199
14040
  }, ComposerCreditsGate));
13200
14041
  } catch (error) {
@@ -13253,6 +14094,114 @@ window.__ModuleLoader__.load({
13253
14094
  }
13254
14095
  };
13255
14096
  /**
14097
+ * The sidebar glyph for the WorkBuddy panel row.
14098
+ *
14099
+ * The sidebar renders `sidebar.panellist` registrants with `{ size, active }`
14100
+ * inside a `currentColor`-themed glyph cell, so the brand mark is drawn as a
14101
+ * small `<img>` — the PNG's own colours read as the plugin's identity, and
14102
+ * the row's selection state is the host's to paint around it.
14103
+ */
14104
+ function WorkBuddyPanelIcon(props) {
14105
+ const edge = typeof props.size === "number" && props.size > 0 ? props.size : 16;
14106
+ return (0, react.createElement)("img", {
14107
+ className: "dsm-workbuddy-panel-icon",
14108
+ src: WORKBUDDY_PLUGIN_ICON,
14109
+ alt: "",
14110
+ width: edge,
14111
+ height: edge,
14112
+ "aria-hidden": "true"
14113
+ });
14114
+ }
14115
+ /**
14116
+ * The WorkBuddy panel in the sidebar (`sidebar.panellist` row + `main` keyed
14117
+ * page), mirroring how the host's own Plugins row and dsh-skill-mcp-panel
14118
+ * put a full page in the centre column.
14119
+ *
14120
+ * OPT-IN (`Config.sidebarPanel`, default false). Registering it is NOT the
14121
+ * same as showing it: `ui-sidebar` builds the nav row from the slot's ENTRY
14122
+ * METADATA (`usePanels` → `PanelRow` with `options.label` and
14123
+ * `renderSlot(...)` as the glyph), so a component returning `null` leaves a
14124
+ * blank but still-clickable button rather than no button. The row therefore
14125
+ * has to be registered only while the switch is on, which is what
14126
+ * {@link syncPanelRegistration} owns. See `panel-switch.ts` for the store
14127
+ * that decision rides on.
14128
+ *
14129
+ * Back navigation reuses the host's layout service: `selectPanel(null)`
14130
+ * hands the main area back to the conversation. It is soft-probed, so a
14131
+ * host that never declares `layout` simply renders the page without the back
14132
+ * affordance instead of blocking the whole plugin (the same degradation the
14133
+ * card already promises for a missing settings form).
14134
+ */
14135
+ const registerPanel = () => {
14136
+ const PANEL_ID = "dsh-connect-workbuddy";
14137
+ const disposers = [];
14138
+ const backToConversation = () => {
14139
+ const layout = softGet("layout");
14140
+ if (layout !== void 0 && typeof layout.selectPanel === "function") layout.selectPanel(null);
14141
+ };
14142
+ try {
14143
+ disposers.push(ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
14144
+ name: "sidebar.panellist",
14145
+ id: PANEL_ID,
14146
+ order: 2,
14147
+ label: () => t("nav.panel"),
14148
+ locale: namespace
14149
+ }, WorkBuddyPanelIcon)));
14150
+ } catch (error) {
14151
+ console.error("[dsh-connect-workbuddy] sidebar panel row failed to register (host provider unaffected):", error);
14152
+ }
14153
+ try {
14154
+ disposers.push(ctx.slots.inject("main", () => ctx.slots.register({
14155
+ name: "main",
14156
+ key: PANEL_ID,
14157
+ locale: namespace,
14158
+ inject: () => settingsScope === void 0 ? {
14159
+ t,
14160
+ surface: "page",
14161
+ backToConversation
14162
+ } : {
14163
+ t,
14164
+ settingsScope,
14165
+ surface: "page",
14166
+ backToConversation
14167
+ }
14168
+ }, WorkBuddyCard)));
14169
+ } catch (error) {
14170
+ console.error("[dsh-connect-workbuddy] sidebar panel page failed to register (host provider unaffected):", error);
14171
+ }
14172
+ return disposers;
14173
+ };
14174
+ /**
14175
+ * The live panel registrations, kept SEPARATE from {@link liveDisposers}.
14176
+ *
14177
+ * They are the only slots in this plugin that come and go while the page is
14178
+ * open (the opt-in switch), so owning them apart from the rest means
14179
+ * flipping the switch does not dispose and re-create the card, the composer
14180
+ * readout and the five other seats — which would be a visible flicker on the
14181
+ * Plugins page for a change that has nothing to do with it.
14182
+ */
14183
+ let panelDisposers = [];
14184
+ /**
14185
+ * Bring the panel registrations in line with the opt-in switch.
14186
+ *
14187
+ * Dispose FIRST, then register, for the reason spelled out on
14188
+ * {@link rebindSlots}: a live `key` / `id` cannot be registered twice, and
14189
+ * the throw would be swallowed into "no entry at all".
14190
+ *
14191
+ * Re-registering (rather than only unregistering) is what keeps the entry
14192
+ * fresh after a settings-scope rebind: the renderer caches each entry's
14193
+ * `inject` result by object identity, so an entry created before the scope
14194
+ * landed would keep serving props without it forever.
14195
+ */
14196
+ const syncPanelRegistration = () => {
14197
+ for (const dispose of panelDisposers) try {
14198
+ dispose();
14199
+ } catch {}
14200
+ panelDisposers = [];
14201
+ if (!sidebarPanelWanted()) return;
14202
+ panelDisposers = registerPanel();
14203
+ };
14204
+ /**
13256
14205
  * The SAME readout in the ambient dock below the composer card (issue #62).
13257
14206
  *
13258
14207
  * Registered unconditionally, like the composer seat, because the CHOICE
@@ -13280,11 +14229,13 @@ window.__ModuleLoader__.load({
13280
14229
  locale: namespace,
13281
14230
  inject: () => settingsScope === void 0 ? {
13282
14231
  t,
13283
- position: "stats"
14232
+ position: "stats",
14233
+ onOpenSettings
13284
14234
  } : {
13285
14235
  t,
13286
14236
  position: "stats",
13287
- settingsScope
14237
+ settingsScope,
14238
+ onOpenSettings
13288
14239
  }
13289
14240
  }, ComposerCreditsGate));
13290
14241
  } catch (error) {
@@ -13426,8 +14377,9 @@ window.__ModuleLoader__.load({
13426
14377
  liveDisposers = [];
13427
14378
  liveDisposers = registerAllSlots();
13428
14379
  try {
13429
- console.info(`[dsh-connect-workbuddy] registered ${String(liveDisposers.length)} slots (settings form: ${settingsScope === void 0 ? "none — card is read-only" : "bound"})`);
14380
+ console.info(`[dsh-connect-workbuddy] registered ${String(liveDisposers.length)} slots (settings form: ${settingsScope === void 0 ? "none — card is read-only" : "bound"}, sidebar panel: ${sidebarPanelWanted() ? "on" : "off"})`);
13430
14381
  } catch {}
14382
+ syncPanelRegistration();
13431
14383
  };
13432
14384
  /**
13433
14385
  * Bind `settingsScope` to whichever namespace the Host really serves, and
@@ -13464,6 +14416,7 @@ window.__ModuleLoader__.load({
13464
14416
  if (forms === void 0 || typeof forms.whileServed !== "function") {
13465
14417
  settingsScope = forms?.get(WORKBUDDY_SETTINGS_NS);
13466
14418
  liveDisposers = registerAllSlots();
14419
+ syncPanelRegistration();
13467
14420
  return;
13468
14421
  }
13469
14422
  ctx.effect(() => forms.whileServed(WORKBUDDY_SETTINGS_NAMESPACE_CANDIDATES, (served) => {
@@ -13475,11 +14428,44 @@ window.__ModuleLoader__.load({
13475
14428
  dispose();
13476
14429
  } catch {}
13477
14430
  liveDisposers = [];
14431
+ for (const dispose of panelDisposers) try {
14432
+ dispose();
14433
+ } catch {}
14434
+ panelDisposers = [];
13478
14435
  };
13479
14436
  }), "dsh-connect-workbuddy: settings namespace binding");
13480
14437
  rebindSlots();
13481
14438
  };
13482
14439
  bindSettingsScope();
14440
+ /**
14441
+ * Follow the opt-in switch, and SEED it from the Host.
14442
+ *
14443
+ * The seed is a status read rather than the settings scope on purpose. This
14444
+ * namespace's browser mirror is documented as stale on the affected 0.1.7
14445
+ * deployments, and here a stale `false` would mean the row never appears —
14446
+ * with no later event to correct it, because `whileServed` only fires on a
14447
+ * namespace edge, not on a value change. The Host's own answer is the
14448
+ * authority (`sidebarPanelEnabled` on the usage document), exactly as it is
14449
+ * for the other Host-carried switches.
14450
+ *
14451
+ * A failed read is NOT an error to show: OFF is a legitimate and, in fact,
14452
+ * the default answer, so a plugin whose status route is unreachable simply
14453
+ * gets no row. There is nothing the user could do about it from here.
14454
+ *
14455
+ * The SUBSCRIPTION is what makes the switch live: the card calls
14456
+ * `setSidebarPanelWanted` after a verified write, so the row appears and
14457
+ * disappears without a reload. `ui-layout` drops an `activePanelId` whose
14458
+ * `main` key has gone, so switching off while the page is open returns the
14459
+ * centre column to the conversation on its own.
14460
+ */
14461
+ ctx.effect(() => subscribeSidebarPanelWanted(syncPanelRegistration), "dsh-connect-workbuddy: sidebar panel opt-in");
14462
+ (async () => {
14463
+ try {
14464
+ const response = await fetch(withWorkBuddyRegion(WORKBUDDY_USAGE_PATH, "cn"), { headers: { accept: "application/json" } });
14465
+ if (!response.ok) return;
14466
+ if ((await response.json()).sidebarPanelEnabled === true) setSidebarPanelWanted(true);
14467
+ } catch {}
14468
+ })();
13483
14469
  } catch (error) {
13484
14470
  console.error("[dsh-connect-workbuddy] client card failed to load (host provider unaffected):", error);
13485
14471
  }