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(workbench): always prefix OpenCode models + stream synchronous turn errors

cyha251a50caa91
diff --git a/core/handlers/message_handler.py b/core/handlers/message_handler.py
index 9321c877a..404c108e5 100644
--- a/core/handlers/message_handler.py
+++ b/core/handlers/message_handler.py
@@ -389,10 +389,11 @@ class MessageHandler(BaseHandler):
await self.controller.processing_indicator.finish(processing_indicator)
except Exception as cleanup_err:
logger.debug(f"Failed to clean up reaction on error: {cleanup_err}")
- await self._get_im_client(context).send_message(
- context,
- self.formatter.format_error(self._t("error.processMessageFailed", error=str(e))),
- )
+ error_text = self.formatter.format_error(self._t("error.processMessageFailed", error=str(e)))
+ await self._get_im_client(context).send_message(context, error_text)
+ # Also surface the failure into the live web-Chat SSE stream before
+ # the turn-complete signal below closes it (no-op for IM/CLI).
+ await self._stream_terminal_error(context, error_text)
return str(e)
finally:
if not agent_dispatched:
@@ -734,6 +735,23 @@ class MessageHandler(BaseHandler):
target = agent_name or self.controller.agent_service.default_agent
msg = f"❌ {self._t('error.agentNotConfigured', agent=target)}"
await self._get_im_client(context).send_message(context, msg)
+ await self._stream_terminal_error(context, msg)
+
+ async def _stream_terminal_error(self, context: MessageContext, text: str) -> None:
+ """Surface a synchronous, no-agent-dispatched failure into the live web
+ Chat SSE stream so the browser shows it instead of silently closing on
+ the turn-complete signal with only the user's message visible.
+
+ A raw ``send_message`` reaches IM and is fine there, but it is NOT
+ forwarded through ``_stream_chunk``, so the web Chat stream never sees
+ it; this bridges that gap. No-op for IM / CLI turns (no active sink).
+ """
+ try:
+ from core.message_dispatcher import _stream_chunk
+
+ await _stream_chunk(self.controller, context, text=text, message_id=None, kind="error")
+ except Exception:
+ logger.debug("failed to stream terminal error chunk", exc_info=True)
async def _delete_ack(self, channel_id: str, request: AgentRequest):
"""Delete acknowledgement message if it still exists."""
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index 0fcc33520..ea175967f 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -518,14 +518,16 @@ const AgentRoutePicker: React.FC<AgentRoutePickerProps> = ({ session, agents, on
if (backend === 'claude') models = (await api.claudeModels()).models ?? [];
else if (backend === 'codex') models = (await api.codexModels()).models ?? [];
else if (backend === 'opencode')
- // OpenCode resolves a model override as ``provider/model`` (the
- // adapter splits on "/" into {providerID, modelID}); a bare id only
- // works when a default provider is configured and otherwise routes
- // to the wrong/failing model in multi-provider setups. Namespace
- // each model with its provider id so the picked value is
- // unambiguous (skip if already namespaced).
+ // The providers endpoint returns RAW model ids per provider (never
+ // provider-prefixed), and the OpenCode adapter resolves the override
+ // by splitting the selected value on the FIRST "/" into
+ // {providerID, modelID}. So ALWAYS prepend the provider id — even
+ // when the raw id itself contains "/" (e.g. OpenRouter's
+ // ``anthropic/claude-*`` must become ``openrouter/anthropic/claude-*``,
+ // not be misread as provider ``anthropic``). The first-slash split
+ // keeps the remainder (``anthropic/claude-*``) intact as the model.
models = ((await api.getOpencodeProviders()).providers ?? []).flatMap((p) =>
- (p.models ?? []).map((m) => (m.includes('/') ? m : `${p.id}/${m}`)),
+ (p.models ?? []).map((m) => `${p.id}/${m}`),
);
if (!cancelled) setModelsByBackend((prev) => ({ ...prev, [backend]: models }));
} catch {