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.

merge origin/master (PR #359 per-session inbox + typed messages + realtime bridge)

cyh01ca7e23d731
diff --cc core/internal_server.py
index 000e9e4dd,13803f5b5..c30b614f0
--- a/core/internal_server.py
+++ b/core/internal_server.py
@@@ -333,36 -317,16 +361,42 @@@ def _build_dispatch_payload(payload: di
if not isinstance(session_id, str) or not session_id.strip():
raise ValueError("session_id is required")
- user_id = payload.get("user_id") or "workbench"
- channel_id = payload.get("channel_id") or session_id
+ context = _build_session_context(
+ session_id,
+ user_id=payload.get("user_id"),
+ channel_id=payload.get("channel_id"),
+ platform=payload.get("platform"),
+ thread_id=payload.get("thread_id"),
+ message_id=payload.get("message_id"),
+ )
+ return text, context
+
+
+def _build_session_context(
+ session_id: str,
+ *,
+ user_id: Optional[str] = None,
+ channel_id: Optional[str] = None,
+ platform: Optional[str] = None,
+ thread_id: Optional[str] = None,
+ message_id: Optional[str] = None,
+) -> MessageContext:
+ """Build the avibe ``MessageContext`` for a workbench session.
+
+ Shared by the dispatch endpoint and the cancel endpoint so a stop reuses
+ the exact same session-routing context (chosen agent / model / effort,
+ native session id, workdir) the turn ran under — that's what lets cancel
+ reuse the IM ``/stop`` path to interrupt the right backend session.
+ Defaults to ``platform="avibe"``.
+ """
- platform_specific: dict[str, Any] = {"workbench_session_id": session_id}
+ # ``agent_session_id`` is the agent_sessions PK; persist_agent_message reads
+ # it to attribute avibe agent replies to the right session (IM stamps it at
+ # session-resolve time). For avibe the dispatch session_id IS that PK.
+ platform_specific: dict[str, Any] = {
+ "workbench_session_id": session_id,
+ "agent_session_id": session_id,
+ }
session_row = _lookup_session(session_id)
if session_row is not None:
target = {
diff --cc core/message_dispatcher.py
index 50d2c13e5,9e72dc4db..938e79248
--- a/core/message_dispatcher.py
+++ b/core/message_dispatcher.py
@@@ -384,14 -360,39 +384,44 @@@ class ConsolidatedMessageDispatcher
text = strip_silent_blocks(text)
if not text or not text.strip():
if canonical_type == "result":
+ # An empty/silent result (e.g. a ``<silent>`` directive whose
+ # text is stripped to nothing) still means the turn finished —
+ # release the streaming SSE waiter so it closes now instead of
+ # hanging until the safety timeout, even with no visible chunk.
await self._clear_consolidated_state(context)
+ self._signal_turn_complete(context)
return None
+ # Resolve the delivery target once. Routed / post_to / thread replies
+ # land in a different channel than the source context, and the persisted
+ # row must follow the reply to where it was actually delivered (IM
+ # cross-platform history) — persist_agent_message attributes IM rows to
+ # this target's scope.
+ target_context = self._get_target_context(context)
+
+ # For a result, persist the SAME cleaned text the user receives:
+ # process_reply() strips file:// markdown links + the trailing
+ # quick-reply button block before delivery/streaming, so persisting the
+ # raw text would surface markup in the inbox preview / chat transcript
+ # that was never shown. Computed once here and reused for delivery below.
+ enhanced = None
+ persist_text = text
+ if canonical_type == "result":
+ quick_replies_on = getattr(self.controller.config, "reply_enhancements", True)
+ enhanced = process_reply(text, include_quick_replies=quick_replies_on)
+ persist_text = enhanced.text if enhanced.text.strip() else text
+
+ # Persistence is decided per delivery path below, not here, so that:
+ # * suppressed scheduled runs (intentionally private) never leak into
+ # the cross-platform messages history,
+ # * a user-facing result/notify that fails every IM send isn't recorded
+ # as if the user received it (matches the old success-only mirror),
+ # * intermediate assistant/tool_call log rows STILL persist pre-mute so
+ # muted process messages land in the store.
+ # avibe always persists its result/notify: the SSE stream is the delivery
+ # and the persisted row is the inbox/transcript source of truth.
+ persists_without_delivery = target_context.platform == "avibe"
+
if (context.platform_specific or {}).get("suppress_delivery"):
message_id = f"suppressed:{(context.platform_specific or {}).get('task_execution_id') or canonical_type}"
self._record_suppressed_run_message(context, text, message_id)
@@@ -401,16 -401,13 +431,14 @@@
return message_id
if canonical_type == "notify":
- target_context = self._get_target_context(context)
try:
message_id = await im_client.send_message(target_context, text, parse_mode=parse_mode)
- # ``target_context`` carries the post-override platform / channel
- # / thread, so the mirror row lands in the scope where the
- # message was actually delivered. Mirroring the original
- # ``context`` would mis-attribute scheduled or post_to-routed
- # replies to their source scope.
- mirror_outbound(target_context, text, native_message_id=message_id, kind="notify")
+ # Record only once delivered (avibe always, via SSE) so a failed
+ # IM send isn't stored as if the user received it.
+ if persists_without_delivery or message_id is not None:
+ persist_agent_message(target_context, "notify", text)
- await _stream_chunk(context, text=text, message_id=message_id, kind="notify")
++ # Live SSE turn stream for the web Chat page (no-op for IM/CLI).
+ await _stream_chunk(self.controller, context, text=text, message_id=message_id, kind="notify")
return message_id
except Exception as err:
logger.error("Failed to send notify message: %s", err)
@@@ -559,17 -554,17 +585,17 @@@
# a fresh log message instead of appending to the previous one.
await self._clear_consolidated_state(context)
+ # Persist the delivered result (cleaned text == what was shown).
+ # avibe always persists (SSE is its delivery); for IM a result that
+ # failed every send/upload (primary_message_id is None) is NOT
+ # recorded, matching the old outbound mirror's success-only rule.
+ if persists_without_delivery or primary_message_id is not None:
+ persist_agent_message(target_context, "result", persist_text)
+
if primary_message_id and display_text:
- # Use ``target_context`` so scheduled / post_to-routed replies
- # mirror under their actual delivery scope, not the source.
- mirror_outbound(
- target_context,
- display_text,
- native_message_id=primary_message_id,
- kind="result",
- )
+ # Stream the delivered result to live consumers (avibe SSE).
await _stream_chunk(
- context, text=display_text, message_id=primary_message_id, kind="result"
+ self.controller, context, text=display_text, message_id=primary_message_id, kind="result"
)
return primary_message_id
diff --cc ui/src/components/workbench/ChatPage.tsx
index c1efb3674,5ada70b6f..23f9eb3a2
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@@ -1,16 -1,18 +1,18 @@@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation, useNavigate, useParams } from 'react-router-dom';
-import { ArrowLeft, Bot, ChevronDown, Loader2, MessageSquare, Pencil, Send, StopCircle } from 'lucide-react';
+import { ArrowLeft, Bot, ChevronDown, Loader2, MessageSquare, Pencil, Plus, Send, Square } from 'lucide-react';
+import ReactMarkdown from 'react-markdown';
+import remarkGfm from 'remark-gfm';
import clsx from 'clsx';
-import { Info } from 'lucide-react';
-
import { useApi } from '../../context/ApiContext';
+ import { useWorkbenchInbox } from '../../context/WorkbenchInboxContext';
import type { VibeAgentBrief, WorkbenchMessage, WorkbenchSession } from '../../context/ApiContext';
import { apiFetch } from '../../lib/apiFetch';
-import { Badge } from '../ui/badge';
+import { formatLocalDateTime } from '../../lib/relativeTime';
import { Button } from '../ui/button';
+ import { Input } from '../ui/input';
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
interface PendingChunk {
@@@ -795,26 -675,20 +821,30 @@@ const MessageRow: React.FC<{ message: W
<span
className={clsx(
'rounded border px-1.5 py-0 font-mono font-bold uppercase',
- isAgent ? 'border-mint/40 bg-mint/[0.10] text-mint' : 'border-border-strong bg-foreground/[0.04] text-muted',
+ isNotify
+ ? 'border-gold/40 bg-gold/10 text-gold'
+ : isAgent
+ ? 'border-mint/40 bg-mint/[0.10] text-mint'
+ : 'border-border-strong bg-foreground/[0.04] text-muted',
)}
>
- {message.author}
+ {isNotify ? t('chat.notifyLabel') : message.author}
</span>
- {message.author_name && <span className="font-semibold text-foreground">{message.author_name}</span>}
+ {!isNotify && message.author_name && <span className="font-semibold text-foreground">{message.author_name}</span>}
{isAgent && session.agent_name && <span className="font-mono text-muted">{session.agent_name}</span>}
- <span className="ml-auto font-mono text-muted">{message.created_at}</span>
+ <span className="ml-auto font-mono text-muted">{formatLocalDateTime(message.created_at)}</span>
</div>
- <div className="whitespace-pre-wrap text-[13px] text-foreground">{message.text || '—'}</div>
+ {/* Agent / system replies are markdown (render it); the user's own
+ message is shown verbatim as typed. */}
+ {message.text ? (
+ isAgent || isSystem ? (
+ <Markdown content={message.text} />
+ ) : (
+ <div className="whitespace-pre-wrap text-[13px] text-foreground">{message.text}</div>
+ )
+ ) : (
+ <div className="text-[13px] text-muted">—</div>
+ )}
</div>
);
};
diff --cc ui/src/i18n/en.json
index c9dab6f47,8ef5b8914..00f441e79
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@@ -1392,23 -1482,10 +1482,24 @@@
"missingSessionId": "Missing session id in the URL.",
"transcriptEmpty": "Type a message below to start the conversation",
"streaming": "Streaming",
+ "thinking": "Thinking…",
+ "notifyLabel": "Notify",
+ "picker": {
+ "agent": "Agent",
+ "model": "Model",
+ "effort": "Effort",
+ "newAgent": "New agent",
+ "noModels": "No models found",
+ "effortOptions": {
+ "low": "Low",
+ "medium": "Medium",
+ "high": "High",
+ "max": "Max"
+ }
+ },
"compose": {
"placeholder": "Type a message…",
- "hint": "⌘/Ctrl+Enter to send",
+ "hint": "Enter to send",
"send": "Send",
"sending": "Sending…",
"stop": "Stop"
diff --cc ui/src/i18n/zh.json
index cd252e515,2259ced3e..5c641c4a8
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@@ -1391,23 -1481,10 +1481,24 @@@
"missingSessionId": "URL 缺少 session id。",
"transcriptEmpty": "在下方输入消息开始对话",
"streaming": "实时输出中",
+ "thinking": "思考中…",
+ "notifyLabel": "通知",
+ "picker": {
+ "agent": "Agent",
+ "model": "模型",
+ "effort": "思考强度",
+ "newAgent": "新建 Agent",
+ "noModels": "未找到模型",
+ "effortOptions": {
+ "low": "低",
+ "medium": "中",
+ "high": "高",
+ "max": "最高"
+ }
+ },
"compose": {
"placeholder": "输入消息…",
- "hint": "⌘/Ctrl+Enter 发送",
+ "hint": "Enter 发送",
"send": "发送",
"sending": "发送中…",
"stop": "停止"