mirror of
https://github.com/NeuralNomadsAI/CodeNomad.git
synced 2026-10-19 15:34:12 +00:00
## Behavior Preferences gains a **Stats** section covering the **entire connected OpenCode service**: all projects, independent clones and subsessions. Every locale states this scope explicitly, because native project IDs span independent clones and cannot be presented as folder-scoped. - **Periods:** rolling 7, 30, 90 or 365 days. - **Figures:** input, output, reasoning and cache tokens; recorded USD cost; session, subsession, prompt and step counts; a per-model table; daily activity. - **Not shown:** transcripts, polling, and provider billing or quota precision. The Usage label stays reserved for provider subscriptions. ## Boundary - **Endpoint:** authenticated `GET /api/workspaces/:id/service-usage` returns native `session.stats` with explicit `scope: "service"`. - `tools` is always `none`. - Periods are bounded to 366 days. - Project, directory and tool selectors are rejected (400). - A connection or workspace change during the read fails closed. - **UI:** an in-memory display snapshot per period. It revalidates on mount, on settled session events (`session.idle`, `session.deleted`, prune) and on reconnect. - **Preferences windows:** the `usage` section is added to the Electron, Tauri and UI native allowlists. ## Validation - Server, UI and Electron typechecks pass. - Backend: `service-usage.test.ts` 3/3. - Browser: dashboard, Preferences reachability, Preferences window and startup scenarios, 5/5. - Unit: `preferences-window.test.ts` 2/2. - Native: `scripts/test-service-usage-native.mjs` passes on an isolated copy of OpenCode 2.0.29. It covers a worktree, an unrelated repository and an independent clone, with synthetic generation and a private home/database only. ## History This was originally #796 (8/8). Because the series was stacked, #796 was squash-merged into the MCP Code Mode branch (#795) rather than `dev`. It is split out here so it can land on its own. Review fixes are included: an in-memory cache instead of `localStorage` keyed by non-persistent workspace IDs, the status-card surface role and spacing tokens. |
||
|---|---|---|
| .. | ||
| scripts | ||
| src-tauri | ||
| tests | ||
| vendor | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| NOTIFICATION_BADGES.md | ||
| package.json | ||