mirror of
https://github.com/NikkeTryHard/zerogravity.git
synced 2026-04-25 23:26:01 +03:00
[GH-ISSUE #50] Feature: Manual account activate without daemon/container restart #45
Labels
No labels
bug
enhancement
enhancement
notice
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/zerogravity#45
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DarKWinGTM on GitHub (Feb 22, 2026).
Original GitHub issue: https://github.com/NikkeTryHard/zerogravity/issues/50
Summary
Manual account switch currently needs daemon/container restart to take effect, while auto-rotation can switch account via internal runtime pipeline (LS recycle) without killing the
zerogravityprocess.Request: add a manual activation path that applies immediately at runtime (similar to auto-rotation behavior), without requiring
zg restart/docker restart.Current behavior (verified)
Manual path (
zg accounts set)zg accounts setupdates active account in store:src/bin/zg/accounts.rs:549src/bin/zg/accounts.rs:552zg restartis stop+start daemon:src/bin/zg/commands.rs:140Auto-rotation path
docs/account-rotation.md:104docs/account-rotation.md:151src/rotation.rs:99src/rotation.rs:125src/rotation.rs:155src/api/rate_limiter.rs:161src/quota.rs:179,src/quota.rs:233API gap
src/api/mod.rs:82src/api/mod.rs:83src/api/mod.rs:84src/api/mod.rs:85src/account_rotator.rs:206(set_active_by_email)Why this matters
Operational/manual account switching is currently heavier and less smooth than auto-rotation:
Providing a runtime-apply manual switch would reduce downtime and align user/admin UX with existing rotation internals.
Flow Diagram
Current manual flow
User command
→
zg accounts set <email>→ write
activein accounts store→ restart-required message
→
zg restart(required)→ switch takes effect
Current auto-rotation flow
429/quota trigger
→ rate_limiter/quota sends rotation signal
→ rotation orchestrator
→
account_rotator.rotate()→ kill old LS
→ spawn new LS
→ backend reconfigure + warmup
→ switch takes effect (daemon remains alive)
Expected manual flow
Manual activate command/API
→ set active account
→ refresh target account token
→ update runtime token handles/backend
→ trigger LS recycle/apply pipeline
→ switch takes effect immediately
→ no daemon/container restart required
Proposal
Either approach would work:
POST /v1/accounts/activatewith{ \"email\": \"...\" }zg accounts set <email> --apply-runtimeBackward-compatible option:
Acceptance criteria
zerogravityprocess remains alive.Reference version
Inspected against repository state:
5f4cc6ed5413fa2c7902254cef10289ddedef4b8@jlwebs commented on GitHub (Feb 23, 2026):
agree, the incompleteness after the switch is currently confusing users.
@NikkeTryHard commented on GitHub (Feb 23, 2026):
Implemented and validated.\n\nWhat changed:\n- Added runtime account activation path via (set active account, refresh token, propagate runtime token, reset limiter, clear cached project, request LS respawn).\n- Updated to try runtime apply when daemon is reachable; if runtime apply is unavailable/fails, it falls back to explicit restart guidance.\n- This keeps Docker container uptime stable (no container restart on account switch) while still recycling LS when needed.\n\nVerification:\n- Integration tests for new endpoint behavior pass.\n- Full test suite and clippy pass.\n\nIf you need it immediately, build from after this push. Otherwise wait for the next release tag.
@NikkeTryHard commented on GitHub (Feb 23, 2026):
Follow-up with clean formatting:\n\nFixed and validated.\n\nWhat changed:\n- Added runtime account activation endpoint: POST /v1/accounts/set_active.\n- Endpoint flow: set active account, refresh token, propagate runtime token, reset limiter, clear cached project, request LS respawn.\n- Updated zg accounts set to attempt runtime apply when daemon is reachable; fallback remains explicit restart guidance if runtime apply is unavailable.\n- Docker container is not restarted for account switch; LS recycle is used instead.\n\nVerification:\n- New integration tests for set_active endpoint behavior pass.\n- Full cargo test and cargo clippy --all-targets pass.\n\nAvailability:\n- Need it now: build from main after push.\n- Prefer stable binaries: wait for next release tag.