dsh-opencode-status 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.4
4
+
5
+ - **去掉面板内的两处重复**:
6
+ - 状态行原本是「OpenCode GO 已连接」,而标题已经是「OpenCode GO 用量」,同一产品名在 40px 内出现两次;现在状态行只表达连接状态(「已连接」/「异常」)。
7
+ - 头部「最紧张」摘要不再带百分比:该数字在对应窗口行已经出现一次(`最紧张 月窗口` + `月窗口 剩余 78%` 是同一个数),现在摘要只给判断,具体数值保留在悬停 `title` 里。
8
+ - 测试 49 保持全绿:更新 2 处头部摘要断言,并新增「该百分比只在窗口行出现一次」的反向断言。
9
+
10
+ ## 0.4.3
11
+
12
+ - **修掉主面板的中英夹杂**:面板头部「最紧张」摘要此前复用了 `shortLabel`(`Weekly` / `Monthly`),而那是给 220px 悬浮微卡窄列准备的紧凑缩写。现在头部改用中文窗口名(`最紧张 月窗口 78%`),`shortLabel` 本身也改为 `5h` / `周` / `月`,两个位置都不再出现英文整词。
13
+ - **新增「采样中」提示**:已有采样点但还攒不够(少于 3 个点,或跨度不足 10 分钟)时,原本的位置显示「采样中」,`title` 说明已有几个点、跨了多少分钟。此前这种情况与「插件没加载」在界面上完全一样,都是空白,用户无法判断该等还是该重启。它只说明状态、不含任何数字,速率为 0 / 剩余为 0 / 重置过期时仍然完全不渲染。
14
+ - 面板头部标题在窄视口下可省略(`flexShrink:1` + ellipsis),把空间让给右侧摘要,避免中文全名撑破一行。
15
+ - 测试 48 → 49:新增「采样中 → 真实估算」的状态迁移用例与悬浮卡不显示采样提示的断言。
16
+
3
17
  ## 0.4.2
4
18
 
5
19
  - **估算时长按两位有效数字粗化**:`<1h` 取 5 分钟、`1–10h` 取 30 分钟、`≥10h` 取 1 小时、`≥48h` 取 1 天(下限 5 分钟,不会出现「约 0m」)。上游只给整数 percent,量化误差会让 ETA 的真实区间比点值宽 2–3 倍,分钟级精度属于虚假精确;现在 `约 13h10m 后耗尽` 显示为 `约 13h 后耗尽`,`约 1h54m` 显示为 `约 2h`。
package/README.md CHANGED
@@ -11,13 +11,14 @@ OpenCode GO 套餐用量与配额状态监控面板插件(DeepSeek Harness)
11
11
  - 右侧显示相对时间「上次同步 12s 前」(刚刚 / Ns 前 / N 分钟前 / N 小时前 / N 天前),绝对时刻 HH:MM:SS 保留在 `title`;同步数据超过 2 分钟追加「· 可能已过期」并用警告色,避免把旧额度当成实时值。
12
12
  - **3 维度用量行**:主百分比只给剩余额度,进度条条长与它同源(条长 = 剩余占比,条色 = 剩余档位),「已用」放在 `title` 与 `aria-valuetext` 里,同一行不再重复表达同一个数字;窗口状态非 `ok` 时给出可见提示。
13
13
  - **滚动窗口 (5h)**:`剩余 70% · 约 13h 后耗尽 · ⏱ 4h20m`
14
- - **周窗口 (Weekly)**:周额度剩余 % + 可用时长估算 + ⏱ 重置倒计时
15
- - **月窗口 (Monthly)**:月额度剩余 % + 可用时长估算 + ⏱ 重置倒计时
16
- - 面板头部只给判断性摘要「最紧张 <窗口> N%」(取剩余最小的窗口),具体数字留在窗口行。
14
+ - **周窗口**:周额度剩余 % + 可用时长估算 + ⏱ 重置倒计时
15
+ - **月窗口**:月额度剩余 % + 可用时长估算 + ⏱ 重置倒计时
16
+ - 面板头部只给判断性摘要「最紧张 月窗口」(取剩余最小的窗口,用中文窗口名而不是悬浮卡的紧凑缩写),**不带百分比**——数字只在该窗口行出现一次,悬停摘要可看具体数值。
17
17
  - **可用时长估算(按当前速率,仅供参考)**:窗口行会顺带告诉你「按现在的用法还能撑多久」。三种状态严格区分,不存在第四种:
18
18
  - `约 13h 后耗尽`(警告色):按当前速率会在窗口重置前用完;
19
19
  - `可支撑到重置`(中性色):按当前速率能撑到重置,此时不再显示具体时长;
20
- - **不显示**:采样点少于 3 个、首尾跨度不足 10 分钟、速率为 0、剩余为 0,或重置时间缺失/已过期时,这个位置直接不出现,也不会用「估算中」「--」占位。
20
+ - **采样中**:已有采样点但还攒不够(少于 3 个点,或首尾跨度不足 10 分钟)时显示「采样中」,`title` 给出已有几个点、跨了多少分钟。它只是状态说明,不含任何数字,用来区分「功能没加载」和「还在攒数据」。
21
+ - **不显示**:速率为 0、剩余为 0、重置时间缺失或已过期时,这个位置直接不出现,也不用「--」「0m」之类占位凑数。
21
22
  - 鼠标悬停会说明依据:「按最近 N 分钟的消耗速率估算(按当前速率),仅供参考」。它是对已有采样点的机械外推(只用首尾两点,不做回归),**不是预测或承诺**。
22
23
  - 时长按两位有效数字粗化:<1h 取 5 分钟、1–10h 取 30 分钟、≥10h 取 1 小时、≥48h 取 1 天。上游只有整数百分比,分钟级精度属于虚假精确,粗化后不再暗示比实际更准。
23
24
  - 采样只存在于页面打开期间的内存里(每窗口最近 60 分钟、最多 120 个点),刷新页面即清空,需要重新积累约 10 分钟才可能再次出现;上游只给整数百分比,样本不足时宁可不出数,也不给看起来精确的假时长。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-opencode-status",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "OpenCode GO quota status panel for DeepSeek Harness: click to open a usage panel with manual refresh, per-window remaining quota, a hover overview card, and in-app connection settings",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
package/src/client.js CHANGED
@@ -271,9 +271,22 @@ window.__ModuleLoader__.load({
271
271
  function etaView(w, options = {}) {
272
272
  if (options?.compact) return null
273
273
  const entry = etaSamples.get(w?.id)
274
- if (!entry) return null
274
+ if (!entry || !entry.samples.length) return null
275
275
  const estimate = estimateEta(entry.samples, w?.remainingPct, w?.resetAt)
276
- if (!estimate) return null
276
+ if (!estimate) {
277
+ // 「采样中」只在样本数或跨度还不够时出现:让用户能区分「功能没加载」与「还在攒数据」。
278
+ // 速率 0、剩余 0、重置缺失或已过期都不是采样问题,仍然什么都不显示。
279
+ const samples = entry.samples
280
+ const span = samples[samples.length - 1].at - samples[0].at
281
+ if (samples.length >= ETA_MIN_SAMPLES && span >= ETA_MIN_SPAN_MS) return null
282
+ if (typeof w?.remainingPct !== 'number' || w.remainingPct <= 0) return null
283
+ if (!w?.resetAt || w.resetAt <= Date.now()) return null
284
+ return {
285
+ text: '采样中',
286
+ color: T.secondary,
287
+ title: `正在积累采样:已有 ${samples.length} 个点、跨度约 ${Math.max(1, Math.round(span / 60_000))} 分钟;需要 ${ETA_MIN_SAMPLES} 个点且跨度满 ${ETA_MIN_SPAN_MS / 60_000} 分钟`,
288
+ }
289
+ }
277
290
  const minutes = Math.max(1, Math.round(estimate.spanMs / 60_000))
278
291
  // 文案只说「按最近 N 分钟的消耗速率(按当前速率)」的实测依据,不写「预计/将」这类预测口吻。
279
292
  const title = `按最近 ${minutes} 分钟的消耗速率估算(按当前速率),仅供参考`
@@ -707,7 +720,8 @@ window.__ModuleLoader__.load({
707
720
  return h('div', null, [
708
721
  h('div', { key: 'sum', style: { display: 'flex', alignItems: 'center', gap: 6 } }, [
709
722
  h('span', { key: 'd', style: dotStyle(st.ok ? T.ok : T.err) }),
710
- h('span', { key: 't', style: { fontSize: 12, fontWeight: 600, color: T.label } }, st.ok ? 'OpenCode GO 已连接' : 'OpenCode GO 异常'),
723
+ // 窄视口下让标题让位给右侧摘要:摘要 flexShrink:0,标题可省略。
724
+ h('span', { key: 't', style: { fontSize: 12, fontWeight: 600, color: T.label, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flexShrink: 1 } }, st.ok ? '已连接' : '异常'),
711
725
  tightest
712
726
  ? h(
713
727
  'span',
@@ -717,7 +731,9 @@ window.__ModuleLoader__.load({
717
731
  title: `最紧张窗口:${tightest.label ?? tightest.id ?? '—'},剩余 ${pctText(tightest.remainingPct)}`,
718
732
  style: { marginLeft: 'auto', fontSize: 11, fontWeight: 600, color: remainingColor(tightest.remainingPct), fontVariantNumeric: 'tabular-nums', flexShrink: 0 },
719
733
  },
720
- `最紧张 ${tightest.shortLabel ?? tightest.label ?? '—'} ${pctText(tightest.remainingPct)}`,
734
+ // 用 label 而不是 shortLabel:shortLabel 是给 220px 悬浮微卡的窄列设计的紧凑缩写,
735
+ // 复用到这里会把「Weekly / Monthly」这类英文缩写漏进主面板。
736
+ `最紧张 ${tightest.label ?? tightest.id ?? '—'}`,
721
737
  )
722
738
  : null,
723
739
  ].filter(Boolean)),
package/src/index.js CHANGED
@@ -287,7 +287,7 @@ export function apply(ctx, config = {}) {
287
287
  {
288
288
  id: 'weekly',
289
289
  label: '周窗口',
290
- shortLabel: 'Weekly',
290
+ shortLabel: '周',
291
291
  ...pctPair(u.weekly?.percent),
292
292
  status: u.weekly?.status ?? 'ok',
293
293
  resetAt: u.weekly?.resetsAt ? Date.parse(u.weekly.resetsAt) : null,
@@ -295,7 +295,7 @@ export function apply(ctx, config = {}) {
295
295
  {
296
296
  id: 'monthly',
297
297
  label: '月窗口',
298
- shortLabel: 'Monthly',
298
+ shortLabel: '月',
299
299
  ...pctPair(u.monthly?.percent),
300
300
  status: u.monthly?.status ?? 'ok',
301
301
  resetAt: u.monthly?.resetsAt ? Date.parse(u.monthly.resetsAt) : null,