dsh-codearts 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,38 +24,105 @@ function stripModelSuffixes(name) {
24
24
  }
25
25
  //#endregion
26
26
  //#region src/client/panel-switch.ts
27
+ /** 一个纯内存的布尔开关 + 订阅表;不持久化,真实值来自 `/api/codearts/dock`。 */
28
+ function createWantedSwitch(initial) {
29
+ let wanted = initial;
30
+ const listeners = /* @__PURE__ */ new Set();
31
+ return {
32
+ get: () => wanted,
33
+ set(next) {
34
+ if (wanted === next) return;
35
+ wanted = next;
36
+ for (const listener of [...listeners]) try {
37
+ listener();
38
+ } catch (error) {
39
+ console.error("[dsh-codearts] entry switch listener failed:", error);
40
+ }
41
+ },
42
+ subscribe(listener) {
43
+ listeners.add(listener);
44
+ return () => {
45
+ listeners.delete(listener);
46
+ };
47
+ }
48
+ };
49
+ }
50
+ /** 侧边栏图标列里的入口(缺省关)。 */
51
+ const sidebarEntrySwitch = createWantedSwitch(false);
52
+ /** 设置左侧导航里的入口(缺省开)。 */
53
+ const settingsEntrySwitch = createWantedSwitch(true);
54
+ const sidebarPanelWanted = sidebarEntrySwitch.get;
55
+ const setSidebarPanelWanted = sidebarEntrySwitch.set;
56
+ const subscribeSidebarPanelWanted = sidebarEntrySwitch.subscribe;
57
+ const settingsEntryWanted = settingsEntrySwitch.get;
58
+ const setSettingsEntryWanted = settingsEntrySwitch.set;
59
+ const subscribeSettingsEntryWanted = settingsEntrySwitch.subscribe;
60
+ BigInt("0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551") >> 1n;
61
+ new TextEncoder();
62
+ //#endregion
63
+ //#region src/web-status.ts
64
+ /**
65
+ * 开关的默认值:没有 settings provider(或老配置没这两个键)时保持原有行为 ——
66
+ * 底部两行都显示;侧边栏相反,缺省不开(那一格是所有插件共用的全局座位)。
67
+ * `modelDetail` 缺省开(保持老版本的样子),`autoClaim` 缺省关。
68
+ */
69
+ const DEFAULT_DOCK_FLAGS = {
70
+ credits: true,
71
+ queue: true,
72
+ sidebar: false,
73
+ settingsEntry: true,
74
+ modelDetail: true,
75
+ autoClaim: false,
76
+ keepAliveDaemon: false
77
+ };
78
+ //#endregion
79
+ //#region src/client/dock-store.ts
27
80
  /**
28
- * 「要不要在 DSH 侧边栏占一格」这个偏好,浏览器侧的单一真相。
81
+ * 「显示」页那些开关在浏览器侧的共享状态。
82
+ *
83
+ * 为什么需要它:同一张卡片会被挂到三个地方 —— 设置里的 CodeArts 页、侧边栏的整页
84
+ * 面板、插件详情页。每个实例各自 fetch `/api/codearts/dock` 的话,在 A 处改了开关,
85
+ * B 处只要已经挂载过就永远显示旧值(实测:设置页取消「设置左侧导航显示 CodeArts」,
86
+ * 侧边栏那张卡片仍显示勾选)。
29
87
  *
30
- * 为什么不靠组件返回 null 来隐藏:宿主是按**槽位里的注册条目**(entry metadata)
31
- * 画侧边栏导航行的 —— 只要注册还在,那一行就在;渲染函数 return null 只会留下一个
32
- * 「空白但可点」的按钮。所以开关必须落到「注册 / 不注册」上,这里只存那个意图,
33
- * 真正的注册动作由 index.tsx 的 sync 控制器按它做。
88
+ * 所以开关值只存一份:谁 fetch/POST 成功就写进来,所有挂着的实例订阅它。
89
+ * 乐观更新只改调用方自己的局部状态,成功后才 publish —— 别的实例不该看到还没被
90
+ * 服务端确认的值。
34
91
  *
35
- * 默认 **false**:读不到配置时必须当作关闭。侧边栏那一格是所有插件共用的全局座位,
36
- * 猜错的代价比「少一个入口」大得多(用户还能从「设置 → 插件」进同一张卡片)。
92
+ * @module dsh-codearts/client/dock-store
37
93
  */
38
- let wanted = false;
39
- /** 当前是否要显示侧边栏入口。 */
40
- function sidebarPanelWanted() {
41
- return wanted;
42
- }
94
+ let snapshot = {
95
+ dock: DEFAULT_DOCK_FLAGS,
96
+ writable: false,
97
+ loaded: false
98
+ };
43
99
  const listeners = /* @__PURE__ */ new Set();
100
+ function dockSnapshot() {
101
+ return snapshot;
102
+ }
44
103
  /**
45
- * 改开关。值没变就直接返回 —— 调用方会在每次刷新状态时调用它,
46
- * 无变化的重注册会让侧边栏闪一下。
104
+ * 写入新值。`patch.dock` 只给变化的键也行:缺省键用 DEFAULT_DOCK_FLAGS 补齐,
105
+ * 老后端少字段时不会把已经打开的开关注销成 undefined。
47
106
  */
48
- function setSidebarPanelWanted(next) {
49
- if (wanted === next) return;
50
- wanted = next;
107
+ function publishDock(patch) {
108
+ const dock = patch.dock === void 0 ? snapshot.dock : {
109
+ ...DEFAULT_DOCK_FLAGS,
110
+ ...patch.dock
111
+ };
112
+ const writable = patch.writable ?? snapshot.writable;
113
+ if (dock === snapshot.dock && writable === snapshot.writable && snapshot.loaded) return;
114
+ snapshot = {
115
+ dock,
116
+ writable,
117
+ loaded: true
118
+ };
51
119
  for (const listener of [...listeners]) try {
52
120
  listener();
53
121
  } catch (error) {
54
- console.error("[dsh-codearts] sidebar panel listener failed:", error);
122
+ console.error("[dsh-codearts] dock-store listener failed:", error);
55
123
  }
56
124
  }
57
- /** 订阅开关变化,返回取消订阅函数。 */
58
- function subscribeSidebarPanelWanted(listener) {
125
+ function subscribeDock(listener) {
59
126
  listeners.add(listener);
60
127
  return () => {
61
128
  listeners.delete(listener);
@@ -78,7 +145,7 @@ function latencyP95Label(latency) {
78
145
  }
79
146
  //#endregion
80
147
  //#region \0dsh-css:/home/runner/work/dsh-codearts/dsh-codearts/src/client/CodeArtsPluginCard.module.css.mjs
81
- const css$1 = ".xoziZG_card{border:.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-settings-card-fill);box-sizing:border-box;width:100%;max-width:none}.xoziZG_header{align-items:flex-start;gap:12px;padding:14px 16px;display:flex}.xoziZG_headText{flex-direction:column;flex:1;gap:6px;min-width:0;display:flex}.xoziZG_name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:22px}.xoziZG_desc{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:20px}.xoziZG_statusLine{color:var(--dsw-alias-label-primary);align-items:center;gap:6px;font-size:14px;font-weight:500;line-height:22px;display:inline-flex}.xoziZG_meta{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:12px;line-height:18px}.xoziZG_body{border-top:.5px solid var(--dsw-alias-border-l2);margin:0 16px;padding:4px 0 16px}.xoziZG_tabs{margin-top:12px}.xoziZG_tabPanel{padding-top:2px}.xoziZG_accountToolbar{gap:8px;margin-top:12px;display:flex}.xoziZG_accountToolbar>*{flex:1}.xoziZG_manualForm{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);margin-top:12px;padding:12px}.xoziZG_accountCard{flex-direction:column;gap:10px;margin-top:12px;display:flex}.xoziZG_accountEntry{border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-2)}.xoziZG_accountRow{align-items:center;gap:10px;padding:12px;display:flex}.xoziZG_claimAllRow{border-top:.5px solid var(--dsw-alias-border-l2);justify-content:flex-end;padding:10px 12px 0;display:flex}.xoziZG_avatar{background:var(--dsw-alias-bg-layer-3);width:32px;height:32px;color:var(--dsw-alias-label-primary);border-radius:50%;flex:none;justify-content:center;align-items:center;font-size:14px;font-weight:600;display:inline-flex}.xoziZG_accountInfo{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.xoziZG_accountNameRow{align-items:center;gap:6px;min-width:0;display:flex}.xoziZG_accountName{color:var(--dsw-alias-label-primary);text-overflow:ellipsis;white-space:nowrap;font-size:14px;font-weight:600;line-height:20px;overflow:hidden}.xoziZG_accountRowActions{flex-wrap:wrap;flex:none;justify-content:flex-end;align-items:center;gap:6px;display:flex}.xoziZG_accountToggle{align-items:center;gap:6px;display:inline-flex}.xoziZG_accountToggleLabel{color:var(--dsw-alias-label-secondary);white-space:nowrap;font-size:12px;line-height:20px}.xoziZG_accountHint{color:var(--dsw-alias-label-tertiary);margin:0;padding:0 12px 12px;font-size:12px;line-height:18px}.xoziZG_creditBlock{border-top:.5px solid var(--dsw-alias-border-l2);padding:12px}.xoziZG_balanceRow{flex-wrap:wrap;align-items:baseline;gap:6px;display:flex}.xoziZG_balance{color:var(--dsw-alias-label-primary);letter-spacing:-.02em;font-variant-numeric:tabular-nums;font-size:28px;font-weight:600;line-height:34px}.xoziZG_balanceUnit{color:var(--dsw-alias-label-secondary);font-size:12px}.xoziZG_balanceMeta{color:var(--dsw-alias-label-tertiary);margin-left:2px;font-size:12px}.xoziZG_updated{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;margin-left:auto;font-size:12px}.xoziZG_creditRows{flex-direction:column;gap:4px;margin-top:8px;display:flex}.xoziZG_creditRow{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;justify-content:space-between;align-items:baseline;gap:12px;font-size:12px;line-height:18px;display:flex}.xoziZG_usageBar{background:var(--dsw-alias-border-l2);border-radius:2px;height:4px;margin-top:4px;display:block;overflow:hidden}.xoziZG_usageFill{background:var(--dsw-alias-brand-primary);border-radius:2px;height:100%;transition:width .2s;display:block}.xoziZG_expiryRow{margin-top:2px}.xoziZG_expiryLabel{color:var(--dsw-alias-state-warn-label)}.xoziZG_bar{background:var(--dsw-alias-bg-layer-3);border-radius:2px;height:4px;margin-top:6px;display:block;overflow:hidden}.xoziZG_barFill{background:var(--dsw-alias-state-warn-primary);border-radius:2px;height:100%;display:block}.xoziZG_creditLink{margin-top:8px;display:inline-block}.xoziZG_creditFooter{border-top:.5px solid var(--dsw-alias-border-l2);justify-content:space-between;align-items:center;gap:8px;margin-top:12px;padding-top:10px;display:flex}.xoziZG_creditHint{color:var(--dsw-alias-label-tertiary);margin:8px 0 0;font-size:12px;line-height:18px}.xoziZG_section{margin-top:16px}.xoziZG_sectionHead{justify-content:space-between;align-items:baseline;gap:12px;display:flex}.xoziZG_sectionLabel{color:var(--dsw-alias-label-tertiary);font-size:11px;font-weight:500}.xoziZG_count{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;flex:none;font-size:12px}.xoziZG_hint{color:var(--dsw-alias-label-secondary);margin:8px 0 0;font-size:13px;line-height:20px}.xoziZG_error{color:var(--dsw-alias-state-error-primary);margin:10px 0 0;font-size:13px;line-height:20px}.xoziZG_actions{flex-wrap:wrap;align-items:center;gap:8px;margin-top:12px;display:flex}.xoziZG_danger{color:var(--dsw-alias-state-error-primary)}.xoziZG_link{appearance:none;color:var(--dsw-alias-brand-text);font:inherit;text-align:left;word-break:break-all;cursor:pointer;background:0 0;border:none;padding:0;font-size:12px}.xoziZG_link:hover{text-decoration:underline}.xoziZG_choices{flex-direction:column;gap:2px;margin-top:8px;display:flex}.xoziZG_choiceRow{border-radius:var(--dsw-radius-sm);align-items:center;gap:8px;margin:0 -6px;padding:5px 6px;display:flex}.xoziZG_choiceRow:hover{background:var(--dsw-alias-interactive-bg-hover)}.xoziZG_statGrid{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:10px 0 14px;display:grid}.xoziZG_statCard{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);flex-direction:column;gap:1px;padding:8px 10px;display:flex}.xoziZG_statLabel{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}.xoziZG_statValue{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-size:15px;line-height:20px}.xoziZG_statSub{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:11px;line-height:16px}.xoziZG_modelChart{flex-direction:column;gap:2px;margin-top:8px;display:flex}.xoziZG_modelRow{font-variant-numeric:tabular-nums;border-radius:6px;grid-template-columns:minmax(0,1.2fr) minmax(48px,1fr) 56px 52px 64px;align-items:center;gap:8px;padding:4px 0;display:grid;position:relative}.xoziZG_modelRow:hover{background:var(--dsw-alias-interactive-bg-hover)}.xoziZG_usageTip{z-index:5;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-3);min-width:180px;max-width:260px;color:var(--dsw-alias-label-secondary);text-align:left;font-variant-numeric:tabular-nums;pointer-events:none;padding:8px 10px;font-size:12px;line-height:1.9;position:absolute;bottom:calc(100% + 6px);right:0;box-shadow:0 10px 28px #00000073}.xoziZG_usageTip[data-float=true]{z-index:40;position:fixed;bottom:auto;right:auto}.xoziZG_usageTipName{max-width:240px;color:var(--dsw-alias-label-primary);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.xoziZG_usageTipSep{background:var(--dsw-alias-border-l2);height:1px;margin:4px 0}.xoziZG_usageTipRow{justify-content:space-between;gap:24px;display:flex}.xoziZG_usageTipRow span:last-child{color:var(--dsw-alias-label-primary);font-weight:600}.xoziZG_modelName{color:var(--dsw-alias-label-primary);text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:18px;overflow:hidden}.xoziZG_modelTrack{background:var(--dsw-alias-border-l2);border-radius:4px;height:8px;display:block;overflow:hidden}.xoziZG_modelFill{background:var(--dsw-alias-brand-primary);border-radius:4px;height:100%;transition:width .16s;display:block}.xoziZG_modelTokens,.xoziZG_modelShare,.xoziZG_modelRequests{color:var(--dsw-alias-label-secondary);text-align:right;white-space:nowrap;font-size:11px;line-height:16px}.xoziZG_modelRequests{color:var(--dsw-alias-label-tertiary)}.xoziZG_heatGrid{grid-template-columns:repeat(7,minmax(0,1fr));gap:4px;margin:8px 0 2px;display:grid}.xoziZG_heatWeekday{color:var(--dsw-alias-label-tertiary);text-align:center;font-size:10px;line-height:14px}.xoziZG_heatCell{background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);height:36px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;border:0;border-radius:8px;outline:0;justify-content:center;align-items:center;font-size:12px;transition:background .12s ease-out;display:flex}.xoziZG_heatCell[data-tone=empty]{color:var(--dsw-alias-label-tertiary)}.xoziZG_heatCell[data-tone=pad]{background:0 0}.xoziZG_heatCell[data-tone=out]{color:var(--dsw-alias-label-tertiary);opacity:.45;background:0 0}.xoziZG_heatCell[data-tone=lv1]{color:#0f1115;background:#ddf4e7}.xoziZG_heatCell[data-tone=lv2]{color:#0f1115;background:#b3e8cc}.xoziZG_heatCell[data-tone=lv3]{color:#0f1115;background:#7dd8ac}.xoziZG_heatCell[data-tone=lv4]{color:#fff;background:#40c584}.xoziZG_heatCell[data-tone=lv5]{color:#fff;background:#16a34a}.xoziZG_heatCell[data-today=true]{box-shadow:inset 0 -2px 0 0 var(--heat-today-mark,#16a34a);font-weight:700}.xoziZG_heatCell[data-today=true][data-tone=lv4],.xoziZG_heatCell[data-today=true][data-tone=lv5]{--heat-today-mark:#fff}.xoziZG_heatHours{grid-template-columns:repeat(24,minmax(0,1fr));gap:3px;margin:8px 0 0;display:grid}.xoziZG_heatHourCell{background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);border-radius:4px;height:26px;transition:background .12s ease-out}.xoziZG_heatHourCell[data-tone=lv1]{background:#ddf4e7}.xoziZG_heatHourCell[data-tone=lv2]{background:#b3e8cc}.xoziZG_heatHourCell[data-tone=lv3]{background:#7dd8ac}.xoziZG_heatHourCell[data-tone=lv4]{background:#40c584}.xoziZG_heatHourCell[data-tone=lv5]{background:#16a34a}.xoziZG_heatAxis{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;grid-template-columns:repeat(24,minmax(0,1fr));gap:3px;font-size:10px;line-height:14px;display:grid}.xoziZG_heatAxisSlot{text-align:center;white-space:nowrap;overflow:hidden}.xoziZG_heatLegend{color:var(--dsw-alias-label-tertiary);justify-content:flex-start;align-items:center;gap:3px;margin:0 0 6px;font-size:10px;display:flex}.xoziZG_heatLegendChip{border-radius:3px;width:10px;height:10px}.xoziZG_heatLegendChip[data-tone=lv1]{background:#ddf4e7}.xoziZG_heatLegendChip[data-tone=lv2]{background:#b3e8cc}.xoziZG_heatLegendChip[data-tone=lv3]{background:#7dd8ac}.xoziZG_heatLegendChip[data-tone=lv4]{background:#40c584}.xoziZG_heatLegendChip[data-tone=lv5]{background:#16a34a}.xoziZG_trendTip{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;margin:2px 0 0;font-size:11px;line-height:16px}.xoziZG_check{flex:1;min-width:0}.xoziZG_check>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.xoziZG_manual{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);margin-top:12px;padding:0 12px}.xoziZG_manual[open]{padding-bottom:12px}.xoziZG_manualSummary{color:var(--dsw-alias-label-secondary);cursor:pointer;align-items:center;gap:6px;padding:9px 0;font-size:13px;list-style:none;display:flex}.xoziZG_manualSummary::-webkit-details-marker{display:none}.xoziZG_field{flex-direction:column;gap:5px;margin-top:10px;display:flex}.xoziZG_fieldLabel{color:var(--dsw-alias-label-tertiary);font-size:12px}.xoziZG_area{box-sizing:border-box;resize:vertical;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);width:100%;color:var(--dsw-alias-label-primary);padding:6px 8px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:13px;line-height:20px}.xoziZG_area::placeholder{color:var(--dsw-alias-label-dimmed)}.xoziZG_area:focus{border-color:var(--dsw-alias-state-business-primary);outline:none}.xoziZG_skeleton{flex-direction:column;gap:10px;padding:4px 0;display:flex}.xoziZG_skeletonRow{border-radius:var(--dsw-radius-sm,4px);background:var(--dsw-alias-border-l2);height:12px;animation:1.4s ease-in-out infinite xoziZG_skeletonBreath}.xoziZG_skeletonRow:nth-child(2){width:72%}.xoziZG_skeletonRow:nth-child(3){width:46%}@keyframes xoziZG_skeletonBreath{0%,to{opacity:.45}50%{opacity:.9}}@media (prefers-reduced-motion:reduce){.xoziZG_skeletonRow{animation:none}}.xoziZG_modelSpec{color:var(--dsw-alias-label-tertiary);white-space:nowrap;font-variant-numeric:tabular-nums;font-size:11px;line-height:16px}.xoziZG_doctorList{flex-direction:column;gap:2px;margin-top:8px;display:flex}.xoziZG_doctorRow{align-items:center;gap:8px;padding:4px 0;display:flex}.xoziZG_doctorName{color:var(--dsw-alias-label-secondary);flex:none;font-size:12px;line-height:18px}.xoziZG_doctorRow .xoziZG_meta{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}";
148
+ const css$1 = ".xoziZG_card{border:.5px solid var(--dsw-alias-settings-card-stroke);border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-settings-card-fill);box-sizing:border-box;width:100%;max-width:none}.xoziZG_header{align-items:flex-start;gap:12px;padding:14px 16px;display:flex}.xoziZG_headText{flex-direction:column;flex:1;gap:6px;min-width:0;display:flex}.xoziZG_name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:22px}.xoziZG_desc{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:20px}.xoziZG_statusLine{color:var(--dsw-alias-label-primary);align-items:center;gap:6px;font-size:14px;font-weight:500;line-height:22px;display:inline-flex}.xoziZG_meta{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:12px;line-height:18px}.xoziZG_body{border-top:.5px solid var(--dsw-alias-border-l2);margin:0 16px;padding:4px 0 16px}.xoziZG_tabs{margin-top:12px}.xoziZG_tabPanel{padding-top:2px}.xoziZG_accountToolbar{gap:8px;margin-top:12px;display:flex}.xoziZG_accountToolbar>*{flex:1}.xoziZG_manualForm{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);margin-top:12px;padding:12px}.xoziZG_accountCard{flex-direction:column;gap:10px;margin-top:12px;display:flex}.xoziZG_accountEntry{border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-2)}.xoziZG_accountRow{align-items:center;gap:10px;padding:12px;display:flex}.xoziZG_claimAllRow{border-top:.5px solid var(--dsw-alias-border-l2);justify-content:flex-end;padding:10px 12px 0;display:flex}.xoziZG_avatar{background:var(--dsw-alias-bg-layer-3);width:32px;height:32px;color:var(--dsw-alias-label-primary);border-radius:50%;flex:none;justify-content:center;align-items:center;font-size:14px;font-weight:600;display:inline-flex}.xoziZG_accountInfo{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.xoziZG_accountNameRow{align-items:center;gap:6px;min-width:0;display:flex}.xoziZG_accountName{color:var(--dsw-alias-label-primary);text-overflow:ellipsis;white-space:nowrap;font-size:14px;font-weight:600;line-height:20px;overflow:hidden}.xoziZG_accountRowActions{flex-wrap:wrap;flex:none;justify-content:flex-end;align-items:center;gap:6px;display:flex}.xoziZG_accountToggle{align-items:center;gap:6px;display:inline-flex}.xoziZG_accountToggleLabel{color:var(--dsw-alias-label-secondary);white-space:nowrap;font-size:12px;line-height:20px}.xoziZG_accountHint{color:var(--dsw-alias-label-tertiary);margin:0;padding:0 12px 12px;font-size:12px;line-height:18px}.xoziZG_creditBlock{border-top:.5px solid var(--dsw-alias-border-l2);padding:12px}.xoziZG_balanceRow{flex-wrap:wrap;align-items:baseline;gap:6px;display:flex}.xoziZG_balance{color:var(--dsw-alias-label-primary);letter-spacing:-.02em;font-variant-numeric:tabular-nums;font-size:28px;font-weight:600;line-height:34px}.xoziZG_balanceUnit{color:var(--dsw-alias-label-secondary);font-size:12px}.xoziZG_balanceMeta{color:var(--dsw-alias-label-tertiary);margin-left:2px;font-size:12px}.xoziZG_updated{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;margin-left:auto;font-size:12px}.xoziZG_creditRows{flex-direction:column;gap:4px;margin-top:8px;display:flex}.xoziZG_creditRow{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;justify-content:space-between;align-items:baseline;gap:12px;font-size:12px;line-height:18px;display:flex}.xoziZG_usageBar{background:var(--dsw-alias-border-l2);border-radius:2px;height:4px;margin-top:4px;display:block;overflow:hidden}.xoziZG_usageFill{background:var(--dsw-alias-brand-primary);border-radius:2px;height:100%;transition:width .2s;display:block}.xoziZG_expiryRow{margin-top:2px}.xoziZG_expiryLabel{color:var(--dsw-alias-state-warn-label)}.xoziZG_bar{background:var(--dsw-alias-bg-layer-3);border-radius:2px;height:4px;margin-top:6px;display:block;overflow:hidden}.xoziZG_barFill{background:var(--dsw-alias-state-warn-primary);border-radius:2px;height:100%;display:block}.xoziZG_creditLink{margin-top:8px;display:inline-block}.xoziZG_creditFooter{border-top:.5px solid var(--dsw-alias-border-l2);justify-content:space-between;align-items:center;gap:8px;margin-top:12px;padding-top:10px;display:flex}.xoziZG_creditHint{color:var(--dsw-alias-label-tertiary);margin:8px 0 0;font-size:12px;line-height:18px}.xoziZG_section{margin-top:16px}.xoziZG_sectionHead{justify-content:space-between;align-items:baseline;gap:12px;display:flex}.xoziZG_sectionLabel{color:var(--dsw-alias-label-tertiary);font-size:11px;font-weight:500}.xoziZG_count{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;flex:none;font-size:12px}.xoziZG_hint{color:var(--dsw-alias-label-secondary);margin:8px 0 0;font-size:13px;line-height:20px}.xoziZG_error{color:var(--dsw-alias-state-error-primary);margin:10px 0 0;font-size:13px;line-height:20px}.xoziZG_actions{flex-wrap:wrap;align-items:center;gap:8px;margin-top:12px;display:flex}.xoziZG_danger{color:var(--dsw-alias-state-error-primary)}.xoziZG_link{appearance:none;color:var(--dsw-alias-brand-text);font:inherit;text-align:left;word-break:break-all;cursor:pointer;background:0 0;border:none;padding:0;font-size:12px}.xoziZG_link:hover{text-decoration:underline}.xoziZG_choices{flex-direction:column;gap:2px;margin-top:8px;display:flex}.xoziZG_choiceRow{border-radius:var(--dsw-radius-sm);align-items:center;gap:8px;margin:0 -6px;padding:5px 6px;display:flex}.xoziZG_choiceRow:hover{background:var(--dsw-alias-interactive-bg-hover)}.xoziZG_statGrid{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:10px 0 14px;display:grid}.xoziZG_statCard{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);flex-direction:column;gap:1px;padding:8px 10px;display:flex}.xoziZG_statLabel{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}.xoziZG_statValue{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-size:15px;line-height:20px}.xoziZG_statSub{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:11px;line-height:16px}.xoziZG_modelChart{flex-direction:column;gap:2px;margin-top:8px;display:flex}.xoziZG_modelRow{font-variant-numeric:tabular-nums;border-radius:6px;grid-template-columns:minmax(0,1.2fr) minmax(48px,1fr) 56px 52px 64px;align-items:center;gap:8px;padding:4px 0;display:grid;position:relative}.xoziZG_modelRow:hover{background:var(--dsw-alias-interactive-bg-hover)}.xoziZG_usageTip{z-index:5;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-3);min-width:180px;max-width:260px;color:var(--dsw-alias-label-secondary);text-align:left;font-variant-numeric:tabular-nums;pointer-events:none;padding:8px 10px;font-size:12px;line-height:1.9;position:absolute;bottom:calc(100% + 6px);right:0;box-shadow:0 10px 28px #00000073}.xoziZG_usageTip[data-float=true]{z-index:40;position:fixed;bottom:auto;right:auto}.xoziZG_usageTipName{max-width:240px;color:var(--dsw-alias-label-primary);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.xoziZG_usageTipSep{background:var(--dsw-alias-border-l2);height:1px;margin:4px 0}.xoziZG_usageTipRow{justify-content:space-between;gap:24px;display:flex}.xoziZG_usageTipRow span:last-child{color:var(--dsw-alias-label-primary);font-weight:600}.xoziZG_modelName{color:var(--dsw-alias-label-primary);text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:18px;overflow:hidden}.xoziZG_modelTrack{background:var(--dsw-alias-border-l2);border-radius:4px;height:8px;display:block;overflow:hidden}.xoziZG_modelFill{background:var(--dsw-alias-brand-primary);border-radius:4px;height:100%;transition:width .16s;display:block}.xoziZG_modelTokens,.xoziZG_modelShare,.xoziZG_modelRequests{color:var(--dsw-alias-label-secondary);text-align:right;white-space:nowrap;font-size:11px;line-height:16px}.xoziZG_modelRequests{color:var(--dsw-alias-label-tertiary)}.xoziZG_heatGrid{grid-template-columns:repeat(7,minmax(0,1fr));gap:4px;margin:8px 0 2px;display:grid}.xoziZG_heatWeekday{color:var(--dsw-alias-label-tertiary);text-align:center;font-size:10px;line-height:14px}.xoziZG_heatCell{background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);height:36px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;border:0;border-radius:8px;outline:0;justify-content:center;align-items:center;font-size:12px;transition:background .12s ease-out;display:flex}.xoziZG_heatCell[data-tone=empty]{color:var(--dsw-alias-label-tertiary)}.xoziZG_heatCell[data-tone=pad]{background:0 0}.xoziZG_heatCell[data-tone=out]{color:var(--dsw-alias-label-tertiary);opacity:.45;background:0 0}.xoziZG_heatCell[data-tone=lv1]{color:#0f1115;background:#ddf4e7}.xoziZG_heatCell[data-tone=lv2]{color:#0f1115;background:#b3e8cc}.xoziZG_heatCell[data-tone=lv3]{color:#0f1115;background:#7dd8ac}.xoziZG_heatCell[data-tone=lv4]{color:#fff;background:#40c584}.xoziZG_heatCell[data-tone=lv5]{color:#fff;background:#16a34a}.xoziZG_heatCell[data-today=true]{box-shadow:inset 0 -2px 0 0 var(--heat-today-mark,#16a34a);font-weight:700}.xoziZG_heatCell[data-today=true][data-tone=lv4],.xoziZG_heatCell[data-today=true][data-tone=lv5]{--heat-today-mark:#fff}.xoziZG_heatHours{grid-template-columns:repeat(24,minmax(0,1fr));gap:3px;margin:8px 0 0;display:grid}.xoziZG_heatHourCell{background:color-mix(in srgb, var(--dsw-alias-label-primary) 6%, transparent);border-radius:4px;height:26px;transition:background .12s ease-out}.xoziZG_heatHourCell[data-tone=lv1]{background:#ddf4e7}.xoziZG_heatHourCell[data-tone=lv2]{background:#b3e8cc}.xoziZG_heatHourCell[data-tone=lv3]{background:#7dd8ac}.xoziZG_heatHourCell[data-tone=lv4]{background:#40c584}.xoziZG_heatHourCell[data-tone=lv5]{background:#16a34a}.xoziZG_heatAxis{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;grid-template-columns:repeat(24,minmax(0,1fr));gap:3px;font-size:10px;line-height:14px;display:grid}.xoziZG_heatAxisSlot{text-align:center;white-space:nowrap;overflow:hidden}.xoziZG_heatLegend{color:var(--dsw-alias-label-tertiary);justify-content:flex-start;align-items:center;gap:3px;margin:0 0 6px;font-size:10px;display:flex}.xoziZG_heatLegendChip{border-radius:3px;width:10px;height:10px}.xoziZG_heatLegendChip[data-tone=lv1]{background:#ddf4e7}.xoziZG_heatLegendChip[data-tone=lv2]{background:#b3e8cc}.xoziZG_heatLegendChip[data-tone=lv3]{background:#7dd8ac}.xoziZG_heatLegendChip[data-tone=lv4]{background:#40c584}.xoziZG_heatLegendChip[data-tone=lv5]{background:#16a34a}.xoziZG_trendTip{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;margin:2px 0 0;font-size:11px;line-height:16px}.xoziZG_check{flex:1;min-width:0}.xoziZG_check>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.xoziZG_manual{border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md);margin-top:12px;padding:0 12px}.xoziZG_manual[open]{padding-bottom:12px}.xoziZG_manualSummary{color:var(--dsw-alias-label-secondary);cursor:pointer;align-items:center;gap:6px;padding:9px 0;font-size:13px;list-style:none;display:flex}.xoziZG_manualSummary::-webkit-details-marker{display:none}.xoziZG_field{flex-direction:column;gap:5px;margin-top:10px;display:flex}.xoziZG_fieldLabel{color:var(--dsw-alias-label-tertiary);font-size:12px}.xoziZG_area{box-sizing:border-box;resize:vertical;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);width:100%;color:var(--dsw-alias-label-primary);padding:6px 8px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:13px;line-height:20px}.xoziZG_area::placeholder{color:var(--dsw-alias-label-dimmed)}.xoziZG_area:focus{border-color:var(--dsw-alias-state-business-primary);outline:none}.xoziZG_skeleton{flex-direction:column;gap:10px;padding:4px 0;display:flex}.xoziZG_skeletonRow{border-radius:var(--dsw-radius-sm,4px);background:var(--dsw-alias-border-l2);height:12px;animation:1.4s ease-in-out infinite xoziZG_skeletonBreath}.xoziZG_skeletonRow:nth-child(2){width:72%}.xoziZG_skeletonRow:nth-child(3){width:46%}@keyframes xoziZG_skeletonBreath{0%,to{opacity:.45}50%{opacity:.9}}@media (prefers-reduced-motion:reduce){.xoziZG_skeletonRow{animation:none}}.xoziZG_modelSpec{color:var(--dsw-alias-label-tertiary);white-space:nowrap;font-variant-numeric:tabular-nums;font-size:11px;line-height:16px}.xoziZG_windowAnchor{flex:none;margin-left:auto;position:relative}.xoziZG_windowButton{font:inherit;color:var(--dsw-alias-label-tertiary);white-space:nowrap;font-variant-numeric:tabular-nums;border-radius:var(--dsw-radius-sm);cursor:pointer;background:0 0;border:.5px solid #0000;align-items:center;gap:3px;padding:1px 4px;font-size:11px;line-height:16px;display:inline-flex}.xoziZG_windowButton:hover,.xoziZG_windowButtonOpen{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover);border-color:var(--dsw-alias-border-l3)}.xoziZG_windowButtonSet{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-state-business-primary);font-weight:500}.xoziZG_windowCaret{opacity:.7;font-size:9px;line-height:1}.xoziZG_windowPopover{z-index:40;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-md);flex-direction:column;gap:8px;width:208px;padding:10px;display:flex;position:absolute;top:calc(100% + 4px);right:0;box-shadow:0 6px 20px #0000002e}.xoziZG_windowPopoverHead{color:var(--dsw-alias-label-secondary);justify-content:space-between;align-items:baseline;gap:8px;font-size:11px;line-height:16px;display:flex}.xoziZG_windowPopoverValue{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary)}.xoziZG_windowRange{cursor:pointer;width:100%;height:16px;accent-color:var(--dsw-alias-brand-primary);margin:0}.xoziZG_windowRange:disabled{cursor:not-allowed;opacity:.5}.xoziZG_windowPopoverRow{align-items:center;gap:6px;display:flex}.xoziZG_windowUnit{color:var(--dsw-alias-label-tertiary);font-size:11px}.xoziZG_windowInput{min-width:0;font:inherit;font-variant-numeric:tabular-nums;text-align:right;color:var(--dsw-alias-label-primary);border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-sm);-moz-appearance:textfield;appearance:textfield;background:0 0;flex:1;padding:2px 6px;font-size:11px;line-height:16px}.xoziZG_windowInput::-webkit-outer-spin-button,.xoziZG_windowInput::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.xoziZG_windowInput:focus{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-brand-primary);outline:none}.xoziZG_windowInputSet{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-state-business-primary);font-weight:500}.xoziZG_windowHint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:10px;line-height:15px}.xoziZG_doctorList{flex-direction:column;gap:2px;margin-top:8px;display:flex}.xoziZG_doctorRow{align-items:center;gap:8px;padding:4px 0;display:flex}.xoziZG_doctorName{color:var(--dsw-alias-label-secondary);flex:none;font-size:12px;line-height:18px}.xoziZG_doctorRow .xoziZG_meta{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}";
82
149
  const tagId$1 = "dsh-codearts/CodeArtsPluginCard.module.css";
83
150
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
84
151
  const tag = document.createElement("style");
@@ -88,98 +155,112 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
88
155
  document.head.appendChild(tag);
89
156
  }
90
157
  var CodeArtsPluginCard_module_css_default = {
91
- "header": "xoziZG_header",
92
- "accountToggle": "xoziZG_accountToggle",
93
- "modelChart": "xoziZG_modelChart",
94
- "modelShare": "xoziZG_modelShare",
95
- "choiceRow": "xoziZG_choiceRow",
96
- "heatHourCell": "xoziZG_heatHourCell",
97
- "accountInfo": "xoziZG_accountInfo",
158
+ "windowButton": "xoziZG_windowButton",
159
+ "actions": "xoziZG_actions",
160
+ "danger": "xoziZG_danger",
161
+ "statCard": "xoziZG_statCard",
162
+ "accountRowActions": "xoziZG_accountRowActions",
163
+ "usageTipSep": "xoziZG_usageTipSep",
164
+ "modelTrack": "xoziZG_modelTrack",
165
+ "heatGrid": "xoziZG_heatGrid",
98
166
  "heatHours": "xoziZG_heatHours",
99
- "headText": "xoziZG_headText",
100
- "usageBar": "xoziZG_usageBar",
101
- "bar": "xoziZG_bar",
102
- "count": "xoziZG_count",
103
- "avatar": "xoziZG_avatar",
104
- "statSub": "xoziZG_statSub",
105
167
  "heatLegendChip": "xoziZG_heatLegendChip",
106
- "statusLine": "xoziZG_statusLine",
107
- "accountRowActions": "xoziZG_accountRowActions",
108
- "expiryLabel": "xoziZG_expiryLabel",
109
- "desc": "xoziZG_desc",
168
+ "accountEntry": "xoziZG_accountEntry",
110
169
  "body": "xoziZG_body",
111
- "updated": "xoziZG_updated",
112
- "usageTipRow": "xoziZG_usageTipRow",
113
- "heatWeekday": "xoziZG_heatWeekday",
114
- "doctorRow": "xoziZG_doctorRow",
115
- "manualForm": "xoziZG_manualForm",
116
- "heatLegend": "xoziZG_heatLegend",
170
+ "tabPanel": "xoziZG_tabPanel",
171
+ "header": "xoziZG_header",
172
+ "accountNameRow": "xoziZG_accountNameRow",
173
+ "creditBlock": "xoziZG_creditBlock",
174
+ "balance": "xoziZG_balance",
175
+ "expiryLabel": "xoziZG_expiryLabel",
117
176
  "creditLink": "xoziZG_creditLink",
118
- "heatAxisSlot": "xoziZG_heatAxisSlot",
119
- "skeletonRow": "xoziZG_skeletonRow",
177
+ "section": "xoziZG_section",
178
+ "accountName": "xoziZG_accountName",
179
+ "sectionHead": "xoziZG_sectionHead",
120
180
  "link": "xoziZG_link",
181
+ "claimAllRow": "xoziZG_claimAllRow",
182
+ "statValue": "xoziZG_statValue",
183
+ "desc": "xoziZG_desc",
184
+ "choices": "xoziZG_choices",
185
+ "name": "xoziZG_name",
186
+ "modelName": "xoziZG_modelName",
187
+ "modelTokens": "xoziZG_modelTokens",
121
188
  "creditRows": "xoziZG_creditRows",
122
- "accountName": "xoziZG_accountName",
123
- "section": "xoziZG_section",
124
- "tabPanel": "xoziZG_tabPanel",
125
- "accountToggleLabel": "xoziZG_accountToggleLabel",
126
- "creditRow": "xoziZG_creditRow",
127
- "creditFooter": "xoziZG_creditFooter",
128
- "creditHint": "xoziZG_creditHint",
189
+ "heatLegend": "xoziZG_heatLegend",
190
+ "manual": "xoziZG_manual",
191
+ "skeletonBreath": "xoziZG_skeletonBreath",
192
+ "modelSpec": "xoziZG_modelSpec",
193
+ "windowPopoverValue": "xoziZG_windowPopoverValue",
194
+ "sectionLabel": "xoziZG_sectionLabel",
195
+ "windowPopoverRow": "xoziZG_windowPopoverRow",
196
+ "windowInput": "xoziZG_windowInput",
197
+ "heatHourCell": "xoziZG_heatHourCell",
198
+ "windowHint": "xoziZG_windowHint",
199
+ "windowCaret": "xoziZG_windowCaret",
200
+ "statusLine": "xoziZG_statusLine",
201
+ "bar": "xoziZG_bar",
129
202
  "usageTip": "xoziZG_usageTip",
130
- "modelFill": "xoziZG_modelFill",
203
+ "updated": "xoziZG_updated",
204
+ "heatCell": "xoziZG_heatCell",
205
+ "heatAxisSlot": "xoziZG_heatAxisSlot",
206
+ "trendTip": "xoziZG_trendTip",
207
+ "windowButtonOpen": "xoziZG_windowButtonOpen",
131
208
  "doctorName": "xoziZG_doctorName",
209
+ "windowPopoverHead": "xoziZG_windowPopoverHead",
210
+ "statGrid": "xoziZG_statGrid",
211
+ "area": "xoziZG_area",
212
+ "fieldLabel": "xoziZG_fieldLabel",
213
+ "expiryRow": "xoziZG_expiryRow",
214
+ "skeletonRow": "xoziZG_skeletonRow",
215
+ "doctorList": "xoziZG_doctorList",
216
+ "count": "xoziZG_count",
217
+ "accountInfo": "xoziZG_accountInfo",
132
218
  "accountCard": "xoziZG_accountCard",
219
+ "meta": "xoziZG_meta",
220
+ "check": "xoziZG_check",
133
221
  "accountRow": "xoziZG_accountRow",
222
+ "balanceRow": "xoziZG_balanceRow",
223
+ "creditRow": "xoziZG_creditRow",
224
+ "skeleton": "xoziZG_skeleton",
134
225
  "tabs": "xoziZG_tabs",
135
- "modelSpec": "xoziZG_modelSpec",
136
- "sectionHead": "xoziZG_sectionHead",
137
- "statValue": "xoziZG_statValue",
138
- "statLabel": "xoziZG_statLabel",
139
- "trendTip": "xoziZG_trendTip",
140
- "doctorList": "xoziZG_doctorList",
226
+ "accountToggle": "xoziZG_accountToggle",
227
+ "field": "xoziZG_field",
228
+ "statSub": "xoziZG_statSub",
229
+ "windowButtonSet": "xoziZG_windowButtonSet",
141
230
  "usageFill": "xoziZG_usageFill",
142
- "heatCell": "xoziZG_heatCell",
143
- "balanceUnit": "xoziZG_balanceUnit",
144
- "meta": "xoziZG_meta",
145
- "name": "xoziZG_name",
146
- "claimAllRow": "xoziZG_claimAllRow",
147
- "choices": "xoziZG_choices",
148
- "modelRow": "xoziZG_modelRow",
149
- "statCard": "xoziZG_statCard",
150
- "balanceRow": "xoziZG_balanceRow",
231
+ "hint": "xoziZG_hint",
232
+ "modelFill": "xoziZG_modelFill",
233
+ "modelChart": "xoziZG_modelChart",
234
+ "creditHint": "xoziZG_creditHint",
235
+ "windowRange": "xoziZG_windowRange",
236
+ "accountToolbar": "xoziZG_accountToolbar",
237
+ "manualSummary": "xoziZG_manualSummary",
238
+ "heatWeekday": "xoziZG_heatWeekday",
151
239
  "heatAxis": "xoziZG_heatAxis",
152
- "usageTipName": "xoziZG_usageTipName",
240
+ "statLabel": "xoziZG_statLabel",
241
+ "windowPopover": "xoziZG_windowPopover",
242
+ "usageBar": "xoziZG_usageBar",
243
+ "accountHint": "xoziZG_accountHint",
244
+ "choiceRow": "xoziZG_choiceRow",
245
+ "modelRow": "xoziZG_modelRow",
246
+ "manualForm": "xoziZG_manualForm",
247
+ "doctorRow": "xoziZG_doctorRow",
248
+ "windowInputSet": "xoziZG_windowInputSet",
153
249
  "card": "xoziZG_card",
154
- "accountEntry": "xoziZG_accountEntry",
155
- "balanceMeta": "xoziZG_balanceMeta",
156
250
  "error": "xoziZG_error",
157
- "usageTipSep": "xoziZG_usageTipSep",
158
- "hint": "xoziZG_hint",
159
- "modelName": "xoziZG_modelName",
160
- "creditBlock": "xoziZG_creditBlock",
161
- "modelTrack": "xoziZG_modelTrack",
162
- "modelTokens": "xoziZG_modelTokens",
163
- "modelRequests": "xoziZG_modelRequests",
164
- "manualSummary": "xoziZG_manualSummary",
165
- "field": "xoziZG_field",
166
- "skeletonBreath": "xoziZG_skeletonBreath",
167
- "area": "xoziZG_area",
168
- "heatGrid": "xoziZG_heatGrid",
169
- "sectionLabel": "xoziZG_sectionLabel",
170
- "accountToolbar": "xoziZG_accountToolbar",
251
+ "usageTipName": "xoziZG_usageTipName",
252
+ "headText": "xoziZG_headText",
253
+ "accountToggleLabel": "xoziZG_accountToggleLabel",
254
+ "usageTipRow": "xoziZG_usageTipRow",
255
+ "modelShare": "xoziZG_modelShare",
171
256
  "barFill": "xoziZG_barFill",
172
- "fieldLabel": "xoziZG_fieldLabel",
173
- "accountHint": "xoziZG_accountHint",
174
- "actions": "xoziZG_actions",
175
- "danger": "xoziZG_danger",
176
- "check": "xoziZG_check",
177
- "manual": "xoziZG_manual",
178
- "balance": "xoziZG_balance",
179
- "skeleton": "xoziZG_skeleton",
180
- "accountNameRow": "xoziZG_accountNameRow",
181
- "statGrid": "xoziZG_statGrid",
182
- "expiryRow": "xoziZG_expiryRow"
257
+ "balanceMeta": "xoziZG_balanceMeta",
258
+ "modelRequests": "xoziZG_modelRequests",
259
+ "balanceUnit": "xoziZG_balanceUnit",
260
+ "creditFooter": "xoziZG_creditFooter",
261
+ "windowUnit": "xoziZG_windowUnit",
262
+ "avatar": "xoziZG_avatar",
263
+ "windowAnchor": "xoziZG_windowAnchor"
183
264
  };
184
265
  //#endregion
185
266
  //#region src/client/CodeArtsPluginCard.tsx
@@ -230,19 +311,6 @@ function claimMessagesOf(data, accountIds, t) {
230
311
  return out;
231
312
  }
232
313
  /**
233
- * 开关的兜底值:后端没这条路由(老版本)时按「都显示」渲染,与原有行为一致。
234
- * 侧边栏那一格相反 —— 缺省关闭;自动领取与常驻保活也缺省关(不替用户动余额、
235
- * 不替用户在系统里留后台进程)。
236
- */
237
- const DOCK_DEFAULT = {
238
- credits: true,
239
- queue: true,
240
- sidebar: false,
241
- modelDetail: true,
242
- autoClaim: false,
243
- keepAliveDaemon: false
244
- };
245
- /**
246
314
  * 上一次读到的状态。`/api/codearts/status` 会顺带去上游拉积分(有 TTL 缓存),
247
315
  * 冷的时候要等近一秒;模块级留一份快照,再进这一页就能立刻按旧值画出来,
248
316
  * 后台再刷新 —— 比每次都先闪骨架舒服,也不会把「还没读到」误判成未登录。
@@ -260,6 +328,37 @@ function formatWindow(tokens) {
260
328
  if (tokens >= 1024) return `${Math.round(tokens / 1024)}K`;
261
329
  return String(tokens);
262
330
  }
331
+ /**
332
+ * 窗口滑块的刻度。
333
+ *
334
+ * 不按 token 线性拖动:8K 到 2M 线性铺开的话,前 90% 的行程都在 100K 以下,最该调
335
+ * 的那一段(目录标称 1M、实际只有 49 万)反而只有几像素。刻度按「人眼能分辨的档」摆,
336
+ * 输入框仍然可以填任意值。
337
+ */
338
+ const WINDOW_STOPS = [
339
+ 8192,
340
+ 16384,
341
+ 32768,
342
+ 65536,
343
+ 131072,
344
+ 196608,
345
+ 262144,
346
+ 393216,
347
+ 491520,
348
+ 524288,
349
+ 774e3,
350
+ 1048576,
351
+ 1572864,
352
+ 2097152
353
+ ];
354
+ /** 当前值落在哪个刻度上(不在刻度里就取最近的)。 */
355
+ function windowStopIndex(tokens) {
356
+ const fallback = WINDOW_STOPS.indexOf(1048576);
357
+ if (tokens === void 0 || !Number.isFinite(tokens) || tokens <= 0) return fallback;
358
+ let best = 0;
359
+ for (let i = 1; i < WINDOW_STOPS.length; i += 1) if (Math.abs(WINDOW_STOPS[i] - tokens) < Math.abs(WINDOW_STOPS[best] - tokens)) best = i;
360
+ return best;
361
+ }
263
362
  /** 体检里一条检查的标题。账号级检查按 id 找回备注名,别让用户对着哈希猜。 */
264
363
  function doctorCheckLabel(id, accounts, t) {
265
364
  if (id.startsWith("account:")) {
@@ -346,6 +445,8 @@ function CreditBlock({ credits, error, t, onClaim, claiming, claimResult, justCl
346
445
  if (credits === void 0 && error === void 0) return null;
347
446
  const c = credits?.credits;
348
447
  const claimedToday = justClaimed || credits?.welfare?.claimedToday === true;
448
+ /** 上游当前每日签到活动给多少分;没有就退回不带数字的文案。 */
449
+ const claimAmount = credits?.welfare?.amount ?? 0;
349
450
  const expiring = c?.total.expiring ?? 0;
350
451
  const expiringRatio = c !== void 0 && c.total.total > 0 ? Math.min(100, Math.max(0, expiring / c.total.total * 100)) : 0;
351
452
  const usedRatio = c !== void 0 && c.total.total > 0 ? Math.min(100, Math.max(0, c.total.used / c.total.total * 100)) : 0;
@@ -450,7 +551,7 @@ function CreditBlock({ credits, error, t, onClaim, claiming, claimResult, justCl
450
551
  }),
451
552
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
452
553
  className: CodeArtsPluginCard_module_css_default.creditHint,
453
- children: claimResult ?? t("claimHint")
554
+ children: claimResult ?? (claimAmount > 0 ? t("claimHintAmount", { amount: formatCredits(claimAmount) }) : t("claimHint"))
454
555
  })
455
556
  ]
456
557
  });
@@ -1010,6 +1111,15 @@ function CodeArtsPluginCard({ t }) {
1010
1111
  const [savingModels, setSavingModels] = (0, react.useState)(false);
1011
1112
  const [savedModels, setSavedModels] = (0, react.useState)(false);
1012
1113
  const [modelError, setModelError] = (0, react.useState)(null);
1114
+ /** 正在编辑的窗口值(拖动/输入过程中不提交,松手或失焦才写后端)。 */
1115
+ const [windowDrafts, setWindowDrafts] = (0, react.useState)({});
1116
+ /** 正在保存窗口的模型 id。 */
1117
+ const [windowSaving, setWindowSaving] = (0, react.useState)(null);
1118
+ const [windowError, setWindowError] = (0, react.useState)(null);
1119
+ /** 弹层展开的模型 id(同一时间只开一个,行内只留一个按钮)。 */
1120
+ const [windowOpenFor, setWindowOpenFor] = (0, react.useState)(null);
1121
+ /** 正在提交窗口值的模型 id(state 更新有延迟,去重用 ref)。 */
1122
+ const windowCommitInFlight = (0, react.useRef)(/* @__PURE__ */ new Set());
1013
1123
  const [refreshing, setRefreshing] = (0, react.useState)(false);
1014
1124
  const [refreshMsg, setRefreshMsg] = (0, react.useState)(null);
1015
1125
  /** 正在实测的模型 id;同一时间只测一个,避免把上游并发槽位占满。 */
@@ -1031,9 +1141,15 @@ function CodeArtsPluginCard({ t }) {
1031
1141
  const [tab, setTab] = (0, react.useState)("accounts");
1032
1142
  const tabIdBase = (0, react.useId)();
1033
1143
  /** 对话底部那一行的两个显隐开关(后端 = 插件 settings 里的两个布尔)。 */
1034
- const [dock, setDock] = (0, react.useState)(DOCK_DEFAULT);
1035
- const [dockWritable, setDockWritable] = (0, react.useState)(false);
1036
- const [dockSaving, setDockSaving] = (0, react.useState)(false);
1144
+ const [dock, setDock] = (0, react.useState)(() => dockSnapshot().dock);
1145
+ const [dockWritable, setDockWritable] = (0, react.useState)(() => dockSnapshot().writable);
1146
+ /**
1147
+ * 正在保存的开关(按键记录)。
1148
+ *
1149
+ * 早先是一个共享布尔:点任何一个勾选框都会把**全部**勾选框置灰,POST 回来再恢复 ——
1150
+ * 肉眼就是「整个配置页的勾选都在闪」。现在只有被点的那一个在处理中。
1151
+ */
1152
+ const [dockSavingKeys, setDockSavingKeys] = (0, react.useState)(() => /* @__PURE__ */ new Set());
1037
1153
  const [dockError, setDockError] = (0, react.useState)(null);
1038
1154
  /** 「结束守护进程」按钮在飞,防止连点。 */
1039
1155
  const [keeperStopping, setKeeperStopping] = (0, react.useState)(false);
@@ -1052,14 +1168,11 @@ function CodeArtsPluginCard({ t }) {
1052
1168
  if (!res.ok) return;
1053
1169
  const data = await res.json();
1054
1170
  if (data.dock !== void 0) {
1055
- const next = {
1056
- ...DOCK_DEFAULT,
1057
- ...data.dock
1058
- };
1059
- setDock(next);
1060
- setSidebarPanelWanted(next.sidebar);
1171
+ publishDock({ dock: data.dock });
1172
+ setSidebarPanelWanted(data.dock.sidebar === true);
1173
+ setSettingsEntryWanted(data.dock.settingsEntry !== false);
1061
1174
  }
1062
- setDockWritable(data.writable === true);
1175
+ publishDock({ writable: data.writable === true });
1063
1176
  } catch {}
1064
1177
  }
1065
1178
  /**
@@ -1074,7 +1187,7 @@ function CodeArtsPluginCard({ t }) {
1074
1187
  ...dock,
1075
1188
  [key]: on
1076
1189
  });
1077
- setDockSaving(true);
1190
+ setDockSavingKeys((current) => new Set(current).add(key));
1078
1191
  setDockError(null);
1079
1192
  if (key === "sidebar") setSidebarPanelWanted(on);
1080
1193
  try {
@@ -1092,19 +1205,21 @@ function CodeArtsPluginCard({ t }) {
1092
1205
  }
1093
1206
  const data = await res.json();
1094
1207
  if (data.dock !== void 0) {
1095
- const next = {
1096
- ...DOCK_DEFAULT,
1097
- ...data.dock
1098
- };
1099
- setDock(next);
1100
- setSidebarPanelWanted(next.sidebar);
1208
+ publishDock({ dock: data.dock });
1209
+ setSidebarPanelWanted(data.dock.sidebar === true);
1210
+ setSettingsEntryWanted(data.dock.settingsEntry !== false);
1101
1211
  }
1102
1212
  } catch (error) {
1103
1213
  setDock(previous);
1104
1214
  if (key === "sidebar") setSidebarPanelWanted(previous.sidebar);
1105
1215
  setDockError(error instanceof Error ? error.message : String(error));
1106
1216
  } finally {
1107
- setDockSaving(false);
1217
+ setDockSavingKeys((current) => {
1218
+ if (!current.has(key)) return current;
1219
+ const next = new Set(current);
1220
+ next.delete(key);
1221
+ return next;
1222
+ });
1108
1223
  }
1109
1224
  }
1110
1225
  /**
@@ -1128,10 +1243,7 @@ function CodeArtsPluginCard({ t }) {
1128
1243
  body: "{}"
1129
1244
  });
1130
1245
  const data = await res.json().catch(() => ({}));
1131
- if (data.dock !== void 0) setDock({
1132
- ...DOCK_DEFAULT,
1133
- ...data.dock
1134
- });
1246
+ if (data.dock !== void 0) publishDock({ dock: data.dock });
1135
1247
  if (!res.ok || data.ok === false) setKeeperNotice(t("displayKeeperStopFailed", { message: data.reason ?? data.error ?? `HTTP ${res.status}` }));
1136
1248
  else setKeeperNotice(t("displayKeeperStopped"));
1137
1249
  } catch (error) {
@@ -1214,9 +1326,37 @@ function CodeArtsPluginCard({ t }) {
1214
1326
  (0, react.useEffect)(() => {
1215
1327
  refreshDock();
1216
1328
  }, []);
1329
+ (0, react.useEffect)(() => subscribeDock(() => {
1330
+ setDock(dockSnapshot().dock);
1331
+ setDockWritable(dockSnapshot().writable);
1332
+ }), []);
1217
1333
  (0, react.useEffect)(() => {
1218
1334
  if (status?.status === "signed-in") refreshSelection();
1219
1335
  }, [status?.status]);
1336
+ (0, react.useEffect)(() => {
1337
+ if (windowOpenFor === null) return;
1338
+ function onPointerDown(event) {
1339
+ const target = event.target;
1340
+ if (target instanceof Element && target.closest("[data-window-anchor]") !== null) return;
1341
+ closeWindow();
1342
+ }
1343
+ function onKeyDown(event) {
1344
+ if (event.key === "Escape") {
1345
+ event.stopPropagation();
1346
+ closeWindow();
1347
+ }
1348
+ }
1349
+ document.addEventListener("click", onPointerDown);
1350
+ document.addEventListener("keydown", onKeyDown);
1351
+ return () => {
1352
+ document.removeEventListener("click", onPointerDown);
1353
+ document.removeEventListener("keydown", onKeyDown);
1354
+ };
1355
+ }, [
1356
+ windowOpenFor,
1357
+ windowDrafts,
1358
+ selection
1359
+ ]);
1220
1360
  async function saveToken(e) {
1221
1361
  e.preventDefault();
1222
1362
  setBusy(true);
@@ -1344,6 +1484,95 @@ function CodeArtsPluginCard({ t }) {
1344
1484
  setSavingModels(false);
1345
1485
  }
1346
1486
  }
1487
+ /** 输入框里该显示的窗口值:编辑中优先显示草稿,否则显示服务端生效值。 */
1488
+ function windowValueText(choice) {
1489
+ const draft = windowDrafts[choice.id];
1490
+ if (draft !== void 0) return draft;
1491
+ const value = choice.contextWindowOverride ?? choice.contextWindow;
1492
+ return value === void 0 ? "" : String(value);
1493
+ }
1494
+ function windowNumberValue(choice) {
1495
+ const parsed = Number(windowValueText(choice));
1496
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
1497
+ }
1498
+ function setWindowDraft(id, value) {
1499
+ setWindowDrafts((current) => ({
1500
+ ...current,
1501
+ [id]: value
1502
+ }));
1503
+ }
1504
+ function clearWindowDraft(id) {
1505
+ setWindowDrafts((current) => {
1506
+ if (!(id in current)) return current;
1507
+ const next = { ...current };
1508
+ delete next[id];
1509
+ return next;
1510
+ });
1511
+ }
1512
+ /**
1513
+ * 提交一个模型的窗口值(滑块松手、回车、收起弹层都走这里)。
1514
+ *
1515
+ * 空值 / 非法值 / 填回上游标称值 = 删除覆盖。这样不需要额外的「重置」按钮 ——
1516
+ * 清空就是重置,和 Qoder 那种「跟随默认」是一个意思,只是少一次点击。
1517
+ */
1518
+ async function commitWindow(choice, raw) {
1519
+ if (windowCommitInFlight.current.has(choice.id)) return;
1520
+ const base = choice.contextWindowDiscovered ?? choice.contextWindow;
1521
+ const text = raw.trim();
1522
+ let target = null;
1523
+ if (text !== "") {
1524
+ const parsed = Math.floor(Number(text));
1525
+ if (!Number.isFinite(parsed) || parsed <= 0) {
1526
+ clearWindowDraft(choice.id);
1527
+ return;
1528
+ }
1529
+ target = base !== void 0 && parsed === base ? null : parsed;
1530
+ }
1531
+ const before = choice.contextWindowOverride ?? null;
1532
+ if (target === before) {
1533
+ clearWindowDraft(choice.id);
1534
+ return;
1535
+ }
1536
+ windowCommitInFlight.current.add(choice.id);
1537
+ setWindowSaving(choice.id);
1538
+ setWindowError(null);
1539
+ try {
1540
+ const res = await fetch("/api/codearts/context-window", {
1541
+ method: "POST",
1542
+ headers: {
1543
+ "Content-Type": "application/json",
1544
+ Accept: "application/json"
1545
+ },
1546
+ body: JSON.stringify({
1547
+ id: choice.id,
1548
+ window: target
1549
+ })
1550
+ });
1551
+ const data = await res.json().catch(() => null);
1552
+ if (!res.ok) throw new Error(data?.error ?? `HTTP ${res.status}`);
1553
+ if (data !== null && data.selection !== void 0) setSelection(data.selection);
1554
+ } catch (err) {
1555
+ setWindowError(err instanceof Error ? err.message : String(err));
1556
+ } finally {
1557
+ clearWindowDraft(choice.id);
1558
+ windowCommitInFlight.current.delete(choice.id);
1559
+ setWindowSaving(null);
1560
+ }
1561
+ }
1562
+ /**
1563
+ * 收起弹层;输入框里还有没提交的草稿就先提交。
1564
+ *
1565
+ * 不靠输入框 onBlur 提交:点外面收起时输入框会被卸载,blur 未必来得及触发,
1566
+ * 用户刚敲的数字就白丢了。收起是唯一的「提交时机」,逻辑放一处就不会漏。
1567
+ */
1568
+ function closeWindow() {
1569
+ const id = windowOpenFor;
1570
+ setWindowOpenFor(null);
1571
+ if (id === null) return;
1572
+ const draft = windowDrafts[id];
1573
+ const choice = (selection?.choices ?? []).find((entry) => entry.id === id);
1574
+ if (draft !== void 0 && choice !== void 0) commitWindow(choice, draft);
1575
+ }
1347
1576
  /**
1348
1577
  * 实测某个模型现在能不能调用。
1349
1578
  *
@@ -1868,16 +2097,87 @@ function CodeArtsPluginCard({ t }) {
1868
2097
  onChange: (on) => setModel(choice.id, on),
1869
2098
  label: modelName(choice)
1870
2099
  }),
1871
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1872
- className: CodeArtsPluginCard_module_css_default.modelSpec,
1873
- title: t("modelSpecTitle", {
1874
- context: choice.contextWindow === void 0 ? "?" : formatCount(choice.contextWindow),
1875
- output: choice.maxTokens === void 0 ? "?" : formatCount(choice.maxTokens)
1876
- }),
1877
- children: t("modelSpec", {
1878
- context: formatWindow(choice.contextWindow),
1879
- output: formatWindow(choice.maxTokens)
1880
- })
2100
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2101
+ className: CodeArtsPluginCard_module_css_default.windowAnchor,
2102
+ "data-window-anchor": true,
2103
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2104
+ type: "button",
2105
+ className: [
2106
+ CodeArtsPluginCard_module_css_default.windowButton,
2107
+ windowOpenFor === choice.id ? CodeArtsPluginCard_module_css_default.windowButtonOpen : "",
2108
+ choice.contextWindowOverride === void 0 ? "" : CodeArtsPluginCard_module_css_default.windowButtonSet
2109
+ ].filter(Boolean).join(" "),
2110
+ "aria-expanded": windowOpenFor === choice.id,
2111
+ "aria-label": t("modelWindowLabel", { model: modelName(choice) }),
2112
+ title: t("modelWindowTitle", {
2113
+ model: modelName(choice),
2114
+ value: formatWindow(choice.contextWindowDiscovered ?? choice.contextWindow)
2115
+ }),
2116
+ onClick: () => setWindowOpenFor((current) => current === choice.id ? null : choice.id),
2117
+ children: [t("modelSpec", {
2118
+ context: formatWindow(windowNumberValue(choice)),
2119
+ output: formatWindow(choice.maxTokens)
2120
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2121
+ className: CodeArtsPluginCard_module_css_default.windowCaret,
2122
+ "aria-hidden": "true",
2123
+ children: "▾"
2124
+ })]
2125
+ }), windowOpenFor === choice.id && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2126
+ className: CodeArtsPluginCard_module_css_default.windowPopover,
2127
+ role: "dialog",
2128
+ "aria-label": t("modelWindowLabel", { model: modelName(choice) }),
2129
+ children: [
2130
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2131
+ className: CodeArtsPluginCard_module_css_default.windowPopoverHead,
2132
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("modelWindowHeading") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2133
+ className: CodeArtsPluginCard_module_css_default.windowPopoverValue,
2134
+ children: windowValueText(choice) || "—"
2135
+ })]
2136
+ }),
2137
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2138
+ type: "range",
2139
+ className: CodeArtsPluginCard_module_css_default.windowRange,
2140
+ min: 0,
2141
+ max: WINDOW_STOPS.length - 1,
2142
+ step: 1,
2143
+ value: windowStopIndex(windowNumberValue(choice)),
2144
+ "aria-label": t("modelWindowLabel", { model: modelName(choice) }),
2145
+ disabled: !selection.writable || windowSaving === choice.id,
2146
+ onChange: (e) => setWindowDraft(choice.id, String(WINDOW_STOPS[Number(e.target.value)] ?? "")),
2147
+ onPointerUp: (e) => void commitWindow(choice, String(WINDOW_STOPS[Number(e.currentTarget.value)] ?? "")),
2148
+ onKeyUp: (e) => void commitWindow(choice, String(WINDOW_STOPS[Number(e.currentTarget.value)] ?? ""))
2149
+ }),
2150
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2151
+ className: CodeArtsPluginCard_module_css_default.windowPopoverRow,
2152
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2153
+ type: "number",
2154
+ className: choice.contextWindowOverride === void 0 ? CodeArtsPluginCard_module_css_default.windowInput : `${CodeArtsPluginCard_module_css_default.windowInput} ${CodeArtsPluginCard_module_css_default.windowInputSet}`,
2155
+ value: windowValueText(choice),
2156
+ min: 1,
2157
+ step: 1024,
2158
+ inputMode: "numeric",
2159
+ autoFocus: true,
2160
+ placeholder: t("modelWindowFollow"),
2161
+ "aria-label": t("modelWindowLabel", { model: modelName(choice) }),
2162
+ disabled: !selection.writable || windowSaving === choice.id,
2163
+ onChange: (e) => setWindowDraft(choice.id, e.target.value),
2164
+ onKeyDown: (e) => {
2165
+ if (e.key === "Enter") {
2166
+ e.preventDefault();
2167
+ closeWindow();
2168
+ }
2169
+ }
2170
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2171
+ className: CodeArtsPluginCard_module_css_default.windowUnit,
2172
+ children: "tokens"
2173
+ })]
2174
+ }),
2175
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2176
+ className: CodeArtsPluginCard_module_css_default.windowHint,
2177
+ children: t("modelWindowHint", { value: formatWindow(choice.contextWindowDiscovered ?? choice.contextWindow) })
2178
+ })
2179
+ ]
2180
+ })]
1881
2181
  }),
1882
2182
  choice.benefit === true && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
1883
2183
  tone: choice.blocked === true ? "warning" : "success",
@@ -1940,6 +2240,10 @@ function CodeArtsPluginCard({ t }) {
1940
2240
  modelError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1941
2241
  className: CodeArtsPluginCard_module_css_default.error,
1942
2242
  children: modelError
2243
+ }),
2244
+ windowError !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2245
+ className: CodeArtsPluginCard_module_css_default.error,
2246
+ children: windowError
1943
2247
  })
1944
2248
  ]
1945
2249
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
@@ -1984,7 +2288,7 @@ function CodeArtsPluginCard({ t }) {
1984
2288
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
1985
2289
  className: CodeArtsPluginCard_module_css_default.check,
1986
2290
  checked: dock.credits,
1987
- disabled: !dockWritable || dockSaving,
2291
+ disabled: !dockWritable || dockSavingKeys.has("credits"),
1988
2292
  onChange: (on) => void toggleDock("credits", on),
1989
2293
  label: t("displayCreditsToggle")
1990
2294
  })
@@ -1994,7 +2298,7 @@ function CodeArtsPluginCard({ t }) {
1994
2298
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
1995
2299
  className: CodeArtsPluginCard_module_css_default.check,
1996
2300
  checked: dock.queue,
1997
- disabled: !dockWritable || dockSaving,
2301
+ disabled: !dockWritable || dockSavingKeys.has("queue"),
1998
2302
  onChange: (on) => void toggleDock("queue", on),
1999
2303
  label: t("displayQueueToggle")
2000
2304
  })
@@ -2004,7 +2308,7 @@ function CodeArtsPluginCard({ t }) {
2004
2308
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
2005
2309
  className: CodeArtsPluginCard_module_css_default.check,
2006
2310
  checked: dock.modelDetail,
2007
- disabled: !dockWritable || dockSaving,
2311
+ disabled: !dockWritable || dockSavingKeys.has("modelDetail"),
2008
2312
  onChange: (on) => void toggleDock("modelDetail", on),
2009
2313
  label: t("displayModelDetailToggle")
2010
2314
  })
@@ -2042,7 +2346,7 @@ function CodeArtsPluginCard({ t }) {
2042
2346
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
2043
2347
  className: CodeArtsPluginCard_module_css_default.check,
2044
2348
  checked: dock.autoClaim,
2045
- disabled: !dockWritable || dockSaving,
2349
+ disabled: !dockWritable || dockSavingKeys.has("autoClaim"),
2046
2350
  onChange: (on) => void toggleDock("autoClaim", on),
2047
2351
  label: t("displayAutoClaimToggle")
2048
2352
  })
@@ -2077,7 +2381,7 @@ function CodeArtsPluginCard({ t }) {
2077
2381
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
2078
2382
  className: CodeArtsPluginCard_module_css_default.check,
2079
2383
  checked: dock.keepAliveDaemon,
2080
- disabled: !dockWritable || dockSaving,
2384
+ disabled: !dockWritable || dockSavingKeys.has("keepAliveDaemon"),
2081
2385
  onChange: (on) => void toggleDock("keepAliveDaemon", on),
2082
2386
  label: t("displayKeeperToggle")
2083
2387
  })
@@ -2100,6 +2404,35 @@ function CodeArtsPluginCard({ t }) {
2100
2404
  })
2101
2405
  ]
2102
2406
  }),
2407
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2408
+ className: CodeArtsPluginCard_module_css_default.section,
2409
+ children: [
2410
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2411
+ className: CodeArtsPluginCard_module_css_default.sectionHead,
2412
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2413
+ className: CodeArtsPluginCard_module_css_default.sectionLabel,
2414
+ children: t("displaySettingsEntryTitle")
2415
+ })
2416
+ }),
2417
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2418
+ className: CodeArtsPluginCard_module_css_default.hint,
2419
+ children: t("displaySettingsEntryHint")
2420
+ }),
2421
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2422
+ className: CodeArtsPluginCard_module_css_default.choices,
2423
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2424
+ className: CodeArtsPluginCard_module_css_default.choiceRow,
2425
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
2426
+ className: CodeArtsPluginCard_module_css_default.check,
2427
+ checked: dock.settingsEntry,
2428
+ disabled: !dockWritable || dockSavingKeys.has("settingsEntry"),
2429
+ onChange: (on) => void toggleDock("settingsEntry", on),
2430
+ label: t("displaySettingsEntryToggle")
2431
+ })
2432
+ })
2433
+ })
2434
+ ]
2435
+ }),
2103
2436
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2104
2437
  className: CodeArtsPluginCard_module_css_default.section,
2105
2438
  children: [
@@ -2121,7 +2454,7 @@ function CodeArtsPluginCard({ t }) {
2121
2454
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
2122
2455
  className: CodeArtsPluginCard_module_css_default.check,
2123
2456
  checked: dock.sidebar,
2124
- disabled: !dockWritable || dockSaving,
2457
+ disabled: !dockWritable || dockSavingKeys.has("sidebar"),
2125
2458
  onChange: (on) => void toggleDock("sidebar", on),
2126
2459
  label: t("displaySidebarToggle")
2127
2460
  })
@@ -2232,23 +2565,6 @@ function CodeArtsPluginCard({ t }) {
2232
2565
  })]
2233
2566
  });
2234
2567
  }
2235
- BigInt("0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551") >> 1n;
2236
- new TextEncoder();
2237
- //#endregion
2238
- //#region src/web-status.ts
2239
- /**
2240
- * 开关的默认值:没有 settings provider(或老配置没这两个键)时保持原有行为 ——
2241
- * 底部两行都显示;侧边栏相反,缺省不开(那一格是所有插件共用的全局座位)。
2242
- * `modelDetail` 缺省开(保持老版本的样子),`autoClaim` 缺省关。
2243
- */
2244
- const DEFAULT_DOCK_FLAGS = {
2245
- credits: true,
2246
- queue: true,
2247
- sidebar: false,
2248
- modelDetail: true,
2249
- autoClaim: false,
2250
- keepAliveDaemon: false
2251
- };
2252
2568
  //#endregion
2253
2569
  //#region src/client/dock-line.ts
2254
2570
  /** 段分隔符 —— 与邻居插件一致,改这里等于改整行的样子。 */
@@ -2362,7 +2678,7 @@ const QUEUE_INTERVAL_MS = 5e3;
2362
2678
  * `min(248px, …)`)取一档窄宽度 —— 这一层回答的是「哪个号还有多少积分」,
2363
2679
  * 用量数字不该把它撑成一张报表。
2364
2680
  */
2365
- const PANEL_WIDTH = 260;
2681
+ const PANEL_WIDTH = 280;
2366
2682
  /** 弹层与那一行之间的缝隙。 */
2367
2683
  const PANEL_GAP = 8;
2368
2684
  /**
@@ -2474,7 +2790,7 @@ function rowsOf(data) {
2474
2790
  function placeAbove(rect) {
2475
2791
  return rect.top > PANEL_MIN_ABOVE;
2476
2792
  }
2477
- function CodeArtsCreditDock({ useProjection, t, zone = "dock" }) {
2793
+ function CodeArtsCreditDock({ useProjection, t, zone = "dock", onOpenSettings }) {
2478
2794
  const selection = readSelection(useProjection);
2479
2795
  const active = isCodeArts(selection);
2480
2796
  const [remain, setRemain] = (0, react.useState)(null);
@@ -2486,8 +2802,12 @@ function CodeArtsCreditDock({ useProjection, t, zone = "dock" }) {
2486
2802
  * 名字用 `stripModelSuffixes` 剥掉尾巴,倍率直接用服务端算好的 `ratio`。
2487
2803
  */
2488
2804
  const [modelInfo, setModelInfo] = (0, react.useState)({});
2489
- const [flags, setFlags] = (0, react.useState)(DEFAULT_DOCK_FLAGS);
2805
+ const [flags, setFlags] = (0, react.useState)(() => dockSnapshot().dock);
2806
+ /** 开关的共享状态:设置页改了「显示」里的勾选,弹层这边立刻跟上。 */
2807
+ (0, react.useEffect)(() => subscribeDock(() => setFlags(dockSnapshot().dock)), []);
2490
2808
  const [queued, setQueued] = (0, react.useState)(null);
2809
+ /** 「设置」按钮两条路都没走通时的提示(宿主壳形状不认识)。 */
2810
+ const [settingsFailed, setSettingsFailed] = (0, react.useState)(false);
2491
2811
  const [anchor, setAnchor] = (0, react.useState)(null);
2492
2812
  /**
2493
2813
  * 弹层的包含块原点(视口坐标)。
@@ -2519,7 +2839,7 @@ function CodeArtsCreditDock({ useProjection, t, zone = "dock" }) {
2519
2839
  if (!res.ok) return;
2520
2840
  const data = await res.json().catch(() => void 0);
2521
2841
  if (data === void 0 || !mounted.current) return;
2522
- setFlags(data.dock ?? DEFAULT_DOCK_FLAGS);
2842
+ if (data.dock !== void 0) publishDock({ dock: data.dock });
2523
2843
  setRows(rowsOf(data));
2524
2844
  setModelInfo(Object.fromEntries((data.models ?? []).map((model) => [model.id, {
2525
2845
  name: model.name,
@@ -2739,16 +3059,46 @@ function CodeArtsCreditDock({ useProjection, t, zone = "dock" }) {
2739
3059
  gap: 8
2740
3060
  },
2741
3061
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2742
- style: { fontWeight: 600 },
3062
+ style: {
3063
+ fontWeight: 600,
3064
+ flex: "1 1 auto",
3065
+ minWidth: 0,
3066
+ overflow: "hidden",
3067
+ textOverflow: "ellipsis",
3068
+ whiteSpace: "nowrap"
3069
+ },
2743
3070
  children: t("creditsDockPanelTitle")
2744
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
2745
- variant: "outline",
2746
- size: "sm",
2747
- disabled: refreshing,
2748
- onClick: () => void forceRefresh(),
2749
- children: refreshing ? t("creditsDockRefreshing") : t("creditsDockRefresh")
3071
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3072
+ style: {
3073
+ display: "inline-flex",
3074
+ alignItems: "center",
3075
+ gap: 6,
3076
+ flex: "0 0 auto",
3077
+ whiteSpace: "nowrap"
3078
+ },
3079
+ children: [onOpenSettings !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3080
+ variant: "outline",
3081
+ size: "sm",
3082
+ style: { whiteSpace: "nowrap" },
3083
+ onClick: () => setSettingsFailed(!onOpenSettings()),
3084
+ children: t("creditsDockSettings")
3085
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
3086
+ variant: "outline",
3087
+ size: "sm",
3088
+ style: { whiteSpace: "nowrap" },
3089
+ disabled: refreshing,
3090
+ onClick: () => void forceRefresh(),
3091
+ children: refreshing ? t("creditsDockRefreshing") : t("creditsDockRefresh")
3092
+ })]
2750
3093
  })]
2751
3094
  }),
3095
+ settingsFailed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3096
+ style: {
3097
+ fontSize: 11,
3098
+ color: "var(--dsw-alias-label-tertiary)"
3099
+ },
3100
+ children: t("creditsDockSettingsFailed")
3101
+ }),
2752
3102
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2753
3103
  style: {
2754
3104
  display: "flex",
@@ -2837,14 +3187,14 @@ if (typeof document !== "undefined" && document.querySelector("style[data-plugin
2837
3187
  document.head.appendChild(tag);
2838
3188
  }
2839
3189
  var CodeArtsPanel_module_css_default = {
2840
- "body": "Z66cgG_body",
2841
- "title": "Z66cgG_title",
2842
- "back": "Z66cgG_back",
3190
+ "desc": "Z66cgG_desc",
2843
3191
  "icon": "Z66cgG_icon",
3192
+ "back": "Z66cgG_back",
2844
3193
  "head": "Z66cgG_head",
2845
- "desc": "Z66cgG_desc",
3194
+ "title": "Z66cgG_title",
2846
3195
  "page": "Z66cgG_page",
2847
- "backCaret": "Z66cgG_backCaret"
3196
+ "backCaret": "Z66cgG_backCaret",
3197
+ "body": "Z66cgG_body"
2848
3198
  };
2849
3199
  //#endregion
2850
3200
  //#region src/client/CodeArtsPanel.tsx
@@ -2915,6 +3265,84 @@ function CodeArtsPanelPage({ t, backToConversation }) {
2915
3265
  });
2916
3266
  }
2917
3267
  //#endregion
3268
+ //#region src/client/settings-route.ts
3269
+ /**
3270
+ * 「打开设置 → CodeArts」这条路的实现。
3271
+ *
3272
+ * 宿主没有给插件一个直白的「打开某节设置」服务,但设置壳把自己挂在
3273
+ * `sidebar.settings` 槽位上,并且带了一个 **store seat**:
3274
+ *
3275
+ * const shellHandle = createSettingsShellStore()
3276
+ * const shellInstance = shellHandle.create()
3277
+ * ctx.slots.register({ name: 'sidebar.settings', store: { ...shellHandle, create: () => shellInstance }, … })
3278
+ *
3279
+ * 这个 seat 是壳公开的状态把手(`StoredEntry.store` 是文档字段,`slots.entries()`
3280
+ * 是公开方法;宿主自己的客户端测试也这么读)。`actions.openSection(id)` 一次把
3281
+ * `activeId = id` 和 `open = true` 都设上,正好是「在 CodeArts 那一节打开设置」。
3282
+ *
3283
+ * 旧壳没有 `openSection` 时退回到「打开设置面板 + 点同名导航行」。判断按**逐字**
3284
+ * 相等:`模型` 是 `模型与预设` 的子串,模糊匹配会点错节。两条路都不抛异常 ——
3285
+ * 调用方是一个按钮的 click handler,抛出去会把整条积分行带没。
3286
+ *
3287
+ * @module dsh-codearts/client/settings-route
3288
+ */
3289
+ /** 设置壳所在的槽位:它的 store seat 就是对外唯一的状态把手。 */
3290
+ const SETTINGS_SLOT = "sidebar.settings";
3291
+ /** 面板挂载后导航行的标签要等一次 locale 快照,所以重试几次、总共约 300ms。 */
3292
+ const RETRY_DELAYS_MS = [
3293
+ 0,
3294
+ 60,
3295
+ 70,
3296
+ 80,
3297
+ 90
3298
+ ];
3299
+ function defaultSchedule(run, ms) {
3300
+ globalThis.setTimeout(run, ms);
3301
+ }
3302
+ function findSectionRow(scope, label) {
3303
+ const want = label.trim();
3304
+ if (want === "") return void 0;
3305
+ return Array.from(scope.querySelectorAll("button")).find((button) => (button.textContent ?? "").trim() === want);
3306
+ }
3307
+ /**
3308
+ * 打开本插件的设置节。
3309
+ *
3310
+ * @returns true = 已经走通一条路(设置面板会在我们这一节打开,或至少已打开)。
3311
+ */
3312
+ function openPluginSettings(deps) {
3313
+ try {
3314
+ const openSection = ((deps.slots?.entries?.(SETTINGS_SLOT))?.[0]?.store?.create?.())?.actions?.openSection;
3315
+ if (typeof openSection === "function") {
3316
+ openSection(deps.sectionId);
3317
+ return true;
3318
+ }
3319
+ } catch {}
3320
+ const doc = deps.doc ?? (typeof document === "undefined" ? void 0 : document);
3321
+ const label = deps.label?.() ?? "";
3322
+ try {
3323
+ const invoke = deps.shortcuts?.invoke;
3324
+ if (typeof invoke === "function") invoke("settings.open", { modal: null });
3325
+ else return false;
3326
+ } catch {
3327
+ return false;
3328
+ }
3329
+ if (doc === void 0 || label.trim() === "") return true;
3330
+ const schedule = deps.schedule ?? defaultSchedule;
3331
+ const scopeOf = () => doc.querySelector("[data-shortcut-modal=\"settings\"]") ?? doc;
3332
+ let clicked = false;
3333
+ for (const delay of RETRY_DELAYS_MS) schedule(() => {
3334
+ if (clicked) return;
3335
+ try {
3336
+ const row = findSectionRow(scopeOf(), label);
3337
+ if (row !== void 0) {
3338
+ clicked = true;
3339
+ row.click();
3340
+ }
3341
+ } catch {}
3342
+ }, delay);
3343
+ return true;
3344
+ }
3345
+ //#endregion
2918
3346
  //#region src/client/locales.ts
2919
3347
  const zh = {
2920
3348
  tabLabel: "CodeArts",
@@ -3006,6 +3434,11 @@ const zh = {
3006
3434
  usageStatLatencyEmpty: "还没有成功请求",
3007
3435
  modelSpec: "{context} 上下文 · {output} 输出",
3008
3436
  modelSpecTitle: "上游返回的上下文窗口 {context} token,最大输出 {output} token",
3437
+ modelWindowLabel: "设置 {model} 的上下文窗口",
3438
+ modelWindowTitle: "上下文窗口:上游标称 {value} token。点击可拖动滑块或直接输入",
3439
+ modelWindowHeading: "上下文窗口",
3440
+ modelWindowFollow: "跟随上游",
3441
+ modelWindowHint: "上游标称 {value}。拖动或输入后立即生效;清空或填回标称值 = 跟随上游",
3009
3442
  accountPaused: "已暂停",
3010
3443
  accountPinned: "已置顶",
3011
3444
  accountEnabled: "启用",
@@ -3071,6 +3504,8 @@ const zh = {
3071
3504
  creditsDockPanelTitle: "CodeArts 积分",
3072
3505
  creditsDockRefresh: "刷新积分",
3073
3506
  creditsDockRefreshing: "刷新中…",
3507
+ creditsDockSettings: "设置",
3508
+ creditsDockSettingsFailed: "打不开设置面板,请从「设置 → CodeArts」进入。",
3074
3509
  creditsDockNoTokens: "今天还没有经插件发出的请求",
3075
3510
  creditsDockEmpty: "暂时没有积分数据",
3076
3511
  creditsDockExpiring: "{account}:{expiring} 积分将在本周期结束时作废",
@@ -3100,6 +3535,9 @@ const zh = {
3100
3535
  displayKeeperLog: "进程日志:{path}",
3101
3536
  displayNotWritable: "这个宿主没给插件开配置存储,开关只能看不能改。",
3102
3537
  displayFailed: "保存失败:{message}",
3538
+ displaySettingsEntryTitle: "设置左侧入口",
3539
+ displaySettingsEntryHint: "勾上以后,DSH 设置左侧那一列里会多一项 CodeArts,点开就是当前这一页。默认勾上:插件自带的配置页本来挂在「内置插件」的详情页里,第一次用的人基本找不到。不想要可以在这里关掉,关掉后仍可从「内置插件 → dsh-codearts」进入。改完立刻生效。",
3540
+ displaySettingsEntryToggle: "在设置左侧导航显示 CodeArts",
3103
3541
  displaySidebarTitle: "侧边栏图标",
3104
3542
  displaySidebarHint: "勾上以后,DSH 左侧那一列图标里会多一个 CodeArts,点它直接在中间列打开当前这一页,不必每次都绕进设置。默认不勾:这列图标是全宿主共用的,每个插件都来占一格很快就挤满了。改完立刻生效,没有保存步骤。",
3105
3543
  displaySidebarToggle: "在侧边栏图标列显示 CodeArts",
@@ -3109,7 +3547,8 @@ const zh = {
3109
3547
  claimButtonDone: "今日已领",
3110
3548
  claimPending: "领取中…",
3111
3549
  claimAll: "全部账号领取",
3112
- claimHint: "每天领一次 1000 积分,走官方福利中心接口(与客户端里那个「每日签到」同一件事)。",
3550
+ claimHint: "每天可领一次签到积分,走官方福利中心接口(与客户端里那个「每日签到」同一件事)。",
3551
+ claimHintAmount: "每天领一次 {amount} 积分,走官方福利中心接口(与客户端里那个「每日签到」同一件事)。",
3113
3552
  claimDone: "已领取 {amount} 积分",
3114
3553
  claimAlready: "今日已领,明天再来",
3115
3554
  claimUnavailable: "这个账号当前没有可领的签到活动",
@@ -3207,6 +3646,11 @@ const en = {
3207
3646
  usageStatLatencyEmpty: "No successful request yet",
3208
3647
  modelSpec: "{context} ctx · {output} out",
3209
3648
  modelSpecTitle: "Context window {context} tokens, max output {output} tokens reported upstream",
3649
+ modelWindowLabel: "Set the context window for {model}",
3650
+ modelWindowTitle: "Context window: upstream reports {value} tokens. Click to drag the slider or type a value",
3651
+ modelWindowHeading: "Context window",
3652
+ modelWindowFollow: "Follow upstream",
3653
+ modelWindowHint: "Upstream reports {value}. Changes apply immediately; clear the field or type the upstream value to follow it",
3210
3654
  accountPaused: "Paused",
3211
3655
  accountPinned: "Pinned",
3212
3656
  accountEnabled: "Enabled",
@@ -3272,6 +3716,8 @@ const en = {
3272
3716
  creditsDockPanelTitle: "CodeArts credits",
3273
3717
  creditsDockRefresh: "Refresh credits",
3274
3718
  creditsDockRefreshing: "Refreshing…",
3719
+ creditsDockSettings: "Settings",
3720
+ creditsDockSettingsFailed: "Could not open Settings. Open Settings → CodeArts instead.",
3275
3721
  creditsDockNoTokens: "No requests through the plugin today yet",
3276
3722
  creditsDockEmpty: "No credit data yet",
3277
3723
  creditsDockExpiring: "{account}: {expiring} credits expire when this cycle ends",
@@ -3301,6 +3747,9 @@ const en = {
3301
3747
  displayKeeperLog: "Process log: {path}",
3302
3748
  displayNotWritable: "This host gives the plugin nowhere to persist settings, so the switches are read-only.",
3303
3749
  displayFailed: "Failed to save: {message}",
3750
+ displaySettingsEntryTitle: "Settings entry",
3751
+ displaySettingsEntryHint: "Once checked, a CodeArts item joins the left navigation of DSH Settings and opens this very page. On by default: the plugin-owned page otherwise lives inside the Built-in plugins detail page, which first-time users rarely find. Uncheck to hide it — the page stays reachable from Built-in plugins → dsh-codearts. Takes effect immediately.",
3752
+ displaySettingsEntryToggle: "Show CodeArts in the Settings navigation",
3304
3753
  displaySidebarTitle: "Sidebar icon",
3305
3754
  displaySidebarHint: "Once checked, a CodeArts icon joins the icon column on the left of DSH and opens this very page in the middle column, so you do not have to go through Settings each time. Off by default: that column is shared by the whole host, and it fills up quickly if every plugin claims a slot. Takes effect immediately — there is nothing to save.",
3306
3755
  displaySidebarToggle: "Show CodeArts in the sidebar icon column",
@@ -3310,7 +3759,8 @@ const en = {
3310
3759
  claimButtonDone: "Claimed today",
3311
3760
  claimPending: "Claiming…",
3312
3761
  claimAll: "Claim for all accounts",
3313
- claimHint: "Claim 1,000 credits once a day through CodeArts’ welfare centre — the same check-in the official client does.",
3762
+ claimHint: "Claim your check-in credits once a day through CodeArts’ welfare centre — the same check-in the official client does.",
3763
+ claimHintAmount: "Claim {amount} credits once a day through CodeArts’ welfare centre — the same check-in the official client does.",
3314
3764
  claimDone: "Claimed {amount} credits",
3315
3765
  claimAlready: "Already claimed today — come back tomorrow",
3316
3766
  claimUnavailable: "No check-in campaign available for this account",
@@ -3347,6 +3797,19 @@ function apply(ctx) {
3347
3797
  en
3348
3798
  }), "dsh-codearts: settings copy");
3349
3799
  const t = ctx.locale.bind(namespace);
3800
+ /**
3801
+ * 打开「设置 → CodeArts」。
3802
+ *
3803
+ * 宿主没有直白的「打开某节设置」服务,走设置壳公开挂在 `sidebar.settings`
3804
+ * 槽位上的 store seat(见 settings-route.ts 的说明)。点按钮时现取,不缓存:
3805
+ * 那个槽位属于另一个 bundle,apply 顺序不是我们能假定的。
3806
+ */
3807
+ const openSettings = () => openPluginSettings({
3808
+ slots: ctx.slots,
3809
+ shortcuts: ctx.get("shortcuts"),
3810
+ sectionId: PANEL_ID,
3811
+ label: () => t("tabLabel")
3812
+ });
3350
3813
  ctx.slots.inject("plugins.bundle.config", () => ctx.slots.register({
3351
3814
  name: "plugins.bundle.config",
3352
3815
  key: "dsh-codearts",
@@ -3359,7 +3822,8 @@ function apply(ctx) {
3359
3822
  locale: namespace,
3360
3823
  inject: () => ({
3361
3824
  t,
3362
- zone: "bar"
3825
+ zone: "bar",
3826
+ onOpenSettings: openSettings
3363
3827
  })
3364
3828
  }, CodeArtsCreditDock));
3365
3829
  ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({
@@ -3369,7 +3833,8 @@ function apply(ctx) {
3369
3833
  locale: namespace,
3370
3834
  inject: () => ({
3371
3835
  t,
3372
- zone: "dock"
3836
+ zone: "dock",
3837
+ onOpenSettings: openSettings
3373
3838
  })
3374
3839
  }, CodeArtsCreditDock));
3375
3840
  /** 每次 claim 拿到的 inject disposer;拆的时候逐个调用(连带注销里面的注册)。 */
@@ -3444,11 +3909,76 @@ function apply(ctx) {
3444
3909
  dropPanelSlots();
3445
3910
  };
3446
3911
  }, "dsh-codearts: sidebar panel opt-in");
3912
+ /**
3913
+ * 设置左侧导航里的入口(settings.section)。
3914
+ *
3915
+ * 和侧边栏那格一样按「注册 / 拆注册」实现:宿主是按槽位条目画导航行的,
3916
+ * 渲染 null 只会留下一个空白可点的行。缺省开 —— 这是用户找插件的主路径
3917
+ * (issue #7),只有明确关掉才拆。
3918
+ */
3919
+ const settingsEntryClaims = [];
3920
+ const dropSettingsEntry = () => {
3921
+ for (const dispose of settingsEntryClaims.splice(0)) try {
3922
+ dispose();
3923
+ } catch (error) {
3924
+ console.error("[dsh-codearts] failed to release settings entry:", error);
3925
+ }
3926
+ };
3927
+ const syncSettingsEntry = () => {
3928
+ dropSettingsEntry();
3929
+ if (!settingsEntryWanted()) return;
3930
+ try {
3931
+ settingsEntryClaims.push(ctx.slots.inject("settings.section", () => {
3932
+ try {
3933
+ return ctx.slots.register({
3934
+ name: "settings.section",
3935
+ id: PANEL_ID,
3936
+ order: 50,
3937
+ label: () => t("tabLabel"),
3938
+ locale: namespace,
3939
+ inject: () => ({ t })
3940
+ }, CodeArtsPluginCard);
3941
+ } catch (error) {
3942
+ console.error("[dsh-codearts] settings entry unavailable:", error);
3943
+ return () => {};
3944
+ }
3945
+ }));
3946
+ } catch (error) {
3947
+ console.error("[dsh-codearts] settings section slot unavailable:", error);
3948
+ }
3949
+ };
3950
+ ctx.effect(() => {
3951
+ const off = subscribeSettingsEntryWanted(syncSettingsEntry);
3952
+ syncSettingsEntry();
3953
+ return () => {
3954
+ off();
3955
+ dropSettingsEntry();
3956
+ };
3957
+ }, "dsh-codearts: settings entry opt-out");
3958
+ /**
3959
+ * 共享的 dock 状态一变,两个入口的注册/拆注册跟着走。
3960
+ *
3961
+ * 以前只有「卡片挂载时」才把开关值写进 panel-switch;如果另一张卡片或 60 秒
3962
+ * 轮询先拿到新值,就会出现「卡片上勾着、导航里却没有入口」(实测)。
3963
+ */
3964
+ ctx.effect(() => {
3965
+ const apply = () => {
3966
+ const { dock, loaded } = dockSnapshot();
3967
+ if (!loaded) return;
3968
+ setSettingsEntryWanted(dock.settingsEntry !== false);
3969
+ setSidebarPanelWanted(dock.sidebar === true);
3970
+ };
3971
+ const off = subscribeDock(apply);
3972
+ apply();
3973
+ return off;
3974
+ }, "dsh-codearts: entry switches follow dock state");
3447
3975
  (async () => {
3448
3976
  try {
3449
3977
  const res = await fetch("/api/codearts/dock", { headers: { Accept: "application/json" } });
3450
3978
  if (!res.ok) return;
3451
- setSidebarPanelWanted((await res.json()).dock?.sidebar === true);
3979
+ const data = await res.json();
3980
+ setSidebarPanelWanted(data.dock?.sidebar === true);
3981
+ setSettingsEntryWanted(data.dock?.settingsEntry !== false);
3452
3982
  } catch {}
3453
3983
  })();
3454
3984
  } catch (error) {