Skip to content

Conversation

@roomote
Copy link

@roomote roomote bot commented Sep 15, 2025

This PR attempts to address Issue #8001. Feedback and guidance are welcome.

Summary

Adds a toggle in Settings > Providers > Z AI to enable GLM Coding Plan routing, allowing users with an active plan to use it instead of API credits.

Changes

  • Added zaiUseGlmCodingPlan field to provider settings schema
  • Updated ZAiHandler to route requests through coding plan endpoints when enabled:
    • International: https://api.z.ai/api/coding/paas/v4
    • China: https://open.bigmodel.cn/api/coding/paas/v4
  • Added UI toggle with appropriate labels and descriptions
  • Added comprehensive test coverage for the new functionality
  • Added English translation keys

Behavior

  • Toggle is OFF by default (uses standard API endpoints)
  • When ON: Routes through GLM Coding Plan endpoints
  • When OFF: Routes through standard API endpoints
  • User preference is persisted in settings

Testing

  • ✅ All existing tests pass
  • ✅ New tests added for both regions and toggle states
  • ✅ TypeScript compilation successful
  • ✅ Linting passed

Notes

  • When plan limits are reached, users can manually toggle OFF to continue with API credits
  • No automatic fallback implemented (as per requirements)

Closes #8001


Important

Adds GLM Coding Plan toggle to Z AI provider settings, updating routing logic, UI, and tests.

  • Behavior:
    • Adds zaiUseGlmCodingPlan toggle in Z AI provider settings to route requests through GLM Coding Plan endpoints.
    • Default is OFF; when ON, routes through GLM Coding Plan endpoints.
    • User preference is saved in settings.
  • Schema:
    • Adds zaiUseGlmCodingPlan to zaiSchema in provider-settings.ts.
  • Handler:
    • Updates ZAiHandler in zai.ts to use GLM Coding Plan URLs based on toggle and region.
  • UI:
    • Adds checkbox for GLM Coding Plan in ZAi.tsx with labels and descriptions.
    • Adds English translation keys in settings.json.
  • Testing:
    • Adds tests in zai.spec.ts for GLM Coding Plan toggle behavior and URL routing.

This description was created by Ellipsis for 5f6f2be. You can customize this summary. It will automatically update as commits are pushed.

- Add zaiUseGlmCodingPlan field to provider settings schema
- Update ZAiHandler to route requests through coding plan endpoints when enabled
- Add UI toggle in Z AI settings with appropriate labels and descriptions
- Add comprehensive tests for the new functionality
- Add English translation keys for the new toggle

This allows users with a Z AI GLM Coding Plan to use their plan instead of API credits
@roomote roomote bot requested review from cte, jr and mrubens as code owners September 15, 2025 20:06
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Sep 15, 2025
Copy link
Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

I reviewed my own code and found 17 missing translations. Classic me.

"zaiEntrypoint": "Z AI Entrypoint",
"zaiEntrypointDescription": "Please select the appropriate API entrypoint based on your location. If you are in China, choose open.bigmodel.cn. Otherwise, choose api.z.ai.",
"zaiUseGlmCodingPlan": "Use GLM Coding Plan",
"zaiUseGlmCodingPlanDescription": "Route requests through GLM Coding Plan endpoints to use your plan instead of API credits. When plan limits are reached, disable this toggle to continue with API credits.",
Copy link
Author

Choose a reason for hiding this comment

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

Critical issue: You've only added the new translation keys to the English locale. All other 17 supported languages are missing and , which will cause the UI to display missing translation keys for non-English users.

Could we add placeholder translations or at least copy the English text to other locales to prevent broken UI?

let baseURL: string
if (options.zaiUseGlmCodingPlan) {
// Use coding plan endpoints
baseURL = isChina ? "https://open.bigmodel.cn/api/coding/paas/v4" : "https://api.z.ai/api/coding/paas/v4"
Copy link
Author

Choose a reason for hiding this comment

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

The implementation looks clean, but I notice there's no error handling specific to GLM Coding Plan failures. The issue mentions showing "a brief notice explaining the situation" when plan limits are reached.

Is this intentional? Should we consider adding a try-catch that could detect plan limit errors and provide user feedback?

const models = isChina ? mainlandZAiModels : internationalZAiModels
const defaultModelId = isChina ? mainlandZAiDefaultModelId : internationalZAiDefaultModelId

// Determine the base URL based on region and GLM Coding Plan toggle
Copy link
Author

Choose a reason for hiding this comment

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

Consider adding a comment here explaining the endpoint routing logic for future maintainability:

</div>
<div>
<VSCodeCheckbox
checked={apiConfiguration?.zaiUseGlmCodingPlan || false}
Copy link
Author

Choose a reason for hiding this comment

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

Should we validate that the API key is configured before allowing the GLM Coding Plan toggle to be enabled? Users might enable this without having set up their API key first.

Consider disabling the checkbox when or showing a warning message.

new ZAiHandler({ zaiApiKey: "test-zai-api-key", zaiApiLine: "international", zaiUseGlmCodingPlan: true })
expect(OpenAI).toHaveBeenCalledWith(
expect.objectContaining({ baseURL: "https://api.z.ai/api/coding/paas/v4" }),
)
Copy link
Author

Choose a reason for hiding this comment

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

Good test coverage for the basic functionality! Consider adding edge case tests:

  • What happens when switching regions while GLM Coding Plan is enabled?
  • How does it behave with missing API key but toggle enabled?
  • Could we test the actual API error responses when plan limits are hit?

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 15, 2025
@daniel-lxs
Copy link
Member

Closed by #8003

@daniel-lxs daniel-lxs closed this Sep 15, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Sep 15, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Z AI: Toggle to use GLM Coding Plan

5 participants