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.

feat(discord): streamline onboarding and settings flows

cyhhao19c98d58aa36
diff --git a/core/controller.py b/core/controller.py
index dd9fa1e95..7fd63f39a 100644
--- a/core/controller.py
+++ b/core/controller.py
@@ -667,6 +667,7 @@ class Controller:
channel_id: Optional[str] = None,
require_mention: Optional[bool] = None,
language: Optional[str] = None,
+ notify_user: bool = True,
):
"""Handle settings update (typically from Slack modal)"""
try:
@@ -713,25 +714,29 @@ class Controller:
)
# Send confirmation
- await self.im_client.send_message(context, f"✅ {self._t('success.settingsUpdated')}")
- if not language_saved:
- await self.im_client.send_message(
- context,
- f"⚠️ {self._t('error.languageUpdateFailed')}",
- )
+ if notify_user:
+ await self.im_client.send_message(context, f"✅ {self._t('success.settingsUpdated')}")
+ if not language_saved:
+ await self.im_client.send_message(
+ context,
+ f"⚠️ {self._t('error.languageUpdateFailed')}",
+ )
except Exception as e:
logger.error(f"Error updating settings: {e}")
- # Create context for error message (without 'message' field)
- context = MessageContext(
- user_id=user_id,
- channel_id=channel_id if channel_id else user_id,
- platform_specific={},
- )
- await self.im_client.send_message(
- context,
- f"❌ {self._t('error.settingsUpdateFailed', error=str(e))}",
- )
+ if notify_user:
+ # Create context for error message (without 'message' field)
+ context = MessageContext(
+ user_id=user_id,
+ channel_id=channel_id if channel_id else user_id,
+ platform_specific={},
+ )
+ await self.im_client.send_message(
+ context,
+ f"❌ {self._t('error.settingsUpdateFailed', error=str(e))}",
+ )
+ else:
+ raise
# Working directory change handler (for Slack modal)
async def handle_change_cwd_submission(self, user_id: str, new_cwd: str, channel_id: Optional[str] = None):
@@ -1032,6 +1037,7 @@ class Controller:
claude_model: Optional[str] = None,
codex_model: Optional[str] = None,
codex_reasoning_effort: Optional[str] = None,
+ notify_user: bool = True,
):
"""Handle routing update submission (from Slack modal)"""
from modules.settings_manager import ChannelRouting
@@ -1102,11 +1108,12 @@ class Controller:
platform_specific={},
)
- await self.im_client.send_message(
- context,
- f"✅ {self._t('success.routingUpdated')}\n" + "\n".join(parts),
- parse_mode="markdown",
- )
+ if notify_user:
+ await self.im_client.send_message(
+ context,
+ f"✅ {self._t('success.routingUpdated')}\n" + "\n".join(parts),
+ parse_mode="markdown",
+ )
logger.info(
f"Routing updated for {settings_key}: backend={backend}, "
@@ -1122,10 +1129,13 @@ class Controller:
channel_id=channel_id if channel_id else user_id,
platform_specific={},
)
- await self.im_client.send_message(
- context,
- f"❌ {self._t('error.routingUpdateFailed', error=str(e))}",
- )
+ if notify_user:
+ await self.im_client.send_message(
+ context,
+ f"❌ {self._t('error.routingUpdateFailed', error=str(e))}",
+ )
+ else:
+ raise
# Main run method
def run(self):
diff --git a/modules/agents/opencode/utils.py b/modules/agents/opencode/utils.py
index 7dd105c82..cfa745c6c 100644
--- a/modules/agents/opencode/utils.py
+++ b/modules/agents/opencode/utils.py
@@ -5,7 +5,7 @@ Keep this module free of agent state. It should only contain pure helpers.
from __future__ import annotations
-from typing import Any, Dict, List, Optional
+from typing import Any, Dict, List, Optional, Tuple
_REASONING_FALLBACK_OPTIONS = [
@@ -26,6 +26,8 @@ _REASONING_VARIANT_LABELS = {
"max": "Max",
}
+_UTILITY_MODEL_KEYWORDS = ["embedding", "tts", "whisper", "ada", "davinci", "turbo-instruct"]
+
def _parse_model_key(model_key: Optional[str]) -> tuple[str, str]:
if not model_key:
@@ -36,6 +38,11 @@ def _parse_model_key(model_key: Optional[str]) -> tuple[str, str]:
return parts[0], parts[1]
+def _parse_provider_id(model_key: Optional[str]) -> Optional[str]:
+ provider_id, _ = _parse_model_key(model_key)
+ return provider_id or None
+
+
def _find_model_variants(opencode_models: dict, target_model: Optional[str]) -> Dict[str, Any]:
target_provider, target_model_id = _parse_model_key(target_model)
if not target_provider or not target_model_id or not isinstance(opencode_models, dict):
@@ -66,6 +73,213 @@ def _find_model_variants(opencode_models: dict, target_model: Optional[str]) ->
return {}
+def _append_unique(target: List[str], value: Optional[str]) -> None:
+ if not value or value in target:
+ return
+ target.append(value)
+
+
+def _extract_provider_ids_from_config(config: dict) -> List[str]:
+ providers: List[str] = []
+ if not isinstance(config, dict):
+ return providers
+
+ provider_value = config.get("provider")
+ if isinstance(provider_value, str):
+ _append_unique(providers, provider_value)
+
+ default_provider = config.get("default_provider")
+ if isinstance(default_provider, str):
+ _append_unique(providers, default_provider)
+
+ config_providers = config.get("providers")
+ if isinstance(config_providers, dict):
+ for key in config_providers.keys():
+ _append_unique(providers, key)
+ elif isinstance(config_providers, list):
+ for entry in config_providers:
+ if isinstance(entry, str):
+ _append_unique(providers, entry)
+ continue
+ if isinstance(entry, dict):
+ value = entry.get("id") or entry.get("provider") or entry.get("name")
+ if isinstance(value, str):
+ _append_unique(providers, value)
+
+ return providers
+
+
+def resolve_opencode_default_model(
+ opencode_default_config: dict,
+ opencode_agents: list,
+ selected_agent: Optional[str],
+) -> Optional[str]:
+ """Resolve default OpenCode model for an agent from config."""
+ agent_names: List[str] = []
+ for agent in opencode_agents or []:
+ if isinstance(agent, dict):
+ name = agent.get("name") or agent.get("id")
+ elif isinstance(agent, str):
+ name = agent
+ else:
+ name = None
+ if isinstance(name, str) and name:
+ agent_names.append(name)
+
+ agent_name = selected_agent or ("build" if "build" in agent_names else (agent_names[0] if agent_names else None))
+
+ if isinstance(opencode_default_config, dict):
+ agents_config = opencode_default_config.get("agent", {})
+ if isinstance(agents_config, dict) and agent_name:
+ agent_config = agents_config.get(agent_name, {})
+ if isinstance(agent_config, dict):
+ model = agent_config.get("model")
+ if isinstance(model, str) and model:
+ return model
+ model = opencode_default_config.get("model")
+ if isinstance(model, str) and model:
+ return model
+ return None
+
+
+def resolve_opencode_provider_preferences(
+ opencode_default_config: dict,
+ current_model: Optional[str] = None,
+) -> List[str]:
+ """Return provider IDs to prefer first when listing models."""
+ providers: List[str] = []
+
+ _append_unique(providers, _parse_provider_id(current_model))
+
+ if isinstance(opencode_default_config, dict):
+ _append_unique(providers, _parse_provider_id(opencode_default_config.get("model")))
+ agents_config = opencode_default_config.get("agent", {})
+ if isinstance(agents_config, dict):
+ for agent_config in agents_config.values():
+ if isinstance(agent_config, dict):
+ _append_unique(providers, _parse_provider_id(agent_config.get("model")))
+
+ for provider_id in _extract_provider_ids_from_config(opencode_default_config):
+ _append_unique(providers, provider_id)
+
+ return providers
+
+
+def resolve_opencode_allowed_providers(
+ opencode_default_config: dict,
+ opencode_models: Optional[dict] = None,
+) -> List[str]:
+ """Return provider IDs to include when listing models."""
+ providers = _extract_provider_ids_from_config(opencode_default_config)
+ if providers:
+ return providers
+ if isinstance(opencode_models, dict):
+ defaults = opencode_models.get("default", {})
+ if isinstance(defaults, dict) and defaults:
+ return [key for key in defaults.keys() if isinstance(key, str) and key]
+ return []
+
+
+def _model_sort_key(model_item: Tuple[str, Any]) -> Tuple[int, int, str]:
+ """Sort models by utility penalty, release date (DESC), then id."""
+ model_id, model_info = model_item
+ mid_lower = (model_id or "").lower()
+ is_utility = any(keyword in mid_lower for keyword in _UTILITY_MODEL_KEYWORDS)
+ utility_penalty = 1 if is_utility else 0
+ release_date = "1970-01-01"
+ if isinstance(model_info, dict):
+ release_date = model_info.get("release_date", "1970-01-01") or "1970-01-01"
+ try:
+ date_int = -int(release_date.replace("-", ""))
+ except (ValueError, AttributeError):
+ date_int = 0
+ return (utility_penalty, date_int, model_id or "")
+
+
+def build_opencode_model_option_items(
+ opencode_models: dict,
+ max_total: int,
+ preferred_providers: Optional[List[str]] = None,
+ allowed_providers: Optional[List[str]] = None,
+) -> List[Dict[str, str]]:
+ """Build sorted model options for OpenCode providers."""
+ if not isinstance(opencode_models, dict) or max_total <= 0:
+ return []
+
+ providers_data = opencode_models.get("providers", [])
+ defaults = opencode_models.get("default", {})
+
+ providers: List[Tuple[str, dict]] = []
+ for provider in providers_data:
+ provider_id = provider.get("id") or provider.get("provider_id") or provider.get("name") or ""
+ if not provider_id:
+ continue
+ providers.append((provider_id, provider))
+
+ if allowed_providers:
+ allowed_set = {p for p in allowed_providers if isinstance(p, str) and p}
+ if allowed_set:
+ providers = [entry for entry in providers if entry[0] in allowed_set]
+
+ if preferred_providers:
+ preferred_set = {p for p in preferred_providers if isinstance(p, str) and p}
+ if preferred_set:
+ provider_map = {pid: provider for pid, provider in providers}
+ ordered: List[Tuple[str, dict]] = []
+ for pid in preferred_providers:
+ provider = provider_map.get(pid)
+ if provider is not None:
+ ordered.append((pid, provider))
+ for pid, provider in providers:
+ if pid not in preferred_set:
+ ordered.append((pid, provider))
+ providers = ordered
+
+ num_providers = len(providers)
+ max_per_provider = max(5, (max_total // num_providers)) if num_providers > 0 else max_total
+
+ options: List[Dict[str, str]] = []
+ for provider_id, provider in providers:
+ provider_name = provider.get("name") or provider_id
+ models = provider.get("models", {})
+
+ if isinstance(models, dict):
+ model_items = list(models.items())
+ elif isinstance(models, list):
+ model_items = [
+ (entry, entry) if isinstance(entry, str) else (entry.get("id", ""), entry)
+ for entry in models
+ ]
+ else:
+ model_items = []
+
+ model_items.sort(key=_model_sort_key)
+ provider_model_count = 0
+ for model_id, model_info in model_items:
+ if provider_model_count >= max_per_provider:
+ break
+ if not model_id:
+ continue
+
+ if isinstance(model_info, dict):
+ model_name = model_info.get("name", model_id) or model_id
+ else:
+ model_name = model_id
+
+ full_model = f"{provider_id}/{model_id}" if provider_id else model_id
+ is_default = defaults.get(provider_id) == model_id if provider_id else False
+ display = f"{provider_name}: {model_name}" if provider_name else model_name
+ if is_default:
+ display += " (default)"
+
+ options.append({"label": display, "value": full_model})
+ provider_model_count += 1
+
+ if len(options) > max_total:
+ options = options[:max_total]
+ return options
+
+
def _build_reasoning_options_from_variants(variants: Dict[str, Any]) -> List[Dict[str, str]]:
sorted_variants = sorted(
variants.keys(),
diff --git a/modules/im/discord.py b/modules/im/discord.py
index ca3ca14ff..8ea6fd0ed 100644
--- a/modules/im/discord.py
+++ b/modules/im/discord.py
@@ -11,6 +11,13 @@ from .base import BaseIMClient, MessageContext, InlineKeyboard, InlineButton, Fi
from config.v2_config import DiscordConfig
from .formatters import DiscordFormatter
from vibe.i18n import get_supported_languages, t as i18n_t
+from modules.agents.opencode.utils import (
+ build_opencode_model_option_items,
+ build_reasoning_effort_options,
+ resolve_opencode_allowed_providers,
+ resolve_opencode_default_model,
+ resolve_opencode_provider_preferences,
+)
logger = logging.getLogger(__name__)
@@ -233,7 +240,10 @@ class DiscordBot(BaseIMClient):
return False
try:
msg = await target.fetch_message(int(message_id))
- await msg.add_reaction(emoji)
+ normalized = emoji
+ if normalized in [":eyes:", "eyes", "eye", "👀"]:
+ normalized = "👀"
+ await msg.add_reaction(normalized)
return True
except Exception as err:
logger.debug("Failed to add Discord reaction: %s", err)
@@ -245,7 +255,10 @@ class DiscordBot(BaseIMClient):
return False
try:
msg = await target.fetch_message(int(message_id))
- await msg.remove_reaction(emoji, self.client.user)
+ normalized = emoji
+ if normalized in [":eyes:", "eyes", "eye", "👀"]:
+ normalized = "👀"
+ await msg.remove_reaction(normalized, self.client.user)
return True
except Exception as err:
logger.debug("Failed to remove Discord reaction: %s", err)
@@ -405,6 +418,8 @@ class DiscordBot(BaseIMClient):
channel_id, global_default=self.config.require_mention
)
+ mentioned_bot = bool(self.client.user and message.mentions and self.client.user in message.mentions)
+
if effective_require_mention and not is_dm:
if isinstance(channel, discord.Thread):
if self.settings_manager:
@@ -440,6 +455,16 @@ class DiscordBot(BaseIMClient):
return
if not content and not files:
+ if mentioned_bot and self.on_message_callback:
+ context = MessageContext(
+ user_id=str(message.author.id),
+ channel_id=channel_id,
+ thread_id=thread_id,
+ message_id=str(message.id),
+ platform_specific={"message": message},
+ files=files,
+ )
+ await self.on_message_callback(context, "")
return
# For non-thread guild messages, create a real thread
@@ -496,59 +521,123 @@ class DiscordBot(BaseIMClient):
):
interaction = trigger_id if isinstance(trigger_id, discord.Interaction) else None
- selected_types = set(user_settings.show_message_types or [])
- type_options = [
- discord.SelectOption(
- label=display_names.get(mt, mt),
- value=mt,
- default=mt in selected_types,
- )
- for mt in message_types
- ]
- require_options = [
- discord.SelectOption(label="Default", value="__default__", default=current_require_mention is None),
- discord.SelectOption(label="Require mention", value="true", default=current_require_mention is True),
- discord.SelectOption(label="No mention required", value="false", default=current_require_mention is False),
- ]
- language_options = [
- discord.SelectOption(label=lang, value=lang, default=lang == current_language)
- for lang in get_supported_languages()
- ]
+ def _prefixed_label(prefix_key: str, label: str, limit: int = 100) -> str:
+ prefix = self._t(prefix_key)
+ combined = f"{prefix}: {label}" if prefix else label
+ if len(combined) > limit:
+ return combined[:limit]
+ return combined
class SettingsView(discord.ui.View):
def __init__(self, outer: DiscordBot, owner_id: Optional[str]):
super().__init__(timeout=900)
self.outer = outer
self.owner_id = owner_id
+ self.selected_types = set(user_settings.show_message_types or [])
+ if current_require_mention is None:
+ self.require_value = "__default__"
+ elif current_require_mention is True:
+ self.require_value = "true"
+ else:
+ self.require_value = "false"
+ self.language_value = current_language or outer._get_lang()
+ self._save_callback = None
+ type_options = []
+ for mt in message_types:
+ display_name = display_names.get(mt, mt)
+ label = _prefixed_label("discord.labels.messageTypes", str(display_name))
+ type_options.append(
+ discord.SelectOption(
+ label=label,
+ value=mt,
+ default=mt in self.selected_types,
+ )
+ )
+ default_status = self.outer._t("common.on") if global_require_mention else self.outer._t("common.off")
+ require_options = [
+ discord.SelectOption(
+ label=_prefixed_label(
+ "discord.labels.mentionPolicy",
+ self.outer._t("modal.settings.optionDefault", status=default_status),
+ ),
+ value="__default__",
+ default=self.require_value == "__default__",
+ ),
+ discord.SelectOption(
+ label=_prefixed_label(
+ "discord.labels.mentionPolicy",
+ self.outer._t("modal.settings.optionRequireMention"),
+ ),
+ value="true",
+ default=self.require_value == "true",
+ ),
+ discord.SelectOption(
+ label=_prefixed_label(
+ "discord.labels.mentionPolicy",
+ self.outer._t("modal.settings.optionDontRequireMention"),
+ ),
+ value="false",
+ default=self.require_value == "false",
+ ),
+ ]
+ language_options = [
+ discord.SelectOption(
+ label=_prefixed_label("discord.labels.language", lang),
+ value=lang,
+ default=lang == self.language_value,
+ )
+ for lang in get_supported_languages()
+ ]
+
self.types_select = discord.ui.Select(
- placeholder="Visible message types",
+ placeholder=self.outer._t("modal.settings.showMessageTypesPlaceholder"),
options=type_options,
min_values=0,
max_values=len(type_options) if type_options else 1,
)
self.require_select = discord.ui.Select(
- placeholder="Require mention",
+ placeholder=self.outer._t("modal.settings.selectMentionBehavior"),
options=require_options,
min_values=1,
max_values=1,
)
self.lang_select = discord.ui.Select(
- placeholder="Language",
+ placeholder=self.outer._t("modal.settings.language"),
options=language_options,
min_values=1,
max_values=1,
)
- async def _defer(interaction: discord.Interaction):
- await interaction.response.defer()
+ async def types_callback(select_interaction: discord.Interaction):
+ self.selected_types = set(self.types_select.values or [])
+ await select_interaction.response.defer()
+
+ async def require_callback(select_interaction: discord.Interaction):
+ if self.require_select.values:
+ self.require_value = self.require_select.values[0]
+ await select_interaction.response.defer()
+
+ async def language_callback(select_interaction: discord.Interaction):
+ if self.lang_select.values:
+ self.language_value = self.lang_select.values[0]
+ await select_interaction.response.defer()
- self.types_select.callback = _defer
- self.require_select.callback = _defer
- self.lang_select.callback = _defer
+ self.types_select.callback = types_callback
+ self.require_select.callback = require_callback
+ self.lang_select.callback = language_callback
self.add_item(self.types_select)
self.add_item(self.require_select)
self.add_item(self.lang_select)
- self.add_item(discord.ui.Button(label="Save", style=discord.ButtonStyle.primary))
+ save_button = discord.ui.Button(
+ label=self.outer._t("common.save"),
+ style=discord.ButtonStyle.primary,
+ )
+ save_button.callback = self._on_save
+ self.add_item(save_button)
+
+ async def _on_save(self, interaction: discord.Interaction):
+ if self._save_callback:
+ await self._save_callback(interaction)
async def interaction_check(self, interaction: discord.Interaction) -> bool:
if self.owner_id and str(interaction.user.id) != self.owner_id:
@@ -565,33 +654,47 @@ class DiscordBot(BaseIMClient):
view = SettingsView(self, owner_id)
async def save_callback(save_interaction: discord.Interaction):
- show_types = list(view.types_select.values or [])
- require_value = view.require_select.values[0] if view.require_select.values else "__default__"
+ show_types = list(view.selected_types or [])
+ require_value = view.require_value
if require_value == "__default__":
require_mention = None
elif require_value == "true":
require_mention = True
else:
require_mention = False
- language = view.lang_select.values[0] if view.lang_select.values else current_language
- if hasattr(self, "_on_settings_update"):
- await self._on_settings_update(
- str(save_interaction.user.id),
- show_types,
- channel_id or str(save_interaction.channel_id or ""),
- require_mention,
- language,
+ language = view.language_value
+ try:
+ await save_interaction.response.defer()
+ if hasattr(self, "_on_settings_update"):
+ await self._on_settings_update(
+ str(save_interaction.user.id),
+ show_types,
+ channel_id or str(save_interaction.channel_id or ""),
+ require_mention,
+ language,
+ notify_user=False,
+ )
+ await save_interaction.edit_original_response(
+ content=f"✅ {self._t('success.settingsUpdated')}",
+ embed=None,
+ view=None,
+ )
+ except Exception as err:
+ await save_interaction.edit_original_response(
+ content=f"❌ {self._t('error.settingsUpdateFailed', error=str(err))}",
+ embed=None,
+ view=None,
)
- await save_interaction.response.edit_message(content="✅ Settings updated.", view=None)
-
- # Patch the save button callback
- for item in view.children:
- if isinstance(item, discord.ui.Button) and item.label == "Save":
- item.callback = save_callback
+ view._save_callback = save_callback
+ settings_title = f"⚙️ {self._t('modal.settings.title')}"
+ settings_embed = discord.Embed(
+ title=settings_title,
+ description=self._t("discord.settingsSubtitle"),
+ )
if interaction:
await interaction.response.send_message(
- "⚙️ Settings",
+ embed=settings_embed,
view=view,
ephemeral=True,
)
@@ -599,7 +702,7 @@ class DiscordBot(BaseIMClient):
channel = await self._fetch_channel(channel_id)
if channel is None:
raise RuntimeError("Discord channel not found")
- await channel.send("⚙️ Settings", view=view)
+ await channel.send(embed=settings_embed, view=view)
async def open_resume_session_modal(
self,
@@ -722,6 +825,40 @@ class DiscordBot(BaseIMClient):
):
interaction = trigger_id if isinstance(trigger_id, discord.Interaction) else None
+ backend_display_names = {
+ "claude": "ClaudeCode",
+ "codex": "Codex",
+ "opencode": "OpenCode",
+ }
+
+ def _prefixed_label(prefix_key: str, label: str, limit: int = 100) -> str:
+ prefix = self._t(prefix_key)
+ combined = f"{prefix}: {label}" if prefix else label
+ if len(combined) > limit:
+ return combined[:limit]
+ return combined
+
+ def _normalize_agent_name(agent: Any) -> Optional[str]:
+ if isinstance(agent, str):
+ return agent
+ if isinstance(agent, dict):
+ for key in ("name", "id", "label", "agent"):
+ value = agent.get(key)
+ if isinstance(value, str) and value:
+ return value
+ return None
+
+ def _unique_agent_names(agents: list) -> list:
+ seen = set()
+ names = []
+ for agent in agents or []:
+ name = _normalize_agent_name(agent)
+ if not name or name in seen:
+ continue
+ seen.add(name)
+ names.append(name)
+ return names
+
class RoutingView(discord.ui.View):
def __init__(self, outer: DiscordBot, owner_id: Optional[str]):
super().__init__(timeout=900)
@@ -746,191 +883,352 @@ class DiscordBot(BaseIMClient):
def _render(self):
self.clear_items()
- if self.step == "backend":
- options = [
- discord.SelectOption(label=backend, value=backend, default=backend == self.selected_backend)
- for backend in registered_backends
- ]
- if len(options) > 25:
- options = options[:25]
- backend_select = discord.ui.Select(
- placeholder="Select backend",
- options=options,
- min_values=1,
- max_values=1,
+ options = []
+ for backend in registered_backends:
+ display = backend_display_names.get(backend, backend.capitalize())
+ label = _prefixed_label("discord.labels.backend", display)
+ options.append(
+ discord.SelectOption(
+ label=label,
+ value=backend,
+ default=backend == self.selected_backend,
+ )
)
+ if len(options) > 25:
+ options = options[:25]
+ backend_select = discord.ui.Select(
+ placeholder=self.outer._t("modal.routing.selectBackend"),
+ options=options,
+ min_values=1,
+ max_values=1,
+ )
- async def backend_callback(select_interaction: discord.Interaction):
+ async def backend_callback(select_interaction: discord.Interaction):
+ if backend_select.values:
self.selected_backend = backend_select.values[0]
- await select_interaction.response.defer()
+ self._render()
+ updated_embed = discord.Embed(
+ title=self._content(),
+ description=self.outer._t("discord.routingSubtitle"),
+ )
+ await select_interaction.response.edit_message(embed=updated_embed, view=self)
- backend_select.callback = backend_callback
- self.add_item(backend_select)
- next_button = discord.ui.Button(label="Next", style=discord.ButtonStyle.primary)
- next_button.callback = self._on_next
- self.add_item(next_button)
- return
+ backend_select.callback = backend_callback
+ self.add_item(backend_select)
- if self.step == "opencode":
- agent_options = [discord.SelectOption(label="Default", value="__default__")]
- agent_options += [
- discord.SelectOption(label=a, value=a, default=a == self.oc_agent) for a in opencode_agents
+ if self.selected_backend == "opencode":
+ opencode_agent_names = _unique_agent_names(opencode_agents)
+ default_model_str = resolve_opencode_default_model(
+ opencode_default_config,
+ opencode_agents,
+ self.oc_agent if self.oc_agent not in ("__default__", None) else None,
+ )
+ target_model = (
+ self.oc_model
+ if self.oc_model not in (None, "__default__")
+ else default_model_str
+ )
+ preferred_providers = resolve_opencode_provider_preferences(
+ opencode_default_config,
+ target_model,
+ )
+ allowed_providers = resolve_opencode_allowed_providers(
+ opencode_default_config,
+ opencode_models,
+ )
+ agent_options = [
+ discord.SelectOption(
+ label=_prefixed_label(
+ "discord.labels.opencodeAgent",
+ self.outer._t("common.default"),
+ ),
+ value="__default__",
+ default=self.oc_agent in (None, "__default__"),
+ )
]
- model_options = [discord.SelectOption(label="Default", value="__default__")]
- model_ids = []
- for provider in opencode_models.get("providers", []):
- provider_id = provider.get("id") or provider.get("name") or provider.get("provider_id")
- if not provider_id:
- continue
- models = provider.get("models", {})
- if isinstance(models, dict):
- model_ids.extend([f"{provider_id}/{mid}" for mid in models.keys()])
- model_options += [
- discord.SelectOption(label=m, value=m, default=m == self.oc_model) for m in model_ids
+ agent_options += [
+ discord.SelectOption(
+ label=_prefixed_label("discord.labels.opencodeAgent", a),
+ value=a,
+ default=a == self.oc_agent,
+ )
+ for a in opencode_agent_names
]
if len(agent_options) > 25:
agent_options = agent_options[:25]
- if len(model_options) > 25:
- model_options = model_options[:25]
- reasoning_options = [
- discord.SelectOption(label="Default", value="__default__"),
- discord.SelectOption(label="low", value="low", default=self.oc_reasoning == "low"),
- discord.SelectOption(label="medium", value="medium", default=self.oc_reasoning == "medium"),
- discord.SelectOption(label="high", value="high", default=self.oc_reasoning == "high"),
- discord.SelectOption(label="xhigh", value="xhigh", default=self.oc_reasoning == "xhigh"),
- ]
-
agent_select = discord.ui.Select(
- placeholder="OpenCode agent", options=agent_options, min_values=1, max_values=1
- )
- model_select = discord.ui.Select(
- placeholder="OpenCode model", options=model_options, min_values=1, max_values=1
- )
- reasoning_select = discord.ui.Select(
- placeholder="Reasoning effort", options=reasoning_options, min_values=1, max_values=1
+ placeholder=self.outer._t("modal.routing.selectOpencodeAgent"),
+ options=agent_options,
+ min_values=1,
+ max_values=1,
)
async def agent_callback(select_interaction: discord.Interaction):
- self.oc_agent = agent_select.values[0]
+ if agent_select.values:
+ self.oc_agent = agent_select.values[0]
await select_interaction.response.defer()
+ agent_select.callback = agent_callback
+ self.add_item(agent_select)
+
+ default_label = self.outer._t("common.default")
+ if default_model_str:
+ default_label = f"{default_label} - {default_model_str}"
+ model_options = [
+ discord.SelectOption(
+ label=_prefixed_label("discord.labels.model", default_label),
+ value="__default__",
+ default=self.oc_model in (None, "__default__"),
+ )
+ ]
+ model_entries = build_opencode_model_option_items(
+ opencode_models,
+ max_total=24,
+ preferred_providers=preferred_providers,
+ allowed_providers=allowed_providers,
+ )
+ for entry in model_entries:
+ label = entry.get("label", "")
+ value = entry.get("value", "")
+ if not label or not value:
+ continue
+ model_options.append(
+ discord.SelectOption(
+ label=_prefixed_label("discord.labels.model", label),
+ value=value,
+ default=value == self.oc_model,
+ )
+ )
+ model_select = discord.ui.Select(
+ placeholder=self.outer._t("modal.routing.selectModel"),
+ options=model_options,
+ min_values=1,
+ max_values=1,
+ )
+
async def model_callback(select_interaction: discord.Interaction):
- self.oc_model = model_select.values[0]
- await select_interaction.response.defer()
+ if model_select.values:
+ self.oc_model = model_select.values[0]
+ self._render()
+ updated_embed = discord.Embed(
+ title=self._content(),
+ description=self.outer._t("discord.routingSubtitle"),
+ )
+ await select_interaction.response.edit_message(embed=updated_embed, view=self)
+
+ model_select.callback = model_callback
+ self.add_item(model_select)
+
+ reasoning_entries = build_reasoning_effort_options(opencode_models, target_model)
+ selected_reasoning = (
+ self.oc_reasoning if self.oc_reasoning not in (None, "__default__") else "__default__"
+ )
+ available_reasoning = {entry.get("value") for entry in reasoning_entries}
+ if selected_reasoning not in available_reasoning:
+ selected_reasoning = "__default__"
+ reasoning_options = []
+ for entry in reasoning_entries:
+ value = entry.get("value")
+ if not value:
+ continue
+ if value == "__default__":
+ label = self.outer._t("common.default")
+ else:
+ translated = self.outer._t(f"reasoning.{value}")
+ label = translated if translated != f"reasoning.{value}" else entry.get("label", value)
+ reasoning_options.append(
+ discord.SelectOption(
+ label=_prefixed_label("discord.labels.reasoningEffort", label),
+ value=value,
+ default=value == selected_reasoning,
+ )
+ )
+ reasoning_select = discord.ui.Select(
+ placeholder=self.outer._t("modal.routing.selectReasoningEffort"),
+ options=reasoning_options,
+ min_values=1,
+ max_values=1,
+ )
async def reasoning_callback(select_interaction: discord.Interaction):
- self.oc_reasoning = reasoning_select.values[0]
+ if reasoning_select.values:
+ self.oc_reasoning = reasoning_select.values[0]
await select_interaction.response.defer()
- agent_select.callback = agent_callback
- model_select.callback = model_callback
reasoning_select.callback = reasoning_callback
- self.add_item(agent_select)
- self.add_item(model_select)
self.add_item(reasoning_select)
- back_button = discord.ui.Button(label="Back", style=discord.ButtonStyle.secondary)
- back_button.callback = self._on_back
- save_button = discord.ui.Button(label="Save", style=discord.ButtonStyle.primary)
- save_button.callback = self._on_save
- self.add_item(back_button)
- self.add_item(save_button)
- return
- if self.step == "claude":
- agent_options = [discord.SelectOption(label="Default", value="__default__")]
- agent_options += [
- discord.SelectOption(label=a, value=a, default=a == self.claude_agent) for a in claude_agents
+ if self.selected_backend == "claude":
+ claude_agent_names = _unique_agent_names(claude_agents)
+ agent_options = [
+ discord.SelectOption(
+ label=_prefixed_label(
+ "discord.labels.claudeAgent",
+ self.outer._t("common.default"),
+ ),
+ value="__default__",
+ default=self.claude_agent in (None, "__default__"),
+ )
]
- model_options = [discord.SelectOption(label="Default", value="__default__")]
- model_options += [
- discord.SelectOption(label=m, value=m, default=m == self.claude_model) for m in claude_models
+ agent_options += [
+ discord.SelectOption(label=a, value=a, default=a == self.claude_agent) for a in claude_agent_names
]
if len(agent_options) > 25:
agent_options = agent_options[:25]
- if len(model_options) > 25:
- model_options = model_options[:25]
-
agent_select = discord.ui.Select(
- placeholder="Claude agent", options=agent_options, min_values=1, max_values=1
- )
- model_select = discord.ui.Select(
- placeholder="Claude model", options=model_options, min_values=1, max_values=1
+ placeholder=self.outer._t("modal.routing.selectClaudeAgent"),
+ options=agent_options,
+ min_values=1,
+ max_values=1,
)
- async def agent_callback(select_interaction: discord.Interaction):
- self.claude_agent = agent_select.values[0]
+ async def claude_agent_callback(select_interaction: discord.Interaction):
+ if agent_select.values:
+ self.claude_agent = agent_select.values[0]
await select_interaction.response.defer()
- async def model_callback(select_interaction: discord.Interaction):
- self.claude_model = model_select.values[0]
+ agent_select.callback = claude_agent_callback
+ self.add_item(agent_select)
+
+ model_options = [
+ discord.SelectOption(
+ label=_prefixed_label("discord.labels.model", self.outer._t("common.default")),
+ value="__default__",
+ default=self.claude_model in (None, "__default__"),
+ )
+ ]
+ model_options += [
+ discord.SelectOption(
+ label=_prefixed_label("discord.labels.model", m),
+ value=m,
+ default=m == self.claude_model,
+ )
+ for m in claude_models
+ ]
+ if len(model_options) > 25:
+ model_options = model_options[:25]
+ model_select = discord.ui.Select(
+ placeholder=self.outer._t("modal.routing.selectModel"),
+ options=model_options,
+ min_values=1,
+ max_values=1,
+ )
+
+ async def claude_model_callback(select_interaction: discord.Interaction):
+ if model_select.values:
+ self.claude_model = model_select.values[0]
await select_interaction.response.defer()
- agent_select.callback = agent_callback
- model_select.callback = model_callback
- self.add_item(agent_select)
+ model_select.callback = claude_model_callback
self.add_item(model_select)
- back_button = discord.ui.Button(label="Back", style=discord.ButtonStyle.secondary)
- back_button.callback = self._on_back
- save_button = discord.ui.Button(label="Save", style=discord.ButtonStyle.primary)
- save_button.callback = self._on_save
- self.add_item(back_button)
- self.add_item(save_button)
- return
- if self.step == "codex":
- model_options = [discord.SelectOption(label="Default", value="__default__")]
+ if self.selected_backend == "codex":
+ model_options = [
+ discord.SelectOption(
+ label=_prefixed_label("discord.labels.model", self.outer._t("common.default")),
+ value="__default__",
+ default=self.codex_model in (None, "__default__"),
+ )
+ ]
model_options += [
- discord.SelectOption(label=m, value=m, default=m == self.codex_model) for m in codex_models
+ discord.SelectOption(
+ label=_prefixed_label("discord.labels.model", m),
+ value=m,
+ default=m == self.codex_model,
+ )
+ for m in codex_models
]
if len(model_options) > 25:
model_options = model_options[:25]
+ model_select = discord.ui.Select(
+ placeholder=self.outer._t("modal.routing.selectModel"),
+ options=model_options,
+ min_values=1,
+ max_values=1,
+ )
+
+ async def codex_model_callback(select_interaction: discord.Interaction):
+ if model_select.values:
+ self.codex_model = model_select.values[0]
+ await select_interaction.response.defer()
+
+ model_select.callback = codex_model_callback
+ self.add_item(model_select)
+
reasoning_options = [
- discord.SelectOption(label="Default", value="__default__"),
discord.SelectOption(
- label="minimal", value="minimal", default=self.codex_reasoning == "minimal"
+ label=_prefixed_label(
+ "discord.labels.reasoningEffort",
+ self.outer._t("common.default"),
+ ),
+ value="__default__",
+ default=self.codex_reasoning in (None, "__default__"),
+ ),
+ discord.SelectOption(
+ label=_prefixed_label(
+ "discord.labels.reasoningEffort",
+ self.outer._t("reasoning.minimal"),
+ ),
+ value="minimal",
+ default=self.codex_reasoning == "minimal",
+ ),
+ discord.SelectOption(
+ label=_prefixed_label(
+ "discord.labels.reasoningEffort",
+ self.outer._t("reasoning.low"),
+ ),
+ value="low",
+ default=self.codex_reasoning == "low",
+ ),
+ discord.SelectOption(
+ label=_prefixed_label(
+ "discord.labels.reasoningEffort",
+ self.outer._t("reasoning.medium"),
+ ),
+ value="medium",
+ default=self.codex_reasoning == "medium",
+ ),
+ discord.SelectOption(
+ label=_prefixed_label(
+ "discord.labels.reasoningEffort",
+ self.outer._t("reasoning.high"),
+ ),
+ value="high",
+ default=self.codex_reasoning == "high",
+ ),
+ discord.SelectOption(
+ label=_prefixed_label(
+ "discord.labels.reasoningEffort",
+ self.outer._t("reasoning.xhigh"),
+ ),
+ value="xhigh",
+ default=self.codex_reasoning == "xhigh",
),
- discord.SelectOption(label="low", value="low", default=self.codex_reasoning == "low"),
- discord.SelectOption(label="medium", value="medium", default=self.codex_reasoning == "medium"),
- discord.SelectOption(label="high", value="high", default=self.codex_reasoning == "high"),
- discord.SelectOption(label="xhigh", value="xhigh", default=self.codex_reasoning == "xhigh"),
]
- model_select = discord.ui.Select(
- placeholder="Codex model", options=model_options, min_values=1, max_values=1
- )
reasoning_select = discord.ui.Select(
- placeholder="Reasoning effort", options=reasoning_options, min_values=1, max_values=1
+ placeholder=self.outer._t("modal.routing.selectReasoningEffort"),
+ options=reasoning_options,
+ min_values=1,
+ max_values=1,
)
- async def model_callback(select_interaction: discord.Interaction):
- self.codex_model = model_select.values[0]
- await select_interaction.response.defer()
-
- async def reasoning_callback(select_interaction: discord.Interaction):
- self.codex_reasoning = reasoning_select.values[0]
+ async def codex_reasoning_callback(select_interaction: discord.Interaction):
+ if reasoning_select.values:
+ self.codex_reasoning = reasoning_select.values[0]
await select_interaction.response.defer()
- model_select.callback = model_callback
- reasoning_select.callback = reasoning_callback
- self.add_item(model_select)
+ reasoning_select.callback = codex_reasoning_callback
self.add_item(reasoning_select)
- back_button = discord.ui.Button(label="Back", style=discord.ButtonStyle.secondary)
- back_button.callback = self._on_back
- save_button = discord.ui.Button(label="Save", style=discord.ButtonStyle.primary)
- save_button.callback = self._on_save
- self.add_item(back_button)
- self.add_item(save_button)
- return
- async def _on_next(self, interaction: discord.Interaction):
- backend = self.selected_backend
- self.step = backend
- self._render()
- await interaction.response.edit_message(content="🤖 Agent routing", view=self)
+ save_button = discord.ui.Button(
+ label=self.outer._t("common.save"),
+ style=discord.ButtonStyle.primary,
+ )
+ save_button.callback = self._on_save
+ self.add_item(save_button)
- async def _on_back(self, interaction: discord.Interaction):
- self.step = "backend"
- self._render()
- await interaction.response.edit_message(content="🤖 Agent routing", view=self)
+ def _content(self) -> str:
+ return f"🤖 {self.outer._t('modal.routing.title')}"
async def _on_save(self, interaction: discord.Interaction):
def _normalize(value: Optional[str]) -> Optional[str]:
@@ -938,31 +1236,48 @@ class DiscordBot(BaseIMClient):
return None
return value
- if hasattr(self.outer, "_on_routing_update"):
- await self.outer._on_routing_update(
- str(interaction.user.id),
- channel_id,
- self.selected_backend,
- _normalize(self.oc_agent),
- _normalize(self.oc_model),
- _normalize(self.oc_reasoning),
- _normalize(self.claude_agent),
- _normalize(self.claude_model),
- _normalize(self.codex_model),
- _normalize(self.codex_reasoning),
+ try:
+ await interaction.response.defer()
+ if hasattr(self.outer, "_on_routing_update"):
+ await self.outer._on_routing_update(
+ str(interaction.user.id),
+ channel_id,
+ self.selected_backend,
+ _normalize(self.oc_agent),
+ _normalize(self.oc_model),
+ _normalize(self.oc_reasoning),
+ _normalize(self.claude_agent),
+ _normalize(self.claude_model),
+ _normalize(self.codex_model),
+ _normalize(self.codex_reasoning),
+ notify_user=False,
+ )
+ await interaction.edit_original_response(
+ content=f"✅ {self.outer._t('success.routingUpdated')}",
+ embed=None,
+ view=None,
+ )
+ except Exception as err:
+ await interaction.edit_original_response(
+ content=f"❌ {self.outer._t('error.routingUpdateFailed', error=str(err))}",
+ embed=None,
+ view=None,
)
- await interaction.response.edit_message(content="✅ Routing updated.", view=None)
owner_id = str(interaction.user.id) if interaction else None
view = RoutingView(self, owner_id)
+ routing_embed = discord.Embed(
+ title=view._content(),
+ description=self._t("discord.routingSubtitle"),
+ )
if interaction:
- await interaction.response.send_message("🤖 Agent routing", view=view, ephemeral=True)
+ await interaction.response.send_message(embed=routing_embed, view=view, ephemeral=True)
else:
channel = await self._fetch_channel(channel_id)
if channel is None:
raise RuntimeError("Discord channel not found")
- await channel.send("🤖 Agent routing", view=view)
+ await channel.send(embed=routing_embed, view=view)
async def open_question_modal(
self,
@@ -972,7 +1287,10 @@ class DiscordBot(BaseIMClient):
callback_prefix: str = "opencode_question",
):
interaction = trigger_id if isinstance(trigger_id, discord.Interaction) else None
- questions = getattr(pending, "questions", None) or []
+ if isinstance(pending, dict):
+ questions = pending.get("questions") or []
+ else:
+ questions = getattr(pending, "questions", None) or []
if not questions or len(questions) > 4:
await self.send_message(
context,
@@ -980,16 +1298,42 @@ class DiscordBot(BaseIMClient):
)
return
+ def _normalize_question(raw: Any) -> tuple[str, list, bool]:
+ if isinstance(raw, dict):
+ header = raw.get("header") or raw.get("question") or raw.get("title") or ""
+ options = raw.get("options") or []
+ multiple = bool(raw.get("multiple"))
+ return str(header), options, multiple
+ header = getattr(raw, "header", None) or getattr(raw, "question", None) or ""
+ options = getattr(raw, "options", None) or []
+ multiple = bool(getattr(raw, "multiple", False))
+ return str(header), options, multiple
+
+ def _normalize_option(option: Any) -> str:
+ if isinstance(option, dict):
+ label = option.get("label") or option.get("value") or option.get("name")
+ if label is not None:
+ return str(label)
+ return str(option)
+
class QuestionView(discord.ui.View):
def __init__(self, outer: DiscordBot):
super().__init__(timeout=900)
self.outer = outer
self.answers: list[list[str]] = [[] for _ in questions]
for idx, q in enumerate(questions):
- options = [discord.SelectOption(label=o.label, value=o.label) for o in q.options]
- max_values = len(options) if getattr(q, "multiple", False) else 1
+ header, options_raw, multiple = _normalize_question(q)
+ option_labels = [_normalize_option(opt) for opt in options_raw]
+ option_labels = [label for label in option_labels if label]
+ if len(option_labels) > 25:
+ option_labels = option_labels[:25]
+ options = [
+ discord.SelectOption(label=label[:100], value=label[:100])
+ for label in option_labels
+ ]
+ max_values = len(options) if multiple else 1
select = discord.ui.Select(
- placeholder=q.header or f"Question {idx + 1}",
+ placeholder=header or f"Question {idx + 1}",
options=options,
min_values=1,
max_values=max_values,
@@ -1024,13 +1368,29 @@ class DiscordBot(BaseIMClient):
item.callback = submit_callback
if interaction:
- await interaction.response.send_message("Please answer:", view=view, ephemeral=True)
+ if interaction.response.is_done():
+ await interaction.followup.send("Please answer:", view=view, ephemeral=True)
+ else:
+ await interaction.response.send_message("Please answer:", view=view, ephemeral=True)
else:
channel = await self._fetch_channel(context.thread_id or context.channel_id)
if channel is None:
raise RuntimeError("Discord channel not found")
await channel.send("Please answer:", view=view)
+ async def open_opencode_question_modal(
+ self,
+ trigger_id: Any,
+ context: MessageContext,
+ pending: Any,
+ ):
+ await self.open_question_modal(
+ trigger_id=trigger_id,
+ context=context,
+ pending=pending,
+ callback_prefix="opencode_question",
+ )
+
class _DiscordButtonView(discord.ui.View):
def __init__(
@@ -1071,7 +1431,12 @@ class _DiscordButtonView(discord.ui.View):
except Exception:
pass
return
- if not needs_modal:
+ if data == "opencode_question:open_modal":
+ try:
+ await interaction.response.defer(ephemeral=True)
+ except Exception:
+ pass
+ elif not needs_modal:
try:
await interaction.response.defer(ephemeral=True)
except Exception:
@@ -1087,7 +1452,8 @@ class _DiscordButtonView(discord.ui.View):
user_id=str(interaction.user.id),
channel_id=channel_id,
thread_id=thread_id,
- message_id=str(interaction.message.id) if interaction.message else None,
+ message_id=self.base_context.message_id
+ or (str(interaction.message.id) if interaction.message else None),
platform_specific={"interaction": interaction},
)
if self.outer.on_callback_query_callback:
diff --git a/modules/im/slack.py b/modules/im/slack.py
index 9059c57ca..e1d8b7f58 100644
--- a/modules/im/slack.py
+++ b/modules/im/slack.py
@@ -15,6 +15,11 @@ from .base import BaseIMClient, MessageContext, InlineKeyboard, InlineButton, Fi
from config.v2_config import SlackConfig
from .formatters import SlackFormatter
from vibe.i18n import get_supported_languages, t as i18n_t
+from modules.agents.opencode.utils import (
+ build_opencode_model_option_items,
+ resolve_opencode_allowed_providers,
+ resolve_opencode_provider_preferences,
+)
logger = logging.getLogger(__name__)
@@ -2034,88 +2039,32 @@ class SlackBot(BaseIMClient):
default_label = f"{self._t('common.default')} - {default_model_str}"
model_options = [{"text": {"type": "plain_text", "text": default_label}, "value": "__default__"}]
- # Add models from providers
- providers_data = opencode_models.get("providers", [])
- defaults = opencode_models.get("default", {})
-
- # Calculate max models per provider to fit within Slack's 100 option limit
- # Reserve 1 for "(Default)" option
- num_providers = len(providers_data)
- max_per_provider = max(5, (99 // num_providers)) if num_providers > 0 else 99
-
- def model_sort_key(model_item):
- """Sort models by release_date (newest first), deprioritize utility models."""
- model_id, model_info = model_item
- mid_lower = model_id.lower()
-
- # 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"]
+ # Add models from providers (sorted, filtered, truncated)
+ preferred_providers = resolve_opencode_provider_preferences(
+ opencode_default_config,
+ current_oc_model or default_model_str,
+ )
+ allowed_providers = resolve_opencode_allowed_providers(
+ opencode_default_config,
+ opencode_models,
+ )
+ model_entries = build_opencode_model_option_items(
+ opencode_models,
+ max_total=99,
+ preferred_providers=preferred_providers,
+ allowed_providers=allowed_providers,
+ )
+ for entry in model_entries:
+ label = entry.get("label", "")
+ value = entry.get("value", "")
+ if not label or not value:
+ continue
+ model_options.append(
+ {
+ "text": {"type": "plain_text", "text": label[:75]}, # Slack limit
+ "value": value,
+ }
)
- utility_penalty = 1 if is_utility else 0
-
- # Get release_date for sorting (newest first)
- # Default to old date if not available, convert to negative int for DESC sort
- release_date = "1970-01-01"
- if isinstance(model_info, dict):
- release_date = model_info.get("release_date", "1970-01-01") or "1970-01-01"
- # Convert YYYY-MM-DD to int (e.g., 20250414) and negate for descending order
- try:
- date_int = -int(release_date.replace("-", ""))
- except (ValueError, AttributeError):
- date_int = 0
-
- # Sort by: utility_penalty ASC, release_date DESC (via negative int), model_id ASC
- return (utility_penalty, date_int, model_id)
-
- for provider in providers_data:
- provider_id = provider.get("id", "")
- provider_name = provider.get("name", provider_id)
- models = provider.get("models", {})
-
- # Handle both dict and list formats for models
- if isinstance(models, dict):
- model_items = list(models.items())
- elif isinstance(models, list):
- model_items = [(m, m) if isinstance(m, str) else (m.get("id", ""), m) for m in models]
- else:
- model_items = []
-
- # Sort models by priority
- model_items.sort(key=model_sort_key)
-
- # Limit models per provider
- provider_model_count = 0
- for model_id, model_info in model_items:
- if provider_model_count >= max_per_provider:
- break
-
- # Get model name
- if isinstance(model_info, dict):
- model_name = model_info.get("name", model_id)
- else:
- model_name = model_id
-
- if model_id:
- full_model = f"{provider_id}/{model_id}"
- # Mark if this is the provider's default
- is_default = defaults.get(provider_id) == model_id
- display = f"{provider_name}: {model_name}"
- if is_default:
- display += " (default)"
-
- 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
- if len(model_options) > 100:
- model_options = model_options[:100]
- logger.warning("Truncated model options to 100 for Slack modal")
# Find initial model
initial_model = model_options[0] # Default
diff --git a/ui/src/components/Wizard.tsx b/ui/src/components/Wizard.tsx
index 8c5812ba3..03319a9a5 100644
--- a/ui/src/components/Wizard.tsx
+++ b/ui/src/components/Wizard.tsx
@@ -91,8 +91,8 @@ export const Wizard: React.FC = () => {
return [
{ id: 'welcome', title: 'Welcome', component: Welcome },
{ id: 'mode', title: 'Mode', component: ModeSelection },
- { id: 'platform', title: 'Platform', component: PlatformSelection },
{ id: 'agents', title: 'Agents', component: AgentDetection },
+ { id: 'platform', title: 'Platform', component: PlatformSelection },
platform === 'discord'
? { id: 'discord', title: 'Discord', component: DiscordConfig }
: { id: 'slack', title: 'Slack', component: SlackConfig },
diff --git a/ui/src/components/steps/ChannelList.tsx b/ui/src/components/steps/ChannelList.tsx
index b1ee64870..44b8aad3c 100644
--- a/ui/src/components/steps/ChannelList.tsx
+++ b/ui/src/components/steps/ChannelList.tsx
@@ -76,6 +76,7 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB
}
}, [data.discord?.guild_allowlist, isPage]);
+
useEffect(() => {
if (isPage) {
api.getConfig().then(c => {
@@ -92,6 +93,15 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB
? (config.discord?.bot_token || data.discord?.bot_token || '')
: (config.slack?.bot_token || config.slackBotToken || '');
+ useEffect(() => {
+ if (platform !== 'discord') return;
+ if (selectedGuild) return;
+ const preferredGuild = config.discord?.guild_allowlist?.[0] || data.discord?.guild_allowlist?.[0] || '';
+ if (preferredGuild) {
+ setSelectedGuild(preferredGuild);
+ }
+ }, [platform, config.discord?.guild_allowlist, data.discord?.guild_allowlist, selectedGuild]);
+
const loadGuilds = async () => {
if (!botToken) return;
try {
diff --git a/ui/src/components/steps/DiscordConfig.tsx b/ui/src/components/steps/DiscordConfig.tsx
index 9c2034693..bad7cccdd 100644
--- a/ui/src/components/steps/DiscordConfig.tsx
+++ b/ui/src/components/steps/DiscordConfig.tsx
@@ -1,5 +1,5 @@
import React, { useEffect, useMemo, useState } from 'react';
-import { Shield, RefreshCw, Check, Server, KeyRound } from 'lucide-react';
+import { Shield, RefreshCw, Check, Server, KeyRound, Plus, ExternalLink, Settings, ChevronDown, ChevronUp, Copy } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import clsx from 'clsx';
import { useApi } from '../../context/ApiContext';
@@ -18,11 +18,27 @@ export const DiscordConfig: React.FC<DiscordConfigProps> = ({ data, onNext, onBa
const [authResult, setAuthResult] = useState<any>(null);
const [guilds, setGuilds] = useState<any[]>([]);
const [selectedGuild, setSelectedGuild] = useState<string>(data.discord?.guild_allowlist?.[0] || '');
+ const [expandedSteps, setExpandedSteps] = useState<Record<number, boolean>>({ 1: true, 2: false, 3: false, 4: false });
+ const [inviteCopied, setInviteCopied] = useState(false);
+ const [clientId, setClientId] = useState(data.discord_client_id || '');
+
+ const inviteUrl = useMemo(() => {
+ const normalized = clientId.trim();
+ if (!normalized) return '';
+ const scope = encodeURIComponent('bot applications.commands');
+ return `https://discord.com/oauth2/authorize?client_id=${normalized}&permissions=534723808320&integration_type=0&scope=${scope}`;
+ }, [clientId]);
useEffect(() => {
setAuthResult(null);
}, [botToken]);
+ useEffect(() => {
+ if (botToken && !expandedSteps[4]) {
+ setExpandedSteps(prev => ({ ...prev, 4: true }));
+ }
+ }, [botToken, expandedSteps]);
+
const isValid = useMemo(() => botToken.length > 0 && authResult?.ok, [botToken, authResult]);
const runAuthTest = async () => {
@@ -55,6 +71,53 @@ export const DiscordConfig: React.FC<DiscordConfigProps> = ({ data, onNext, onBa
}
}, [authResult?.ok]);
+ const toggleStep = (step: number) => {
+ setExpandedSteps(prev => ({ ...prev, [step]: !prev[step] }));
+ };
+
+ const openDiscordDeveloperPortal = () => {
+ window.open('https://discord.com/developers/applications', '_blank');
+ };
+
+ const copyInviteUrl = async () => {
+ if (!inviteUrl) return;
+ try {
+ await navigator.clipboard.writeText(inviteUrl);
+ setInviteCopied(true);
+ setTimeout(() => setInviteCopied(false), 2000);
+ } catch {
+ setInviteCopied(false);
+ }
+ };
+
+ const StepHeader: React.FC<{ step: number; title: string; icon: React.ReactNode; completed?: boolean }> = ({
+ step,
+ title,
+ icon,
+ completed,
+ }) => (
+ <button
+ onClick={() => toggleStep(step)}
+ className="w-full px-4 py-3 flex items-center justify-between bg-neutral-50 hover:bg-neutral-100 transition-colors"
+ >
+ <div className="flex items-center gap-3">
+ <span
+ className={clsx(
+ 'w-7 h-7 rounded-full text-sm font-bold flex items-center justify-center transition-colors',
+ completed ? 'bg-success text-white' : 'bg-accent text-white'
+ )}
+ >
+ {completed ? <Check size={14} /> : step}
+ </span>
+ <span className="flex items-center gap-2 font-semibold text-text">
+ {icon}
+ {title}
+ </span>
+ </div>
+ {expandedSteps[step] ? <ChevronUp size={18} className="text-muted" /> : <ChevronDown size={18} className="text-muted" />}
+ </button>
+ );
+
return (
<div className="flex flex-col h-full max-w-2xl mx-auto">
<div className="mb-4">
@@ -62,67 +125,193 @@ export const DiscordConfig: React.FC<DiscordConfigProps> = ({ data, onNext, onBa
<p className="text-muted mt-1">{t('discordConfig.subtitle')}</p>
</div>
- <div className="space-y-6 flex-1">
- <div className="space-y-2">
- <label className="text-sm font-medium text-text flex items-center gap-2">
- <KeyRound size={16} className="text-accent" /> {t('discordConfig.botToken')}
- </label>
- <input
- type="password"
- value={botToken}
- onChange={(e) => setBotToken(e.target.value)}
- placeholder={t('discordConfig.botTokenPlaceholder')}
- className="w-full bg-bg border border-border rounded-lg p-3 text-text focus:outline-none focus:border-accent focus:ring-1 focus:ring-accent font-mono transition-colors"
+ <div className="space-y-3 overflow-y-auto flex-1 pr-1">
+ <div className="bg-panel border border-border rounded-xl overflow-hidden">
+ <StepHeader
+ step={1}
+ title={t('discordConfig.step1Title')}
+ icon={<Plus size={16} className="text-accent" />}
/>
- <p className="text-xs text-muted">{t('discordConfig.botTokenHint')}</p>
+ {expandedSteps[1] && (
+ <div className="p-4 space-y-4 border-t border-border">
+ <p className="text-sm text-muted">{t('discordConfig.step1Description')}</p>
+ <ol className="list-decimal list-inside space-y-1.5 text-sm text-muted pl-1">
+ <li>{t('discordConfig.step1Item1')}</li>
+ <li>{t('discordConfig.step1Item2')}</li>
+ <li>{t('discordConfig.step1Item3')}</li>
+ </ol>
+ <div>
+ <button
+ onClick={openDiscordDeveloperPortal}
+ className="flex items-center gap-2 px-4 py-2 bg-accent text-white rounded-lg hover:bg-accent/90 transition-colors font-medium shadow-sm"
+ >
+ <ExternalLink size={16} />
+ {t('discordConfig.openDeveloperPortal')}
+ </button>
+ </div>
+ </div>
+ )}
</div>
- <div className="flex items-center gap-3">
- <button
- onClick={runAuthTest}
- disabled={!botToken || checking}
- className="px-4 py-2 bg-accent text-white rounded-lg flex items-center gap-2 transition-colors font-medium shadow-sm hover:bg-accent/90 disabled:opacity-50 disabled:cursor-not-allowed"
- >
- {checking ? <RefreshCw size={16} className="animate-spin" /> : <Shield size={16} />}
- {t('discordConfig.validateToken')}
- </button>
- {authResult && (
- <span
- className={clsx(
- 'flex items-center gap-2 text-sm font-medium px-3 py-1.5 rounded-lg border',
- authResult.ok ? 'text-success bg-success/10 border-success/20' : 'text-danger bg-danger/10 border-danger/20'
- )}
- >
- {authResult.ok ? (
- <>
- <Check size={14} />
- <span>{t('discordConfig.tokenValidated')}</span>
- </>
- ) : (
- <span>{t('discordConfig.authFailed')}: {authResult.error}</span>
- )}
- </span>
+ <div className="bg-panel border border-border rounded-xl overflow-hidden">
+ <StepHeader
+ step={2}
+ title={t('discordConfig.step2Title')}
+ icon={<Settings size={16} className="text-accent" />}
+ />
+ {expandedSteps[2] && (
+ <div className="p-4 space-y-4 border-t border-border">
+ <p className="text-sm text-muted">{t('discordConfig.step2Description')}</p>
+ <ol className="list-decimal list-inside space-y-1.5 text-sm text-muted pl-1">
+ <li>{t('discordConfig.step2Item1')}</li>
+ <li>{t('discordConfig.step2Item2')}</li>
+ </ol>
+ <div className="bg-blue-50 border border-blue-200 rounded-lg p-3 text-sm text-blue-800">
+ <strong>{t('slackConfig.tip')}:</strong> {t('discordConfig.step2Tip')}
+ </div>
+ </div>
)}
</div>
- {authResult?.ok && (
- <div className="space-y-2">
- <label className="text-sm font-medium text-text flex items-center gap-2">
- <Server size={16} className="text-accent" /> {t('discordConfig.guild')}
- </label>
- <select
- value={selectedGuild}
- onChange={(e) => setSelectedGuild(e.target.value)}
- className="w-full bg-bg border border-border rounded-lg p-3 text-text focus:outline-none focus:border-accent focus:ring-1 focus:ring-accent"
- >
- <option value="">{t('discordConfig.guildPlaceholder')}</option>
- {guilds.map((g) => (
- <option key={g.id} value={g.id}>{g.name}</option>
- ))}
- </select>
- <p className="text-xs text-muted">{t('discordConfig.guildHint')}</p>
- </div>
- )}
+ <div className="bg-panel border border-border rounded-xl overflow-hidden">
+ <StepHeader
+ step={3}
+ title={t('discordConfig.step3Title')}
+ icon={<ExternalLink size={16} className="text-accent" />}
+ />
+ {expandedSteps[3] && (
+ <div className="p-4 space-y-4 border-t border-border">
+ <p className="text-sm text-muted">{t('discordConfig.step3Description')}</p>
+ <ol className="list-decimal list-inside space-y-1.5 text-sm text-muted pl-1">
+ <li>{t('discordConfig.step3Item1')}</li>
+ <li>{t('discordConfig.step3Item2')}</li>
+ <li>{t('discordConfig.step3Item3')}</li>
+ <li>{t('discordConfig.step3Item4')}</li>
+ </ol>
+ <div className="space-y-2">
+ <label className="text-sm font-medium text-text">{t('discordConfig.clientId')}</label>
+ <input
+ type="text"
+ value={clientId}
+ onChange={(e) => setClientId(e.target.value)}
+ placeholder={t('discordConfig.clientIdPlaceholder')}
+ className="w-full bg-bg border border-border rounded-lg p-3 text-text focus:outline-none focus:border-accent focus:ring-1 focus:ring-accent font-mono transition-colors"
+ />
+ <p className="text-xs text-muted">{t('discordConfig.clientIdHint')}</p>
+ </div>
+ <div className="space-y-2">
+ <div className="flex items-center justify-between">
+ <span className="text-xs font-semibold text-muted uppercase">{t('discordConfig.inviteUrlLabel')}</span>
+ <button
+ onClick={copyInviteUrl}
+ disabled={!inviteUrl}
+ className="flex items-center gap-1 text-xs text-accent hover:text-accent/80 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
+ >
+ {inviteCopied ? <Check size={12} /> : <Copy size={12} />}
+ {inviteCopied ? t('discordConfig.inviteUrlCopied') : t('discordConfig.inviteUrlCopy')}
+ </button>
+ </div>
+ <input
+ type="text"
+ value={inviteUrl}
+ readOnly
+ placeholder={t('discordConfig.inviteUrlPlaceholder')}
+ className="w-full bg-white border border-border rounded-md p-2 text-xs font-mono text-text"
+ />
+ </div>
+ <div>
+ <button
+ onClick={() => inviteUrl && window.open(inviteUrl, '_blank')}
+ disabled={!inviteUrl}
+ className="flex items-center gap-2 px-4 py-2 bg-accent text-white rounded-lg hover:bg-accent/90 transition-colors font-medium shadow-sm disabled:opacity-50 disabled:cursor-not-allowed"
+ >
+ <ExternalLink size={16} />
+ {t('discordConfig.openInviteUrl')}
+ </button>
+ </div>
+ </div>
+ )}
+ </div>
+
+ <div className="bg-panel border border-border rounded-xl overflow-hidden">
+ <StepHeader
+ step={4}
+ title={t('discordConfig.step4Title')}
+ icon={<KeyRound size={16} className="text-accent" />}
+ completed={isValid}
+ />
+ {expandedSteps[4] && (
+ <div className="p-4 space-y-4 border-t border-border">
+ <p className="text-sm text-muted">{t('discordConfig.step4Description')}</p>
+ <ol className="list-decimal list-inside space-y-1.5 text-sm text-muted pl-1">
+ <li>{t('discordConfig.step4Item1')}</li>
+ <li>{t('discordConfig.step4Item2')}</li>
+ <li>{t('discordConfig.step4Item3')}</li>
+ </ol>
+
+ <div className="space-y-2 pt-2">
+ <label className="text-sm font-medium text-text flex items-center gap-2">
+ <KeyRound size={16} className="text-accent" /> {t('discordConfig.botToken')}
+ </label>
+ <input
+ type="password"
+ value={botToken}
+ onChange={(e) => setBotToken(e.target.value)}
+ placeholder={t('discordConfig.botTokenPlaceholder')}
+ className="w-full bg-bg border border-border rounded-lg p-3 text-text focus:outline-none focus:border-accent focus:ring-1 focus:ring-accent font-mono transition-colors"
+ />
+ <p className="text-xs text-muted">{t('discordConfig.botTokenHint')}</p>
+ </div>
+
+ <div className="flex items-center gap-3">
+ <button
+ onClick={runAuthTest}
+ disabled={!botToken || checking}
+ className="px-4 py-2 bg-accent text-white rounded-lg flex items-center gap-2 transition-colors font-medium shadow-sm hover:bg-accent/90 disabled:opacity-50 disabled:cursor-not-allowed"
+ >
+ {checking ? <RefreshCw size={16} className="animate-spin" /> : <Shield size={16} />}
+ {t('discordConfig.validateToken')}
+ </button>
+ {authResult && (
+ <span
+ className={clsx(
+ 'flex items-center gap-2 text-sm font-medium px-3 py-1.5 rounded-lg border',
+ authResult.ok ? 'text-success bg-success/10 border-success/20' : 'text-danger bg-danger/10 border-danger/20'
+ )}
+ >
+ {authResult.ok ? (
+ <>
+ <Check size={14} />
+ <span>{t('discordConfig.tokenValidated')}</span>
+ </>
+ ) : (
+ <span>{t('discordConfig.authFailed')}: {authResult.error}</span>
+ )}
+ </span>
+ )}
+ </div>
+
+ {authResult?.ok && (
+ <div className="space-y-2">
+ <label className="text-sm font-medium text-text flex items-center gap-2">
+ <Server size={16} className="text-accent" /> {t('discordConfig.guild')}
+ </label>
+ <select
+ value={selectedGuild}
+ onChange={(e) => setSelectedGuild(e.target.value)}
+ className="w-full bg-bg border border-border rounded-lg p-3 text-text focus:outline-none focus:border-accent focus:ring-1 focus:ring-accent"
+ >
+ <option value="">{t('discordConfig.guildPlaceholder')}</option>
+ {guilds.map((g) => (
+ <option key={g.id} value={g.id}>{g.name}</option>
+ ))}
+ </select>
+ <p className="text-xs text-muted">{t('discordConfig.guildHint')}</p>
+ </div>
+ )}
+ </div>
+ )}
+ </div>
</div>
<div className="mt-auto flex justify-between pt-6 border-t border-border">
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index efe2d0899..3a34af33a 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -76,7 +76,7 @@
},
"discordConfig": {
"title": "Discord Configuration",
- "subtitle": "Add your bot token and validate access.",
+ "subtitle": "Create a Discord app, invite the bot, then add your token.",
"botToken": "Bot Token",
"botTokenPlaceholder": "Paste your Discord bot token",
"botTokenHint": "Use the token from the Discord Developer Portal.",
@@ -85,7 +85,38 @@
"authFailed": "Validation failed",
"guild": "Guild",
"guildPlaceholder": "Select a guild",
- "guildHint": "Choose the guild where the bot is installed."
+ "guildHint": "Choose the guild where the bot is installed.",
+ "step1Title": "Create Discord App",
+ "step1Description": "Create a new application in the Developer Portal.",
+ "step1Item1": "Open the Discord Developer Portal",
+ "step1Item2": "Click \"New Application\" and name it",
+ "step1Item3": "Open the Bot tab (your bot is created automatically)",
+ "openDeveloperPortal": "Open Developer Portal",
+ "step2Title": "Enable Message Content Intent",
+ "step2Description": "Enable Message Content Intent in the Bot tab. Permissions are included in the invite link.",
+ "step2Item1": "In the Bot tab, enable \"Message Content Intent\" and save",
+ "step2Item2": "No need to set Bot Permissions here",
+ "step2Tip": "Message Content Intent is required to read message text.",
+ "step3Title": "Generate Invite URL",
+ "step3Description": "Paste your Client ID and we will generate a ready-to-use OAuth2 invite link.",
+ "step3Item1": "In your app, open General Information and copy Client ID",
+ "step3Item2": "Paste it below to generate the invite URL",
+ "step3Item3": "Permissions are prefilled in the invite URL",
+ "step3Item4": "Open the invite URL, choose a server, and authorize",
+ "clientId": "Client ID",
+ "clientIdPlaceholder": "Paste Client ID",
+ "clientIdHint": "Find this in General Information of your Discord application.",
+ "inviteUrlLabel": "OAuth2 Invite URL",
+ "inviteUrlPlaceholder": "Invite URL will appear here after Client ID",
+ "inviteUrlCopy": "Copy URL",
+ "inviteUrlCopied": "Copied",
+ "openInviteUrl": "Open OAuth2 Invite URL",
+ "openUrlGenerator": "Open OAuth2 URL Generator",
+ "step4Title": "Add Token & Validate",
+ "step4Description": "Copy the bot token and validate access.",
+ "step4Item1": "In the Bot tab, click \"Reset Token\" or \"View Token\"",
+ "step4Item2": "Copy the token and paste it here",
+ "step4Item3": "Validate the token and choose a guild"
},
"slackConfig": {
"title": "Slack Configuration",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 85659575b..1c420a4c7 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -76,7 +76,7 @@
},
"discordConfig": {
"title": "Discord 配置",
- "subtitle": "填写机器人令牌并验证权限。",
+ "subtitle": "创建 Discord 应用、邀请机器人加入服务器,然后填写令牌。",
"botToken": "机器人令牌",
"botTokenPlaceholder": "粘贴 Discord 机器人令牌",
"botTokenHint": "在 Discord Developer Portal 获取令牌。",
@@ -85,7 +85,38 @@
"authFailed": "验证失败",
"guild": "服务器",
"guildPlaceholder": "选择服务器",
- "guildHint": "选择已安装机器人的服务器。"
+ "guildHint": "选择已安装机器人的服务器。",
+ "step1Title": "创建 Discord 应用",
+ "step1Description": "在开发者后台创建新应用。",
+ "step1Item1": "打开 Discord Developer Portal",
+ "step1Item2": "点击「New Application」并命名",
+ "step1Item3": "进入「Bot」(机器人会自动创建)",
+ "openDeveloperPortal": "打开开发者后台",
+ "step2Title": "开启 Message Content Intent",
+ "step2Description": "在 Bot 页面开启 Message Content Intent,权限会自动包含在邀请链接中。",
+ "step2Item1": "在「Bot」中开启「Message Content Intent」并保存",
+ "step2Item2": "无需在此配置 Bot Permissions",
+ "step2Tip": "读取消息正文必须开启 Message Content Intent。",
+ "step3Title": "生成邀请链接",
+ "step3Description": "填写 Client ID,我们会自动生成可用的 OAuth2 邀请链接。",
+ "step3Item1": "进入应用的 General Information,复制 Client ID",
+ "step3Item2": "粘贴到下方生成邀请链接",
+ "step3Item3": "权限已预置在邀请链接中",
+ "step3Item4": "打开邀请链接,选择服务器并授权",
+ "clientId": "Client ID",
+ "clientIdPlaceholder": "粘贴 Client ID",
+ "clientIdHint": "在 Discord 应用的 General Information 中可找到。",
+ "inviteUrlLabel": "OAuth2 邀请链接",
+ "inviteUrlPlaceholder": "填写 Client ID 后自动生成",
+ "inviteUrlCopy": "复制链接",
+ "inviteUrlCopied": "已复制",
+ "openInviteUrl": "打开 OAuth2 邀请链接",
+ "openUrlGenerator": "打开 OAuth2 URL Generator",
+ "step4Title": "填写令牌并验证",
+ "step4Description": "复制机器人令牌并验证访问。",
+ "step4Item1": "在「Bot」中点击「Reset Token」或「View Token」",
+ "step4Item2": "复制令牌并粘贴到此处",
+ "step4Item3": "验证令牌并选择服务器"
},
"slackConfig": {
"title": "Slack 配置",
diff --git a/vibe/i18n/en.json b/vibe/i18n/en.json
index 575081077..06bc7d64f 100644
--- a/vibe/i18n/en.json
+++ b/vibe/i18n/en.json
@@ -3,6 +3,8 @@
"save": "Save",
"cancel": "Cancel",
"submit": "Submit",
+ "next": "Next",
+ "back": "Back",
"change": "Change",
"resume": "Resume",
"on": "On",
@@ -61,6 +63,20 @@
"visibilityHidden": "hidden",
"messageTypeStatus": "{name} messages are now {action}"
},
+ "discord": {
+ "settingsSubtitle": "Adjust message visibility, mention behavior, and language.",
+ "routingSubtitle": "Select backend and model settings for this channel.",
+ "labels": {
+ "messageTypes": "Message types",
+ "mentionPolicy": "Mention policy",
+ "language": "Language",
+ "backend": "Backend",
+ "opencodeAgent": "OpenCode agent",
+ "claudeAgent": "Claude agent",
+ "model": "Model",
+ "reasoningEffort": "Reasoning effort"
+ }
+ },
"info": {
"messageTypesTitle": "Message Types Info:",
"messageTypesFooter": "Hidden messages won't be sent to your IM platform.",
diff --git a/vibe/i18n/zh.json b/vibe/i18n/zh.json
index 62fcd097a..e5fdffecf 100644
--- a/vibe/i18n/zh.json
+++ b/vibe/i18n/zh.json
@@ -3,6 +3,8 @@
"save": "保存",
"cancel": "取消",
"submit": "提交",
+ "next": "下一步",
+ "back": "返回",
"change": "更改",
"resume": "恢复",
"on": "开启",
@@ -61,6 +63,20 @@
"visibilityHidden": "隐藏",
"messageTypeStatus": "{name} 消息已设为 {action}"
},
+ "discord": {
+ "settingsSubtitle": "调整消息可见性、@提及策略与语言。",
+ "routingSubtitle": "为该频道选择后端与模型配置。",
+ "labels": {
+ "messageTypes": "消息类型",
+ "mentionPolicy": "提及策略",
+ "language": "语言",
+ "backend": "后端",
+ "opencodeAgent": "OpenCode Agent",
+ "claudeAgent": "Claude Agent",
+ "model": "模型",
+ "reasoningEffort": "推理强度"
+ }
+ },
"info": {
"messageTypesTitle": "消息类型说明:",
"messageTypesFooter": "隐藏的消息类型不会发送到你的 IM 平台。",