github / github/copilot-cli

Collapsible real-time session stats panel (tokens, context, API calls, premium requests, cache, duration)

Đang mở
#1,784 1 bình luận 3 reaction 0 người được giao Xem trên GitHub
area:context-memory area:sessions
Ngôn ngữ chính
Shell
Star
11.2k
Fork
1.9k
Merge trung bình
14 giờ 16 phút
Pull request đã merge (30 ngày)
6

Mô tả

### Describe the feature or problem you'd like to solve

There is currently no way to monitor session resource usage at a glance during an active session. To understand how much context has been consumed, how many API calls have been made, or how many premium requests have been used, a user must either wait for a crash/compaction or dig through logs after the fact. For power users, teams on metered plans, and anyone running long or expensive sessions, this lack of real-time visibility is a significant gap.

### Proposed solution

Add an optional **Session Stats panel** — collapsible/expandable, togglable via config — that renders a live compact summary of resource and performance metrics for the current session.

**Folded (compact, one-line):**
```
📊 Stats ctx 68% ↑42k/↓18k tok 🕒 12m 34s calls 37 premium 8
```

**Unfolded (expanded):**
```
📊 Session Stats
Context 68% used (87,040 / 128,000 tokens)
Tokens sent 42,310
Tokens received 18,045
Cached tokens 11,200 (21% of sent)
API calls 37 total (28 standard · 8 premium · 1 cached)
Premium requests 8
Duration 12m 34s
Avg. turn time ~20s
```

**Suggested stats to surface:**

| Stat | Description |
|---|---|
| Context usage | Current fill % and absolute tokens vs. window size |
| Tokens sent | Cumulative input tokens for the session |
| Tokens received | Cumulative output tokens for the session |
| Cached tokens | Tokens served from prompt cache (where applicable) |
| API calls | Total LLM requests, broken down by standard / premium / cached |
| Premium requests | Count of premium-model calls against plan quota |
| Session duration | Wall-clock time since session start |
| Avg. turn time | Average time per agent turn |

**Controls:**
- Toggle fold/unfold: a dedicated keyboard shortcut (the specific key should avoid conflicts — e.g. `Ctrl+S` sends XOFF in some terminals and should not be used; a safe alternative such as a function key or a free modifier combo should be chosen) or by clicking the panel header
- Opt-in via `config.json`:
```json
{ "statsPanel": true }
```
- Fully disabled by default to preserve a clean UI for new users; power users explicitly enable it.
- Stats persist and accumulate across compaction events so the total is always session-wide, not just the current context window.

### Example prompts or workflows

1. User on a metered Copilot plan monitors premium request count in real time — knows at a glance when they're approaching their quota before the session ends.
2. Long refactor session running for 45 minutes: user glances at the folded one-liner to see context is at 72% and decides to manually `/compact` before it auto-compacts.
3. User notices cached token % is low and adjusts their workflow to reuse more context, reducing cost.
4. Team lead shares a screenshot of the expanded stats panel with their team to communicate session cost and complexity.
5. User keeps the panel folded for minimal UI footprint — the single-line summary gives just enough signal without cluttering the screen.

### Additional context

- OS: Windows 11 Pro (Build 26200 / 24H2)
- Shell: PowerShell 7.5.4
- Copilot CLI: 0.0.420 (win32-x64)
- The `/context` command already surfaces context usage — this panel extends that concept to a persistent, live, multi-metric view accessible without leaving the main session flow.
- The collapsible panel pattern is already established in the TUI (checkpoints, MCP, context) — this fits the same model.
- Stats should survive context compaction and reflect true session totals, not just the current window's figures.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.