[PR #7648] [MERGED] feat(connections): Claude and ChatGPT plan usage in the subscription meter #7855

Closed
opened 2026-10-24 04:08:11 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7648
Author: @ylli-selmani
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ylli-selmani

Base: staging ← Head: feat/claude-subscription-usage


📝 Commits (6)

  • 77857de feat(connections): show Claude plan usage on Claude (Subscription) connections
  • f653a71 feat(connections): show ChatGPT plan usage on OpenAI (ChatGPT) connections
  • 8363048 feat(connections): show when NanoGPT's usage window resets
  • 9b13745 fix(connections): never read a reset under an hour away as "in 0h"
  • 093670e docs(connections): say the NanoGPT meter shows when its window resets
  • 12dd69a fix(connections): read Claude plan usage with the same Claude Code as chat

📊 Changes

23 files changed (+838 additions, -110 deletions)

View changed files

📝 docs/connections/providers-reference.md (+32 -1)
📝 e2e/nanogpt-usage.e2e.ts (+2 -2)
📝 packages/client/src/components/chat/QuickConnectionSwitcher.tsx (+4 -4)
📝 packages/client/src/components/chat/QuickSwitcherMobile.tsx (+4 -4)
📝 packages/client/src/components/connections/ConnectionEditor.tsx (+91 -31)
📝 packages/client/src/components/connections/SubscriptionUsageWidget.tsx (+116 -25)
📝 packages/client/src/features/chat-settings/sections/ConnectionSection.tsx (+5 -5)
📝 packages/client/src/hooks/use-connections.ts (+8 -4)
📝 packages/client/src/lib/connection-filters.ts (+29 -5)
📝 packages/client/src/lib/relative-time.ts (+19 -0)
📝 packages/client/src/localization/locales/en.json (+13 -0)
📝 packages/server/src/db/schema/connections.ts (+4 -1)
📝 packages/server/src/routes/connections.routes.ts (+37 -5)
➕ packages/server/src/services/llm/openai-chatgpt-usage.ts (+104 -0)
📝 packages/server/src/services/llm/providers/claude-subscription.provider.ts (+1 -1)
➕ packages/server/src/services/llm/providers/claude-subscription/plan-usage.ts (+117 -0)
📝 packages/server/src/services/storage/connections.storage.ts (+10 -5)
📝 packages/shared/src/constants/providers.ts (+13 -0)
📝 packages/shared/src/schemas/connection.schema.ts (+4 -1)
📝 packages/shared/src/types/connection.ts (+30 -1)

...and 3 more files

📄 Description

Requested by Ylli

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7646

Why this change

  • The subscription usage meter from #6686 only knew NanoGPT. Claude (Subscription) and OpenAI (ChatGPT) connections run on plans with a 5-hour and a weekly limit, and the only way to see them was to leave Marinara for Claude Code, Codex or claude.ai. From a phone there was no quick way at all. These windows are shared with everything else on the account, so they run out by surprise more easily than NanoGPT's weekly tokens.
  • The NanoGPT meter said how much was used but not when the window resets, although NanoGPT reports it.

What changed

  • Claude (Subscription) plan usage. The server reads the plan's 5-hour and weekly windows through the Claude Agent SDK Marinara already ships (the data behind Claude Code's /usage). No prompt is sent, so a reading spends nothing. The SDK marks this call as experimental, so it lives in one file (claude-subscription/plan-usage.ts) and a failure shows "unavailable", never a fake 0%.
  • OpenAI (ChatGPT) plan usage. The server reads the same two windows from the endpoint the Codex CLI uses for its own limits, with the existing Codex login (openai-chatgpt-usage.ts).
  • Per-window switches. Under Show subscription usage, each Claude or ChatGPT connection gets 5-hour window and Weekly window checkboxes, both on by default. The server only reads the windows that are on.
  • One meter for all three providers. NanoGptUsageWidget became SubscriptionUsageWidget, and the gate and hook got provider-neutral names. Plan windows render as "58% · resets in 2h" in the connection editor, the chat's Connection settings and the Connections quick switcher (desktop and phone).
  • NanoGPT reset time. The editor and chat settings read "42M remaining · resets in 4d" under the bar, and the quick switcher shows "resets in 4d" beside the percentage.
  • Docs. A "Plan usage" section for both providers in docs/connections/providers-reference.md.
  • Regressions. claude-plan-usage and openai-chatgpt-plan-usage cover window parsing, fractions and unavailable plans; nanogpt-usage-meter-gate covers the new providers.

Plans report percentages and reset times only, and their numbers are account-wide, not Marinara's share; the editor says so under the bars. Grok CLI (Subscription) is left out because it has no documented way to read usage, and Google Vertex AI is pay-per-use. Other subscriptions with a usage endpoint can be added later on the same windows shape.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

What the agent ran: pnpm check (including the build) passed after the rebase onto current staging, and node scripts/run-regressions.mjs --filter plan-usage / --filter nanogpt passed (6/6). The Claude meter was checked against a real Pro plan, and the NanoGPT "resets in" against a real NanoGPT subscription, both in the editor and the quick switcher. Local CodeRabbit found two items: a reset just under an hour away could read "in 0h" (fixed), and the docs-i18n follow-up (opened, see below).

Still to verify by hand:

  • Manually verify a live ChatGPT reading with a ChatGPT plan signed in through codex login. It has only been tested against the payload shape from the Codex source.
  • Manually verify the meter in the light theme and on a phone-width viewport.
  • Manually verify that turning Weekly window off removes that bar in all three places.
  • Manually verify a Claude (Subscription) connection with an API key says it has no plan windows.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

docs/connections/providers-reference.md changed; the translated packs are tracked in #7647.

UI evidence (if applicable)

Screenshots to be attached: the Claude meter in the connection editor, the quick switcher, and the NanoGPT "resets in" in both.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added subscription usage meters for Claude Subscription and OpenAI ChatGPT connections, alongside NanoGPT.
    • Added controls to show or hide five-hour and weekly usage periods independently.
    • Usage meters display plan limits, percentage used, and reset times where available.
  • Documentation
    • Clarified which account limits are shown, how usage data is reported, and what to expect when usage data is unavailable.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7648 **Author:** [@ylli-selmani](https://github.com/ylli-selmani) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ylli-selmani](https://github.com/ylli-selmani) **Base:** `staging` ← **Head:** `feat/claude-subscription-usage` --- ### 📝 Commits (6) - [`77857de`](https://github.com/Pasta-Devs/Marinara-Engine/commit/77857de6ec4a471be52337995dfc0eb47c527d5a) feat(connections): show Claude plan usage on Claude (Subscription) connections - [`f653a71`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f653a71dd5c123fa25a34f3c3d7c80f5ff7d5a9c) feat(connections): show ChatGPT plan usage on OpenAI (ChatGPT) connections - [`8363048`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8363048d03e1ea9b04f6c6fbabe7018d368b1cf8) feat(connections): show when NanoGPT's usage window resets - [`9b13745`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9b137458af6f91f917364bb388353dc42929b4da) fix(connections): never read a reset under an hour away as "in 0h" - [`093670e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/093670ebd181495e59da8bb5a322c7c78ac869aa) docs(connections): say the NanoGPT meter shows when its window resets - [`12dd69a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/12dd69a06774e71c8431865994d1e60f504d5068) fix(connections): read Claude plan usage with the same Claude Code as chat ### 📊 Changes **23 files changed** (+838 additions, -110 deletions) <details> <summary>View changed files</summary> 📝 `docs/connections/providers-reference.md` (+32 -1) 📝 `e2e/nanogpt-usage.e2e.ts` (+2 -2) 📝 `packages/client/src/components/chat/QuickConnectionSwitcher.tsx` (+4 -4) 📝 `packages/client/src/components/chat/QuickSwitcherMobile.tsx` (+4 -4) 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+91 -31) 📝 `packages/client/src/components/connections/SubscriptionUsageWidget.tsx` (+116 -25) 📝 `packages/client/src/features/chat-settings/sections/ConnectionSection.tsx` (+5 -5) 📝 `packages/client/src/hooks/use-connections.ts` (+8 -4) 📝 `packages/client/src/lib/connection-filters.ts` (+29 -5) 📝 `packages/client/src/lib/relative-time.ts` (+19 -0) 📝 `packages/client/src/localization/locales/en.json` (+13 -0) 📝 `packages/server/src/db/schema/connections.ts` (+4 -1) 📝 `packages/server/src/routes/connections.routes.ts` (+37 -5) ➕ `packages/server/src/services/llm/openai-chatgpt-usage.ts` (+104 -0) 📝 `packages/server/src/services/llm/providers/claude-subscription.provider.ts` (+1 -1) ➕ `packages/server/src/services/llm/providers/claude-subscription/plan-usage.ts` (+117 -0) 📝 `packages/server/src/services/storage/connections.storage.ts` (+10 -5) 📝 `packages/shared/src/constants/providers.ts` (+13 -0) 📝 `packages/shared/src/schemas/connection.schema.ts` (+4 -1) 📝 `packages/shared/src/types/connection.ts` (+30 -1) _...and 3 more files_ </details> ### 📄 Description <!-- claude-projects-attribution: {"github_login":"bobneumann77-hub"} --> _Requested by **Ylli**_ > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7646 ## Why this change - The subscription usage meter from #6686 only knew NanoGPT. Claude (Subscription) and OpenAI (ChatGPT) connections run on plans with a 5-hour and a weekly limit, and the only way to see them was to leave Marinara for Claude Code, Codex or claude.ai. From a phone there was no quick way at all. These windows are shared with everything else on the account, so they run out by surprise more easily than NanoGPT's weekly tokens. - The NanoGPT meter said how much was used but not when the window resets, although NanoGPT reports it. ## What changed - **Claude (Subscription) plan usage.** The server reads the plan's 5-hour and weekly windows through the Claude Agent SDK Marinara already ships (the data behind Claude Code's `/usage`). No prompt is sent, so a reading spends nothing. The SDK marks this call as experimental, so it lives in one file (`claude-subscription/plan-usage.ts`) and a failure shows "unavailable", never a fake 0%. - **OpenAI (ChatGPT) plan usage.** The server reads the same two windows from the endpoint the Codex CLI uses for its own limits, with the existing Codex login (`openai-chatgpt-usage.ts`). - **Per-window switches.** Under **Show subscription usage**, each Claude or ChatGPT connection gets **5-hour window** and **Weekly window** checkboxes, both on by default. The server only reads the windows that are on. - **One meter for all three providers.** `NanoGptUsageWidget` became `SubscriptionUsageWidget`, and the gate and hook got provider-neutral names. Plan windows render as "58% · resets in 2h" in the connection editor, the chat's Connection settings and the Connections quick switcher (desktop and phone). - **NanoGPT reset time.** The editor and chat settings read "42M remaining · resets in 4d" under the bar, and the quick switcher shows "resets in 4d" beside the percentage. - **Docs.** A "Plan usage" section for both providers in `docs/connections/providers-reference.md`. - **Regressions.** `claude-plan-usage` and `openai-chatgpt-plan-usage` cover window parsing, fractions and unavailable plans; `nanogpt-usage-meter-gate` covers the new providers. Plans report percentages and reset times only, and their numbers are account-wide, not Marinara's share; the editor says so under the bars. Grok CLI (Subscription) is left out because it has no documented way to read usage, and Google Vertex AI is pay-per-use. Other subscriptions with a usage endpoint can be added later on the same `windows` shape. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes What the agent ran: `pnpm check` (including the build) passed after the rebase onto current staging, and `node scripts/run-regressions.mjs --filter plan-usage` / `--filter nanogpt` passed (6/6). The Claude meter was checked against a real Pro plan, and the NanoGPT "resets in" against a real NanoGPT subscription, both in the editor and the quick switcher. Local CodeRabbit found two items: a reset just under an hour away could read "in 0h" (fixed), and the docs-i18n follow-up (opened, see below). Still to verify by hand: - Manually verify a **live ChatGPT reading** with a ChatGPT plan signed in through `codex login`. It has only been tested against the payload shape from the Codex source. - Manually verify the meter in the **light theme** and on a **phone-width viewport**. - Manually verify that turning **Weekly window** off removes that bar in all three places. - Manually verify a Claude (Subscription) connection **with an API key** says it has no plan windows. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) `docs/connections/providers-reference.md` changed; the translated packs are tracked in #7647. ## UI evidence (if applicable) Screenshots to be attached: the Claude meter in the connection editor, the quick switcher, and the NanoGPT "resets in" in both. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added subscription usage meters for Claude Subscription and OpenAI ChatGPT connections, alongside NanoGPT. * Added controls to show or hide five-hour and weekly usage periods independently. * Usage meters display plan limits, percentage used, and reset times where available. * **Documentation** * Clarified which account limits are shown, how usage data is reported, and what to expect when usage data is unavailable. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:08:11 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7855
No description provided.