Skip to content

VS extension: batch all CLI calls into a single all --json invocation#530

Merged
rajbos merged 3 commits intomainfrom
copilot/fix-batched-cli-call-optimization
Mar 30, 2026
Merged

VS extension: batch all CLI calls into a single all --json invocation#530
rajbos merged 3 commits intomainfrom
copilot/fix-batched-cli-call-optimization

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

Multiple sequential CLI spawns on extension load caused multiple loader spinners and unnecessary latency. This replaces them with a single batched call that populates all view caches upfront.

CLI — new all command

  • cli/src/commands/all.ts: runs calculateDetailedStats, calculateDailyStats, and calculateUsageAnalysisStats in parallel, then returns a single JSON envelope:
    { "details": {...}, "chart": {...}, "usage": {...}, "fluency": {...} }

VS extension — CliBridge batched fetch

  • GetAllDataAsync(): runs all --json once, deserializes each top-level key, and populates all in-memory caches (_cachedStats, _cachedChartJson, _cachedUsageAnalysisJson, _cachedMaturity). Concurrent callers share the same in-flight Task — no duplicate processes.
  • Individual Get*Async() methods now serve from cache when fresh; fall back to a per-command CLI call otherwise (backwards-compatible).

VS extension — single-spinner preload

  • PrewarmAllViewsAsync() (called once during WebView init): shows one loading indicator, calls GetAllDataAsync(), then builds and caches rendered HTML for all five views (details, chart, usage, environmental, maturity). Tab switches after this point are instant with no additional spinners.

CI

  • Added all --json validation step to both cli-build.yml and visualstudio-build.yml to catch regressions in the batched command.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • teststorage.blob.core.windows.net
    • Triggering command: /opt/hostedtoolcache/node/20.20.1/x64/bin/node /opt/hostedtoolcache/node/20.20.1/x64/bin/node --require ./out/test/unit/vscode-shim-register.js --test-force-exit /home/REDACTED/work/github-copilot-token-usage/github-copilot-token-usage/vscode-extension/out/test/unit/backend-blobUploadService.test.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Issue Reference

Fixes #496

Problem Statement

The Visual Studio extension currently runs multiple CLI calls sequentially, causing multiple loader spinners to appear and resulting in a slower user experience. We need to optimize this by batching all the necessary data loading calls into a single grouped operation.

Requirements

  1. Analyze the current implementation to identify where individual CLI calls are being made for loading data across different views
  2. Design and implement a grouped call mechanism that can fetch all required data in one batch operation
  3. Update the data loading logic to use the new grouped call approach
  4. Ensure all views receive the data they need from the single batched call
  5. Reduce the number of loader spinners shown to the user
  6. Maintain the same functionality and data accuracy as the current implementation
  7. Test that all views continue to display the correct information after the changes

Expected Outcome

  • Single batched CLI call that retrieves all necessary data at once
  • Reduced number of loader spinners displayed to the user
  • Improved performance and user experience
  • All extension views continue to function correctly with the same data

Technical Considerations

  • Review the current CLI command structure and parameters
  • Consider backwards compatibility with existing CLI versions
  • Ensure error handling works correctly for the grouped call
  • Update any related documentation or comments in the code

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: find my open issues

Assistant: You have 2 open issues in rajbos/github-copilot-token-usage:

data:
- url: "https://github.com/rajbos/github-copilot-token-usage/issues/496"
  repository: "rajbos/github-copilot-token-usage"
  state: "open"
  draft: false
  title: "[FEATURE] Visual Studio Extension: Run all cli calls in one go"
  number: 496
  created_at: "2026-03-27T00:00:00Z"
  closed_at: ""
  merged_at: ""
  labels:
  - "enhancement"
  author: "rajbos"
  comments: 1
  assignees_avatar_urls:
  - "https://avatars.githubusercontent.com/u/6085745?v=4"
  - "https://avatars.githubusercontent.com/in/1143301?v=4"
- url: "https://github.com/rajbos/github-copilot-token-usage/issues/127"
  repository: "rajbos/github-copilot-token-usage"
  state: "open"
  draft: false
  title: "Setup and Document making screenshots in Coding Agent"
  number: 127
  created_at: "2026-01-20T00:00:00Z"
  closed_at: ""
  merged_at: ""
  labels: []
  author: "rajbos"
  comments: 1
  assignees_avatar_urls:
  - "https://avatars.githubusercontent.com/u/6085745?v=4"
  - "https://avatars.githubusercontent.com/in/1143301?v=4"

#496 — Optimization for the Visual Studio extension to run all CLI calls in a single batch instead of one-by-one to reduce loader spinners.

#127 — Documentation and automation for taking screenshots of the extension UI using the Coding Agent and test data, to be packaged as a reusable GitHub Copilot skill.

User: is there already a pr for #496

Assistant: No, there are currently no pull requests linked to issue #496 in rajbos/github-copilot-token-usage.

User: implement the needed changes for this issue so that we can call all info at once

Assistant: I'm waiting for your confirmation to proceed with creating a pull request that implements the batched CLI call optimization for issue #496.

This pull request was created from Copilot chat.


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI changed the title [WIP] Optimize CLI calls by implementing batched data loading VS extension: batch all CLI calls into a single all --json invocation Mar 30, 2026
Copilot AI requested a review from rajbos March 30, 2026 09:25
@rajbos rajbos marked this pull request as ready for review March 30, 2026 16:43
@rajbos rajbos merged commit 44cf2da into main Mar 30, 2026
20 of 21 checks passed
@rajbos rajbos deleted the copilot/fix-batched-cli-call-optimization branch March 30, 2026 16:45
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.

[FEATURE] Visual Studio Extension: Run all cli calls in one go

2 participants