mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #6686] [MERGED] Feat/nano gpt sub usage indicator #7287
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#7287
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6686
Author: @ylli-selmani
Created: 9/25/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/nanoGPTSubUsageIndicator📝 Commits (10+)
cbb4e13feat(connections): show NanoGPT subscription usage and model quota coste4c4195fix(connections): show the NanoGPT usage meter in the chat HUD8168471feat(connections): show the NanoGPT meter in the connection picker6ab6f41feat(connections): label the usage meter and fit it to the picker57eb404fix(connections): de-duplicate the compact meter and re-card the panel19bf96efix(connections): theme the quota bar and drop the leftover percentage09bc52bfix(connections): restore spacing around the usage toggle and theme it22f45b2fix(chat-settings): space the usage meter from the connection select394f97dfix(connections): address review findings on the NanoGPT usage feature45dc64bMerge branch 'staging' into feat/nanoGPTSubUsageIndicator📊 Changes
24 files changed (+1483 additions, -36 deletions)
View changed files
📝
CHANGELOG.md(+2 -0)📝
docs/connections/providers-reference.md(+20 -0)➕
e2e/nanogpt-usage.e2e.ts(+97 -0)📝
packages/client/src/components/chat/ChatSettingsDrawer.tsx(+9 -18)📝
packages/client/src/components/chat/QuickConnectionSwitcher.tsx(+26 -3)📝
packages/client/src/components/chat/QuickSwitcherMobile.tsx(+22 -2)📝
packages/client/src/components/connections/ConnectionEditor.tsx(+144 -1)➕
packages/client/src/components/connections/NanoGptUsageWidget.tsx(+319 -0)📝
packages/client/src/features/chat-settings/sections/ConnectionSection.tsx(+23 -5)📝
packages/client/src/hooks/use-connections.ts(+44 -0)📝
packages/client/src/lib/connection-filters.ts(+13 -0)➕
packages/client/src/lib/nanogpt-quota.ts(+36 -0)📝
packages/client/src/localization/locales/en.json(+35 -0)📝
packages/server/src/db/schema/connections.ts(+7 -0)📝
packages/server/src/routes/backup.routes.ts(+4 -1)📝
packages/server/src/routes/connections.routes.ts(+61 -3)➕
packages/server/src/services/nanogpt/subscription-usage.ts(+234 -0)📝
packages/server/src/services/storage/connections.storage.ts(+33 -2)📝
packages/shared/src/schemas/connection.schema.ts(+8 -0)📝
packages/shared/src/types/connection.ts(+2 -0)...and 4 more files
📄 Description
Linked issue
Closes #6684
Why this change
leaving Marinara for the NanoGPT dashboard, and the model dropdown gives no hint
which models are covered, which cost more of the quota, and which bill to the
paid balance instead. You find out you are near the limit when generation starts
failing, and the expensive model looks identical to the cheap one.
What changed
1. An optional Management Token field on NanoGPT connections, below the API
key. A management token can be created with a
usage:read-only scope, so thecredential used for quota reads cannot spend balance. It is preferred when
present; the API key is used as a fallback when it is not. Can be cleared with a toggle
that triggers on connection save.
2. A per-connection "Show subscription usage" toggle (off by default) that
displays weekly and daily input-token quotas in three places: the connection
editor, the chat settings connection section, and the inline connection picker
above the composer. The picker variant mirrors the context budget bar directly
above it.
3. Model list indicators, from the
subscriptionblock already returned bythe existing
detailed=truemodels call, so they cost no extra request:Nxpill (accent) when the subscription covers the model and it consumes morethan one input token per token sent
1xpill when covered at the normal ratePaidpill when the model is not in the subscriptionDesign decisions worth reviewing
The management token is a quota-widget credential, not an API-key substitute.
NanoGPT's management endpoint rejects inference keys, and the inference endpoint
rejects management tokens, so the two are not interchangeable. The widget tries
the management token first and falls back to the API key.
Both endpoint hosts are hardcoded. Neither is derivable from the stored base
URL (
https://nano-gpt.com/api/v1). Management tokens only work againstnano-gpt.com/...(noapi.prefix); inference keys only againstapi.nano-gpt.com/....The multiplier pill only renders for
included: true. Excluded models reporta multiplier of 1, which would otherwise read as full subscription coverage.
"Unknown" is rendered as unknown, never as 0% or 100%. A
degraded: trueresponse with null counters has no honest bar to draw.
percentUsedis a fraction and may exceed 1, so the bar clamps rather thanoverflowing.
subscription.includedis free from thedetailed=truecall already beingmade, so the
Paidpill adds no requests.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
connection with the toggle enabled, and does not appear with it disabled
spaced correctly from the select above it
not appear when the active connection is Random
gradient accent setting
"via API key" to "via management token"
1x/2x/Paidpills against a real NanoGPT model listin duplicated connection.
Docs and release impact
No docs changes needed
Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
Translated docs on the
docs-i18nbranch 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)
Notes for the reviewer
subscription.inputTokenMultiplieris not in NanoGPT's published OpenAPIdump, but it is returned by the live API and was verified by direct request. It
is nested under
subscriptionalongsideincluded. Happy to drop themultiplier pill if you would rather not depend on an undocumented field.
The new columns use defaults, so no migration and no
STORAGE_VERSIONbump:normalizeRow()backfills missing columns viadefaultForColumn().Both new columns are cleared when a connection's provider changes away from
NanoGPT.
Docs:
docs/connections/providers-reference.mdis updated. PerAGENTS.mdthis needs a
docs-i18nmirror or a[docs-i18n]follow-up issue — flaggingrather than assuming which you prefer.
Future providers: what this widget already supports
The meter is deliberately provider-shaped rather than NanoGPT-shaped, so a later
PR can extend it. Three seams exist today:
Already reusable without change
QuotaBarand the widget shell contain no provider logic. Their only NanoGPTreferences are the import, the hook call, and the type/component names.
nanogpt-quota.tsoperates on a structuralQuotaWindowLike(used/remaining/percentUsed), not on NanoGPT's concrete type. Any provider thatcan produce those three numbers reuses this file as-is.
data.credential), not by aprovider check.
providerDisplayName()reads the sharedPROVIDERScatalog, so a secondprovider is labelled from its own definition.
Requires work before a second provider can report usage
resolveNanoGptUsageConnectionhardcodesprovider !== "nanogpt". All threerender sites gate through it, so it needs to resolve which providers support a
meter instead of naming one.
GET /connections/:id/subscription-usagerejects non-NanoGPT connections andis a single-provider path; the client hook hardcodes that URL.
credentialenum is"management_token" | "api_key", which isNanoGPT-specific vocabulary that other providers will not share.
managementTokenEncryptedis provider-shaped storage.showUsageWidgetisalready generic.
Note on providers with no endpoint
Claude (Subscription) and Grok CLI route through local harnesses rather than a
quota API, and NovelAI's Opus tier for diffusion v5 exposes no usage endpoint
today. The current
degraded: truepath means "the lookup failed, counters areunknown" — it assumes a lookup was attempted. A provider with no usage
capability at all is a different state and should simply not render the meter,
rather than render a permanent unknown. Worth deciding before the next provider
lands, but out of scope here.
No refactor is included in this PR: the shape of the next provider's API is not
known yet, and guessing at it would add abstraction without a caller.
UI evidence (if applicable)
Mobile
PC - On States
Other Providers | or toggled off
new ui after coderabbit review
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.