fix(api): parse zh-locale usage labels and reset phrases - #2
Open
waknow wants to merge 1 commit into
Open
Conversation
The opencode.ai dashboard renders usage labels in the UI locale. For a cookie with oc_locale=zh the labels are Chinese (rolling/weekly/monthly usage) and the reset phrase is '重置于' instead of 'Resets in', so the SSR scrape parsed every window as empty and the chip showed <err:http302> (cookie expired or invalid?) despite the cookie being valid. - labelToKind: recognize the Chinese labels - reset-time regex: accept both 'Resets in' and '重置于' - parseDurationToSec: accept Chinese time units (秒/分钟/小时/天/周/月/年) Adds a zh-locale SSR fixture and zh unit tests.
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.
Problem
The opencode.ai dashboard renders the usage page in the UI locale negotiated from the cookie. With oc_locale=zh the data-slot=usage-label values come back as Chinese (rolling/weekly/monthly usage in Chinese) and the reset phrase as Chinese instead of Resets in.
The SSR scraper in src/api.ts only recognizes the English labels and the English reset phrase, so with a zh-locale cookie:
Net effect: the chip shows err:http302 even though the cookie is perfectly valid.
Fix
Also rebuilt lib/ (the checked-in build output) so GitHub/npm installs work without a local build.
Tests
All 48 tests pass (pnpm test), typecheck and build pass.