feat: DeepSeek usage panel — balance, per-request cost, daily history#163
feat: DeepSeek usage panel — balance, per-request cost, daily history#163rbinar wants to merge 9 commits into
Conversation
Adds a "Context Window" dropdown in the Copilot Chat model configuration panel, letting users switch between 200K and 1M token context windows per model. - Combine reasoningEffort and contextSize into a single configurationSchema so both controls appear in the model picker dropdown (non-public VS Code API, same mechanism used by Copilot for thinking effort). - maxInputTokens raised from 656K to 1,000,000 to support 1M mode. - maxOutputTokens set to 128,000 — a conservative middle ground that keeps the displayed context window reasonable (200K input + 128K output = 328K, 1M input + 128K output = ~1.1M) without sacrificing DeepSeek's actual generation headroom. This does NOT affect API-level max_tokens, which is controlled by a separate VS Code setting. - Sync dropdown choice back to workspace setting (deepseek-copilot.contextSize) after each request so the value persists across sessions. - Both DeepSeek V4 Flash and Pro supported. - English and Chinese i18n for dropdown labels and descriptions. Why: the default 656K input window was too small for long sessions, while always reserving 1M adds latency and cost. Giving users control lets them pick the right trade-off between speed/cost (200K) and capacity (1M).
- Status bar button with hubot icon opening persistent webview panel - Balance display from /user/balance API with refresh - Session token tracker with per-request history - Estimated cost calculation using model pricing - Click-to-expand per-request breakdown table - DeepSeek links (API Keys, Usage, Status) - Extension version in footer
- Sessions survive VS Code restarts via globalState - Auto-reset at day boundary, saves previous day to history - Daily history table in panel (click 'history' to expand) - Mid-session date change detection
- Session tokens grouped by first user message title - 'sessions' toggle in Session Tokens card shows group breakdown - Balance color: rgb(96, 179, 254) blue - Est. cost color: rgb(255, 161, 10) amber
- Status bar butonu ve webview panel eklendi (DeepSeek paneli) - Balance, token kullanımı, maliyet takibi yapıldı - Session (oturum) bazlı gruplama: aynı Copilot sohbetindeki tüm istekler tek grupta toplanıyor - Copilot Chat session başlıkları state.vscdb üzerinden okunuyor (<userRequest> fallback ile) - Günlük geçmiş (daily history) globalState üzerinde kalıcı - Session kartına tıklayınca per-request detay gösterimi - Panelde reset butonu ile veri temizleme - maxInputTokens 655360 → 1000000 artırıldı - contextSize konfigürasyonu package.json'a eklendi
Reworks the status-bar panel (originally Vizards#158) to address architectural feedback from the maintainer. Removed (fragile VS Code internals): - src/session.ts — state.vscdb / ChatSessionStore.index / sqlite3 shell-out - Session grouping by Copilot chat (sessionId/title heuristics) - <userRequest> prompt text extraction for titles Kept (stable, from provider's own request stream): - Balance, per-request usage, daily history, cost tracking, reset, quick links Added: - getUsageByModel() — legitimate model-based breakdown, no internals needed - Future seam comment for microsoft/vscode#305853 (stable session id) Side benefit: no longer persists user prompt text or chat titles (PII/privacy). Fixes pre-existing merge-conflict corruption in stream.ts and wrong import in precheck.ts discovered during this work.
|
Hi @rbinar Thanks for reworking the usage panel direction and removing the dependency on VS Code internal storage. Sourcing usage from the provider stream is a much better foundation. That said, this PR currently mixes several unrelated changes, which makes it difficult to review safely. The title and description are about the usage panel, but the diff also includes:
Could you split this into smaller PRs? I’d suggest keeping this PR focused only on the usage panel: balance fetching, status bar / webview, usage tracking from provider-reported usage, and persistence. The context-window work and model token metadata changes should stay in #156 or a separate PR, because they need their own discussion and validation. The thinking-compat/debug-dump changes also look like a separate concern. This would make the review much easier and reduce the risk of accidentally merging unrelated behavior changes with the usage panel. Until this is split, I don’t think this PR is in a reviewable shape. |
|
Thanks @Vizards — agreed on all points. I've split this up. The panel-only version is now #167, which contains only the usage panel (balance fetch, status bar + webview, provider-reported usage tracking, persistence). Everything you flagged as unrelated has been dropped from it:
#167's diff is purely additive (2 new files + panel wiring + a 3-line Closing this in favor of #167. |
Supersedes #158, reworked to address the architectural feedback there.
What changed vs #158
state.vscdb/chat.ChatSessionStore.indexreads, nosqlite3shell-out, nolastMessageDateheuristic. The previous conversation-grouping could misattribute usage across windows/workspaces/concurrent chats, as you noted.provideLanguageModelChatResponse→ reportedusage), which is stable and authoritative. Panel aggregates by day, model, and total, plus a chronological per-request breakdown.Deferred
chatSessionResourcetoLanguageModelChatProvider.provideLanguageModelChatResponse()microsoft/vscode#305853). The code leaves a clean seam to add it on that foundation.Kept from #158
/user/balance, estimated cost, persistent daily history with day-boundary reset, reset button, quick links.