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
fix(slack): address review feedback for file attachments
yh c025cc27b6b3f
diff --git a/core/handlers/message_handler.py b/core/handlers/message_handler.pyindex cca1c0296..c15f5b9b8 100644--- a/core/handlers/message_handler.py+++ b/core/handlers/message_handler.py@@ -52,9 +52,10 @@ class MessageHandler:if hasattr(self.controller, "update_checker"):self.controller.update_checker.record_activity()- # If message is empty (e.g., user just @mentioned bot without text),+ # If message is empty AND no files attached (e.g., user just @mentioned bot without text),# trigger the /start command instead of sending empty message to agent- if not message or not message.strip():+ has_files = bool(context.files)+ if (not message or not message.strip()) and not has_files:await self.controller.command_handler.handle_start(context, "")return@@ -485,7 +486,7 @@ class MessageHandler:attachment.size = len(content)# Determine file type for logging- is_image = attachment.mimetype.startswith("image/")+ is_image = (attachment.mimetype or "").startswith("image/")file_type = "image" if is_image else "file"logger.info(f"Saved {file_type} '{attachment.name}' ({len(content)} bytes) to '{local_path}'")diff --git a/modules/agents/claude_agent.py b/modules/agents/claude_agent.pyindex 3547ae023..fac0dbbf9 100644--- a/modules/agents/claude_agent.py+++ b/modules/agents/claude_agent.py@@ -515,7 +515,7 @@ class ClaudeAgent(BaseAgent):if not attachment.local_path:continue- is_image = attachment.mimetype.startswith("image/")+ is_image = (attachment.mimetype or "").startswith("image/")if is_image:images.append(attachment)else:diff --git a/modules/agents/opencode/agent.py b/modules/agents/opencode/agent.pyindex 243de26f8..f28c9d7fe 100644--- a/modules/agents/opencode/agent.py+++ b/modules/agents/opencode/agent.py@@ -485,7 +485,7 @@ class OpenCodeAgent(OpenCodeMessageProcessorMixin, BaseAgent):if not attachment.local_path:continue- is_image = attachment.mimetype.startswith("image/")+ is_image = (attachment.mimetype or "").startswith("image/")if is_image:images.append(attachment)else:diff --git a/modules/im/base.py b/modules/im/base.pyindex 4ddb76d81..004206673 100644--- a/modules/im/base.py+++ b/modules/im/base.py@@ -2,7 +2,7 @@import loggingfrom abc import ABC, abstractmethod-from typing import Optional, Callable, Dict, Any+from typing import Optional, Callable, Dict, Any, Listfrom dataclasses import dataclasslogger = logging.getLogger(__name__)@@ -30,7 +30,7 @@ class MessageContext:thread_id: Optional[str] = Nonemessage_id: Optional[str] = Noneplatform_specific: Optional[Dict[str, Any]] = None- files: Optional[list] = None # List of FileAttachment objects+ files: Optional[List[FileAttachment]] = None # List of file attachments@dataclassdiff --git a/modules/im/slack.py b/modules/im/slack.pyindex 2fb5010d8..de828f5ec 100644--- a/modules/im/slack.py+++ b/modules/im/slack.py@@ -1,5 +1,4 @@import asyncio-import asyncioimport hashlibimport loggingimport time@@ -91,9 +90,7 @@ class SlackBot(BaseIMClient):self.web_client = AsyncWebClient(token=self.config.bot_token)if self.socket_client is None and self.config.app_token:- self.socket_client = SocketModeClient(- app_token=self.config.app_token, web_client=self.web_client- )+ self.socket_client = SocketModeClient(app_token=self.config.app_token, web_client=self.web_client)def _convert_markdown_to_slack_mrkdwn(self, text: str) -> str:"""Convert standard markdown to Slack mrkdwn format using third-party library@@ -112,9 +109,7 @@ class SlackBot(BaseIMClient):converted_text = self.markdown_converter.convert(text)return converted_textexcept Exception as e:- logger.warning(- f"Error converting markdown to mrkdwn: {e}, using original text"- )+ logger.warning(f"Error converting markdown to mrkdwn: {e}, using original text")# Fallback to original text if conversion failsreturn text@@ -141,9 +136,7 @@ class SlackBot(BaseIMClient):if context.thread_id:kwargs["thread_ts"] = context.thread_id# Optionally broadcast to channel- if context.platform_specific and context.platform_specific.get(- "reply_broadcast"- ):+ if context.platform_specific and context.platform_specific.get("reply_broadcast"):kwargs["reply_broadcast"] = Trueelif reply_to:# If reply_to is specified, use it as thread timestamp@@ -172,9 +165,7 @@ class SlackBot(BaseIMClient):# Mark thread as active if we sent a message to a threadif self.settings_manager and (context.thread_id or reply_to):thread_ts = context.thread_id or reply_to- self.settings_manager.mark_thread_active(- context.user_id, context.channel_id, thread_ts- )+ self.settings_manager.mark_thread_active(context.user_id, context.channel_id, thread_ts)logger.debug(f"Marked thread {thread_ts} as active after bot message")return response["ts"]@@ -204,11 +195,18 @@ class SlackBot(BaseIMClient):file_id = result.get("files", [{}])[0].get("id")return file_id or ""- async def download_file(self, file_info: Dict[str, Any]) -> Optional[bytes]:+ async def download_file(+ self,+ file_info: Dict[str, Any],+ max_bytes: int = 20 * 1024 * 1024, # 20MB default limit+ timeout_seconds: int = 30,+ ) -> Optional[bytes]:"""Download a Slack file using the private URL.Args:file_info: Slack file object containing url_private_download and other metadata+ max_bytes: Maximum file size to download (default 20MB)+ timeout_seconds: Request timeout in seconds (default 30s)Returns:File content as bytes, or None if download fails@@ -218,15 +216,42 @@ class SlackBot(BaseIMClient):logger.warning(f"No download URL for file: {file_info.get('name')}")return None+ # Check file size before download if available+ file_size = file_info.get("size")+ if file_size and file_size > max_bytes:+ logger.warning(f"File too large ({file_size} bytes > {max_bytes}), skipping: {file_info.get('name')}")+ return None+try:headers = {"Authorization": f"Bearer {self.config.bot_token}"}- async with aiohttp.ClientSession() as session:+ timeout = aiohttp.ClientTimeout(total=timeout_seconds)+ async with aiohttp.ClientSession(timeout=timeout) as session:async with session.get(url, headers=headers) as response:- if response.status == 200:- return await response.read()- else:+ if response.status != 200:logger.error(f"Failed to download file: HTTP {response.status}")return None++ # Check content-length header+ content_length = response.headers.get("Content-Length")+ if content_length and int(content_length) > max_bytes:+ logger.warning(f"File too large ({content_length} bytes), skipping: {file_info.get('name')}")+ return None++ # Stream download with size limit+ chunks = []+ total_size = 0+ async for chunk in response.content.iter_chunked(64 * 1024):+ total_size += len(chunk)+ if total_size > max_bytes:+ logger.warning(f"File exceeds max size during download, aborting: {file_info.get('name')}")+ return None+ chunks.append(chunk)++ return b"".join(chunks)++ except asyncio.TimeoutError:+ logger.error(f"Timeout downloading file: {file_info.get('name')}")+ return Noneexcept Exception as e:logger.error(f"Error downloading Slack file: {e}")return None@@ -289,9 +314,7 @@ class SlackBot(BaseIMClient):# NOTE: reaction failures were previously DEBUG-only; surface at INFO/WARN for operability.if error_code in ["missing_scope", "not_in_channel", "channel_not_found"]:- logger.warning(- f"Slack reaction add failed: error={error_code}, needed={needed}"- )+ logger.warning(f"Slack reaction add failed: error={error_code}, needed={needed}")else:logger.info(f"Slack reaction add failed: {err}")return False@@ -392,9 +415,7 @@ class SlackBot(BaseIMClient):# Mark thread as active if we sent a message to a threadif self.settings_manager and context.thread_id:- self.settings_manager.mark_thread_active(- context.user_id, context.channel_id, context.thread_id- )+ self.settings_manager.mark_thread_active(context.user_id, context.channel_id, context.thread_id)logger.debug(f"Marked thread {context.thread_id} as active after bot message with buttons")return response["ts"]@@ -500,9 +521,7 @@ class SlackBot(BaseIMClient):logger.error(f"Error removing Slack buttons: {e}")return False- async def answer_callback(- self, callback_id: str, text: Optional[str] = None, show_alert: bool = False- ) -> bool:+ async def answer_callback(self, callback_id: str, text: Optional[str] = None, show_alert: bool = False) -> bool:"""Answer a Slack interactive callback"""# Slack does not have a direct equivalent to answer_callback_query# Instead, we typically update the message or send an ephemeral message@@ -512,19 +531,13 @@ class SlackBot(BaseIMClient):def register_handlers(self):"""Register Slack event handlers"""if not self.socket_client:- logger.warning(- "Socket mode client not configured, skipping handler registration"- )+ logger.warning("Socket mode client not configured, skipping handler registration")return# Register socket mode request handler- self.socket_client.socket_mode_request_listeners.append(- self._handle_socket_mode_request- )+ self.socket_client.socket_mode_request_listeners.append(self._handle_socket_mode_request)- async def _handle_socket_mode_request(- self, client: SocketModeClient, req: SocketModeRequest- ):+ async def _handle_socket_mode_request(self, client: SocketModeClient, req: SocketModeRequest):"""Handle incoming Socket Mode requests"""try:if req.type == "events_api":@@ -573,12 +586,18 @@ class SlackBot(BaseIMClient):if event.get("bot_id"):return- # Ignore message subtypes (edited, deleted, joins, etc.)- # We only process plain user messages without subtype+ # Check for file attachments first+ slack_files = event.get("files", [])+ has_files = bool(slack_files)++ # Ignore most message subtypes (edited, deleted, joins, etc.)+ # But allow file-related subtypes when files are presentevent_subtype = event.get("subtype")+ file_subtypes = {"file_share", "file_comment", "file_mention"}if event_subtype:- logger.debug(f"Ignoring Slack message with subtype: {event_subtype}")- return+ if not has_files and event_subtype not in file_subtypes:+ logger.debug(f"Ignoring Slack message with subtype: {event_subtype}")+ returnchannel_id = event.get("channel")@@ -591,8 +610,7 @@ class SlackBot(BaseIMClient):logger.info(f"Skipping message event with bot mention: '{text}'")return- # Extract file attachments if present- slack_files = event.get("files", [])+ # Extract file attachments (slack_files already checked above)file_attachments = self._extract_file_attachments(slack_files) if slack_files else None# Ignore messages without user or without actual text/files@@ -696,9 +714,7 @@ class SlackBot(BaseIMClient):# Mark thread as active when bot is @mentionedif self.settings_manager and thread_id:- self.settings_manager.mark_thread_active(- event.get("user"), channel_id, thread_id- )+ self.settings_manager.mark_thread_active(event.get("user"), channel_id, thread_id)logger.info(f"Marked thread {thread_id} as active due to @mention")# Remove the mention from the text@@ -707,9 +723,7 @@ class SlackBot(BaseIMClient):text = re.sub(r"<@[\w]+>", "", text).strip()- logger.info(- f"App mention processed: original='{event.get('text')}', cleaned='{text}'"- )+ logger.info(f"App mention processed: original='{event.get('text')}', cleaned='{text}'")# Check if this is a command after mentionif text.startswith("/"):@@ -717,9 +731,7 @@ class SlackBot(BaseIMClient):command = parts[0][1:] # Remove the /args = parts[1] if len(parts) > 1 else ""- logger.info(- f"Command detected: '{command}', available: {list(self.on_command_callbacks.keys())}"- )+ logger.info(f"Command detected: '{command}', available: {list(self.on_command_callbacks.keys())}")if command in self.on_command_callbacks:logger.info(f"Executing command handler for: {command}")@@ -786,9 +798,7 @@ class SlackBot(BaseIMClient):"cwd","queue",]:- await self.send_slash_response(- response_url, f"⏳ Processing `/{command}`..."- )+ await self.send_slash_response(response_url, f"⏳ Processing `/{command}`...")await handler(context, payload.get("text", ""))elif actual_command in self.slash_command_handlers:@@ -814,6 +824,7 @@ class SlackBot(BaseIMClient):for action in actions:if action.get("action_id") == "vibe_update_now":from core.update_checker import handle_update_button_click+if hasattr(self, "_controller") and self._controller:await handle_update_button_click(self._controller, payload)return@@ -828,9 +839,7 @@ class SlackBot(BaseIMClient):# Check if channel is authorized for interactive componentsif not await self._is_authorized_channel(channel_id):- logger.info(- f"Unauthorized interactive action from channel: {channel_id}"- )+ logger.info(f"Unauthorized interactive action from channel: {channel_id}")try:await self._send_unauthorized_message(channel_id)except Exception as e:@@ -907,18 +916,14 @@ class SlackBot(BaseIMClient):values = view.get("state", {}).get("values", {})# Extract selected show message types- show_types_data = values.get("show_message_types", {}).get(- "show_types_select", {}- )+ show_types_data = values.get("show_message_types", {}).get("show_types_select", {})selected_options = show_types_data.get("selected_options", [])# Get the values from selected optionsshow_types = [opt.get("value") for opt in selected_options]# Extract require_mention setting- require_mention_data = values.get("require_mention_block", {}).get(- "require_mention_select", {}- )+ require_mention_data = values.get("require_mention_block", {}).get("require_mention_select", {})require_mention_value = require_mention_data.get("selected_option", {}).get("value")# Convert to Optional[bool]: "__default__" -> None, "true" -> True, "false" -> Falseif require_mention_value == "__default__":@@ -1017,17 +1022,13 @@ class SlackBot(BaseIMClient):backend = backend_data.get("selected_option", {}).get("value")# Extract OpenCode agent (optional)- oc_agent_data = values.get("opencode_agent_block", {}).get(- "opencode_agent_select", {}- )+ oc_agent_data = values.get("opencode_agent_block", {}).get("opencode_agent_select", {})oc_agent = oc_agent_data.get("selected_option", {}).get("value")if oc_agent == "__default__":oc_agent = None# Extract OpenCode model (optional)- oc_model_data = values.get("opencode_model_block", {}).get(- "opencode_model_select", {}- )+ oc_model_data = values.get("opencode_model_block", {}).get("opencode_model_select", {})oc_model = oc_model_data.get("selected_option", {}).get("value")if oc_model == "__default__":oc_model = None@@ -1048,25 +1049,19 @@ class SlackBot(BaseIMClient):oc_reasoning = None# Extract Claude agent (optional)- claude_agent_data = values.get("claude_agent_block", {}).get(- "claude_agent_select", {}- )+ claude_agent_data = values.get("claude_agent_block", {}).get("claude_agent_select", {})claude_agent = claude_agent_data.get("selected_option", {}).get("value")if claude_agent == "__default__":claude_agent = None# Extract Claude model (optional)- claude_model_data = values.get("claude_model_block", {}).get(- "claude_model_select", {}- )+ claude_model_data = values.get("claude_model_block", {}).get("claude_model_select", {})claude_model = claude_model_data.get("selected_option", {}).get("value")if claude_model == "__default__":claude_model = None# Extract Codex model (optional)- codex_model_data = values.get("codex_model_block", {}).get(- "codex_model_select", {}- )+ codex_model_data = values.get("codex_model_block", {}).get("codex_model_select", {})codex_model = codex_model_data.get("selected_option", {}).get("value")if codex_model == "__default__":codex_model = None@@ -1284,9 +1279,7 @@ class SlackBot(BaseIMClient):if msg_type in user_settings.show_message_types:selected_options.append(option) # Same object reference!- logger.info(- f"Creating modal with {len(options)} options, {len(selected_options)} selected"- )+ logger.info(f"Creating modal with {len(options)} options, {len(selected_options)} selected")logger.info(f"Show types: {user_settings.show_message_types}")# Debug: Log the actual data being sent@@ -1435,9 +1428,7 @@ 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- ):+ 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()@@ -1568,15 +1559,15 @@ class SlackBot(BaseIMClient):backend_options = []for backend in registered_backends:display_name = backend_display_names.get(backend, backend.capitalize())- backend_options.append({- "text": {"type": "plain_text", "text": display_name},- "value": backend,- })+ backend_options.append(+ {+ "text": {"type": "plain_text", "text": display_name},+ "value": backend,+ }+ )# Find initial backend option- selected_backend_value = (- current_backend if selected_backend is _UNSET else selected_backend- )+ selected_backend_value = current_backend if selected_backend is _UNSET else selected_backendinitial_backend = Nonefor option in backend_options:if option["value"] == selected_backend_value:@@ -1619,23 +1610,17 @@ class SlackBot(BaseIMClient):if effective_backend == "opencode" and "opencode" in registered_backends:# Get current opencode settingsif selected_opencode_agent is _UNSET:- current_oc_agent = (- current_routing.opencode_agent if current_routing else None- )+ current_oc_agent = current_routing.opencode_agent if current_routing else Noneelse:current_oc_agent = selected_opencode_agentif selected_opencode_model is _UNSET:- current_oc_model = (- current_routing.opencode_model if current_routing else None- )+ current_oc_model = current_routing.opencode_model if current_routing else Noneelse:current_oc_model = selected_opencode_modelif selected_opencode_reasoning is _UNSET:- current_oc_reasoning = (- current_routing.opencode_reasoning_effort if current_routing else None- )+ current_oc_reasoning = current_routing.opencode_reasoning_effort if current_routing else Noneelse:current_oc_reasoning = selected_opencode_reasoning@@ -1645,16 +1630,16 @@ class SlackBot(BaseIMClient):)# Build agent options- agent_options = [- {"text": {"type": "plain_text", "text": "(Default)"}, "value": "__default__"}- ]+ agent_options = [{"text": {"type": "plain_text", "text": "(Default)"}, "value": "__default__"}]for agent in opencode_agents:agent_name = agent.get("name", "")if agent_name:- agent_options.append({- "text": {"type": "plain_text", "text": agent_name},- "value": agent_name,- })+ agent_options.append(+ {+ "text": {"type": "plain_text", "text": agent_name},+ "value": agent_name,+ }+ )# Find initial agentinitial_agent = agent_options[0] # Default@@ -1676,9 +1661,7 @@ class SlackBot(BaseIMClient):default_label = "(Default)"if default_model_str:default_label = f"(Default) - {default_model_str}"- model_options = [- {"text": {"type": "plain_text", "text": default_label}, "value": "__default__"}- ]+ model_options = [{"text": {"type": "plain_text", "text": default_label}, "value": "__default__"}]# Add models from providersproviders_data = opencode_models.get("providers", [])@@ -1696,8 +1679,7 @@ class SlackBot(BaseIMClient):# Deprioritize embedding and utility models (put them at the end)is_utility = any(- kw in mid_lower- for kw in ["embedding", "tts", "whisper", "ada", "davinci", "turbo-instruct"]+ kw in mid_lower for kw in ["embedding", "tts", "whisper", "ada", "davinci", "turbo-instruct"])utility_penalty = 1 if is_utility else 0@@ -1751,10 +1733,12 @@ class SlackBot(BaseIMClient):if is_default:display += " (default)"- model_options.append({- "text": {"type": "plain_text", "text": display[:75]}, # Slack limit- "value": full_model,- })+ model_options.append(+ {+ "text": {"type": "plain_text", "text": display[:75]}, # Slack limit+ "value": full_model,+ }+ )provider_model_count += 1# Final safety check for Slack's 100 option limit@@ -1784,8 +1768,7 @@ class SlackBot(BaseIMClient):reasoning_model_key = target_model or "__default__"reasoning_action_id = (- "opencode_reasoning_select__"- + hashlib.sha1(reasoning_model_key.encode("utf-8")).hexdigest()[:8]+ "opencode_reasoning_select__" + hashlib.sha1(reasoning_model_key.encode("utf-8")).hexdigest()[:8])if target_model:@@ -1807,10 +1790,7 @@ class SlackBot(BaseIMClient):model_info = candidateelif isinstance(models, list):for entry in models:- if (- isinstance(entry, dict)- and entry.get("id") == target_model_id- ):+ if isinstance(entry, dict) and entry.get("id") == target_model_id:model_info = entrybreak@@ -1822,9 +1802,7 @@ class SlackBot(BaseIMClient):break# Build options from variants or use fallback- reasoning_effort_options = [- {"text": {"type": "plain_text", "text": "(Default)"}, "value": "__default__"}- ]+ reasoning_effort_options = [{"text": {"type": "plain_text", "text": "(Default)"}, "value": "__default__"}]if model_variants:# Use model-specific variants with stable ordering@@ -1848,17 +1826,21 @@ class SlackBot(BaseIMClient):)for variant_key in sorted_variants:display_name = variant_display_names.get(variant_key, variant_key.capitalize())- reasoning_effort_options.append({- "text": {"type": "plain_text", "text": display_name},- "value": variant_key,- })+ reasoning_effort_options.append(+ {+ "text": {"type": "plain_text", "text": display_name},+ "value": variant_key,+ }+ )else:# Fallback to common options- reasoning_effort_options.extend([- {"text": {"type": "plain_text", "text": "Low"}, "value": "low"},- {"text": {"type": "plain_text", "text": "Medium"}, "value": "medium"},- {"text": {"type": "plain_text", "text": "High"}, "value": "high"},- ])+ reasoning_effort_options.extend(+ [+ {"text": {"type": "plain_text", "text": "Low"}, "value": "low"},+ {"text": {"type": "plain_text", "text": "Medium"}, "value": "medium"},+ {"text": {"type": "plain_text", "text": "High"}, "value": "high"},+ ]+ )# Find initial reasoning effortinitial_reasoning = reasoning_effort_options[0] # Default@@ -1877,39 +1859,41 @@ class SlackBot(BaseIMClient):}# Add OpenCode section- blocks.extend([- {"type": "divider"},- {- "type": "section",- "text": {- "type": "mrkdwn",- "text": "*OpenCode Settings*",+ blocks.extend(+ [+ {"type": "divider"},+ {+ "type": "section",+ "text": {+ "type": "mrkdwn",+ "text": "*OpenCode Settings*",+ },},- },- {- "type": "input",- "block_id": "opencode_agent_block",- "optional": True,- "dispatch_action": True,- "element": agent_select,- "label": {"type": "plain_text", "text": "OpenCode Agent"},- },- {- "type": "input",- "block_id": "opencode_model_block",- "optional": True,- "dispatch_action": True,- "element": model_select,- "label": {"type": "plain_text", "text": "Model"},- },- {- "type": "input",- "block_id": "opencode_reasoning_block",- "optional": True,- "element": reasoning_select,- "label": {"type": "plain_text", "text": "Reasoning Effort (Thinking Mode)"},- },- ])+ {+ "type": "input",+ "block_id": "opencode_agent_block",+ "optional": True,+ "dispatch_action": True,+ "element": agent_select,+ "label": {"type": "plain_text", "text": "OpenCode Agent"},+ },+ {+ "type": "input",+ "block_id": "opencode_model_block",+ "optional": True,+ "dispatch_action": True,+ "element": model_select,+ "label": {"type": "plain_text", "text": "Model"},+ },+ {+ "type": "input",+ "block_id": "opencode_reasoning_block",+ "optional": True,+ "element": reasoning_select,+ "label": {"type": "plain_text", "text": "Reasoning Effort (Thinking Mode)"},+ },+ ]+ )# Claude-specific options (only if claude is selected)if effective_backend == "claude" and "claude" in registered_backends:@@ -1918,31 +1902,27 @@ class SlackBot(BaseIMClient):# Get current claude settingsif selected_claude_agent is _UNSET:- current_cl_agent = (- current_routing.claude_agent if current_routing else None- )+ current_cl_agent = current_routing.claude_agent if current_routing else Noneelse:current_cl_agent = selected_claude_agentif selected_claude_model is _UNSET:- current_cl_model = (- current_routing.claude_model if current_routing else None- )+ current_cl_model = current_routing.claude_model if current_routing else Noneelse:current_cl_model = selected_claude_model# Build agent options- cl_agent_options = [- {"text": {"type": "plain_text", "text": "(Default)"}, "value": "__default__"}- ]+ cl_agent_options = [{"text": {"type": "plain_text", "text": "(Default)"}, "value": "__default__"}]for agent in claude_agents:agent_id = agent.get("id", "")agent_name = agent.get("name", agent_id)if agent_id:- cl_agent_options.append({- "text": {"type": "plain_text", "text": agent_name[:75]},- "value": agent_id,- })+ cl_agent_options.append(+ {+ "text": {"type": "plain_text", "text": agent_name[:75]},+ "value": agent_id,+ }+ )# Find initial agentinitial_cl_agent = cl_agent_options[0]@@ -1961,22 +1941,24 @@ class SlackBot(BaseIMClient):}# Build model options- cl_model_options = [- {"text": {"type": "plain_text", "text": "(Default)"}, "value": "__default__"}- ]+ cl_model_options = [{"text": {"type": "plain_text", "text": "(Default)"}, "value": "__default__"}]for model in claude_models:if model:- cl_model_options.append({- "text": {"type": "plain_text", "text": model[:75]},- "value": model,- })+ cl_model_options.append(+ {+ "text": {"type": "plain_text", "text": model[:75]},+ "value": model,+ }+ )# Add current model if not in list (preserve custom models)if current_cl_model and not any(opt["value"] == current_cl_model for opt in cl_model_options):- cl_model_options.append({- "text": {"type": "plain_text", "text": current_cl_model[:75]},- "value": current_cl_model,- })+ cl_model_options.append(+ {+ "text": {"type": "plain_text", "text": current_cl_model[:75]},+ "value": current_cl_model,+ }+ )# Limit to 100 optionsif len(cl_model_options) > 100:@@ -1999,30 +1981,32 @@ class SlackBot(BaseIMClient):}# Add Claude section- blocks.extend([- {"type": "divider"},- {- "type": "section",- "text": {- "type": "mrkdwn",- "text": "*Claude Settings*",+ blocks.extend(+ [+ {"type": "divider"},+ {+ "type": "section",+ "text": {+ "type": "mrkdwn",+ "text": "*Claude Settings*",+ },},- },- {- "type": "input",- "block_id": "claude_agent_block",- "optional": True,- "element": cl_agent_select,- "label": {"type": "plain_text", "text": "Claude Agent"},- },- {- "type": "input",- "block_id": "claude_model_block",- "optional": True,- "element": cl_model_select,- "label": {"type": "plain_text", "text": "Model"},- },- ])+ {+ "type": "input",+ "block_id": "claude_agent_block",+ "optional": True,+ "element": cl_agent_select,+ "label": {"type": "plain_text", "text": "Claude Agent"},+ },+ {+ "type": "input",+ "block_id": "claude_model_block",+ "optional": True,+ "element": cl_model_select,+ "label": {"type": "plain_text", "text": "Model"},+ },+ ]+ )# Codex-specific options (only if codex is selected)if effective_backend == "codex" and "codex" in registered_backends:@@ -2030,36 +2014,34 @@ class SlackBot(BaseIMClient):# Get current codex settingsif selected_codex_model is _UNSET:- current_cx_model = (- current_routing.codex_model if current_routing else None- )+ current_cx_model = current_routing.codex_model if current_routing else Noneelse:current_cx_model = selected_codex_modelif selected_codex_reasoning is _UNSET:- current_cx_reasoning = (- current_routing.codex_reasoning_effort if current_routing else None- )+ current_cx_reasoning = current_routing.codex_reasoning_effort if current_routing else Noneelse:current_cx_reasoning = selected_codex_reasoning# Build model options- cx_model_options = [- {"text": {"type": "plain_text", "text": "(Default)"}, "value": "__default__"}- ]+ cx_model_options = [{"text": {"type": "plain_text", "text": "(Default)"}, "value": "__default__"}]for model in codex_models:if model:- cx_model_options.append({- "text": {"type": "plain_text", "text": model[:75]},- "value": model,- })+ cx_model_options.append(+ {+ "text": {"type": "plain_text", "text": model[:75]},+ "value": model,+ }+ )# Add current model if not in list (preserve custom models)if current_cx_model and not any(opt["value"] == current_cx_model for opt in cx_model_options):- cx_model_options.append({- "text": {"type": "plain_text", "text": current_cx_model[:75]},- "value": current_cx_model,- })+ cx_model_options.append(+ {+ "text": {"type": "plain_text", "text": current_cx_model[:75]},+ "value": current_cx_model,+ }+ )# Limit to 100 optionsif len(cx_model_options) > 100:@@ -2106,41 +2088,45 @@ class SlackBot(BaseIMClient):}# Add Codex section- blocks.extend([- {"type": "divider"},- {- "type": "section",- "text": {- "type": "mrkdwn",- "text": "*Codex Settings*",+ blocks.extend(+ [+ {"type": "divider"},+ {+ "type": "section",+ "text": {+ "type": "mrkdwn",+ "text": "*Codex Settings*",+ },},- },- {- "type": "input",- "block_id": "codex_model_block",- "optional": True,- "element": cx_model_select,- "label": {"type": "plain_text", "text": "Model"},- },- {- "type": "input",- "block_id": "codex_reasoning_block",- "optional": True,- "element": cx_reasoning_select,- "label": {"type": "plain_text", "text": "Reasoning Effort"},- },- ])+ {+ "type": "input",+ "block_id": "codex_model_block",+ "optional": True,+ "element": cx_model_select,+ "label": {"type": "plain_text", "text": "Model"},+ },+ {+ "type": "input",+ "block_id": "codex_reasoning_block",+ "optional": True,+ "element": cx_reasoning_select,+ "label": {"type": "plain_text", "text": "Reasoning Effort"},+ },+ ]+ )# Add tip- blocks.append({- "type": "context",- "elements": [- {- "type": "mrkdwn",- "text": "_💡 Select (Default) to use the backend's configured defaults._",- }- ],- })+ blocks.append(+ {+ "type": "context",+ "elements": [+ {+ "type": "mrkdwn",+ "text": "_💡 Select (Default) to use the backend's configured defaults._",+ }+ ],+ }+ )return {"type": "modal",@@ -2533,16 +2519,12 @@ class SlackBot(BaseIMClient):if "on_ready" in kwargs:self._on_ready = kwargs["on_ready"]- async def get_or_create_thread(- self, channel_id: str, user_id: str- ) -> Optional[str]:+ 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"""# Deprecated: Thread handling now uses user's message timestamp directlyreturn None- async def send_slash_response(- self, response_url: str, text: str, ephemeral: bool = True- ) -> bool:+ async def send_slash_response(self, response_url: str, text: str, ephemeral: bool = True) -> bool:"""Send response to a slash command via response_url"""try:import aiohttp