Skip to content

feat(usage): include Kimi Code activity - #7936

Closed
Hylouis233 wants to merge 8 commits into
pingdotgg:mainfrom
Hylouis233:feat/kimi-code-usage
Closed

Hylouis233 wants to merge 8 commits into
pingdotgg:mainfrom
Hylouis233:feat/kimi-code-usage

Conversation

@Hylouis233

@Hylouis233 Hylouis233 commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

T3 Code's Usage page does not include Kimi Code activity. Kimi Code's terminal UI and desktop app persist turn-scoped usage under separate session homes, so both surfaces are missing from provider totals, charts, and model breakdowns.

What changed

  • scan turn-scoped usage.record events from Kimi Code wire transcripts
  • cover the Kimi Code TUI home and the platform-specific Kimi Desktop runtime home
  • support KIMI_CODE_HOME and KIMI_DESKTOP_DATA_DIR overrides
  • preserve uncached input, cache reads/writes, output, sessions, and models
  • cache window-bounded transcript results without reusing narrow scans for wider requests
  • propagate transcript walk/read failures into per-provider coverage health
  • negotiate v4/v5 responses so rolling client and server upgrades remain decodable
  • add Kimi Code presentation on web and mobile, plus user documentation

Verification

  • 10 focused usage test files: 96 tests passed
  • targeted server, contracts, shared, web, and mobile typechecks passed
  • focused lint, formatting, and git diff --check passed
  • validated against local TUI and Desktop stores: 98 wire files across 14 sessions produced 6,073 turn-scoped usage records with expected models and token categories

Merge order

This PR, #7877, #7904, and #7939 independently target the current v4 usage contract and each introduces v5. Every PR merged after the first must be rebased and advance the combined contract version before merge.

The available before/after usage captures contain private local totals, so they are not attached to this Draft.

Built with Codex (GPT-5).

Note

Add Kimi Code provider to usage tracking

  • Adds kimi to the UsageProviderKind schema and bumps USAGE_CONTRACT_VERSION to 5, allowing the server and UI to track Kimi Code transcript activity.
  • The server parses Kimi .jsonl lines via parseKimiLine and discovers directories using resolveTranscriptDirs, covering both TUI and desktop paths.
  • Uses negotiateUsageContractVersion to fall back to the pre-Kimi contract (v4) when the client does not request v5, maintaining backward compatibility.
  • Updates UsageAggregator and usageMerge to split usage by physical sourcePath, enabling better cross-environment de-duplication.
  • Risk: Bumps USAGE_SCAN_CACHE_VERSION to 3, which invalidates existing scan caches and forces repopulation.

Macroscope summarized dc732f7.


Note

Medium Risk
Touches the usage contract, scan cache, and cross-environment source ownership. A cache version bump forces a one-time cold rescan; merge logic changes can alter which environment’s totals win.

Overview
Adds Kimi Code to usage totals by scanning TUI (KIMI_CODE_HOME / ~/.kimi-code) and Desktop session homes, parsing turn-scoped usage.record lines, and showing the provider on web and mobile.

Bumps the usage contract to v5 (kimi + optional sourcePath). Clients advertise contractVersion; servers still emit v4 without Kimi for older clients. Scan cache is v3 with a completeFromMs bound so windowed Kimi scans are not reused for wider windows.

Walk/read failures now mark sources partial/failed instead of looking healthy. Merge claims stores by physical path, prefers the more complete environment, and surfaces incompleteSources in the coverage notice.

Reviewed by Cursor Bugbot for commit dc732f7. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 17f52715-bda8-4354-b66b-dbfb12d849a0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 22, 2026

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One finding on the web UI: the new Kimi Code mark hardcodes its own light/dark violets instead of the --usage-provider-kimi theme token that the rest of the usage surface reads, and the light value drifts from that token, so the legend swatch and the mark next to it render different colors in light mode.

Posted via Macroscope — UI Consistency

Comment thread apps/web/src/components/Icons.tsx Resolved
Comment thread apps/server/src/usage/UsageService.ts Resolved

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One dependency-acquisition finding in apps/server/src/usage/UsageService.ts. Everything else in the changed Effect code (service/tag layout, make/layer exports, namespace imports, no new runtimes or service-instance parameters) matches the conventions.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/src/usage/UsageService.ts Resolved
@Hylouis233
Hylouis233 marked this pull request as ready for review August 22, 2026 22:29
Copilot AI lite review requested due to automatic review settings August 22, 2026 22:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b4d4555bf7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/shared/src/usageMerge.ts Resolved
@macroscopeapp

macroscopeapp Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Skipped

Macroscope did not run approvability analysis for this PR. Macroscope could not determine whether this PR modifies its approvability configuration, so the PR was not approved automatically. A PR that may change the rules that govern approval is never approved automatically.

@Hylouis233 Hylouis233 mentioned this pull request Aug 22, 2026
3 of 4 tasks
@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Aug 22, 2026
Comment thread packages/shared/src/usageMerge.ts Resolved
Comment thread packages/shared/src/usageMerge.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d01c3af90

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/shared/src/usageMerge.ts Resolved
Comment thread apps/server/src/usage/UsageService.ts Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c70e660. Configure here.

Comment thread packages/shared/src/usageMerge.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c70e660a79

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/shared/src/usageMerge.ts Resolved
Comment thread apps/server/src/usage/UsageService.ts Resolved

Copy link
Copy Markdown
Contributor Author

Maintainer follow-up: all review threads are resolved across the four usage-provider PRs (#7877, #7904, #7936, and #7939). Their GitHub Actions runs are currently blocked at action_required, so no CI jobs have executed yet. Could a maintainer approve the fork workflows when convenient? I will rebase and advance the combined usage contract/cache version according to the eventual merge order.

@t3dotgg

t3dotgg commented Aug 23, 2026

Copy link
Copy Markdown
Member

Note

🤖 GPT-5.6 Sol responding on behalf of Theo

Closing this PR after an automated pass over open pull requests. Expands usage contracts and client interfaces for a provider that the product does not support.

@t3dotgg t3dotgg closed this Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants