[1133] feature: local-usage-stats (3/4) - #52
Closed
myk1yt wants to merge 31 commits into
Closed
Conversation
…cit-any Add new test file to eslint-suppressions.json with count of 26 no-explicit-any suppressions. These are standard test patterns (mock objects, private property access via 'as any') consistent with other test files in the suppressions list. Fixes CI lint failure in PR #25 compile (lint) job.
…cing - Remove UTF-8 BOM (U+FEFF) from costRecalculation.ts and costRecalculation.spec.ts - Fix qwenCodeModels pricing: qwen3-coder-plus inputPrice 0->1.0, outputPrice 0->5.0 - Fix qwenCodeModels pricing: qwen3-coder-flash inputPrice 0->0.3, outputPrice 0->1.5 Fixes invisible-chars CI check and 3 failing costRecalculation tests
…exactly-once recorder - UsageRecorder: per-task exactly-once usage event recording with endpoint domain extraction - costRecalculation: compute effective cost from token deltas and model pricing - Provider usage deltas: moonshot, openai, openai-codex, vscode-lm yield cumulative usage; Task diffs and records - Task finalization: flush pending usage events on abort/complete - ClineProvider: initialize UsageStatsService, expose getUsageStatsService, forward usageStatsChanged to webview - types: add usage-stats schemas and usageStatsChanged ExtensionMessage type
…proper types, fix run->start renames, add UsageEventStore import
The B15 usage-capture cherry-pick was authored against an older base and reverted newer upstream/base behavior in several files, causing e2e-mock subtask timeouts (7 tests) and unit-test failures. Restore clobbered base behavior while keeping B15's genuine usage/cost capture additions: - Task.ts: restore run() + _runPromise/_isHistoryTask, safeEnsureModelFetched (def + 3 call sites), abort-aware ask wait, resume_completed_task via initialStatus, and t() i18n in sayAndCreateMissingParamError. - ClineProvider.ts: scheduler gates on task.run() (completion promise) instead of fire-and-forget task.start(). This is the root cause of the subtask/resume e2e timeouts. - openai-codex.ts: restore service-tier feature alongside cost capture. - moonshot.ts, vscode-lm.ts, vscode-lm-format.ts, eslint-suppressions.json: revert to base (pure clobber, no genuine B15 content). - task-run-dispatch.spec.ts: bind run() (not start()). - openai-usage-tracking.spec.ts: assert totalCost from cost capture.
…rn (PR Zoo-Code-Org#1133) CI failures: 1. Code QA Roo Code run 31231476937 (platform-unit-test): 8 unhandled EnvironmentTeardownError rejections from core/task/__tests__/grace-retry-errors.spec.ts. The Task constructor's usage-recorder init called the mocked provider's getUsageStatsService(); the catch block's console.warn fired during the test and tripped vitest's 'Closing rpc while onUserConsoleLog was pending'. Silenced the best-effort init catch (recorder stays disabled). 2. E2E Tests (Mocked) run 31231476961: usage-capture.test.ts startNewTask calls (USAGE_CAPTURE_SMOKE, USAGE_CAPTURE_HOOK_2) had no aimock fixture ('404 No fixture matched'). Fix: - Add fixtures/usage-capture.json with attempt_completion fixtures for both tags. Runs: https://github.com/Zoo-Code-Org/Zoo-Code/actions/runs/31231476937 https://github.com/Zoo-Code-Org/Zoo-Code/actions/runs/31231476961
…llect all recorded events
…ry on Linux runners
…path lookup to prevent I/O event loop congestion
getStatsDirs() computed repoRoot as 3 levels up from __dirname which resolves to apps/ instead of project root on Linux CI. Use vscode.extensions.getExtension() to get the authoritative globalStorageUri at runtime, matching where ClineProvider writes data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack Position
feature/local-usage-statsDescription
https://www.youtube.com/shorts/UHnnOCM1_f0
Full Feature Description
feature/local-usage-statsusage-stats.ts,src/services/stats, the provider/task capture pathsTask.ts, the stats IPCusageStatsMessageHandler.ts, and the UIDashboardView.tsxanduseDashboardStatsStream.ts.Why Split Into 17 PRs
Instead of submitting this feature as a single unified PR, it was split into individual PRs because as code size grows, safely reviewing a PR becomes very difficult. The feature was broken into mutually exclusive individual PRs so that each can be reviewed independently.
What This PR Specifically Changes
Records provider usage delta exactly once from task API attempt finalization. Handles success, error, cancel, retry, incremental usage, and duplicate finalization. Does not include query/UI.
Included Files
src/services/stats/UsageRecorder.tssrc/core/task/Task.tssrc/api/providers/openai.tssrc/api/providers/openai-codex.tsExclusion Scope
Summary by CodeRabbit
Upstream PR: Zoo-Code-Org#1133