Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

fix(backends): resolve Claude config via agents.<backend> for web OAuth path; harden copy-button bubble-stop

cyhc976ea4dff77
diff --git a/core/agent_auth_service.py b/core/agent_auth_service.py
index 45efea403..c89d54602 100644
--- a/core/agent_auth_service.py
+++ b/core/agent_auth_service.py
@@ -344,6 +344,30 @@ class AgentAuthService:
lang = getattr(self.controller, "_get_lang", lambda: getattr(self.controller.config, "language", "en"))()
return i18n_t(key, lang, **kwargs)
+ def _resolve_backend_config(self, backend: str):
+ """Return the backend's config object regardless of controller shape.
+
+ The IM ``Controller`` carries an ``AppCompatConfig`` with backends at
+ the top level (``config.claude``, ``config.codex``, ...), so the long-
+ standing ``getattr(self.controller.config, backend, None)`` access
+ works there. The web OAuth flow uses ``_WebControllerStub`` which
+ exposes the raw ``V2Config`` instead — backends live under
+ ``config.agents.<backend>`` and the top-level attribute is ``None``.
+
+ Falling back through both shapes means ``build_claude_subprocess_env``
+ (and similar) consistently sees the user's stored ``auth_mode`` /
+ ``api_key`` / ``base_url`` whether the call originates from an IM
+ session or from the Settings → Backends OAuth panel.
+ """
+ cfg = getattr(self, "controller", None)
+ cfg = getattr(cfg, "config", None) if cfg is not None else None
+ if cfg is None:
+ return None
+ top = getattr(cfg, backend, None)
+ if top is not None:
+ return top
+ return getattr(getattr(cfg, "agents", None), backend, None)
+
def _get_im_client(self, context: MessageContext):
getter = getattr(self.controller, "get_im_client_for_context", None)
if callable(getter):
@@ -829,7 +853,7 @@ class AgentAuthService:
# still get the key into the control-channel SDK client.
from vibe.claude_config import build_claude_subprocess_env
- claude_env = build_claude_subprocess_env(getattr(self.controller.config, "claude", None))
+ claude_env = build_claude_subprocess_env(self._resolve_backend_config("claude"))
should_force_sandbox = getattr(session_handler, "_should_force_claude_sandbox", None)
if callable(should_force_sandbox) and should_force_sandbox():
@@ -841,7 +865,7 @@ class AgentAuthService:
"setting_sources": ["user", "project", "local"],
"max_buffer_size": CLAUDE_SDK_MAX_BUFFER_SIZE,
}
- permission_mode = getattr(getattr(self.controller.config, "claude", None), "permission_mode", None)
+ permission_mode = getattr(self._resolve_backend_config("claude"), "permission_mode", None)
if permission_mode:
option_kwargs["permission_mode"] = permission_mode
@@ -1635,7 +1659,7 @@ class AgentAuthService:
env_override.update(
build_claude_subprocess_env(
- getattr(self.controller.config, "claude", None),
+ self._resolve_backend_config("claude"),
base_env=env_override,
)
)
diff --git a/ui/src/components/settings/BackendOAuthPanel.tsx b/ui/src/components/settings/BackendOAuthPanel.tsx
index 3cc2be7b0..c89f7f4a0 100644
--- a/ui/src/components/settings/BackendOAuthPanel.tsx
+++ b/ui/src/components/settings/BackendOAuthPanel.tsx
@@ -263,7 +263,12 @@ export const BackendOAuthPanel: React.FC<BackendOAuthPanelProps> = ({
}
};
- const copyUrl = async () => {
+ const copyUrl = async (e?: React.MouseEvent) => {
+ // Defensively stop the click from bubbling. If a parent had an
+ // accidental form / radio handler, copying the URL must never
+ // also trigger a tab switch or a save.
+ e?.preventDefault();
+ e?.stopPropagation();
if (!url) return;
try {
await navigator.clipboard.writeText(url);
@@ -273,7 +278,14 @@ export const BackendOAuthPanel: React.FC<BackendOAuthPanelProps> = ({
}
};
- const copyDeviceCode = async () => {
+ const copyDeviceCode = async (e?: React.MouseEvent) => {
+ // Same defensive bubble-stop as copyUrl. Reported symptom: clicking
+ // "Copy" on the Codex device code in Settings was bouncing the auth-
+ // mode segmented radio from OAuth to API Key, interrupting the
+ // login flow. Without seeing a repro path in code, guard the
+ // click here so the side effect can't survive in any browser.
+ e?.preventDefault();
+ e?.stopPropagation();
if (!deviceCode) return;
try {
await navigator.clipboard.writeText(deviceCode);
@@ -378,7 +390,7 @@ export const BackendOAuthPanel: React.FC<BackendOAuthPanelProps> = ({
<ExternalLink className="size-3 shrink-0" />
<span className="break-all">{url}</span>
</a>
- <Button type="button" variant="secondary" size="xs" onClick={() => void copyUrl()}>
+ <Button type="button" variant="secondary" size="xs" onClick={(e) => void copyUrl(e)}>
<Copy className="size-3" />
{t('common.copy')}
</Button>
@@ -395,7 +407,7 @@ export const BackendOAuthPanel: React.FC<BackendOAuthPanelProps> = ({
<code className="rounded-md bg-cyan-soft/40 px-2.5 py-1 font-mono text-[14px] font-semibold tracking-[0.18em] text-cyan">
{deviceCode}
</code>
- <Button type="button" variant="secondary" size="xs" onClick={() => void copyDeviceCode()}>
+ <Button type="button" variant="secondary" size="xs" onClick={(e) => void copyDeviceCode(e)}>
<Copy className="size-3" />
{t('common.copy')}
</Button>