Skip to content

feat(usage): include ZCode activity - #7877

Open
Hylouis233 wants to merge 11 commits into
pingdotgg:mainfrom
Hylouis233:feat/zcode-usage
Open

feat(usage): include ZCode activity#7877
Hylouis233 wants to merge 11 commits into
pingdotgg:mainfrom
Hylouis233:feat/zcode-usage

Conversation

@Hylouis233

@Hylouis233 Hylouis233 commented Aug 22, 2026

Copy link
Copy Markdown

Problem

T3 Code's Usage page only scans Codex and Claude Code history, so usage recorded by ZCode is missing from provider totals, charts, and model breakdowns.

What changed

  • scan ZCode's ~/.zcode/cli/db/db.sqlite model_usage rows read-only
  • include the SQLite WAL in the scan fingerprint so active writes invalidate the cache
  • normalize cached input without double counting and ignore incomplete attempts
  • make SQLite scans window-aware, wait through brief locks, and cache their coverage bounds
  • surface missing, partial, and failed provider coverage on web and mobile
  • negotiate v4/v5 responses so rolling client and server upgrades remain decodable
  • add ZCode presentation on web and mobile, plus user documentation

Verification

  • 10 focused usage test files: 90 tests passed
  • targeted server, contracts, shared, web, and mobile typechecks passed
  • focused lint, formatting, and git diff --check passed
  • compared upstream and this branch in isolated local dev instances; the ZCode provider row and chart band render with real local data and no browser-console errors

The before/after screenshots are intentionally omitted because the available captures contain private local usage totals.

Built with Codex (GPT-5).

Merge order

This PR and #7904 independently target the current v4 usage contract and therefore both introduce v5. Whichever merges second must be rebased and advance the combined contract version before it is ready to merge.

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

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: 781b5aea-2fe2-4a31-812f-c68b06b57135

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 PR 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 usage provider presentation: the new ZCode mark does not carry its declared brand tone, unlike the two existing provider marks.

Posted via Macroscope — UI Consistency

Comment thread apps/web/src/components/usage/usageProviders.ts Outdated
Comment thread packages/contracts/src/usage.ts
@Hylouis233

Hylouis233 commented Aug 22, 2026

Copy link
Copy Markdown
Author

All code-side checks are green on latest HEAD 5f72a303: vp check (0 errors), all 15 workspace typechecks, 70 focused usage/web tests, and the full desktop production build/preload verification all pass. Macroscope Effect and UI checks are green; earlier latest-content Correctness and Cursor reviews were also clean, and the refreshed Cursor review is still running. The upstream CI, Mobile Fingerprint Check, Mobile EAS Preview, and Web Preview runs remain action_required because this is a first-time fork contribution. Could a repository admin please approve the latest fork workflow runs when convenient?

@Hylouis233
Hylouis233 marked this pull request as ready for review August 22, 2026 12:05
Copilot AI lite review requested due to automatic review settings August 22, 2026 12:05

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: 739df49a2c

ℹ️ 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/contracts/src/usage.ts
Comment thread apps/server/src/usage/usageTranscriptReader.ts Outdated
Comment thread apps/server/src/usage/usageTranscriptReader.ts

@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.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 739df49. Configure here.

Comment thread apps/server/src/usage/usageTranscriptReader.ts
@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.

Comment thread apps/server/src/usage/UsageService.ts
Comment thread apps/server/src/usage/UsageService.ts Outdated

@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: ee01b7bd6c

ℹ️ 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 apps/server/src/usage/UsageService.ts Outdated

@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 consistency issue found in the web usage UI: the time-breakdown table's empty-state cell still assumes two providers.

Posted via Macroscope — UI Consistency

@macroscopeapp

macroscopeapp Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

UI consistency finding (could not be anchored inline because the file is unchanged in this PR):

apps/web/src/components/usage/UsagePage.tsx:393 — time-breakdown empty state under-spans the table now that PROVIDER_ORDER has three entries.

The header row of that table renders 1 + PROVIDER_ORDER.length + 2 columns (now 6), but the "No activity in this window." cell is still hardcoded to colSpan={5}, so the message no longer spans the full width and the row gains a stray trailing cell under the Tokens column. Deriving the span from PROVIDER_ORDER keeps it correct as providers are added:

                         {breakdownPeriods.length === 0 ? (
                           <tr>
-                            <td colSpan={5} className="py-6 text-center text-muted-foreground">
+                            <td
+                              colSpan={PROVIDER_ORDER.length + 3}
+                              className="py-6 text-center text-muted-foreground"
+                            >
                               No activity in this window.
                             </td>

Posted via Macroscope — UI Consistency

Comment thread packages/shared/src/usageMerge.ts
@Hylouis233

Hylouis233 commented Aug 22, 2026

Copy link
Copy Markdown
Author

Fixed the outstanding time-breakdown empty-state colSpan finding from #7877 (comment) in da356cf. The span now derives from PROVIDER_ORDER.length + 3, with a regression test for the six-column ZCode layout.

@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: 5f72a3038c

ℹ️ 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/contracts/src/usage.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants