Skip to content

feat(chat): let the context ring lead with used or remaining capacity (D396 / ADR 0222) - #230

Merged
vastsa merged 2 commits into
vastsa:mainfrom
panda-z519:feat/context-usage-display
Sep 11, 2026
Merged

feat(chat): let the context ring lead with used or remaining capacity (D396 / ADR 0222)#230
vastsa merged 2 commits into
vastsa:mainfrom
panda-z519:feat/context-usage-display

Conversation

@panda-z519

@panda-z519 panda-z519 commented Sep 11, 2026

Copy link
Copy Markdown

What

在 composer 工具栏的上下文用量检查器上,让「引导数值」可由用户选择:剩余容量(现有行为,默认)或已用容量

Why

检查器此前固定显示剩余容量。在低占用时剩余数字接近窗口总量,一眼看去信号很弱;而且对习惯「已经花了多少」心智模型的用户不直观。

How

  • 新增 AppSettings.contextUsageDisplay?: "remaining" | "used"(缺省/非法值回退 remaining)。
  • 环弧长(strokeDashoffset)、触发器百分比与令牌标签、弹层标题、tooltip 与 aria-label 全部跟随该设置。
  • 警告/临界颜色阈值仍按剩余容量判定(剩余 ≤ 25 % warning、≤ 10 % critical),不随显示模式变化——避免「已用 90 %」被画成安全色。
  • 设置入口:设置 → AI → 默认项卡片新增「剩余 / 已用」分段控件(位于 Link open destination 之后、Enter-to-send 之前)。
  • 纯渲染器改动:无协议、存储、宿主或迁移变更(host-core 的设置合并保留未知字段)。

Verification

在本分支(基于 main,含 f1b6916b)实测:

检查 结果
pnpm --filter @pi-desktop/desktop typecheck ✅ 0 error
node --test apps/desktop/test/*.test.mjs ✅ 1367 passed
packages/i18nrenderer-keys / catalogs / user-facing-copy ✅ 22 passed
node scripts/check-style-tokens.mjs(lint) ✅ style tokens OK
node docs/scripts/check-locales.mjs ✅ 77 English/Chinese spec pairs

未运行 E2E(按仓库规则,仅在你明确要求时运行)。

Docs

  • 新增 ADR 0223、决策 D398(decisions-log.md 表格 + 日期小节,中英同步)。
  • 更新设置 IA、组件规格、E2E-250 场景,并把 E2E-250 登记进 §8 追溯矩阵(C / Quality / M5)。
  • 新增/修改的 i18n 键已在全部 8 个语言目录补齐。

Impacted specs / E2E

  • docs/adr/0222-context-usage-display-preference.md
  • docs/spec/04-ux/06-settings-ia.md04-ux/08-component-spec.md
  • docs/spec/06-delivery/04-e2e-test-plan.md(E2E-250)
  • docs/spec/08-meta/decisions-log.md(D398)

Notes for the maintainer

  • 沿用仓库既有的 settings-segment 分段控件模式,因而与既有的 CloseBehaviorSection 一样没有 roving tabindex / 方向键导航(既有可达性债务,本次未扩大范围)。
  • usedRatio 恰落在取整边界时,remainingused 两种模式可能相差 1 个百分点(同源 usedRatio 取整),已在 ADR 中如实记录。

@vercel

vercel Bot commented Sep 11, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the vastsa's projects Team on Vercel.

A member of the Team first needs to authorize it.

zhangsiqiang added 2 commits September 11, 2026 15:38
Composer 工具栏的上下文用量环此前固定显示剩余容量。新增设置项
AppSettings.contextUsageDisplay(remaining 默认 / used),让环弧长、
触发器百分比与令牌标签、弹层标题、tooltip 与 aria-label 跟随所选数值。
颜色分级(remaining ≤ 25% warning、≤ 10% critical)仍按剩余容量判定,
避免「已用 90%」显示为安全色。设置入口位于 AI → 默认项卡片。
…223)

新增 ADR 0223 与决策 D398,同步设置信息架构、组件规格与 E2E-250
场景(含中英 spec 对),并把 E2E-250 登记进 §8 追溯矩阵。
说明默认 remaining、颜色阈值仍按剩余容量,以及本次为纯渲染器改动、
无协议与存储迁移。
@panda-z519
panda-z519 force-pushed the feat/context-usage-display branch from a4e96a4 to a7f8032 Compare September 11, 2026 07:39
| D393 | User-invoked Skills in the composer | **Amend D123 / D174 / ADR 0024 / ADR 0039: active built-in, plugin, and user Skills appear in a separate `Skills` group at the end of the composer slash menu. Selecting one inserts its exact id; Electron main revalidates the active project scope at send time and asks the model to call the local `Skill` tool, preserving on-demand body loading and existing permissions. Existing command names win collisions; inactive Skills remain literal slash text. See ADR 0219 and E2E-088b.** | D174's model-invoked catalog remains the body-loading and security contract, while a final explicit entry makes known workflows discoverable without moving Skill bodies into the renderer, prompt, or host protocol. |
| D394 | Windows work-panel chrome keeps one resource action cluster | **Amend D154 / D357 / ADR 0195: the open work-panel header keeps one compact resource switcher; resource close is owned by the existing keyboard-operable context-menu rows, the viewport-fixed toggle remains the only panel collapse control, and subagent detail returns with a back chevron. Windows/Linux native controls remain fixed at the window edge. Renderer-only; no panel state, window geometry, IPC, protocol, or storage change. See ADR 0220 and E2E-067.** | The header resource `X`, viewport-fixed toggle, and Windows native close cluster read as duplicate close actions and became cramped at narrow panel widths. |
| D396 | Renderer and plugin-panel scrollbars share one compact contract | **Amend D300: every renderer scroll container uses one 6px, trackless, transparent-at-rest scrollbar with the same hover, focus-within, scroll-reveal, and dragged-thumb states. Remove the sidebar-specific width and opacity override. The plugin-panel preload applies the same contract and 300ms reveal mark to docked and detached plugin documents, including the bundled Files view. External pages loaded inside the Browser guest remain page-owned. Presentation-only; no protocol, storage, host runtime, or external-page behavior change. See E2E-157.** | Windows' classic scrollbar made the right-side work-panel Files view visibly heavier than the conversation, while the sidebar retained a second scrollbar treatment. |
| D398 | Context usage display preference | **Amend D347 / ADR 0184: the context usage inspector's leading figure — the trigger ring arc, percentage, token label, popover heading, tooltip, and `aria-label` — is configurable via `AppSettings.contextUsageDisplay` (`"remaining"` or `"used"`). Default and fallback for absent/unrecognised values is `"remaining"`. When `"used"`, the ring fills by `usedRatio`, and text shows the used-capacity pair. Warning and critical color thresholds (remaining ≤ 25 % / ≤ 10 %) stay based on remaining capacity regardless of display mode. Settings → AI → Defaults adds a segmented control (Remaining / Used) after Link open destination and before Enter-to-send. Renderer only; no protocol, storage, host, or migration change. See ADR 0222 and E2E-250.** | The remaining-only display gave weak signal at low occupancy and did not match users who reason in terms of "how much have I spent". Color must stay on remaining to avoid a misleading green ring at 90 % used. |

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] 将 ADR 交叉引用改为 0223。此提交新增的是 docs/adr/0223-context-usage-display-preference.md,而 ADR 0222 在当前 main 中已被原生文件/文件夹拖拽决策占用;这里仍写 0222 会把读者带到错误的决策文档。中文镜像同样需要同步修正。

@vastsa
vastsa merged commit 57d66d9 into vastsa:main Sep 11, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants