Fix skip token-usage API calls in OSS mode — fetch only in cloud #3
Merged
wicky-zipstack merged 5 commits intomainfrom Mar 25, 2026
Merged
Fix skip token-usage API calls in OSS mode — fetch only in cloud #3wicky-zipstack merged 5 commits intomainfrom
wicky-zipstack merged 5 commits intomainfrom
Conversation
wicky-zipstack
added a commit
that referenced
this pull request
Mar 26, 2026
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
##What
Removes getTokenUsage from the OSS codebase and makes it a cloud-only optional import. The token-usage API is no longer called in OSS mode.
Files changed:
##Why
The getTokenUsage function calls a token-usage API backed by the subscriptions module, which only exists in cloud. Having it in the OSS service layer caused:
This aligns getTokenUsage with the existing pattern used for other cloud-only features (fetchOrganizationTokenBalance, getTokenBalance, TokenTopupDrawer) —
optional try { require(...) } catch {} imports that resolve to null in OSS.
##How
Frontend:
let getTokenUsage = null;
try {
({ getTokenUsage } = require("../../plugins/token-management/token-usage"));
} catch {
// OSS: token usage API not available
}
in cloud mode AND there are messages to fetch
Backend:
5. Reverted message_views.py — removed the fake 200 fallback response for token_data is None and restored the proper 500 error. This endpoint is now only called
from cloud, so the OSS workaround is unnecessary.
##Can this PR break any existing features?
OSS: No. The token-usage API call is completely skipped. Previously it was called and silently returned zeroed data with token_tracking_available: false —
removing it has no user-visible impact.
Cloud: No, provided the companion cloud PR (adding plugins/token-management/token-usage.js) is merged first or simultaneously. If the cloud plugin is temporarily
missing, the try/catch gracefully falls back to null and token usage simply doesn't load — no crash, no error.
##Dependencies
##Testing
Checklist
I have read and understood the Contribution Guidelines.