Skip to content

Address PR-review findings for Cost View and Copilot prompt parsing#94

Merged
jayparikh merged 12 commits into
mainfrom
copilot/add-cost-view-token-spend
May 15, 2026
Merged

Address PR-review findings for Cost View and Copilot prompt parsing#94
jayparikh merged 12 commits into
mainfrom
copilot/add-cost-view-token-spend

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 11, 2026

Bug Fix

What was the bug?

This branch still had unresolved review findings after introducing Cost View and Copilot prompt-export parsing. The follow-up request was to run PR review and close all actionable issues.

How did you fix it?

  • Dead-code cleanup in cost analysis

    Removed unused recommit constants/fields from src/lib/costAnalysis.js so analysis output only contains consumed fields.
  • Cost View copy aligned to actual behavior

    Updated Cost View helper text in src/components/CostView.jsx to consistently describe cache misses.
  • Parser truncation correctness + clarity

    Refined truncation logic in src/lib/copilotCostParser.ts to guarantee display strings cap at the intended length (including ellipsis), and renamed constants/helpers for display-specific intent.
  • Missing coverage added

    Added src/__tests__/costView.test.jsx and extended src/__tests__/copilotCostParser.test.ts with a long-prompt truncation regression case.
const MAX_DISPLAY_TEXT_LENGTH = 4000;

function truncateForDisplay(text: string): string {
  if (text.length <= MAX_DISPLAY_TEXT_LENGTH) return text;
  const visibleLength = Math.max(MAX_DISPLAY_TEXT_LENGTH - 1, 0);
  if (visibleLength === 0) return "…";
  return text.slice(0, visibleLength) + "…";
}

Testing

Scope includes targeted regression coverage for:

  • Cost View rendering (empty state + cache-miss annotation path)
  • Copilot prompt parser display truncation boundary behavior

Copilot AI linked an issue May 11, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add Cost view for token spend and context buildup in Copilot Chat sessions Add Cost view: token spend & context buildup for Copilot Chat sessions May 11, 2026
Copilot AI requested a review from jayparikh May 11, 2026 04:19
Copilot AI changed the title Add Cost view: token spend & context buildup for Copilot Chat sessions Add Cost view mockup screenshot for PR review May 11, 2026
Copilot AI changed the title Refine Cost view mockup styling Add Cost view for Copilot prompt token spend May 11, 2026
Copilot AI changed the title Add Cost view for Copilot prompt token spend Add cost pricing for GPT 5.x and Claude model aliases May 11, 2026
Copilot AI changed the title Add cost pricing for GPT 5.x and Claude model aliases Fix PR review findings for Cost view May 11, 2026
Copilot AI changed the title Fix PR review findings for Cost view Address PR-review findings for Cost View and Copilot prompt parsing May 13, 2026
@jayparikh jayparikh requested a review from Copilot May 15, 2026 05:13
@jayparikh jayparikh marked this pull request as ready for review May 15, 2026 05:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR closes prior review findings around the new Cost View and Copilot prompt-export parsing by tightening cost/token accounting, improving copy/format support strings, expanding model pricing coverage, and adding regression tests.

Changes:

  • Adds Cost View UI + supporting aggregation logic (per-call spend, cache miss heuristics, context composition).
  • Adds VS Code Copilot prompt-export parsing (“copilot-prompts”) with display-safe truncation + metadata totals.
  • Expands pricing support to OpenAI/Copilot models and improves model-name normalization; adds targeted tests and docs updates.
Show a summary per file
File Description
src/lib/sessionTypes.ts Extends SessionFormat with copilot-prompts.
src/lib/sessionParsing.ts Updates parse failure “supported formats” message.
src/lib/pricing.js Adds OpenAI/Copilot pricing, normalizes model names, adjusts cached-input cost calculation.
src/lib/pricing.d.ts Adds TS declarations for pricing.js exports.
src/lib/parseSession.ts Routes detection/parsing for Copilot prompt-export JSON.
src/lib/costAnalysis.js Adds per-call cost/context/cache-miss aggregation helpers for Cost View.
src/lib/copilotCostParser.ts Implements prompt-export parser, usage extraction, context breakdown, truncation behavior.
src/lib/commandPalette.js Registers “Cost View” in the command palette.
src/hooks/useKeyboardShortcuts.js Adds keyboard shortcut 6 for Cost View and shifts Coach to 7.
src/components/ShortcutsModal.jsx Updates shortcuts legend to match new view ordering.
src/components/CostView.jsx Adds Cost View UI (summary cards + cost/context bars + cache miss annotations).
src/components/app/constants.js Registers cost in APP_VIEWS.
src/App.jsx Lazy-loads and renders Cost View for activeView === "cost".
src/tests/pricing.test.js Updates pricing expectations and adds cached-input + normalization + GPT pricing tests.
src/tests/keyboardShortcuts.test.js Verifies new view shortcut mapping (6=cost, 7=coach).
src/tests/costView.test.jsx Adds Cost View rendering coverage (empty + cache-miss annotation).
src/tests/costAnalysis.test.js Adds unit tests for cost analysis aggregation + cache miss detection.
src/tests/copilotCostParser.test.ts Adds parser routing/normalization tests + truncation regression coverage.
src/tests/autonomyMetrics.test.js Adjusts cost estimation expectations for priced vs unpriced non-Claude models.
README.md Updates feature description, view list, shortcuts, formats table, and adds Cost View section.
CLAUDE.md Updates architecture/file tree references for Cost View and prompt-export parser.

Copilot's findings

  • Files reviewed: 20/21 changed files
  • Comments generated: 7

Comment thread src/lib/sessionParsing.ts Outdated
Comment thread src/lib/sessionTypes.ts
Comment thread src/lib/copilotCostParser.ts Outdated
Comment thread src/components/CostView.jsx
Comment thread src/components/CostView.jsx Outdated
Comment thread README.md
Comment thread README.md
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jayparikh jayparikh merged commit c4e3d6b into main May 15, 2026
1 check passed
@jayparikh jayparikh deleted the copilot/add-cost-view-token-spend branch May 15, 2026 18:25
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.

Add a Cost view: token spend & context buildup for Copilot Chat sessions

3 participants