Skip to content

feat: session-based token tracking dashboard and Copilot session title integration#158

Closed
rbinar wants to merge 6 commits into
Vizards:mainfrom
rbinar:feat/status-bar-panel
Closed

feat: session-based token tracking dashboard and Copilot session title integration#158
rbinar wants to merge 6 commits into
Vizards:mainfrom
rbinar:feat/status-bar-panel

Conversation

@rbinar

@rbinar rbinar commented Jun 13, 2026

Copy link
Copy Markdown

What was done?

Status Bar & Webview Panel

  • Added DeepSeek icon (hubot) to the status bar
  • Clicking it opens a webview panel showing balance, token usage, and cost

Session-Based Token Tracking

  • Each Copilot Chat conversation is grouped as a single session
  • Multiple messages within the same chat (e.g. "hey", "how are you") are aggregated into one group
  • Grouping uses Copilot Chat's own session ID from chat.ChatSessionStore.index
  • Clicking a session card expands a per-request detail table (model, in/out tokens, cost)

Copilot Session Title Integration

  • Reads Copilot Chat session titles from the state.vscdb SQLite database
  • Falls back to <userRequest> content when Copilot hasn't generated a title yet ("New Chat")
  • Session ID-based grouping is stable; titles can update later without breaking groups

Daily History

  • Token usage persisted via VS Code globalState
  • Auto-resets at midnight, archiving the previous day into history
  • history link in the panel shows past days

Other

  • maxInputTokens increased from 655,360 → 1,000,000
  • Added deepseek-copilot.contextSize configuration property
  • reset button in the panel to clear all data
  • Balance, API Keys, Usage, Status quick links
  • Estimated cost display (USD)

Why?

  1. Track token usage — DeepSeek API is pay-as-you-go; seeing costs is essential
  2. Session-based grouping — Know which conversation consumed how many tokens at a glance
  3. Copilot session titles — Groups match the conversation names in Copilot Chat's own sessions panel, avoiding confusion
  4. Usage history — Understand daily/monthly usage patterns over time
deepseek-panel.mov
image

rbinar added 6 commits June 13, 2026 01:26
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
@rbinar rbinar changed the title feat: session bazlı token takibi paneli ve Copilot session başlığı entegrasyonu feat: session-based token tracking dashboard and Copilot session title integration Jun 13, 2026
@Vizards

Vizards commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Hi @rbinar, thank you for putting this together. There is a lot of thoughtful work here, especially around making usage/cost visible and improving the panel UX.

After digging into the session-tracking approach, I don’t think we should continue with this PR in its current direction. The main concern is architectural rather than implementation effort: chat.ChatSessionStore.index / state.vscdb is VS Code internal storage, not a stable extension API contract. Its storage scope, schema, and update timing can change, and picking the most recent lastMessageDate cannot reliably identify the chat session for a specific provider request, especially across multiple windows, workspaces, or concurrent chats.

For this feature to be robust, VS Code needs to expose a stable chat/session identity to LanguageModelChatProvider.provideLanguageModelChatResponse() directly. There is already an upstream feature request for exactly this: microsoft/vscode#305853

Because session grouping would be misleading if it ever attributes usage to the wrong conversation, I’d rather not build on top of private storage heuristics. I’m going to close this PR for now, but I really appreciate the exploration here. If VS Code exposes a stable session id in the provider API later, I’d be happy to revisit this feature on that foundation.

I hope this doesn’t come across as dismissing the work. The UX direction is useful; I just don’t want us to ship a feature whose correctness depends on VS Code internals we don’t control.

@rbinar rbinar left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Reworked this in #163 per the architectural feedback — all VS Code internal storage access (state.vscdb, ChatSessionStore.index, sqlite3, lastMessageDate) is removed.

The panel now aggregates usage purely from the provider's own request stream: daily totals, per-model breakdown, and chronological per-request list. No more session-to-chat mapping heuristics that could misattribute across windows/workspaces.

Conversation-level grouping is intentionally deferred until VS Code exposes a stable session id (tracking microsoft/vscode#305853) — left a clean seam for it.

See #163 for the full diff and reasoning.

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