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(controller): use original trigger_message_id when clearing consolidated msg

cyhhaoaf47d7e7e21b
diff --git a/core/controller.py b/core/controller.py
index 463bf258b..550df3262 100644
--- a/core/controller.py
+++ b/core/controller.py
@@ -232,13 +232,25 @@ class Controller:
self._consolidated_message_locks[key] = asyncio.Lock()
return self._consolidated_message_locks[key]
- def clear_consolidated_message_id(self, context: MessageContext) -> None:
+ def clear_consolidated_message_id(
+ self, context: MessageContext, trigger_message_id: Optional[str] = None
+ ) -> None:
"""Clear consolidated message ID so next log message starts fresh.
Call this after user answers a question to make subsequent log messages
appear after the user's reply instead of editing the old consolidated message.
+
+ Args:
+ context: The message context
+ trigger_message_id: If provided, use this instead of context.message_id
+ for the consolidated key (needed when context is from
+ user's answer message, not original request)
"""
- key = self._get_consolidated_message_key(context)
+ # Build key with the original trigger message_id if provided
+ settings_key = self._get_settings_key(context)
+ thread_key = context.thread_id or context.channel_id
+ msg_id = trigger_message_id if trigger_message_id else (context.message_id or "")
+ key = f"{settings_key}:{thread_key}:{msg_id}"
self._consolidated_message_ids.pop(key, None)
# Also clear the buffer so we don't append to stale content
self._consolidated_message_buffers.pop(key, None)
diff --git a/modules/agents/opencode/question_handler.py b/modules/agents/opencode/question_handler.py
index 32440f555..4ac4ddb91 100644
--- a/modules/agents/opencode/question_handler.py
+++ b/modules/agents/opencode/question_handler.py
@@ -244,6 +244,7 @@ class OpenCodeQuestionHandler:
question_count = pending.get("question_count")
pending_thread_id = pending.get("thread_id")
question_message_id = pending.get("prompt_message_id")
+ trigger_message_id = pending.get("trigger_message_id") # Original request msg_id
if pending_thread_id and not request.context.thread_id:
request.context.thread_id = pending_thread_id
@@ -421,7 +422,7 @@ class OpenCodeQuestionHandler:
# Clear consolidated message ID so subsequent log messages appear after user's reply
# instead of editing the old consolidated message from before the question
- self._controller.clear_consolidated_message_id(request.context)
+ self._controller.clear_consolidated_message_id(request.context, trigger_message_id)
evt = self._question_answer_events.get(request.base_session_id)
if evt:
@@ -720,6 +721,7 @@ class OpenCodeQuestionHandler:
"multiple": multiple,
"questions": qlist,
"thread_id": request.context.thread_id,
+ "trigger_message_id": request.context.message_id, # For consolidated key
}
self._pending_questions[request.base_session_id] = pending_payload
diff --git a/modules/agents/opencode/types.py b/modules/agents/opencode/types.py
index 61b5eadba..a77de1889 100644
--- a/modules/agents/opencode/types.py
+++ b/modules/agents/opencode/types.py
@@ -24,6 +24,7 @@ class PendingQuestionPayload(TypedDict, total=False):
multiple: bool
questions: List[Dict[str, Any]]
thread_id: Optional[str]
+ trigger_message_id: Optional[str] # Original request message_id for consolidated key
@dataclass(frozen=True)