fix(wizard): restore Antigravity OAuth by matching the 3-tuple session API

0d9005f changed start_profile_oauth to return (session_id, auth_url, port) and
updated the tests, but not its callers. The wizard still unpacked two values, so
every Antigravity connection raised ValueError inside _init_antigravity_oauth,
the handler swallowed it, and the authorization URL never appeared — the primary
onboarding flow has been dead since that commit.

Also stores the listener port as wizard.oauth_port, which the single-session
invariance test reads to prove that repeat "open browser" clicks reuse the
existing listener instead of binding a new one.

Both defects were caught only by tests that the headless run skips, which is why
they survived several reviews.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Hermes Team 2026-08-21 08:00:42 +07:00
parent 83409d5354
commit 39b1f928f4
2 changed files with 5 additions and 2 deletions

View file

@ -233,7 +233,7 @@ def start_oauth(req: StartOAuthRequest) -> Dict[str, Any]:
raise HTTPException(status_code=400, detail="Нет свободных слотов для Antigravity аккаунтов") raise HTTPException(status_code=400, detail="Нет свободных слотов для Antigravity аккаунтов")
try: try:
session_id, auth_url = start_profile_oauth(profile_id) session_id, auth_url, _port = start_profile_oauth(profile_id)
display_name, _, _ = AutoAssigner.get_display_name_and_role(profile_id) display_name, _, _ = AutoAssigner.get_display_name_and_role(profile_id)
return { return {
"success": True, "success": True,

View file

@ -48,6 +48,7 @@ class AddAccountWizard(HubModal):
# Session tracking # Session tracking
self.oauth_session_id: Optional[str] = None self.oauth_session_id: Optional[str] = None
self.oauth_url: Optional[str] = None self.oauth_url: Optional[str] = None
self.oauth_port: Optional[int] = None
self.codex_session_id: Optional[str] = None self.codex_session_id: Optional[str] = None
self.codex_url: Optional[str] = None self.codex_url: Optional[str] = None
@ -83,6 +84,7 @@ class AddAccountWizard(HubModal):
except Exception: except Exception:
pass pass
self.oauth_session_id = None self.oauth_session_id = None
self.oauth_port = None
if self.codex_session_id: if self.codex_session_id:
try: try:
@ -340,9 +342,10 @@ class AddAccountWizard(HubModal):
def _init_antigravity_oauth(self): def _init_antigravity_oauth(self):
try: try:
from antigravity_provider.router.profile_oauth import start_profile_oauth from antigravity_provider.router.profile_oauth import start_profile_oauth
session_id, auth_url = start_profile_oauth(self.target_slot) session_id, auth_url, port = start_profile_oauth(self.target_slot)
self.oauth_session_id = session_id self.oauth_session_id = session_id
self.oauth_url = auth_url self.oauth_url = auth_url
self.oauth_port = port
self.oauth_url_entry.delete(0, "end") self.oauth_url_entry.delete(0, "end")
self.oauth_url_entry.insert(0, auth_url) self.oauth_url_entry.insert(0, auth_url)