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: Handle platform-specific markdown formatting differences

cyhhao1a2a13780dc4
diff --git a/core/controller.py b/core/controller.py
index 4da2ee057..745327875 100644
--- a/core/controller.py
+++ b/core/controller.py
@@ -121,9 +121,10 @@ How it works:
Choose a command below or type any message to add it to the processing queue."""
target_context = self._get_target_context(context)
+ formatted_welcome = self.im_client.format_markdown(welcome_text)
await self.im_client.send_message_with_buttons(
target_context,
- welcome_text,
+ formatted_welcome,
keyboard,
parse_mode='markdown'
)
@@ -146,16 +147,20 @@ Choose a command below or type any message to add it to the processing queue."""
target_context.thread_id = thread_ts
# Send confirmation with thread context
+ confirmation_text = f"📝 *Received:* {message}\n⏳ *Processing...*"
+ formatted_confirmation = self.im_client.format_markdown(confirmation_text)
confirmation_msg = await self.im_client.send_message(
target_context,
- f"📝 *Received:* {message}\n⏳ *Processing...*",
+ formatted_confirmation,
parse_mode='markdown'
)
else:
# For non-Slack platforms, just send confirmation
+ confirmation_text = f"📝 *Received:* {message}\n⏳ *Processing...*"
+ formatted_confirmation = self.im_client.format_markdown(confirmation_text)
confirmation_msg = await self.im_client.send_message(
target_context,
- f"📝 *Received:* {message}\n⏳ *Processing...*",
+ formatted_confirmation,
parse_mode='markdown'
)
@@ -214,7 +219,8 @@ Choose a command below or type any message to add it to the processing queue."""
if thread_id:
target_context.thread_id = thread_id
- await self.im_client.send_message(target_context, claude_msg, parse_mode='markdown')
+ formatted_msg = self.im_client.format_markdown(claude_msg)
+ await self.im_client.send_message(target_context, formatted_msg, parse_mode='markdown')
try:
await self.claude_client.stream_execute(message, on_claude_message, context.user_id)
@@ -338,7 +344,8 @@ Choose a command below or type any message to add it to the processing queue."""
else:
response_text += "\n💡 (Default from .env)"
- await self.im_client.send_message(context, response_text, parse_mode='markdown')
+ formatted_text = self.im_client.format_markdown(response_text)
+ await self.im_client.send_message(context, formatted_text, parse_mode='markdown')
except Exception as e:
logger.error(f"Error getting cwd: {e}")
await self.im_client.send_message(context, f"Error getting working directory: {str(e)}")
@@ -383,7 +390,8 @@ Choose a command below or type any message to add it to the processing queue."""
f"{absolute_path}\n\n"
f"This setting has been saved for your user."
)
- await self.im_client.send_message(context, response_text, parse_mode='markdown')
+ formatted_text = self.im_client.format_markdown(response_text)
+ await self.im_client.send_message(context, formatted_text, parse_mode='markdown')
except Exception as e:
logger.error(f"Error setting cwd: {e}")
@@ -571,7 +579,8 @@ Choose a command below or type any message to add it to the processing queue."""
_Tip: All commands work in DMs, channels, and threads!_"""
- await self.im_client.send_message(context, info_text, parse_mode='markdown')
+ formatted_text = self.im_client.format_markdown(info_text)
+ await self.im_client.send_message(context, formatted_text, parse_mode='markdown')
return
# Handle settings toggle buttons (existing functionality)
@@ -638,7 +647,8 @@ _Tip: All commands work in DMs, channels, and threads!_"""
)
# Send as new message
- await self.im_client.send_message(context, info_text, parse_mode='markdown')
+ formatted_text = self.im_client.format_markdown(info_text)
+ await self.im_client.send_message(context, formatted_text, parse_mode='markdown')
except Exception as e:
logger.error(f"Error handling callback query: {e}")
diff --git a/modules/im/base.py b/modules/im/base.py
index 30d9a2534..02dab4c3f 100644
--- a/modules/im/base.py
+++ b/modules/im/base.py
@@ -240,4 +240,16 @@ class BaseIMClient(ABC):
Args:
message: Info message
"""
- logger.info(message)
\ No newline at end of file
+ logger.info(message)
+
+ @abstractmethod
+ def format_markdown(self, text: str) -> str:
+ """Format markdown text for the specific platform
+
+ Args:
+ text: Text with common markdown formatting
+
+ Returns:
+ Platform-specific formatted text
+ """
+ pass
\ No newline at end of file
diff --git a/modules/im/slack.py b/modules/im/slack.py
index 625b84989..56d4c894b 100644
--- a/modules/im/slack.py
+++ b/modules/im/slack.py
@@ -487,6 +487,21 @@ class SlackBot(BaseIMClient):
logger.error(f"Error getting channel info: {e}")
raise
+ def format_markdown(self, text: str) -> str:
+ """Format markdown text for Slack mrkdwn format
+
+ Slack uses single asterisks for bold and different formatting rules
+ """
+ # Convert double asterisks to single for bold
+ formatted = text.replace('**', '*')
+
+ # Convert inline code blocks (backticks work the same)
+ # Lists work similarly
+ # Links work similarly [text](url) -> <url|text>
+ # But we'll keep simple for now - just handle bold
+
+ return formatted
+
async def open_settings_modal(self, trigger_id: str, user_settings: Any, message_types: list, display_names: dict):
"""Open a modal dialog for settings"""
self._ensure_clients()
diff --git a/modules/im/telegram.py b/modules/im/telegram.py
index c06bf4920..dea2c1481 100644
--- a/modules/im/telegram.py
+++ b/modules/im/telegram.py
@@ -390,4 +390,13 @@ class TelegramBot(BaseIMClient):
}
except TelegramError as e:
logger.error(f"Error getting channel info: {e}")
- raise
\ No newline at end of file
+ raise
+
+ def format_markdown(self, text: str) -> str:
+ """Format markdown text for Telegram
+
+ Telegram already uses double asterisks for bold, so we don't need to change much
+ """
+ # Telegram uses standard markdown with double asterisks for bold
+ # Just return the text as-is since it's already in the right format
+ return text
\ No newline at end of file