Skip to content

fix(providers): promote weekly window to primary for Qwen Cloud - #284

Merged
Finesssee merged 3 commits into
nesszer:mainfrom
hellhole8:fix/qwencloud-weekly-window
Aug 16, 2026
Merged

Finesssee merged 3 commits into
nesszer:mainfrom
hellhole8:fix/qwencloud-weekly-window

Conversation

@hellhole8

@hellhole8 hellhole8 commented Aug 14, 2026 •

Copy link
Copy Markdown

Summary

Fixes Qwen Cloud individual plans that expose only the weekly usage window
(per1WeekPercentage, no per5HourPercentage / legacy quota). Previously
snapshot_to_usage failed with "Qwen Cloud usage windows missing"; now the
weekly window is promoted to primary.

Behavior change

  • Weekly-only accounts now show the weekly percentage (e.g. 84.39%) instead
    of no data / error.
  • When both windows exist, weekly remains secondary (unchanged).
  • Added test weekly_only_shape_promotes_weekly_to_primary with real-world
    fixture.

Commands run

  • cargo test -p codexbar qwencloud — 9/9 pass
  • cargo fmt --all

Validation

Validated in the desktop app (debug build): provider now shows the weekly
84.39% window correctly.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@Finesssee

Copy link
Copy Markdown
Collaborator

Thanks for the PR, I will review it ASAP

@Finesssee Finesssee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The weekly-only behavior fix is directionally correct and the existing tests protect normal five-hour/weekly precedence, but I am requesting changes before merge: model the primary/secondary result directly instead of retaining branch-history state, remove the unrelated redundant esbuild dependency, and run cargo fmt --all. The current required Local check fails cargo fmt --all --check at qwencloud/mod.rs:363.

Comment thread rust/src/providers/qwencloud/mod.rs Outdated
// Prefer the 5-hour window; fall back to the legacy 30-day envelope; if the
// account only exposes the weekly window (e.g. Qwen Cloud individual plans),
// promote it to primary instead of failing the whole fetch.
let has_five_hour_or_legacy = five_hour.is_some() || legacy.is_some();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This boolean preserves how we reached the result, which then forces weekly.clone() and a second conditional to reconstruct whether weekly was promoted. The actual model is just (primary, secondary). Please match directly on (five_hour.or(legacy), weekly): (Some(primary), secondary) => (primary, secondary), (None, Some(weekly)) => (weekly, None), and (None, None) => error. That deletes the flag and clone and keeps promotion plus secondary selection atomic, so those decisions cannot drift apart later.

Comment thread apps/desktop-tauri/package.json Outdated
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@vitejs/plugin-react": "4.7.0",
"esbuild": "^0.25.12",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please remove this from the Qwen parser fix. The base lockfile already resolves esbuild 0.25.12 through pinned vite 6.4.2, so making it a direct dependency does not change the installed version or address the current CI failure (which is Rust formatting). It also uses an open ^ range while every other direct dependency here is exact-versioned, despite the commit calling it pinned. If direct ownership is genuinely required, it should be an independently justified build change with an exact version.

@Finesssee
Finesssee force-pushed the fix/qwencloud-weekly-window branch from 35424d7 to f172ada Compare August 16, 2026 12:09
@Finesssee
Finesssee merged commit 566d620 into nesszer:main Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants