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.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(chat): show Web narration once, as written, with its quick replies (#2349)
Call White15d49ed01ca4
diff --git a/core/message_dispatcher.py b/core/message_dispatcher.pyindex 17b8f3bca..4b2503fc9 100644--- a/core/message_dispatcher.py+++ b/core/message_dispatcher.py@@ -63,6 +63,7 @@ from storage.background import (normalize_run_status,)from vibe.i18n import t as i18n_t+from vibe.message_types import TRANSCRIPT_COPY_KEYlogger = logging.getLogger(__name__)@@ -3617,22 +3618,51 @@ class ConsolidatedMessageDispatcher:)return None- # Persist the intermediate log row BEFORE the mute filter so muted- # assistant / tool_call messages still land in the store (product- # requirement: the process log is complete even when a channel hides it).- persist_agent_message(target_context, canonical_type, persist_text, citations=citations)- # Web only: the same text additionally lands as a transcript-visible+ # Web only: substantial narration also lands as a transcript-visible# ``interim`` row. Every backend emits ``assistant`` only once later output# has proved the text is not the Turn's final answer, so this never# duplicates the result. ``level="process"`` keeps a row log-only (for# example reasoning summaries).+ interim_row = Noneif (canonical_type == "assistant"and level != "process"and target_context.platform == "avibe"- and self._is_interim_worthy(persist_text)):- persist_agent_message(target_context, "interim", persist_text, citations=citations)+ # The bubble is the agent's words like a reply, so it gets the same+ # button parse, and only the remaining body decides if it is one.+ interim = process_reply(+ raw_text,+ include_quick_replies=getattr(+ self.controller.config, "reply_enhancements", True+ ),+ allow_unseparated_quick_replies=self._supports_quick_replies(+ target_context+ ),+ keep_file_links=True,+ )+ if self._is_interim_worthy(interim.text):+ interim_row = persist_agent_message(+ target_context,+ "interim",+ interim.text,+ quick_replies=[+ b.text for b in _written_buttons(interim.buttons, citations)+ ]+ or None,+ citations=citations,+ )+ # Persist the intermediate log row BEFORE the mute filter so muted+ # assistant / tool_call messages still land in the store (product+ # requirement: the process log is complete even when a channel hides it).+ # Only a narration whose bubble was stored is left out of Activity.+ persist_agent_message(+ target_context,+ canonical_type,+ persist_text,+ citations=citations,+ metadata={TRANSCRIPT_COPY_KEY: "interim"} if interim_row else None,+ )# The row above is the only copy of an intermediate message that carries a# sidecar. Everything left below is what the channel is shown - the concisediff --git a/core/message_mirror.py b/core/message_mirror.pyindex d6eb7b989..cdfc329f5 100644--- a/core/message_mirror.py+++ b/core/message_mirror.py@@ -35,7 +35,7 @@ from core.services import sessions as workbench_sessions_servicefrom modules.im.base import MessageContextfrom storage import agent_events_service, messages_service, settings_servicefrom storage.db import get_cached_sqlite_engine-from vibe.message_types import spec_for+from vibe.message_types import activity_role_for, spec_forlogger = logging.getLogger(__name__)@@ -546,7 +546,7 @@ def persist_agent_message(if context.platform == "avibe" and not suppress_delivery and (message_type in messages_service.TRANSCRIPT_TYPESor (- spec_for(message_type)["activityRole"] == "activity"+ activity_role_for(message_type, metadata) == "activity"and _activity_streaming_enabled())):diff --git a/docs/plans/chat-agent-activity-panel.md b/docs/plans/chat-agent-activity-panel.mdindex c10c04511..ad86091a4 100644--- a/docs/plans/chat-agent-activity-panel.md+++ b/docs/plans/chat-agent-activity-panel.md@@ -73,6 +73,11 @@ Event rows:users read the content). Wrapped, rendered with the existing `Markdown`component in a compact style (smaller font); no truncation. In the compactrunning viewport the fixed window simply follows the tail.+ Narration that the Web transcript already draws as a muted `interim` bubble+ (owner decision, 2026-10-02) is not repeated here: its `assistant` row carries+ `metadata.transcript_copy = "interim"`, which `activity_role_for` maps to role+ `none` for both the durable groups and the live stream. Short narration below+ the bubble threshold and process-only rows stay in the panel.Grouping rules:diff --git a/modules/agents/claude_agent.py b/modules/agents/claude_agent.pyindex 043e38b98..2d02d29f7 100644--- a/modules/agents/claude_agent.py+++ b/modules/agents/claude_agent.py@@ -2350,8 +2350,11 @@ class ClaudeAgent(BaseAgent):)if text_parts:- formatted_assistant = formatter.format_assistant_message(text_parts)- self._pending_assistant_message[composite_key] = formatted_assistant+ # Claude writes Markdown; keep it as written, like the+ # Result and every other backend's narration.+ self._pending_assistant_message[composite_key] = "\n\n".join(+ text_parts+ )pending_assistant_phase = response_phase# AskUserQuestion handling disabled - SDK cannot respond programmatically@@ -4703,10 +4706,8 @@ class ClaudeAgent(BaseAgent):parse_mode="markdown",status_label=toolcall_label,)- if formatter is not None and assistant_text:- self._pending_assistant_message[composite_key] = (- formatter.format_assistant_message([assistant_text])- )+ if assistant_text:+ self._pending_assistant_message[composite_key] = assistant_textexcept asyncio.CancelledError:raiseexcept Exception:diff --git a/tests/test_agent_activity_service.py b/tests/test_agent_activity_service.pyindex f5fb801bd..f0ef72fa3 100644--- a/tests/test_agent_activity_service.py+++ b/tests/test_agent_activity_service.py@@ -275,6 +275,38 @@ def test_a_narration_row_carries_its_citation_sidecar(isolated_state):assert "citations" not in rows["m_plain"]+def test_narration_the_transcript_draws_is_not_repeated_in_activity(isolated_state):+ """A narration with an ``interim`` transcript copy appears once, as the bubble."""+ engine = create_sqlite_engine()+ sid = "ses_twin"+ with engine.begin() as conn:+ scope = _seed_session(conn, session_id=sid)+ _msg(conn, scope, sid, mid="m_u", mtype="user", author="user", created_at="2026-06-01T10:00:00.000000+00:00", text="q", source="user")+ _msg(+ conn, scope, sid, mid="m_long", mtype="assistant", author="agent",+ created_at="2026-06-01T10:00:01.000000+00:00", text="Found it.\nThe cache is shared.\nFixing it.",+ metadata={"transcript_copy": "interim"},+ )+ _msg(+ conn, scope, sid, mid="m_bubble", mtype="interim", author="agent",+ created_at="2026-06-01T10:00:01.000000+00:00", text="Found it.\nThe cache is shared.\nFixing it.",+ )+ _evt(conn, scope, sid, eid="e_tool", created_at="2026-06-01T10:00:02.000000+00:00", text="🔧 `Bash`")+ _msg(+ conn, scope, sid, mid="m_short", mtype="assistant", author="agent",+ created_at="2026-06-01T10:00:03.000000+00:00", text="Still working.",+ )+ _msg(conn, scope, sid, mid="m_r", mtype="result", author="agent", created_at="2026-06-01T10:00:04.000000+00:00", text="done")++ with engine.connect() as conn:+ summary = agent_activity_service.list_turn_groups(conn, session_id=sid)+ [group] = summary["groups"]+ detail = agent_activity_service.get_turn_group(conn, session_id=sid, group_id=group["id"])++ assert detail is not None+ assert [row["id"] for row in detail["rows"]] == ["e_tool", "m_short"]++def test_agent_annotation_marks_are_not_activity(isolated_state):engine = create_sqlite_engine()sid = "ses_sp"diff --git a/tests/test_claude_agent_sessions.py b/tests/test_claude_agent_sessions.pyindex 8c6617330..aba01f4f9 100644--- a/tests/test_claude_agent_sessions.py+++ b/tests/test_claude_agent_sessions.py@@ -1608,6 +1608,63 @@ class ClaudeAgentSessionTests(unittest.IsolatedAsyncioTestCase):self.assertNotIn(composite_key, agent._pending_requests)self.assertNotIn(composite_key, agent._native_input_receipts)+ async def test_narration_keeps_claude_markdown_as_written(self):+ """Narration reaches every surface as the Markdown Claude wrote, like the Result."""++ from modules.im.formatters.avibe_formatter import AvibeFormatter++ controller = _StubController()+ controller._get_session_key = lambda _context: "session-1"+ controller.emit_agent_message = AsyncMock()+ controller.session_handler.mark_session_idle = lambda _key: None+ controller.session_handler.handle_session_error = AsyncMock()+ agent = ClaudeAgent(controller)+ agent.emit_result_message = AsyncMock()+ agent._get_formatter = lambda _context: AvibeFormatter()+ composite_key = "session-markdown-narration:/tmp/work"+ context = SimpleNamespace(+ user_id="U1",+ channel_id="C1",+ platform_specific={"turn_token": "T1"},+ )+ agent._pending_requests[composite_key] = [+ SimpleNamespace(+ context=context,+ started_at=None,+ ack_reaction_message_id=None,+ ack_reaction_emoji=None,+ )+ ]+ narration = "**Plan:** run `vibe status`, then pick one:\n\n---\n[Check] | [Skip]"++ class _Client:+ def receive_messages(self):+ async def _iterate():+ for text in (narration, "Done."):+ yield type("AssistantMessage", (), {"content": [TextBlock(text)]})()+ yield type(+ "ResultMessage",+ (),+ {"subtype": "success", "result": "Done.", "duration_ms": 1},+ )()++ return _iterate()++ await agent._receive_messages(+ _Client(),+ "session-markdown-narration",+ "/tmp/work",+ context,+ composite_key=composite_key,+ )++ controller.emit_agent_message.assert_any_await(+ context,+ "assistant",+ narration,+ parse_mode="markdown",+ )+async def test_ambiguous_results_emit_each_answer_in_order(self):controller = _StubController()controller._get_session_key = lambda _context: "session-1"diff --git a/tests/test_message_dispatcher_interim.py b/tests/test_message_dispatcher_interim.pyindex c10417884..8648b33d3 100644--- a/tests/test_message_dispatcher_interim.py+++ b/tests/test_message_dispatcher_interim.py@@ -19,18 +19,32 @@ TWO_LINES = "Reading a.py\nthen b.py"class InterimBubbleTests(unittest.IsolatedAsyncioTestCase):- async def _persisted_types(self, platform, text, **kwargs):+ async def _persisted(+ self, platform, text, *, reply_enhancements=False, interim_stored=True, **kwargs+ ):controller = _StubController(platform)+ controller.config.reply_enhancements = reply_enhancementsdispatcher = ConsolidatedMessageDispatcher(controller)context = MessageContext(user_id="u", channel_id="c", platform=platform)- with mock.patch("core.message_dispatcher.persist_agent_message") as persist:++ def _persist(_context, message_type, *_args, **_kwargs):+ if message_type == "interim" and not interim_stored:+ return None+ return {"id": f"row-{message_type}"}++ with mock.patch(+ "core.message_dispatcher.persist_agent_message", side_effect=_persist+ ) as persist:await dispatcher.emit_agent_message(context, "assistant", text, **kwargs)- return [call.args[1] for call in persist.call_args_list]+ return persist.call_args_list++ async def _persisted_types(self, platform, text, **kwargs):+ return [call.args[1] for call in await self._persisted(platform, text, **kwargs)]async def test_promotion_rule(self):cases = [- ("avibe", THREE_LINES, {}, ["assistant", "interim"]),- ("avibe", LONG_LINE, {}, ["assistant", "interim"]),+ ("avibe", THREE_LINES, {}, ["interim", "assistant"]),+ ("avibe", LONG_LINE, {}, ["interim", "assistant"]),("avibe", TWO_LINES, {}, ["assistant"]),("avibe", "a\n\n\n\nb", {}, ["assistant"]),("avibe", THREE_LINES, {"level": "process"}, ["assistant"]),@@ -40,6 +54,33 @@ class InterimBubbleTests(unittest.IsolatedAsyncioTestCase):with self.subTest(platform=platform, text=text[:20], kwargs=kwargs):self.assertEqual(await self._persisted_types(platform, text, **kwargs), expected)+ async def test_bubble_owns_the_narration_and_its_quick_replies(self):+ text = f"{THREE_LINES}\n\n---\n[Check backup] | [Skip]"+ interim, assistant = await self._persisted("avibe", text, reply_enhancements=True)++ # The process-log row keeps the raw narration and tells Activity that the+ # transcript draws it.+ self.assertEqual(assistant.args[1:3], ("assistant", text))+ self.assertEqual(assistant.kwargs["metadata"], {"transcript_copy": "interim"})+ # The bubble parses buttons exactly like a reply.+ self.assertEqual(interim.args[1:3], ("interim", THREE_LINES))+ self.assertEqual(interim.kwargs["quick_replies"], ["Check backup", "Skip"])++ # Activity keeps the narration whenever no bubble holds it: below the+ # threshold, a body that is only buttons, or a bubble that failed to store.+ for text, kwargs in (+ (TWO_LINES, {}),+ ("\n\n---\n[A]\n[B]\n[C]", {"reply_enhancements": True}),+ (THREE_LINES, {"interim_stored": False}),+ ):+ with self.subTest(text=text[:12], kwargs=kwargs):+ calls = await self._persisted("avibe", text, **kwargs)+ [log_only] = [call for call in calls if call.args[1] == "assistant"]+ self.assertIsNone(log_only.kwargs["metadata"])+ self.assertNotIn(+ "---", "".join(call.args[2] for call in calls if call.args[1] == "interim")+ )+if __name__ == "__main__":unittest.main()diff --git a/tests/test_message_mirror.py b/tests/test_message_mirror.pyindex ea95a51ef..b72c794b2 100644--- a/tests/test_message_mirror.py+++ b/tests/test_message_mirror.py@@ -845,12 +845,19 @@ def test_persist_agent_assistant_publishes_when_activity_enabled(isolated_state,async def scenario():sub_id, queue = inbox_events.bus.subscribe()try:+ # The transcript draws a marked narration as its ``interim`` copy, so+ # the live Activity stream must not repeat it.+ persist_agent_message(+ ctx, "assistant", "drawn as a bubble", metadata={"transcript_copy": "interim"}+ )+ marked = await _drain_published(queue)persist_agent_message(ctx, "assistant", "thinking out loud")- return await _drain_published(queue)+ return marked, await _drain_published(queue)finally:inbox_events.bus.unsubscribe(sub_id)- events = asyncio.run(scenario())+ marked_events, events = asyncio.run(scenario())+ assert "message.new" not in marked_eventsassert "message.new" in events and "inbox.session.updated" not in eventsassert events["message.new"]["type"] == "assistant"assert events["message.new"]["text"] == "thinking out loud"@@ -858,7 +865,7 @@ def test_persist_agent_assistant_publishes_when_activity_enabled(isolated_state,# Persisted as an assistant row (unchanged from the off case).with engine.connect() as conn:every = messages_service.list_session_messages(conn, session_id="ses_ia", types=("assistant",))- assert [m["type"] for m in every["messages"]] == ["assistant"]+ assert [m["type"] for m in every["messages"]] == ["assistant", "assistant"]def test_persist_agent_output_is_visible_without_activity_streaming(diff --git a/vibe/message_types.py b/vibe/message_types.pyindex 2a9e22f31..ea3dfed85 100644--- a/vibe/message_types.py+++ b/vibe/message_types.py@@ -145,6 +145,11 @@ def is_detached_completion(message_type: str, metadata: Any = None) -> bool:)+# Metadata on a process-log row whose text the transcript already draws as+# another row type (the Web ``interim`` bubble). The Activity timeline omits it.+TRANSCRIPT_COPY_KEY = "transcript_copy"++def activity_role_for(message_type: str, metadata: Any = None) -> str:"""Resolve one row's role in the current Turn's Activity timeline."""@@ -152,6 +157,8 @@ def activity_role_for(message_type: str, metadata: Any = None) -> str:values = metadata if isinstance(metadata, Mapping) else {}if is_detached_completion(message_type, values):return "none"+ if values.get(TRANSCRIPT_COPY_KEY):+ return "none"# Recovery has already ended the referenced Turn. A delayed visible notice# must not close a newer chronological Activity group during history reads.if (