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): address a251a50 Codex review — i18n, stop backend, reply event

cyhdf4e509ed96f
diff --git a/core/handlers/command_handlers.py b/core/handlers/command_handlers.py
index eeb3c64b6..999c9fbd2 100644
--- a/core/handlers/command_handlers.py
+++ b/core/handlers/command_handlers.py
@@ -928,7 +928,22 @@ class CommandHandlers(BaseHandler):
session_handler = self.controller.session_handler
base_session_id, working_path, composite_key = session_handler.get_session_info(context)
session_key = self._get_session_key(context)
- agent_name = self.controller.resolve_agent_for_context(context)
+ # Stop the backend the turn actually ran on. The web Chat cancel path
+ # hands in the turn's captured context, which carries the session's
+ # chosen agent in ``agent_session_target``; honor that backend before
+ # the generic per-context resolution. Otherwise, if the Chat header
+ # switched the session's agent mid-stream, Stop would resolve the new
+ # (or default) backend and ``handle_stop`` returns False while the
+ # real turn keeps running. IM ``/stop`` carries no
+ # ``agent_session_target`` and falls back to the generic resolver, so
+ # its behavior is unchanged.
+ session_target = (context.platform_specific or {}).get("agent_session_target")
+ session_agent_backend = (
+ str(session_target["agent_backend"])
+ if isinstance(session_target, dict) and session_target.get("agent_backend")
+ else None
+ )
+ agent_name = session_agent_backend or self.controller.resolve_agent_for_context(context)
request = AgentRequest(
context=context,
message="stop",
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index ea175967f..c1efb3674 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -733,21 +733,24 @@ const Markdown: React.FC<{ content: string }> = ({ content }) => (
// chunk yet — an agent-styled bubble with three dots that fade in sequence
// (``.vr-typing-dot`` keyframes in index.css), so the user gets immediate
// feedback that their message landed and a reply is coming (feedback #1).
-const ThinkingBubble: React.FC<{ session: WorkbenchSession }> = ({ session }) => (
- <div className="flex flex-col gap-1.5 rounded-xl border border-mint/20 bg-mint/[0.04] px-4 py-3">
- <div className="flex items-center gap-2 text-[10px]">
- <span className="rounded border border-mint/40 bg-mint/[0.10] px-1.5 py-0 font-mono font-bold uppercase text-mint">
- agent
- </span>
- {session.agent_name && <span className="font-mono text-muted">{session.agent_name}</span>}
- </div>
- <div className="flex items-center gap-1 py-0.5">
- <span className="vr-typing-dot size-1.5 rounded-full bg-mint" />
- <span className="vr-typing-dot size-1.5 rounded-full bg-mint [animation-delay:0.2s]" />
- <span className="vr-typing-dot size-1.5 rounded-full bg-mint [animation-delay:0.4s]" />
+const ThinkingBubble: React.FC<{ session: WorkbenchSession }> = ({ session }) => {
+ const { t } = useTranslation();
+ return (
+ <div className="flex flex-col gap-1.5 rounded-xl border border-mint/20 bg-mint/[0.04] px-4 py-3">
+ <div className="flex items-center gap-2 text-[10px]">
+ <span className="rounded border border-mint/40 bg-mint/[0.10] px-1.5 py-0 font-mono font-bold uppercase text-mint">
+ {t('chat.thinking')}
+ </span>
+ {session.agent_name && <span className="font-mono text-muted">{session.agent_name}</span>}
+ </div>
+ <div className="flex items-center gap-1 py-0.5">
+ <span className="vr-typing-dot size-1.5 rounded-full bg-mint" />
+ <span className="vr-typing-dot size-1.5 rounded-full bg-mint [animation-delay:0.2s]" />
+ <span className="vr-typing-dot size-1.5 rounded-full bg-mint [animation-delay:0.4s]" />
+ </div>
</div>
- </div>
-);
+ );
+};
// Renders the SSE chunks from the still-active turn. Once the turn
// settles, ``reloadMessages()`` reloads persisted rows and ``streamChunks`` is
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 3544d99e8..c9dab6f47 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -1392,6 +1392,7 @@
"missingSessionId": "Missing session id in the URL.",
"transcriptEmpty": "Type a message below to start the conversation",
"streaming": "Streaming",
+ "thinking": "Thinking…",
"picker": {
"agent": "Agent",
"model": "Model",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index dff92459e..cd252e515 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -1391,6 +1391,7 @@
"missingSessionId": "URL 缺少 session id。",
"transcriptEmpty": "在下方输入消息开始对话",
"streaming": "实时输出中",
+ "thinking": "思考中…",
"picker": {
"agent": "Agent",
"model": "模型",
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 51654fdaa..b13b8ce9d 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -2926,9 +2926,11 @@ async def sessions_messages_create(session_id: str):
# persisted user-message id so the consumer can dedupe against
# the optimistic update it already rendered.
yield _sse_frame("stream.start", {"user_message": message})
+ turn_completed = False
try:
async for event_name, data in internal_client.stream_dispatch(dispatch_payload):
yield _sse_frame(event_name, data)
+ turn_completed = True
except internal_client.InternalServerUnavailable as exc:
yield _sse_frame(
"stream.error",
@@ -2940,6 +2942,23 @@ async def sessions_messages_create(session_id: str):
"stream.error",
{"reason": "proxy_crashed", "detail": str(exc)},
)
+ if turn_completed:
+ # The agent reply was persisted by the controller's avibe mirror
+ # during the turn, but the controller runs in a separate process and
+ # can't reach this UI server's in-process SSE broker. So publish the
+ # session-activity signal HERE, once the turn settles — otherwise
+ # other open workbench views (inbox, session list) would update on
+ # the user's message (above) but never on the agent's reply. Bump
+ # the session's activity timestamp too so list ordering reflects it.
+ try:
+ with engine.begin() as conn:
+ workbench_sessions_service.touch_session(conn, session_id)
+ except Exception: # pragma: no cover - best effort
+ logger.debug("touch_session after agent reply failed", exc_info=True)
+ broker.publish(
+ "session.activity",
+ {"session_id": session_id, "scope_id": session["scope_id"], "event": "agent_reply"},
+ )
def _sse_frame(event_type: str, data) -> str:
return f"event: {event_type}\ndata: {_json.dumps(data)}\n\n"