Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
feat(backends): show signed-in account identity for Codex ChatGPT auth
cyhf5265be7bea6
diff --git a/ui/src/components/settings/BackendOAuthPanel.tsx b/ui/src/components/settings/BackendOAuthPanel.tsxindex 713921255..aee190852 100644--- a/ui/src/components/settings/BackendOAuthPanel.tsx+++ b/ui/src/components/settings/BackendOAuthPanel.tsx@@ -31,6 +31,11 @@ export type BackendOAuthPanelProps = {title: string;/** Short paragraph under the heading describing what login does. */subtitle: string;+ /** Optional one-line identifier rendered under the "signed in" banner+ * (e.g. "[email protected] · Pro" for Codex's ChatGPT account). When+ * ``null`` / undefined the banner shows only the generic "signed in"+ * copy. Plaintext only — never leak tokens here. */+ signedInDetail?: string | null;/** Optional callback fired once after the flow lands on ``state === "success"``.* The parent typically re-reads ``getClaudeAuth`` / ``getCodexAuth`` here so* the on-screen "signed in" indicators move. */@@ -55,6 +60,7 @@ export const BackendOAuthPanel: React.FC<BackendOAuthPanelProps> = ({signedIn,title,subtitle,+ signedInDetail,onSuccess,}) => {const { t } = useTranslation();@@ -274,9 +280,14 @@ export const BackendOAuthPanel: React.FC<BackendOAuthPanelProps> = ({{signedIn && state === 'idle' && (<div className="flex items-start gap-2 rounded-md border border-mint/30 bg-mint-soft/40 px-3 py-2"><CheckCircle2 className="mt-0.5 size-3.5 shrink-0 text-mint" />- <p className="text-[12px] text-mint">- {t(`settings.backends.${backend === 'claude' ? 'claudeOauthSignedIn' : 'codexOauthSignedIn'}`)}- </p>+ <div className="flex flex-col gap-0.5">+ <p className="text-[12px] text-mint">+ {t(`settings.backends.${backend === 'claude' ? 'claudeOauthSignedIn' : 'codexOauthSignedIn'}`)}+ </p>+ {signedInDetail && (+ <p className="font-mono text-[11px] text-mint/80">{signedInDetail}</p>+ )}+ </div></div>)}diff --git a/ui/src/components/settings/SettingsCodexProviderPage.tsx b/ui/src/components/settings/SettingsCodexProviderPage.tsxindex 1504ac18e..ca1d26691 100644--- a/ui/src/components/settings/SettingsCodexProviderPage.tsx+++ b/ui/src/components/settings/SettingsCodexProviderPage.tsx@@ -254,6 +254,21 @@ export const SettingsCodexProviderPage: React.FC = () => {<BackendOAuthPanelbackend="codex"signedIn={!!state?.has_chatgpt_tokens}+ signedInDetail={(() => {+ // Compose a single-line identity (``email · plan ·+ // org``) from the JWT-decoded ``chatgpt_account``+ // bundle. We render only the pieces present so a+ // partial JWT still surfaces something useful.+ const acct = state?.chatgpt_account;+ if (!acct) return null;+ const parts: string[] = [];+ if (acct.email) parts.push(acct.email);+ if (acct.plan_type) parts.push(acct.plan_type);+ const defaultOrg = acct.organizations?.find((o) => o.is_default)+ || acct.organizations?.[0];+ if (defaultOrg?.title) parts.push(defaultOrg.title);+ return parts.length ? parts.join(' · ') : null;+ })()}title={t('settings.backends.codexOauthPanelTitle')}subtitle={t('settings.backends.codexOauthPanelSubtitle')}onSuccess={() => {diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsxindex c4cf74df7..cf589a64f 100644--- a/ui/src/context/ApiContext.tsx+++ b/ui/src/context/ApiContext.tsx@@ -150,6 +150,21 @@ export type CodexCredentialsStore = 'file' | 'keyring' | 'auto' | (string & {});export type ActiveAuthMode = 'oauth' | 'api_key' | 'none';+// Identity decoded from the ChatGPT JWT inside ``~/.codex/auth.json``.+// All fields are best-effort — the OAuth bundle may carry partial+// claims, in which case the panel renders only what's present.+export type CodexChatGptAccount = {+ email: string | null;+ name: string | null;+ plan_type: string | null;+ organizations: Array<{+ id: string | null;+ title: string | null;+ role: string | null;+ is_default: boolean;+ }> | null;+};+export type CodexAuthState = {ok: boolean;auth_mode: CodexAuthMode;@@ -166,6 +181,7 @@ export type CodexAuthState = {api_key_masked: string | null;base_url: string | null;has_chatgpt_tokens: boolean;+ chatgpt_account?: CodexChatGptAccount | null;credentials_store: CodexCredentialsStore;file_store_active: boolean;// True when Codex is in keyring-preferred mode and disk shows nodiff --git a/vibe/api.py b/vibe/api.pyindex 3bf41467e..ee5c256ca 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -2334,6 +2334,7 @@ def get_codex_auth() -> dict:"api_key_masked": _mask_api_key(disk_state.get("api_key_raw")),"base_url": disk_state.get("base_url"),"has_chatgpt_tokens": has_chatgpt_live,+ "chatgpt_account": disk_state.get("chatgpt_account"),# Forward the live Codex credentials-store status so the UI can# warn when the user is about to switch storage backends# (Codex's documented default is ``auto`` → keyring-preferred).diff --git a/vibe/codex_config.py b/vibe/codex_config.pyindex b3ae609af..26c6afc1c 100644--- a/vibe/codex_config.py+++ b/vibe/codex_config.py@@ -348,6 +348,68 @@ def read_codex_api_key(home: Path | None = None) -> Optional[str]:return None+def _extract_chatgpt_account(auth_data: dict) -> Optional[Dict[str, Any]]:+ """Best-effort decode of the ChatGPT identity stored in ``auth.json``.++ Codex stores the OAuth bundle as ``{"tokens": {"id_token": "<JWT>",+ ...}}``. The id_token's payload carries an ``email`` and a nested+ ChatGPT-specific block with plan + org info. Decoding is signature-+ free (we don't verify it — these are tokens we received from+ ``codex login`` and we trust them at-rest); failures fall back to+ ``None`` so the Settings UI just shows the generic "signed in"+ banner instead of crashing.+ """+ tokens = auth_data.get("tokens") if isinstance(auth_data, dict) else None+ if not isinstance(tokens, dict):+ return None+ id_token = tokens.get("id_token")+ if not isinstance(id_token, str):+ return None+ parts = id_token.split(".")+ if len(parts) < 2:+ return None+ payload_b64 = parts[1]+ # Pad base64 to a multiple of 4 (JWTs strip ``=`` padding).+ pad = "=" * (-len(payload_b64) % 4)+ try:+ import base64++ decoded = base64.urlsafe_b64decode((payload_b64 + pad).encode("ascii"))+ claims = json.loads(decoded)+ except (ValueError, json.JSONDecodeError):+ return None+ if not isinstance(claims, dict):+ return None++ email = claims.get("email") if isinstance(claims.get("email"), str) else None+ name = claims.get("name") if isinstance(claims.get("name"), str) else None+ chatgpt = claims.get("https://api.openai.com/auth")+ plan_type: Optional[str] = None+ organizations: list[Dict[str, Any]] = []+ if isinstance(chatgpt, dict):+ if isinstance(chatgpt.get("chatgpt_plan_type"), str):+ plan_type = chatgpt["chatgpt_plan_type"]+ orgs_raw = chatgpt.get("organizations")+ if isinstance(orgs_raw, list):+ for entry in orgs_raw:+ if not isinstance(entry, dict):+ continue+ organizations.append(+ {+ "id": entry.get("id") if isinstance(entry.get("id"), str) else None,+ "title": entry.get("title") if isinstance(entry.get("title"), str) else None,+ "role": entry.get("role") if isinstance(entry.get("role"), str) else None,+ "is_default": bool(entry.get("is_default")),+ }+ )+ return {+ "email": email,+ "name": name,+ "plan_type": plan_type,+ "organizations": organizations or None,+ }++def read_codex_auth_state(home: Path | None = None) -> Dict[str, Any]:"""Return the user-visible auth state for the Settings UI.@@ -367,6 +429,7 @@ def read_codex_auth_state(home: Path | None = None) -> Dict[str, Any]:toml_data = _load_toml(config_path)api_key = auth_data.get("OPENAI_API_KEY")has_chatgpt_tokens = isinstance(auth_data.get("tokens"), dict)+ chatgpt_account = _extract_chatgpt_account(auth_data) if has_chatgpt_tokens else Noneproviders = toml_data.get("model_providers")base_url: Optional[str] = None@@ -419,6 +482,12 @@ def read_codex_auth_state(home: Path | None = None) -> Dict[str, Any]:"api_key_raw": api_key if isinstance(api_key, str) and api_key else None,"base_url": base_url,"has_chatgpt_tokens": has_chatgpt_tokens,+ # ``chatgpt_account``: best-effort identity from the OAuth JWT in+ # ``auth.json`` so the Settings page can show "Signed in as+ # [email protected] (Pro)" instead of just "ChatGPT credentials+ # detected". Returns ``None`` when no JWT is available or the+ # claims are missing — the UI degrades to the generic banner.+ "chatgpt_account": chatgpt_account,"credentials_store": effective_store,"file_store_active": file_store_active,"auth_mode_uncertain": auth_mode_uncertain,