refactor(desktop): extract Usage settings into a renderer feature slice
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 502
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 715
Description
## Problem
`Settings → Usage` (`apps/desktop/src/renderer/settings/usage-settings-page.tsx` and its tabs) is still **legacy-zone** renderer code inside the AppShell closure. Since the renderer-architecture ratchet landed (#4088, the R1 foundation of #3439), the legacy AppShell closure is frozen: no new file may enter it, and no legacy file's dependency count may grow (only shrink).
This blocks **net-new** Usage functionality. Concretely, #2015 / PR #4164 (editable Runtime Host-backed pricing overrides) must add a Pricing **tab inside the Usage settings page** — #2015 explicitly requires it stay a Usage tab, *not* a new top-level Settings destination. Adding that tab forces `usage-settings-page.tsx` to import the pricing surface: a **+1 dependency on a frozen file with no existing code to remove as an offset** (unlike the Workbar/Goals extractions, whose feature import replaced removed code, netting ≤0). The ratchet correctly rejects it, and there is currently **no `features/usage` slice** to attach to.
Usage/Settings was never a tracked slice under #3439 (which covered Workbar, Goals, Module Hub, Session Navigation, Task Entry, Conversation, …). This issue tracks that missing slice.
## Proposed direction
Extract the Usage settings surface into a renderer feature `src/renderer/features/usage/`, following the reference boundary from #3439 (`model / controller / ui / ports / desktop adapter / testing`):
- The four existing tabs (Activity / Providers / Models / Tools), the range control, and the summary metrics move behind the feature's ports and controller.
- The Pricing override editor (#2015) lives inside the feature rather than as legacy debt.
- `usage-settings-page.tsx` (legacy) delegates to the feature's public API via a single migration-dependency edge, keeping closure debt flat-or-lower.
- Services are provided from `composition/desktop-feature-services.tsx`; the Desktop adapter lives under `platform/desktop/`.
## Scope
- `features/usage/`: model/controller/ui/ports for the Usage stats surface + the Pricing override editor.
- Desktop adapter + `composition` provider wiring.
- Retire the legacy `usage-settings-page.tsx` internals.
## Invariants (per #3439)
No product, visual, IPC, storage-schema, copy, or shortcut changes. The Usage stats behavior, range persistence, and the pricing load/mutate/CAS semantics from #2015 must remain compatible.
## Refs
- Foundation / ratchet: #3439, #4088
- Blocked feature: #2015 (PR #4164)
## Non-goals
- No product/visual/IPC/copy changes.
- No pricing product-direction change (that is #2330 / the #2015 pause) — this issue is purely the renderer-ownership migration that unblocks it.
---
中文摘要:`设置 → 使用统计` 仍是 legacy 区、被架构棘轮(#4088)冻结,无法新增依赖;而 #2015/#4164 的定价必须做成 Usage 标签页(净新增,无可抵消),于是撞墙。本 issue 跟踪按 #3439 的 `model/controller/ui/ports/adapter` 模式,把整个 Usage 设置面(4 个标签页 + 数据加载 + 定价 tab)抽取为 `features/usage` 切片,从而解除阻塞。行为/文案/IPC 不变。
Contributor guide
Assessment
This issue has not been assessed yet.