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): tidy OpenCode page UX + fix 'configured' staleness

cyh9afc1089b6d5
diff --git a/ui/src/components/settings/SettingsOpencodeProviderPage.tsx b/ui/src/components/settings/SettingsOpencodeProviderPage.tsx
index 6930dc471..0102e2f3f 100644
--- a/ui/src/components/settings/SettingsOpencodeProviderPage.tsx
+++ b/ui/src/components/settings/SettingsOpencodeProviderPage.tsx
@@ -128,6 +128,11 @@ export const SettingsOpencodeProviderPage: React.FC = () => {
const [providersLoading, setProvidersLoading] = useState(false);
const [providersError, setProvidersError] = useState<string | null>(null);
const [serverStartAttempts, setServerStartAttempts] = useState(0);
+ // ``true`` when opencode.json carries ``permission: "allow"`` — the
+ // Settings page suppresses the "Allow tool calls" affordance once
+ // this is the case (page feedback: a permanent "Setup permission"
+ // button is misleading once permission is already set).
+ const [permissionAllowed, setPermissionAllowed] = useState(false);
// Toolbar state.
const [searchQuery, setSearchQuery] = useState('');
@@ -175,6 +180,7 @@ export const SettingsOpencodeProviderPage: React.FC = () => {
if (result.ok && result.providers) {
setProviders(result.providers);
setDefaultProvider(result.default_provider || null);
+ setPermissionAllowed(result.permission_allowed === true);
setServerStartAttempts(0);
setProvidersError(null);
} else {
@@ -277,6 +283,12 @@ export const SettingsOpencodeProviderPage: React.FC = () => {
setPermissionState(result.ok ? 'success' : 'error');
setPermissionMessage(result.message);
showToast(result.message, result.ok ? 'success' : 'error');
+ if (result.ok) {
+ // Flip locally so the affordance vanishes immediately rather
+ // than waiting for the next provider refresh tick — the next
+ // ``loadProviders`` will recompute the value from disk anyway.
+ setPermissionAllowed(true);
+ }
} catch (e: any) {
setPermissionState('error');
const msg = e?.message || String(e);
@@ -686,9 +698,13 @@ export const SettingsOpencodeProviderPage: React.FC = () => {
</div>
)}
- {cliStatus === 'ok' && (
+ {/* Hide the Allow affordance once opencode.json carries
+ ``permission: "allow"``. Until then show the strong
+ copy that explains why the agent will stall without
+ this setting. */}
+ {cliStatus === 'ok' && !permissionAllowed && (
<div className="rounded-lg border border-gold/30 bg-gold/10 px-3 py-2.5">
- <p className="mb-2 text-[12px] text-gold">{t('agentDetection.permissionHint')}</p>
+ <p className="mb-2 text-[12px] text-gold">{t('agentDetection.permissionHintStrong')}</p>
<div className="flex flex-wrap items-center gap-3">
<Button
variant="brand-gold"
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index 136778b14..997c24783 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -330,6 +330,11 @@ export type OpencodeProviderListResult = {
message?: string;
providers?: OpencodeProvider[];
default_provider?: string;
+ // True when ``opencode.json`` has ``permission: "allow"`` — the
+ // setting that lets OpenCode skip the interactive tool-call approval
+ // prompt Vibe Remote can't reply to. The Settings page hides the
+ // "Allow tool calls" affordance when this is already true.
+ permission_allowed?: boolean;
};
export type OpencodeMutationResult = {
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index ffc8d4916..60798b0a3 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -204,7 +204,7 @@
"activeAuthNone": "Not signed in",
"replaceApiKey": "Replace",
"opencodeProvidersTitle": "Providers",
- "opencodeProvidersSubtitle": "Lazy-loaded from the OpenCode server · auth handled via API key or `opencode auth login`",
+ "opencodeProvidersSubtitle": "Lazy-loaded from the OpenCode server · auth handled via API key or OAuth sign-in",
"opencodeProvidersCount": "{{configured}}/{{total}} configured",
"opencodeServerRunning": "Server reachable",
"opencodeServerStopped": "Server unavailable",
@@ -688,7 +688,8 @@
"cliPathDetection": "CLI path detection and enablement",
"recommended": "(recommended)",
"permissionHint": "OpenCode requires permission config to skip approval prompts.",
- "setupPermission": "Setup Permission",
+ "permissionHintStrong": "OpenCode will block every tool call with an interactive approval prompt unless ``permission`` is set to ``allow`` in ``opencode.json``. Vibe Remote can't reply to those prompts — without this, the agent stalls on the first action it takes. Click to write the setting now.",
+ "setupPermission": "Allow tool calls in opencode.json",
"installHint": "Agent not found. Click to install automatically.",
"installAgent": "Install",
"installing": "Installing...",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index f9aad66aa..b2717cbb4 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -204,7 +204,7 @@
"activeAuthNone": "未登录",
"replaceApiKey": "替换",
"opencodeProvidersTitle": "服务商",
- "opencodeProvidersSubtitle": "从 OpenCode Server 实时拉取 · 通过 API Key 或 `opencode auth login` 完成授权",
+ "opencodeProvidersSubtitle": "从 OpenCode Server 实时拉取 · 通过 API Key 或 OAuth 登录完成授权",
"opencodeProvidersCount": "已配置 {{configured}}/{{total}}",
"opencodeServerRunning": "服务器可用",
"opencodeServerStopped": "服务器不可用",
@@ -688,7 +688,8 @@
"cliPathDetection": "CLI 路径检测和启用设置",
"recommended": "(推荐)",
"permissionHint": "OpenCode 需要配置权限以跳过审批提示。",
- "setupPermission": "一键设置权限",
+ "permissionHintStrong": "如果不在 ``opencode.json`` 里把 ``permission`` 设成 ``allow``,OpenCode 会在每次工具调用前弹审批提示。Vibe Remote 没法替你回复这些提示,结果是 Agent 一开始就卡住。点击立即写入。",
+ "setupPermission": "在 opencode.json 写入 allow",
"installHint": "未找到 Agent,点击自动安装。",
"installAgent": "一键安装",
"installing": "安装中...",
diff --git a/vibe/api.py b/vibe/api.py
index 54c915ba3..40b81a426 100644
--- a/vibe/api.py
+++ b/vibe/api.py
@@ -2824,6 +2824,15 @@ async def _get_opencode_providers_async() -> dict:
# can pre-fill the input ("sk-proj-•••H8mN") without leaking plaintext.
# OAuth-type providers map to ``None`` and the UI skips the mask
# block in that case.
+ #
+ # Reading auth.json directly also doubles as the source of truth for
+ # the "configured" badge: OpenCode 1.14.48 caches its in-memory
+ # ``connected`` list at server startup, so a freshly-saved provider
+ # stays absent from ``/provider``'s ``connected`` until the daemon
+ # restarts. Our ``configured`` flag therefore unions ``connected``
+ # with "has an entry in auth.json" (regardless of api vs oauth type),
+ # giving the user immediate feedback after Save without waiting for
+ # an OpenCode restart.
try:
from vibe.opencode_config import read_opencode_provider_keys
@@ -2838,6 +2847,7 @@ async def _get_opencode_providers_async() -> dict:
masked = _mask_api_key(raw_key) if raw_key else None
if masked:
api_key_mask_index[pid_key] = masked
+ auth_file_provider_set: set = set(provider_keys.keys())
out_providers = []
for pid, entry in all_providers.items():
@@ -2850,7 +2860,11 @@ async def _get_opencode_providers_async() -> dict:
for method in auth_methods_list
)
local = _is_local_provider(pid, auth_methods_list)
- configured = pid in connected_set
+ # Union OpenCode's runtime ``connected`` list with auth.json
+ # presence so a fresh PUT /auth/<id> immediately reflects as
+ # configured — OpenCode caches ``connected`` and won't refresh
+ # without a daemon restart.
+ configured = pid in connected_set or pid in auth_file_provider_set
models_for_provider = model_index.get(pid, {})
provider_models = models_for_provider.get("models")
if isinstance(provider_models, dict):
@@ -2883,10 +2897,20 @@ async def _get_opencode_providers_async() -> dict:
out_providers.sort(key=lambda p: (not p["configured"], p["local"], p["id"]))
+ # Surface the current ``permission`` setting from opencode.json so the
+ # Settings page can hide the "Allow tool calls" affordance once it's
+ # already ``allow`` — and strengthen the copy when it isn't, since a
+ # missing/blocking setting silently makes every tool call wait for an
+ # approval prompt that Vibe Remote can't reply to.
+ permission_allowed = False
+ if opencode_probe is not None and isinstance(opencode_probe.config, dict):
+ permission_allowed = opencode_probe.config.get("permission") == "allow"
+
return {
"ok": True,
"providers": out_providers,
"default_provider": default_provider,
+ "permission_allowed": permission_allowed,
}