dsh-model-health 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/client.js +66 -28
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -179,33 +179,49 @@ window.__ModuleLoader__.load({
179
179
  fontSize: 12,
180
180
  fontFamily: "var(--ds-font-family-code, monospace)",
181
181
  },
182
- badge: {
183
- display: "inline-block",
184
- padding: "2px 8px",
185
- borderRadius: 10,
182
+ statusWrap: {
183
+ display: "inline-flex",
184
+ alignItems: "center",
185
+ gap: 6,
186
186
  fontSize: 12,
187
- fontWeight: 500,
188
187
  whiteSpace: "nowrap",
189
188
  },
190
- badgeOk: {
191
- background: "var(--dsw-alias-state-success-bg, #e6f4ea)",
189
+ statusTextIdle: {
190
+ color: "var(--dsw-alias-label-tertiary, #999)",
191
+ },
192
+ statusTextTesting: {
193
+ color: "var(--dsw-alias-state-info-primary, #1967d2)",
194
+ },
195
+ statusTextOk: {
192
196
  color: "var(--dsw-alias-state-success-primary, #1e8e3e)",
193
197
  },
194
- badgeFail: {
195
- background: "var(--dsw-alias-state-error-bg, #fce8e6)",
198
+ statusTextFail: {
196
199
  color: "var(--dsw-alias-state-error-primary, #d32f2f)",
197
200
  },
198
- badgeTesting: {
199
- background: "var(--dsw-alias-state-info-bg, #e8f0fe)",
200
- color: "var(--dsw-alias-state-info-primary, #1967d2)",
201
- },
202
- badgeSkip: {
203
- background: "var(--dsw-alias-bg-layer-2, #f0f0f0)",
201
+ statusTextSkip: {
204
202
  color: "var(--dsw-alias-label-tertiary, #888)",
205
203
  },
206
- badgeIdle: {
207
- background: "var(--dsw-alias-bg-layer-2, #f0f0f0)",
208
- color: "var(--dsw-alias-label-tertiary, #999)",
204
+ dot: {
205
+ width: 6,
206
+ height: 6,
207
+ borderRadius: "50%",
208
+ flex: "none",
209
+ },
210
+ dotIdle: {
211
+ background: "var(--dsw-alias-label-dimmed, #bbb)",
212
+ },
213
+ dotTesting: {
214
+ background: "var(--dsw-alias-state-info-primary, #1967d2)",
215
+ animation: "dsmh-pulse 1s ease-in-out infinite",
216
+ },
217
+ dotOk: {
218
+ background: "var(--dsw-alias-state-success-primary, #1e8e3e)",
219
+ },
220
+ dotFail: {
221
+ background: "var(--dsw-alias-state-error-primary, #d32f2f)",
222
+ },
223
+ dotSkip: {
224
+ background: "var(--dsw-alias-label-dimmed, #bbb)",
209
225
  },
210
226
  center: {
211
227
  textAlign: "center",
@@ -265,14 +281,32 @@ window.__ModuleLoader__.load({
265
281
  fail: "statusFail",
266
282
  skip: "statusSkip",
267
283
  };
268
- const STATUS_STYLE = {
269
- idle: STYLES.badgeIdle,
270
- testing: STYLES.badgeTesting,
271
- ok: STYLES.badgeOk,
272
- fail: STYLES.badgeFail,
273
- skip: STYLES.badgeSkip,
284
+ // 状态 → 圆点颜色 / 文字颜色映射(圆点 + 彩色文字;测试中圆点带脉冲动画)
285
+ const STATUS_DOT_STYLE = {
286
+ idle: STYLES.dotIdle,
287
+ testing: STYLES.dotTesting,
288
+ ok: STYLES.dotOk,
289
+ fail: STYLES.dotFail,
290
+ skip: STYLES.dotSkip,
291
+ };
292
+ const STATUS_TEXT_STYLE = {
293
+ idle: STYLES.statusTextIdle,
294
+ testing: STYLES.statusTextTesting,
295
+ ok: STYLES.statusTextOk,
296
+ fail: STYLES.statusTextFail,
297
+ skip: STYLES.statusTextSkip,
274
298
  };
275
299
 
300
+ /** 注入测试中圆点的脉冲动画 keyframes(内联样式无法定义 @keyframes)。 */
301
+ function ensureStatusCss() {
302
+ const id = "dsh-model-health-status-style";
303
+ if (document.getElementById(id)) return;
304
+ const el = document.createElement("style");
305
+ el.id = id;
306
+ el.textContent = "@keyframes dsmh-pulse { 0%,100% { opacity:1; } 50% { opacity:.25; } }";
307
+ document.head.appendChild(el);
308
+ }
309
+
276
310
  /**
277
311
  * 模型列表 section 组件。
278
312
  * fetch /api/model-health/json 获取数据 → React 渲染表格。
@@ -562,7 +596,8 @@ window.__ModuleLoader__.load({
562
596
  const tr = testResults[row.key] || { status: "idle" };
563
597
  const labelKey = STATUS_LABEL[tr.status];
564
598
  const statusLabel = labelKey ? t(labelKey) : tr.status;
565
- const statusStyle = STATUS_STYLE[tr.status] || STYLES.badgeIdle;
599
+ const dotStyle = STATUS_DOT_STYLE[tr.status] || STYLES.dotIdle;
600
+ const textStyle = STATUS_TEXT_STYLE[tr.status] || STYLES.statusTextIdle;
566
601
  const latencyText = tr.latency != null ? `${tr.latency}ms` : "-";
567
602
  return h("tr", { key: (row.modelId || "") + i },
568
603
  visibleCols.map((col) => {
@@ -583,8 +618,8 @@ window.__ModuleLoader__.load({
583
618
  },
584
619
  h("span", {
585
620
  style: {
586
- ...STYLES.badge,
587
- ...statusStyle,
621
+ ...STYLES.statusWrap,
622
+ ...textStyle,
588
623
  cursor: hasError ? "help" : "default",
589
624
  },
590
625
  onMouseEnter: hasError
@@ -607,7 +642,9 @@ window.__ModuleLoader__.load({
607
642
  onMouseLeave: hasError
608
643
  ? () => setTooltip(null)
609
644
  : undefined,
610
- }, statusLabel)
645
+ },
646
+ h("span", { style: { ...STYLES.dot, ...dotStyle } }),
647
+ statusLabel)
611
648
  );
612
649
  }
613
650
  if (col.key === "_latency") {
@@ -662,6 +699,7 @@ window.__ModuleLoader__.load({
662
699
  * @param {import('@deepseek-ai/dsh-client-runtime/client').ClientContext} ctx
663
700
  */
664
701
  function apply(ctx) {
702
+ ensureStatusCss();
665
703
  // 注册 zh/en 词典;t 每次调用读取当前激活语言
666
704
  ctx.effect(() => ctx.locale.register(NS, { zh, en }), "dsh-model-health: dictionaries");
667
705
  const t = ctx.locale.bind(NS);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-model-health",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "DSH plugin that lists all configured models with availability/latency testing, by reading $DSH_HOME/settings.yaml.",
5
5
  "license": "MIT",
6
6
  "repository": {