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: Simplify Slack interface to single /start command
cyhhao41938f627eb8
diff --git a/CLAUDE.md b/CLAUDE.mdindex e4f0e87b0..adec4f025 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -75,6 +75,32 @@ The system uses an abstract factory pattern with platform-agnostic interfaces:4. Claude Code executes message sequentially5. Real-time output streamed back through same IM platform+## User Interface++### Slack Commands+Slack uses a simplified command structure with only one slash command:+- `/start` - Opens the main menu with interactive buttons++All functionality is accessed through buttons in the /start menu:+- **Queue Status** - Shows current queue status and messages+- **Execute Queue** - Manually trigger queue processing+- **Clear Queue** - Remove all pending messages+- **Current Dir** - Display current working directory+- **Change Work Dir** - Open modal to change working directory+- **Settings** - Configure message visibility preferences+- **How it Works** - Display help information++### Telegram Commands+Telegram supports traditional slash commands:+- `/start` - Show welcome message and available commands+- `/status` - Show current queue status+- `/queue` - Display messages in queue+- `/execute` - Manually process queue+- `/clear` - Clear message queue+- `/cwd` - Show current working directory+- `/set_cwd <path>` - Change working directory+- `/settings` - Open personalization settings+## Configuration Requirements### Essential Environment Variables@@ -101,7 +127,7 @@ Reference `modules/slack_bot.py` for a complete implementation example.## Thread and Session Management### Slack Thread Handling-Slack conversations are automatically organized into threads using `thread_timestamps` dict. Each user/channel combination gets a persistent thread for continuity.+Slack conversations are automatically organized into threads. Each user message creates a thread, and all bot responses are posted as replies in that thread for better organization.### Session IsolationEach user has an independent message queue and execution state managed by `SessionManager`. This allows concurrent users without interference.diff --git a/core/controller.py b/core/controller.pyindex 27b2572fe..67d10363d 100644--- a/core/controller.py+++ b/core/controller.py@@ -58,7 +58,8 @@ class Controller:on_message=self.handle_user_message,on_command=self.command_handlers,on_callback_query=self.handle_callback_query,- on_settings_update=self.handle_settings_update+ on_settings_update=self.handle_settings_update,+ on_change_cwd=self.handle_change_cwd_submission)async def handle_start(self, context: MessageContext, args: str = ""):@@ -109,25 +110,24 @@ How it works:# Create interactive buttons for commandsbuttons = [- # Row 1: Status commands+ # Row 1: Queue operations[- InlineButton(text="📊 Queue Status", callback_data="cmd_status"),- InlineButton(text="📋 Show Queue", callback_data="cmd_queue")+ InlineButton(text="📊 Queue Status", callback_data="cmd_queue_status"),+ InlineButton(text="🚀 Execute Queue", callback_data="cmd_execute")],- # Row 2: Queue management+ # Row 2: Queue management & Directory[- InlineButton(text="🚀 Execute Queue", callback_data="cmd_execute"),- InlineButton(text="🗑️ Clear Queue", callback_data="cmd_clear")+ InlineButton(text="🗑️ Clear Queue", callback_data="cmd_clear"),+ InlineButton(text="📁 Current Dir", callback_data="cmd_cwd")],- # Row 3: Directory commands+ # Row 3: Configuration[- InlineButton(text="📁 Current Dir", callback_data="cmd_cwd"),+ InlineButton(text="📂 Change Work Dir", callback_data="cmd_change_cwd"),InlineButton(text="⚙️ Settings", callback_data="cmd_settings")],- # Row 4: Help and info+ # Row 4: Help[- InlineButton(text="ℹ️ How it Works", callback_data="info_how_it_works"),- InlineButton(text="📖 All Commands", callback_data="info_all_commands")+ InlineButton(text="ℹ️ How it Works", callback_data="info_how_it_works")]]@@ -140,7 +140,7 @@ How it works:📍 Channel: **{channel_info.get('name', 'Unknown')}****Quick Actions:**-Choose a command below or type any message to add it to the processing queue."""+Use the buttons below to manage your Claude Code sessions, or simply 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)@@ -166,7 +166,7 @@ Choose a command below or type any message to add it to the processing queue."""target_context.thread_id = user_message_ts# Send confirmation as reply in the thread- confirmation_text = f"📝 *Received:* {message}\n⏳ *Processing...*"+ confirmation_text = f"📝 *Received*\n⏳ *Processing...*"formatted_confirmation = self.im_client.format_markdown(confirmation_text)confirmation_msg = await self.im_client.send_message(target_context,@@ -176,7 +176,7 @@ Choose a command below or type any message to add it to the processing queue.""")else:# For non-Slack platforms, just send confirmation- confirmation_text = f"📝 *Received:* {message}\n⏳ *Processing...*"+ confirmation_text = f"📝 *Received*\n⏳ *Processing...*"formatted_confirmation = self.im_client.format_markdown(confirmation_text)confirmation_msg = await self.im_client.send_message(target_context,@@ -461,6 +461,52 @@ Choose a command below or type any message to add it to the processing queue."""logger.error(f"Error getting queue details: {e}")await self.im_client.send_message(context, f"Error getting queue information: {str(e)}")+ async def handle_queue_status(self, context: MessageContext):+ """Handle combined queue status - merges status and queue details"""+ try:+ # Get both status and queue details+ status = await self.session_manager.get_status(context.user_id)+ queue_details = await self.session_manager.get_queue_details(context.user_id)++ # Combine the information+ combined_info = f"{status}\n\n{queue_details}"++ await self.im_client.send_message(context, combined_info)+ except Exception as e:+ logger.error(f"Error getting queue status: {e}")+ await self.im_client.send_message(context, f"Error getting queue status: {str(e)}")++ async def handle_change_cwd_modal(self, context: MessageContext):+ """Handle Change Work Dir button - open modal for Slack"""+ if self.config.platform != "slack":+ # For non-Slack platforms, just send instructions+ await self.im_client.send_message(+ context,+ "📂 To change working directory, use:\n`/set_cwd <path>`\n\nExample:\n`/set_cwd ~/projects/myapp`"+ )+ return++ # For Slack, open a modal dialog+ trigger_id = context.platform_specific.get('trigger_id') if context.platform_specific else None++ if trigger_id and hasattr(self.im_client, 'open_change_cwd_modal'):+ try:+ # Get current CWD to show in modal+ settings_key = self._get_settings_key(context)+ custom_cwd = self.settings_manager.get_custom_cwd(settings_key)+ current_cwd = custom_cwd if custom_cwd else self.config.claude.cwd++ await self.im_client.open_change_cwd_modal(trigger_id, current_cwd, context.channel_id)+ except Exception as e:+ logger.error(f"Error opening change CWD modal: {e}")+ await self.im_client.send_message(context, "❌ Failed to open directory change dialog. Please try again.")+ else:+ # No trigger_id, show instructions+ await self.im_client.send_message(+ context,+ "📂 Click the 'Change Work Dir' button in the /start menu to change working directory."+ )+async def handle_settings(self, context: MessageContext, args: str = ""):"""Handle settings command - show settings menu"""try:@@ -578,8 +624,15 @@ Choose a command below or type any message to add it to the processing queue."""command = callback_data.replace("cmd_", "")logger.info(f"Executing command via button click: {command}")- # Execute the corresponding command handler- if command in self.command_handlers:+ # Handle special commands+ if command == "queue_status":+ # Merge queue and status info+ await self.handle_queue_status(context)+ elif command == "change_cwd":+ # Open modal for changing work directory+ await self.handle_change_cwd_modal(context)+ elif command in self.command_handlers:+ # Execute the standard command handlerhandler = self.command_handlers[command]await handler(context, "")else:@@ -602,14 +655,14 @@ Choose a command below or type any message to add it to the processing queue."""• Use 🗑️ Clear Queue to remove all pending messages📁 *Directory Control:*-• Set working directory with `/set_cwd <path>`+• Use 📂 Change Work Dir button to set working directory• All Claude Code operations use your specified directory-• Default directory can be configured in settings+• Each channel can have its own working directory🎛️ *Personalization:*• Use ⚙️ Settings to customize message visibility• Hide `system messages`, `responses`, or `results` as needed-• Settings are saved _per user_"""+• Settings are saved _per channel_ for Slack"""elif callback_data == "info_all_commands":info_text = """📖 *All Available Commands:*@@ -739,6 +792,45 @@ _Tip: All commands work in DMs, channels, and threads!_"""# In modal context, errors are handled differentlyraise+ async def handle_change_cwd_submission(self, user_id: str, new_cwd: str, channel_id: str = None):+ """Handle CWD change from modal submission (Slack)"""+ try:+ # Expand user path and get absolute path+ expanded_path = os.path.expanduser(new_cwd.strip())+ absolute_path = os.path.abspath(expanded_path)++ # Check if directory exists+ if not os.path.exists(absolute_path):+ # Try to create it+ try:+ os.makedirs(absolute_path, exist_ok=True)+ logger.info(f"Created directory: {absolute_path}")+ except Exception as e:+ logger.error(f"Cannot create directory: {str(e)}")+ # In modal context, we can't send error messages directly+ # The modal will close, but we log the error+ return++ if not os.path.isdir(absolute_path):+ logger.error(f"Path exists but is not a directory: {absolute_path}")+ return++ # For Slack, use channel_id as the settings key+ settings_key = channel_id if self.config.platform == "slack" and channel_id else user_id++ # Save to settings+ self.settings_manager.set_custom_cwd(settings_key, absolute_path)++ logger.info(f"Updated CWD for key {settings_key}: {absolute_path}")++ # Note: In Slack modal context, we can't send a confirmation message directly+ # The modal will close automatically, indicating success++ except Exception as e:+ logger.error(f"Error updating CWD: {e}")+ # In modal context, errors are handled differently+ raise+async def periodic_cleanup(self):"""Periodic cleanup of inactive sessions"""while True:diff --git a/modules/im/slack.py b/modules/im/slack.pyindex b6675688c..f29a8d94e 100644--- a/modules/im/slack.py+++ b/modules/im/slack.py@@ -354,15 +354,9 @@ class SlackBot(BaseIMClient):return# Map Slack slash commands to internal commands+ # Only /start command is exposed to userscommand_mapping = {- 'claude-start': 'start',- 'claude-status': 'status',- 'claude-clear': 'clear',- 'claude-cwd': 'cwd',- 'claude-set-cwd': 'set_cwd',- 'claude-queue': 'queue',- 'claude-settings': 'settings',- 'claude-execute': 'execute'+ 'start': 'start'}# Get the actual command name@@ -399,10 +393,9 @@ class SlackBot(BaseIMClient):else:# Send response back to Slack for unknown commandif response_url:- available_commands = [f"`/{k}`" for k in command_mapping.keys()]await self.send_slash_response(response_url,- f"❌ Unknown command: `/{command}`\n\nAvailable commands:\n{chr(10).join(available_commands)}"+ f"❌ Unknown command: `/{command}`\n\nPlease use `/start` to access all bot features.")async def _handle_interactive(self, payload: Dict[str, Any]):@@ -467,6 +460,22 @@ class SlackBot(BaseIMClient):# Update settings - need access to settings managerif hasattr(self, '_on_settings_update'):await self._on_settings_update(user_id, hidden_types, channel_id)++ elif callback_id == "change_cwd_modal":+ # Handle change CWD modal submission+ user_id = payload.get("user", {}).get("id")+ values = view.get("state", {}).get("values", {})++ # Extract new CWD path+ new_cwd_data = values.get("new_cwd_block", {}).get("new_cwd_input", {})+ new_cwd = new_cwd_data.get("value", "")++ # Get channel_id from private_metadata+ channel_id = view.get("private_metadata")++ # Update CWD - need access to controller or settings manager+ if hasattr(self, '_on_change_cwd'):+ await self._on_change_cwd(user_id, new_cwd, channel_id)# Send success message to the user (via DM or channel)# We need to find the right channel to send the message@@ -681,6 +690,86 @@ class SlackBot(BaseIMClient):}return descriptions.get(msg_type, f"{msg_type} messages")+ async def open_change_cwd_modal(self, trigger_id: str, current_cwd: str, channel_id: str = None):+ """Open a modal dialog for changing working directory"""+ self._ensure_clients()++ # Create the modal view+ view = {+ "type": "modal",+ "callback_id": "change_cwd_modal",+ "private_metadata": channel_id or "", # Store channel_id for later use+ "title": {+ "type": "plain_text",+ "text": "Change Working Directory",+ "emoji": True+ },+ "submit": {+ "type": "plain_text",+ "text": "Change",+ "emoji": True+ },+ "close": {+ "type": "plain_text",+ "text": "Cancel",+ "emoji": True+ },+ "blocks": [+ {+ "type": "section",+ "text": {+ "type": "mrkdwn",+ "text": f"Current working directory:\n`{current_cwd}`"+ }+ },+ {+ "type": "divider"+ },+ {+ "type": "input",+ "block_id": "new_cwd_block",+ "element": {+ "type": "plain_text_input",+ "action_id": "new_cwd_input",+ "placeholder": {+ "type": "plain_text",+ "text": "Enter new directory path",+ "emoji": True+ },+ "initial_value": current_cwd+ },+ "label": {+ "type": "plain_text",+ "text": "New Working Directory:",+ "emoji": True+ },+ "hint": {+ "type": "plain_text",+ "text": "Use absolute path (e.g., /home/user/project) or ~ for home directory",+ "emoji": True+ }+ },+ {+ "type": "context",+ "elements": [+ {+ "type": "mrkdwn",+ "text": "💡 _Tip: The directory will be created if it doesn't exist._"+ }+ ]+ }+ ]+ }++ try:+ await self.web_client.views_open(+ trigger_id=trigger_id,+ view=view+ )+ except SlackApiError as e:+ logger.error(f"Error opening change CWD modal: {e}")+ raise+def register_callbacks(self, on_message: Optional[Callable] = None,on_command: Optional[Dict[str, Callable]] = None,on_callback_query: Optional[Callable] = None,@@ -701,6 +790,10 @@ class SlackBot(BaseIMClient):# Register settings update handlerif 'on_settings_update' in kwargs:self._on_settings_update = kwargs['on_settings_update']++ # Register change CWD handler+ if 'on_change_cwd' in kwargs:+ self._on_change_cwd = kwargs['on_change_cwd']async def get_or_create_thread(self, channel_id: str, user_id: str) -> Optional[str]:"""Get existing thread timestamp or return None for new thread"""