Skip to content

feat: add Copilot Cloud Agent sessions view#835

Merged
rajbos merged 3 commits into
mainfrom
rajbos/agentic-sessions-view
May 10, 2026
Merged

feat: add Copilot Cloud Agent sessions view#835
rajbos merged 3 commits into
mainfrom
rajbos/agentic-sessions-view

Conversation

@rajbos
Copy link
Copy Markdown
Owner

@rajbos rajbos commented May 10, 2026

Summary

Adds a new 🤖 Cloud Agent tab to the Usage Analysis webview showing GitHub Copilot cloud agent session statistics — tasks, sessions, and AI credits consumed — without double-counting CLI or local IDE chat sessions.

What's new

New Cloud Agent tab in Usage Analysis

  • Shows summary totals: Tasks / Sessions / AI Credits
  • Per-repo breakdown table with partial-scan indicator when capped
  • Lazy-loaded on first tab visit with live progress updates
  • Explicit note that CLI/remote sessions and local IDE sessions are excluded

vscode-extension/src/agentSessionsService.ts (new)

  • Calls the GitHub /agents/repos/{owner}/{repo}/tasks API
  • 3-way source detection: cloud-agent / cli-remote / unknown
    • cloud-agent: model !== '' OR usage field present
    • cli-remote: model field present but empty string
    • unknown: model field absent entirely
  • Paginates both active + archived tasks, deduplicates by task ID
  • Caps detail fetches at 50 tasks/repo to limit API load; sets partial: true when exceeded
  • Returns aggregate-only data (no raw prompts/sessions)

scripts/fetch-agent-sessions.js (new)

  • Node.js script for pre-fetching agent session data in GitHub Actions
  • Non-fatal: exits 0 on any error, writes an empty result file
  • Outputs to ./usage-data/agent-sessions.json

.github/workflows/copilot-setup-steps.yml

  • Adds daily-cached agent session fetch using actions/cache (v4.2.3)
  • Cache key: agent-sessions-{repo}-{YYYY-MM-DD} — refreshes once per day
  • Added actions: write permission for cache save
  • Fetch step is continue-on-error: true — workflow never fails due to this

Tests

  • 11 new unit tests in agentSessionsService.test.ts
  • All 50 test files pass ✅

No double-counting

Session type Source Where shown
Cloud agent sessions /agents/repos/.../tasks API New Cloud Agent tab only
CLI/remote sessions Same API, excluded by source filter Not shown anywhere
Local IDE chat VSCode workspaceStorage log files Existing My Activity tab

- New 'Cloud Agent' tab in Usage Analysis showing tasks, sessions, AI credits
- agentSessionsService.ts: fetches /agents/repos/{owner}/{repo}/tasks API
- Source detection: cloud-agent vs cli-remote vs unknown (no double-counting)
- Detail fetch capped at 50 tasks/repo with partial flag for transparency
- Lazy-loaded on first tab visit with progress updates
- scripts/fetch-agent-sessions.js for workflow data pre-fetch
- copilot-setup-steps.yml: daily cached agent session fetch via actions/cache
- 11 new unit tests for detectSessionSource and fetchAgentSessionsForRepo

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread vscode-extension/src/webview/usage/main.ts Fixed
rajbos and others added 2 commits May 10, 2026 14:47
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add sanitizeAgentSessionsData() that escapes all string fields when
receiving message.data from the extension host, matching the existing
sanitizeRepoPrStatsData() pattern. renderAgentSessionsContent() then
works with pre-sanitized strings and no longer calls escapeHtml()
internally. Resolves CodeQL cross-site scripting finding.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rajbos rajbos merged commit f8caeee into main May 10, 2026
20 checks passed
@rajbos rajbos deleted the rajbos/agentic-sessions-view branch May 10, 2026 13:08
rajbos added a commit that referenced this pull request May 11, 2026
- Add rolling average toggle for Total Tokens and Est. Cost chart views (#836)
- Add Copilot Cloud Agent sessions view (#835)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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