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: Add /stop command to interrupt Claude execution
cyhhao47c4deecfe59
diff --git a/core/controller.py b/core/controller.pyindex 0aa59a4a5..b36cf60f4 100644--- a/core/controller.py+++ b/core/controller.py@@ -88,7 +88,8 @@ class Controller:'clear': self.command_handler.handle_clear,'cwd': self.command_handler.handle_cwd,'set_cwd': self.command_handler.handle_set_cwd,- 'settings': self.settings_handler.handle_settings+ 'settings': self.settings_handler.handle_settings,+ 'stop': self.command_handler.handle_stop}# Register callbacks with the IM clientdiff --git a/core/handlers/command_handlers.py b/core/handlers/command_handlers.pyindex 710edf0f1..a8e979d30 100644--- a/core/handlers/command_handlers.py+++ b/core/handlers/command_handlers.py@@ -74,6 +74,7 @@ class CommandHandlers:formatter.format_text("/cwd - Show current working directory"),formatter.format_text("/set_cwd <path> - Set working directory"),formatter.format_text("/settings - Personalization settings"),+ formatter.format_text("/stop - Interrupt Claude execution"),"",formatter.format_bold("How it works:"),formatter.format_text(@@ -317,3 +318,76 @@ Use the buttons below to manage your Claude Code sessions, or simply type any mechannel_context,"📂 Click the 'Change Work Dir' button in the /start menu to change working directory.",)++ async def handle_stop(self, context: MessageContext, args: str = ""):+ """Handle /stop command - send interrupt message to Claude"""+ try:+ # Get the session handler directly from controller+ session_handler = self.controller.session_handler+ if not session_handler:+ channel_context = self._get_channel_context(context)+ await self.im_client.send_message(+ channel_context,+ "❌ Session handler not available"+ )+ return++ # Get session info for the current context+ base_session_id, working_path, composite_key = session_handler.get_session_info(context)++ # Check if there's an active Claude session+ if composite_key not in self.controller.claude_sessions:+ channel_context = self._get_channel_context(context)++ # Provide helpful guidance based on platform+ if self.config.platform == "slack":+ formatter = self.im_client.formatter+ help_text = (+ f"ℹ️ {formatter.format_bold('No active Claude session to stop')}\n\n"+ f"The stop command interrupts Claude during execution.\n\n"+ f"{formatter.format_bold('How to use in Slack:')}\n"+ f"• In channel: `/stop`\n"+ f"• In thread: Type `stop` or `@bot /stop`\n"+ f" _(Slack doesn't support slash commands in threads)_\n\n"+ f"{formatter.format_bold('Steps:')}\n"+ f"1. Send a message to Claude in a thread\n"+ f"2. While Claude is processing, send `stop` in the thread\n"+ f"3. Claude will stop but keep the session active\n\n"+ f"💡 Tip: Start a conversation with Claude first, then use stop if needed."+ )+ else:+ help_text = (+ "ℹ️ **No active Claude session to stop**\n\n"+ "The `/stop` command interrupts Claude during execution.\n\n"+ "**How to use:**\n"+ "1. Send a message to Claude\n"+ "2. While Claude is processing, send `/stop`\n"+ "3. Claude will stop execution but keep the session active\n\n"+ "💡 Tip: Start a conversation with Claude first, then use `/stop` if needed."+ )++ await self.im_client.send_message(channel_context, help_text)+ return++ # Get the Claude client for this session+ client = self.controller.claude_sessions[composite_key]++ # Send acknowledgment - use original context to send to thread if applicable+ await self.im_client.send_message(+ context, # Use original context, not channel_context+ "🛑 Sending stop signal to Claude..."+ )++ # Send interrupt message to Claude through the same session+ stop_message = "Please stop the current execution immediately and wait for further instructions."+ await client.query(stop_message, session_id=composite_key)++ logger.info(f"Sent stop command to Claude session {composite_key}")++ except Exception as e:+ logger.error(f"Error sending stop command: {e}", exc_info=True)+ # For errors, still use original context to maintain thread consistency+ await self.im_client.send_message(+ context, # Use original context+ f"❌ Error sending stop command: {str(e)}"+ )diff --git a/core/handlers/message_handler.py b/core/handlers/message_handler.pyindex 771743866..01d8683e3 100644--- a/core/handlers/message_handler.py+++ b/core/handlers/message_handler.py@@ -67,6 +67,15 @@ class MessageHandler:async def handle_user_message(self, context: MessageContext, message: str):"""Process regular user messages and send to Claude"""try:+ # Check if message is a stop command in thread (for Slack)+ # This handles the case where slash commands don't work in threads+ if context.thread_id and message.strip().lower() in ['stop', '/stop']:+ logger.info(f"Detected stop command in thread: '{message}'")+ # Delegate to the stop command handler+ if hasattr(self.controller, 'command_handler'):+ await self.controller.command_handler.handle_stop(context, "")+ return+# Get or create Claude sessionbase_session_id, working_path, composite_key = self.session_handler.get_session_info(context)client = await self.session_handler.get_or_create_claude_session(context)diff --git a/modules/im/slack.py b/modules/im/slack.pyindex 64b4b028e..466f21a59 100644--- a/modules/im/slack.py+++ b/modules/im/slack.py@@ -409,9 +409,10 @@ class SlackBot(BaseIMClient):return# Map Slack slash commands to internal commands- # Only /start command is exposed to users+ # Only /start and /stop commands are exposed to userscommand_mapping = {- 'start': 'start'+ 'start': 'start',+ 'stop': 'stop'}# Get the actual command name