1
0
Fork 0
mirror of https://github.com/maziggy/bambuddy.git synced 2026-05-09 08:25:54 +02:00

[PR #1013] [MERGED] feat(cloud): support China region for token-based login #1151

Closed
opened 2026-05-07 00:16:18 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/maziggy/bambuddy/pull/1013
Author: @Minidoracat
Created: 4/17/2026
Status: Merged
Merged: 4/18/2026
Merged by: @maziggy

Base: devHead: feature/token-login-region-selector


📝 Commits (4)

  • adfee88 feat(cloud): support China region for token-based login
  • 97b6c6b Merge branch 'dev' into feature/token-login-region-selector
  • 40a70fe feat(cloud): persist region, drop singleton, fix login/verify parity
  • eebda84 feat(cloud): route-level region tests, status payload, shared http pool

📊 Changes

12 files changed (+558 additions, -193 deletions)

View changed files

📝 backend/app/api/routes/cloud.py (+128 -102)
📝 backend/app/api/routes/inventory.py (+34 -29)
📝 backend/app/core/database.py (+1 -0)
📝 backend/app/main.py (+17 -0)
📝 backend/app/models/user.py (+2 -0)
📝 backend/app/schemas/cloud.py (+8 -1)
📝 backend/app/services/bambu_cloud.py (+41 -16)
📝 backend/app/services/github_backup.py (+11 -11)
📝 backend/tests/integration/test_cloud_auth.py (+222 -16)
📝 backend/tests/unit/services/test_bambu_cloud.py (+55 -0)
📝 frontend/src/api/client.ts (+5 -4)
📝 frontend/src/pages/ProfilesPage.tsx (+34 -14)

📄 Description

Description

The /cloud/token endpoint previously always used the global Bambu API
endpoint, so users with China-region access tokens could not validate
their token. The password-login flow already exposes a region selector;
this brings the token-login flow to parity.

N/A — small enhancement mirroring the existing password-login region
option. Happy to open a tracking issue first if preferred.

Documentation

Companion docs PRs: not opened (see reason below)

Pick one:

  • Docs PR(s) linked above
  • No docs update required — reason: the new region selector mirrors
    the existing password-login control. No new concepts, config keys,
    or endpoints. Happy to add a wiki note if maintainers prefer.

Type of Change

  • New feature (non-breaking change that adds functionality)

Changes Made

  • Backend: CloudTokenRequest gains a region field (default "global")
  • Backend: bambu_cloud exposes reset_cloud_service(region) so the
    singleton can be rebuilt against the requested region
  • Backend: /cloud/token calls reset_cloud_service before set_token
    so the China endpoint is used when selected
  • Frontend: cloudSetToken accepts a region argument
  • Frontend: ProfilesPage token-auth step now shows the same
    Global / China region dropdown as the password-auth step

Screenshots

image image

Testing

  • I have tested this on my local machine (Docker build + swap, token
    flow with Global and China regions)
  • I have tested with my printer model: P1S

Checklist

  • My code follows the project's coding style (ruff check + ruff format pass)
  • I have commented my code where necessary
  • My changes generate no new warnings (tsc --noEmit + eslint pass)
  • I have tested my changes thoroughly

Additional Notes

Follow-up observation (out of scope for this PR, happy to file separately):
the /cloud/login handler already accepts CloudLoginRequest.region
from the schema and the frontend sends it, but the handler doesn't read
request.region — it just calls get_cloud_service(). So the
password-login region selector is currently a UI-only affordance.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/maziggy/bambuddy/pull/1013 **Author:** [@Minidoracat](https://github.com/Minidoracat) **Created:** 4/17/2026 **Status:** ✅ Merged **Merged:** 4/18/2026 **Merged by:** [@maziggy](https://github.com/maziggy) **Base:** `dev` ← **Head:** `feature/token-login-region-selector` --- ### 📝 Commits (4) - [`adfee88`](https://github.com/maziggy/bambuddy/commit/adfee889d33993e18e21fe628f8da7d69d61c344) feat(cloud): support China region for token-based login - [`97b6c6b`](https://github.com/maziggy/bambuddy/commit/97b6c6b2f33d73238c79862e240e75927c6d8d00) Merge branch 'dev' into feature/token-login-region-selector - [`40a70fe`](https://github.com/maziggy/bambuddy/commit/40a70fe43663c3b0e3d17ff1f34a97f974071ec6) feat(cloud): persist region, drop singleton, fix login/verify parity - [`eebda84`](https://github.com/maziggy/bambuddy/commit/eebda848a1552a247b5a59d6fe26d057eaf07e24) feat(cloud): route-level region tests, status payload, shared http pool ### 📊 Changes **12 files changed** (+558 additions, -193 deletions) <details> <summary>View changed files</summary> 📝 `backend/app/api/routes/cloud.py` (+128 -102) 📝 `backend/app/api/routes/inventory.py` (+34 -29) 📝 `backend/app/core/database.py` (+1 -0) 📝 `backend/app/main.py` (+17 -0) 📝 `backend/app/models/user.py` (+2 -0) 📝 `backend/app/schemas/cloud.py` (+8 -1) 📝 `backend/app/services/bambu_cloud.py` (+41 -16) 📝 `backend/app/services/github_backup.py` (+11 -11) 📝 `backend/tests/integration/test_cloud_auth.py` (+222 -16) 📝 `backend/tests/unit/services/test_bambu_cloud.py` (+55 -0) 📝 `frontend/src/api/client.ts` (+5 -4) 📝 `frontend/src/pages/ProfilesPage.tsx` (+34 -14) </details> ### 📄 Description ## Description The `/cloud/token` endpoint previously always used the global Bambu API endpoint, so users with China-region access tokens could not validate their token. The password-login flow already exposes a region selector; this brings the token-login flow to parity. ## Related Issue N/A — small enhancement mirroring the existing password-login region option. Happy to open a tracking issue first if preferred. ## Documentation **Companion docs PRs**: not opened (see reason below) **Pick one**: - [ ] Docs PR(s) linked above - [x] No docs update required — reason: the new region selector mirrors the existing password-login control. No new concepts, config keys, or endpoints. Happy to add a wiki note if maintainers prefer. ## Type of Change - [x] New feature (non-breaking change that adds functionality) ## Changes Made - Backend: `CloudTokenRequest` gains a `region` field (default `"global"`) - Backend: `bambu_cloud` exposes `reset_cloud_service(region)` so the singleton can be rebuilt against the requested region - Backend: `/cloud/token` calls `reset_cloud_service` before `set_token` so the China endpoint is used when selected - Frontend: `cloudSetToken` accepts a `region` argument - Frontend: `ProfilesPage` token-auth step now shows the same Global / China region dropdown as the password-auth step ## Screenshots <img width="1673" height="956" alt="image" src="https://github.com/user-attachments/assets/8768d476-3d1a-4697-b37f-7b4651aaa0ac" /> <img width="1371" height="335" alt="image" src="https://github.com/user-attachments/assets/104c3de7-294c-4695-9e3a-b4343400ad0a" /> ## Testing - [x] I have tested this on my local machine (Docker build + swap, token flow with Global and China regions) - [x] I have tested with my printer model: P1S ## Checklist - [x] My code follows the project's coding style (`ruff check` + `ruff format` pass) - [x] I have commented my code where necessary - [x] My changes generate no new warnings (`tsc --noEmit` + `eslint` pass) - [x] I have tested my changes thoroughly ## Additional Notes Follow-up observation (out of scope for this PR, happy to file separately): the `/cloud/login` handler already accepts `CloudLoginRequest.region` from the schema and the frontend sends it, but the handler doesn't read `request.region` — it just calls `get_cloud_service()`. So the password-login region selector is currently a UI-only affordance. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 00:16:18 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/bambuddy-maziggy-1#1151
No description provided.