Skip to content

feat(zai): add weekly usage tracking#255

Merged
validatedev merged 7 commits intorobinebers:mainfrom
musashi3814:feat/zai-weekly-usage-tracking
Mar 4, 2026
Merged

feat(zai): add weekly usage tracking#255
validatedev merged 7 commits intorobinebers:mainfrom
musashi3814:feat/zai-weekly-usage-tracking

Conversation

@musashi3814
Copy link
Contributor

@musashi3814 musashi3814 commented Mar 1, 2026

Description

Z.ai (BigModel / Zhipu AI) operates on a weekly reset cycle for many of its usage quotas. The API now returns a TOKENS_LIMIT entry with unit: 6 representing the 7-day weekly limit. This implementation adds support for parsing and displaying this weekly quota.

Related Issue

#242

Type of Change

  • Bug fix
  • New feature
  • New provider plugin
  • Documentation
  • Performance improvement
  • Other (describe below)

Testing

  • I ran bun run build and it succeeded
  • I ran bun run test and all tests pass
  • I tested the change locally with bun tauri dev

Screenshots

スクリーンショット 2026-03-01 18 04 55

Checklist

  • I read CONTRIBUTING.md
  • My PR targets the main branch
  • I did not introduce new dependencies without justification

Additional Context

Please refer to Z.ai url.
https://z.ai/manage-apikey/subscription


Summary by cubic

Adds weekly usage tracking for Z.ai token quotas on a 7-day cycle, with a new Weekly progress line. Makes limit parsing unit-aware, aligns line order with runtime output, and updates docs/tests.

  • New Features

    • Support TOKENS_LIMIT unit: 6 with a "Weekly" progress line (percent, resetsAt, 7-day period).
    • Add WEEK_MS and periodDurationMs; update README/docs; add tests for Weekly values.
  • Bug Fixes

    • Bind Session to TOKENS_LIMIT unit: 3 via unit-aware findLimit with fallback to entries without unit.
    • Guard Weekly percentage with Number.isFinite; enforce Session → Weekly → Web Searches order; add test for weekly appearing first.

Written for commit 28bc9c1. Summary will update on new commits.

musashi3814 and others added 3 commits March 1, 2026 18:08
Add support for Z.ai's weekly usage limit (unit: 6) to track
token usage on a 7-day rolling period.

Changes:
- Add WEEK_MS constant for 7-day period
- Update findLimit() to accept optional unit parameter
- Add Weekly progress line for TOKENS_LIMIT with unit: 6
- Update plugin.json with Weekly line definition
- Add tests for Weekly line rendering
- Update documentation

Closes robinebers#242

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 5 files

davidarny
davidarny previously approved these changes Mar 1, 2026
Copy link
Collaborator

@davidarny davidarny left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds weekly quota support to the Z.ai provider to reflect the API’s new weekly tokens limit, and surfaces it in the UI/docs.

Changes:

  • Parse TOKENS_LIMIT with unit: 6 and render a new Weekly progress line (percent + reset time + 7-day period).
  • Expose Weekly in the Z.ai plugin manifest overview lines.
  • Update docs/README and add Vitest coverage for the new Weekly line.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
plugins/zai/plugin.js Adds weekly period constant, extends limit selection helper, and emits a new “Weekly” progress line.
plugins/zai/plugin.json Adds “Weekly” to the plugin’s overview line manifest.
plugins/zai/plugin.test.js Adds fixtures and tests validating Weekly line rendering/reset metadata.
docs/providers/zai.md Documents the new weekly quota line and updated API details.
README.md Updates provider capability summary to include weekly for Z.ai.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@validatedev
Copy link
Collaborator

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3dba7a9f10

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- Reorder lines in plugin.json to match runtime output order (Session -> Weekly -> Web Searches)
- Make findLimit unit-aware for Session to correctly bind to unit 3, with fallback to first entry without unit
- Add Number.isFinite check for weeklyTokenLimit.percentage
- Add test case for weekly appearing before session in API response

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@robinebers
Copy link
Owner

@cubic-dev-ai review

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Mar 3, 2026

@cubic-dev-ai review

@robinebers I have started the AI code review. It will take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/providers/zai.md">

<violation number="1" location="docs/providers/zai.md:16">
P2: Conflicting web-search reset semantics in the same provider doc (renewal-date-based vs 1st-of-month).</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Owner

@robinebers robinebers left a comment

Choose a reason for hiding this comment

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

LGTM

@musashi3814
Copy link
Contributor Author

thank you for your feedback!!

@musashi3814
Copy link
Contributor Author

@validatedev @robinebers @davidarny
Could you please "Approve and run" the GitHub Actions workflow for my PR? It's currently pending approval as a first-time contributor.

@davidarny
Copy link
Collaborator

@musashi3814 sure no problem

Copy link
Collaborator

@validatedev validatedev left a comment

Choose a reason for hiding this comment

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

LGTM!

@validatedev validatedev merged commit 4951f69 into robinebers:main Mar 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants