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): reset consolidated message after question answer

cyhhao114ddc8e39da
diff --git a/core/controller.py b/core/controller.py
index 42e12e934..463bf258b 100644
--- a/core/controller.py
+++ b/core/controller.py
@@ -232,6 +232,17 @@ class Controller:
self._consolidated_message_locks[key] = asyncio.Lock()
return self._consolidated_message_locks[key]
+ def clear_consolidated_message_id(self, context: MessageContext) -> 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.
+ """
+ key = self._get_consolidated_message_key(context)
+ 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)
+
def _get_consolidated_max_bytes(self) -> int:
# Slack API hard limit is exactly 4000 BYTES (not characters) for chat.update
# Chinese/emoji characters take 3-4 bytes each in UTF-8
@@ -443,6 +454,7 @@ class Controller:
first_part = self._truncate_consolidated(updated, target_bytes)
first_part = first_part.rstrip("…") + continuation_notice # Replace truncation marker
+ send_ok = False
if existing_message_id:
try:
await self.im_client.edit_message(
@@ -451,6 +463,7 @@ class Controller:
text=first_part,
parse_mode="markdown",
)
+ send_ok = True
except Exception as err:
logger.warning(f"Failed to edit oversized Log Message: {err}")
else:
@@ -458,9 +471,15 @@ class Controller:
await self.im_client.send_message(
target_context, first_part, parse_mode="markdown"
)
+ send_ok = True
except Exception as err:
logger.error(f"Failed to send oversized Log Message: {err}")
+ if not send_ok:
+ # Failed to send/edit - stop splitting and truncate the remainder
+ logger.warning("Stopping split loop due to send failure, truncating remainder")
+ break
+
# Continue with remainder (skip the part we already sent)
# Don't lstrip() - preserve intentional indentation in code blocks
sent_chars = len(first_part) - len(continuation_notice)
diff --git a/modules/agents/opencode/question_handler.py b/modules/agents/opencode/question_handler.py
index a852ef217..32440f555 100644
--- a/modules/agents/opencode/question_handler.py
+++ b/modules/agents/opencode/question_handler.py
@@ -419,6 +419,10 @@ class OpenCodeQuestionHandler:
except Exception as err:
logger.debug(f"Failed to add reaction to question message: {err}")
+ # 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)
+
evt = self._question_answer_events.get(request.base_session_id)
if evt:
evt.set()