Skip to content

feat(desktop): show token and compute usage - #79066

Merged
trunk-io[bot] merged 6 commits into
masterfrom
posthog-code/desktop-app-usage-ui
Aug 7, 2026
Merged

feat(desktop): show token and compute usage#79066
trunk-io[bot] merged 6 commits into
masterfrom
posthog-code/desktop-app-usage-ui

Conversation

@adboio

@adboio adboio commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Problem

PostHog Desktop users can see combined organization usage but cannot distinguish token spend from cloud-compute usage. The page also mixes organization billing with personal analysis without clearly explaining their different scope and freshness.

Changes

Screenshot 2026-08-06 at 3.27.24 PM.png

  • Shows token and cloud-compute spend while keeping combined usage as the only authoritative meter and limit.
  • Shows CPU core-seconds and memory GiB-seconds without prices or independent limits.
  • Removes the redundant usage-based billing status card.
  • Combines the organization meter and component breakdown into one billing surface.
  • Separates near-real-time personal spend analysis from delayed organization billing.
  • Treats a missing breakdown as awaiting data and preserves explicit zero values.
  • Keeps existing exhaustion, upgrade, and Plan & Usage navigation behavior.
  • Depends on #76889 for the optional gateway response field. It does not depend on compute enforcement.
  • Adds Storybook states for standard, loading, unavailable, explicit-zero, and exhausted usage.

How did you test this code?

  • Ran focused usage-display tests covering conversion, missing values, explicit zero, and large integers.
  • Ran gateway client tests covering the optional breakdown wire shape.
  • Ran Desktop core and UI type checks.
  • Built Storybook and reviewed the primary Plan & Usage story at desktop size.
  • Did not manually test the packaged Electron application.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Automatic notifications

  • Publish to changelog?

Docs update

No documentation changes. The Plan & Usage surface explains scope, units, and freshness in context.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Authored with PostHog Code using the local /frontend-design skill. The page now treats combined organization usage as the billing ledger and personal analysis as a separate near-real-time workspace.


Created with PostHog Code

@trunk-io

trunk-io Bot commented Aug 6, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions github-actions Bot added the feature/desktop Feature Tag: Desktop label Aug 6, 2026
@adboio
adboio requested a review from a team August 6, 2026 19:34
@adboio
adboio marked this pull request as ready for review August 6, 2026 19:35
@adboio adboio added the stamphog Request AI approval (no full review) label Aug 6, 2026 — with Graphite App

@charlesvien charlesvien left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is really good, gonna help answer a lot of questions users keep asking in the Discord

@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
### Issue 1
products/desktop/packages/ui/src/features/settings/sections/PlanUsageSettings.tsx:343-345
**Disclosure resets selected window**

When a user selects another spend window, collapses “Your spend,” and expands it again, the conditional render remounts `SpendAnalysisSection` and resets its local state to the 30-day default, causing the analysis to display a different range than the user selected.

```suggestion
      {children && (
        <div
          hidden={!expanded}
          className="border-(--gray-5) border-t p-4"
        >
          {children}
        </div>
      )}
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "feat(desktop): collapse personal spend a..." | Re-trigger Greptile

Comment on lines +343 to +345
{expanded && children && (
<div className="border-(--gray-5) border-t p-4">{children}</div>
)}

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.

P1 Disclosure resets selected window

When a user selects another spend window, collapses “Your spend,” and expands it again, the conditional render remounts SpendAnalysisSection and resets its local state to the 30-day default, causing the analysis to display a different range than the user selected.

Suggested change
{expanded && children && (
<div className="border-(--gray-5) border-t p-4">{children}</div>
)}
{children && (
<div
hidden={!expanded}
className="border-(--gray-5) border-t p-4"
>
{children}
</div>
)}

Knowledge Base Used: Desktop App and Agent Framework

Prompt To Fix With AI
This is a comment left during a code review.
Path: products/desktop/packages/ui/src/features/settings/sections/PlanUsageSettings.tsx
Line: 343-345

Comment:
**Disclosure resets selected window**

When a user selects another spend window, collapses “Your spend,” and expands it again, the conditional render remounts `SpendAnalysisSection` and resets its local state to the 30-day default, causing the analysis to display a different range than the user selected.

```suggestion
      {children && (
        <div
          hidden={!expanded}
          className="border-(--gray-5) border-t p-4"
        >
          {children}
        </div>
      )}
```

**Knowledge Base Used:** [Desktop App and Agent Framework](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/posthog/-/docs/desktop-app.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@adboio

adboio commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

/trunk merge

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Hey @adboio! 👋

It looks like your git author email on this PR isn't your @posthog.com address (adambowker98@gmail.com). Since you're on the PostHog team, it's worth pointing your local git author email at your @posthog.com address. Why it matters:

  • Consistent work identity in git history — internal tooling that attributes commits to team members keys off your @posthog.com address.
  • Keeps team contributions easy to tell apart from external community ones when scanning history.

You can fix it for this repo with:

git config user.email "you@posthog.com"

Or set it globally with git config --global user.email "you@posthog.com". No need to redo this PR — just a nudge for next time. 🙂

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

React Doctor found 1 issue in 1 file · 1 warning.

1 warning

packages/ui/src/features/settings/sections/PlanUsageSettings.tsx

Reviewed by React Doctor for commit a0da4d8.

@trunk-io

trunk-io Bot commented Aug 6, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@adboio

adboio commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

/trunk merge

adboio added 5 commits August 7, 2026 11:15
Generated-By: PostHog Code
Task-Id: 7cc3caf7-5e0e-4d3d-b896-ee51a2f01856
Generated-By: PostHog Code
Task-Id: 7cc3caf7-5e0e-4d3d-b896-ee51a2f01856
Generated-By: PostHog Code
Task-Id: 7cc3caf7-5e0e-4d3d-b896-ee51a2f01856
Generated-By: PostHog Code
Task-Id: 7cc3caf7-5e0e-4d3d-b896-ee51a2f01856
Generated-By: PostHog Code
Task-Id: 7cc3caf7-5e0e-4d3d-b896-ee51a2f01856
@adboio
adboio force-pushed the posthog-code/desktop-app-usage-ui branch from 0114c31 to ad939f3 Compare August 7, 2026 15:16
@stamphog

stamphog Bot commented Aug 7, 2026

Copy link
Copy Markdown

Note

🤖 stamphog reviewed ad939f372a594a8a02464767b6dc01e5fac2683e — verdict: REFUSED

Gates denied this PR (deny-list match on billing-related content and it's classified as T2-never for size/scope), so it's outside auto-approval scope; also the author is not on the owning team and there's an unresolved inline concern about state reset on disclosure toggle.

  • 👍 on the PR from greptile-apps[bot], hex-security-app[bot].
  • Deny-list match: PR touches billing-related surface, which is excluded from automated approval by policy
  • Classified as T2-never by size/scope gates — requires human review regardless of content
  • Author adboio is not on the owning team @PostHog/team-posthog-code
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list matches: billing
size 581L, 7F substantive, 658L/9F incl. docs/generated/snapshots — within ceiling
tier classified as T2-never: T2-never (658L, 9F, single-area, feat)
stamphog 2.0.0b4 .stamphog/policy.yml @ 90b6195 · reviewed head ad939f3

@stamphog stamphog Bot removed the stamphog Request AI approval (no full review) label Aug 7, 2026
Generated-By: PostHog Code
Task-Id: 7cc3caf7-5e0e-4d3d-b896-ee51a2f01856
@trunk-io
trunk-io Bot merged commit e4302b2 into master Aug 7, 2026
195 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/desktop-app-usage-ui branch August 7, 2026 16:43
@deployment-status-posthog

deployment-status-posthog Bot commented Aug 7, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-08-07 17:22 UTC Run
prod-us ✅ Deployed 2026-08-07 17:38 UTC Run
prod-eu ✅ Deployed 2026-08-07 17:40 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature/desktop Feature Tag: Desktop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants