Skip to content

feat: DeepSeek usage panel — balance, per-request cost, daily history#163

Closed
rbinar wants to merge 9 commits into
Vizards:mainfrom
rbinar:fix/remove-vscode-internals-keep-panel
Closed

feat: DeepSeek usage panel — balance, per-request cost, daily history#163
rbinar wants to merge 9 commits into
Vizards:mainfrom
rbinar:fix/remove-vscode-internals-keep-panel

Conversation

@rbinar

@rbinar rbinar commented Jun 15, 2026

Copy link
Copy Markdown

Supersedes #158, reworked to address the architectural feedback there.

What changed vs #158

  • Removed all dependence on VS Code internal storage. No more state.vscdb / chat.ChatSessionStore.index reads, no sqlite3 shell-out, no lastMessageDate heuristic. The previous conversation-grouping could misattribute usage across windows/workspaces/concurrent chats, as you noted.
  • Usage is now sourced solely from the provider's own request stream (provideLanguageModelChatResponse → reported usage), which is stable and authoritative. Panel aggregates by day, model, and total, plus a chronological per-request breakdown.
  • As a side benefit, the panel no longer extracts or persists user prompt text or chat titles (privacy improvement).

Deferred

Kept from #158

  • Status bar entry + webview panel, balance from /user/balance, estimated cost, persistent daily history with day-boundary reset, reset button, quick links.

Vizards and others added 9 commits June 11, 2026 13:21
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.
@Vizards

Vizards commented Jun 17, 2026

Copy link
Copy Markdown
Owner

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.

@rbinar

rbinar commented Jun 17, 2026

Copy link
Copy Markdown
Author

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 modelId field + a one-line recordUsage hook + the views/viewsContainers contributions), so it should be much easier to review safely.

Closing this in favor of #167.

@rbinar rbinar closed this Jun 17, 2026
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