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
feat(workbench): publish message.updated when a quick-reply choice is recorded (#2357)
Max0f5afdaea2c3
diff --git a/tests/test_ui_session_stream.py b/tests/test_ui_session_stream.pyindex 5b4884948..417d7f4c6 100644--- a/tests/test_ui_session_stream.py+++ b/tests/test_ui_session_stream.py@@ -269,6 +269,69 @@ def test_workbench_side_actions_have_fail_closed_core_message_kinds()+def test_quick_reply_choice_publishes_the_answered_row_after_it_commits(+ isolated_state,+ tmp_path,+):+ """Scenario: other windows (another tab, the desktop pet) learn that a+ quick-reply group was answered from one ``message.updated`` event that is+ published only after the choice is persisted, and only once."""+ from vibe.ui_server import app++ scope_id, session_id = _make_session(tmp_path)+ engine = create_sqlite_engine()+ with engine.begin() as conn:+ agent_row = messages_service.append(+ conn,+ scope_id=scope_id,+ session_id=session_id,+ platform="avibe",+ author="agent",+ source="agent",+ message_type="result",+ text="Pick one",+ content={"kind": "result", "quick_replies": ["Yes", "No"]},+ )++ published: list[tuple[str, dict, str | None]] = []++ def record(event_type: str, data: Any) -> None:+ # Read the committed row at publish time: the event must never+ # precede the write it announces.+ with engine.connect() as conn:+ persisted = messages_service.get_quick_reply_chosen(+ conn, session_id, agent_row["id"],+ )+ published.append((event_type, data, persisted))++ client = app.test_client()+ headers = csrf_headers(client)+ with patch("vibe.internal_client.dispatch_async", _accepted_dispatch(session_id)), \+ patch("vibe.sse_broker.broker.publish", side_effect=record):+ first = client.post(+ f"/api/sessions/{session_id}/messages",+ json={"text": "Yes", "metadata": {"quick_reply_for": agent_row["id"]}},+ headers=headers,+ )+ updates_after_first = [event for event in published if event[0] == "message.updated"]+ second = client.post(+ f"/api/sessions/{session_id}/messages",+ json={"text": "No", "metadata": {"quick_reply_for": agent_row["id"]}},+ headers=headers,+ )++ assert first.status_code == 201+ assert second.get_json() == {"already_answered": True}+ assert len(updates_after_first) == 1+ _, data, persisted = updates_after_first[0]+ assert data["id"] == agent_row["id"]+ assert data["session_id"] == session_id+ assert data["content"]["quick_reply_chosen"] == "Yes"+ assert persisted == "Yes"+ # Set-once: the second click records nothing new, so it publishes no update.+ assert [event for event in published if event[0] == "message.updated"] == updates_after_first++def test_workbench_text_uses_authenticated_author_and_core_message_kind(isolated_state,tmp_path,diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex 7a4ca289a..2de946a67 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -11805,7 +11805,23 @@ async def sessions_messages_create(session_id: str):# is set-once, so a rare double-dispatch still records one consistent answer.if status == 202 and quick_reply_for:with engine.begin() as conn:- messages_service.set_quick_reply_chosen(conn, session_id, quick_reply_for, dispatch_text)+ chosen_recorded = messages_service.set_quick_reply_chosen(+ conn, session_id, quick_reply_for, dispatch_text,+ )+ # Publish the answered agent row only after the write has committed, so+ # every window (another tab, the desktop pet) locks the group and clears+ # "needs input" from one ordered event. The user message's own+ # ``message.new`` is published during dispatch, before this write, so it+ # cannot carry the choice. Set-once: a repeat click publishes nothing.+ if chosen_recorded:+ with engine.connect() as conn:+ answered = messages_service.get_message(+ conn, quick_reply_for, session_id=session_id, include_local_error_detail=True,+ )+ if answered is not None:+ from vibe.sse_broker import broker++ broker.publish("message.updated", answered)if status == 202:delivery_state = str(body.get("delivery_state") or "")current = _current_delivery_response()