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(ui): clarify user binding menus
cyhef6e9a1b270d
diff --git a/core/handlers/command_handlers.py b/core/handlers/command_handlers.pyindex ad5d4a4c7..eeb3c64b6 100644--- a/core/handlers/command_handlers.py+++ b/core/handlers/command_handlers.py@@ -76,6 +76,17 @@ class CommandHandlers(BaseHandler):lines.extend(commands)return "\n".join(line for line in lines if line)+ def _build_bind_success_message(self, *, name: str, is_admin: bool, platform: str) -> str:+ key = "bind.successAdmin" if is_admin else "bind.success"+ message = self._t(key, name=name)+ try:+ supports_buttons = get_platform_descriptor(platform).capabilities.supports_buttons+ except ValueError:+ supports_buttons = False++ hint_key = "bind.menuHintButtons" if supports_buttons else "bind.menuHintStart"+ return f"{message}\n\n{self._t(hint_key)}"+def _normalize_resume_agent(self, value: str) -> Optional[str]:normalized = (value or "").strip().lower()aliases = {@@ -892,10 +903,11 @@ class CommandHandlers(BaseHandler):await im_client.send_message(channel_context, self._t("bind.invalidCode"))return- if is_admin:- msg = self._t("bind.successAdmin", name=display_name)- else:- msg = self._t("bind.success", name=display_name)+ msg = self._build_bind_success_message(+ name=display_name,+ is_admin=is_admin,+ platform=platform,+ )channel_context = self._get_channel_context(context)await im_client.send_message(channel_context, msg)diff --git a/tests/test_command_handler_user_names.py b/tests/test_command_handler_user_names.pyindex 9922e6b87..5636cbb57 100644--- a/tests/test_command_handler_user_names.py+++ b/tests/test_command_handler_user_names.py@@ -82,11 +82,11 @@ class _StubSettingsManager:def __init__(self):self.bind_calls = []- def is_bound_user(self, user_id):+ def is_bound_user(self, user_id, platform=None):return False- def bind_user_with_code(self, user_id, display_name, code, dm_chat_id=""):- self.bind_calls.append((user_id, display_name, code, dm_chat_id))+ def bind_user_with_code(self, user_id, display_name, code, dm_chat_id="", platform=None):+ self.bind_calls.append((user_id, display_name, code, dm_chat_id, platform))return True, False@@ -128,11 +128,41 @@ class CommandHandlerUserNameTests(unittest.IsolatedAsyncioTestCase):self.assertEqual(controller.settings_manager.bind_calls,- [("U0E0FM3QT", "Alex", "bind-code", "D123")],+ [("U0E0FM3QT", "Alex", "bind-code", "D123", "slack")],)self.assertEqual(controller.im_client.sent_messages,- [("D123", "✅ 绑定成功!欢迎,Alex。你现在可以通过私信使用 Vibe Remote。")],+ [+ (+ "D123",+ "✅ 绑定成功!欢迎,Alex。你现在可以通过私信使用 Vibe Remote。\n\n"+ "要打开操作菜单,直接 @bot 即可,不需要加任何内容。",+ )+ ],+ )++ async def test_wechat_bind_success_points_to_start_menu(self):+ controller = _StubController({"display_name": "小王"})+ setattr(controller.config, "platform", "wechat")+ handler = CommandHandlers(controller)+ context = MessageContext(+ user_id="wx-user",+ channel_id="wx-user",+ platform="wechat",+ platform_specific={"platform": "wechat", "is_dm": True},+ )++ await handler.handle_bind(context, "bind-code")++ self.assertEqual(+ controller.im_client.sent_messages,+ [+ (+ "wx-user",+ "✅ 绑定成功!欢迎,小王。你现在可以通过私信使用 Vibe Remote。\n\n"+ "发送 `/start` 即可唤起更多操作菜单。",+ )+ ],)async def test_wechat_start_message_uses_localized_compact_commands(self):diff --git a/tests/test_ui_server_fastapi.py b/tests/test_ui_server_fastapi.pyindex a77c94d08..6083dc586 100644--- a/tests/test_ui_server_fastapi.py+++ b/tests/test_ui_server_fastapi.py@@ -1,9 +1,12 @@import pytest+from unittest.mock import Mockfrom vibe.ui_compat import CompatApp, normalize_response, route_path_to_fastapi, run_maybe_async, requestfrom starlette.websockets import WebSocketDisconnect+from vibe import ui_serverfrom vibe.ui_server import app+from tests.ui_server_test_helpers import csrf_headersdef test_websocket_echo_is_disabled_by_default(monkeypatch):@@ -86,3 +89,74 @@ def test_run_maybe_async_offloads_sync_handlers_without_losing_context():assert result == "/threadpool-check"assert tick == "tick"+++def test_wechat_qr_poll_schedules_bind_hint_without_awaiting_send(monkeypatch):+ class _Auth:+ async def poll_status(self, session_key):+ assert session_key == "qr-session"+ return {+ "status": "confirmed",+ "bot_token": "wechat-token",+ "base_url": "https://wechat.example.com",+ "user_id": "wx-user",+ }++ scheduled = []++ monkeypatch.setattr(ui_server, "_get_wechat_auth", lambda: _Auth())+ monkeypatch.setattr(+ ui_server,+ "_schedule_wechat_bind_success_hint",+ lambda **kwargs: scheduled.append(kwargs),+ )+ monkeypatch.setattr(+ "vibe.api.auto_bind_wechat_user",+ lambda user_id: {"ok": True, "already_bound": False, "is_admin": True},+ )++ client = app.test_client()+ response = client.post(+ "/wechat/qr_login/poll",+ json={"session_key": "qr-session"},+ headers=csrf_headers(client),+ )++ assert response.status_code == 200+ assert response.get_json()["status"] == "confirmed"+ assert scheduled == [+ {+ "user_id": "wx-user",+ "bot_token": "wechat-token",+ "base_url": "https://wechat.example.com",+ "already_bound": False,+ "is_admin": True,+ }+ ]+++def test_wechat_bind_hint_scheduler_uses_persistent_loop(monkeypatch):+ scheduled_coroutines = []+ fake_loop = object()+ fake_future = Mock()++ monkeypatch.setattr(ui_server, "_ensure_wechat_hint_loop", lambda: fake_loop)+ monkeypatch.setattr(+ ui_server.asyncio,+ "run_coroutine_threadsafe",+ lambda coro, loop: scheduled_coroutines.append((coro, loop)) or fake_future,+ )++ ui_server._schedule_wechat_bind_success_hint(+ user_id="wx-user",+ bot_token="wechat-token",+ base_url="https://wechat.example.com",+ already_bound=False,+ is_admin=False,+ )++ assert len(scheduled_coroutines) == 1+ assert scheduled_coroutines[0][1] is fake_loop+ assert scheduled_coroutines[0][0].cr_code.co_name == "_send_hint"+ fake_future.add_done_callback.assert_called_once()+ scheduled_coroutines[0][0].close()diff --git a/tests/test_wechat_auth.py b/tests/test_wechat_auth.pyindex 0aa9598ba..1328a5ed6 100644--- a/tests/test_wechat_auth.py+++ b/tests/test_wechat_auth.py@@ -1,11 +1,13 @@import sysimport unittest+from types import SimpleNamespacefrom pathlib import Pathfrom unittest.mock import AsyncMock, patchsys.path.insert(0, str(Path(__file__).resolve().parents[1]))from modules.im.wechat_auth import WeChatAuthManager+from vibe import api as vibe_apiclass WeChatAuthManagerTests(unittest.IsolatedAsyncioTestCase):@@ -50,3 +52,86 @@ class WeChatAuthManagerTests(unittest.IsolatedAsyncioTestCase):self.assertEqual(result["status"], "expired")self.assertIn("start a new login", result["message"].lower())++ async def test_send_wechat_bind_success_hint_uses_start_instruction(self):+ sent = {}++ async def fake_send_message(base_url, token, to_user_id, context_token, item_list):+ sent.update(+ {+ "base_url": base_url,+ "token": token,+ "to_user_id": to_user_id,+ "context_token": context_token,+ "item_list": item_list,+ }+ )+ return {}++ config = SimpleNamespace(language="zh")++ with patch("vibe.api.load_config", return_value=config), patch(+ "modules.im.wechat_api.send_message",+ new=AsyncMock(side_effect=fake_send_message),+ ):+ result = await vibe_api.send_wechat_bind_success_hint(+ user_id="wx-user",+ bot_token="token",+ base_url="https://wechat.example.com",+ is_admin=True,+ )++ self.assertTrue(result)+ self.assertEqual(sent["to_user_id"], "wx-user")+ self.assertIn("绑定成功", sent["item_list"][0]["text_item"]["text"])+ self.assertIn("第一个用户", sent["item_list"][0]["text_item"]["text"])+ self.assertIn("/start", sent["item_list"][0]["text_item"]["text"])++ async def test_send_wechat_bind_success_hint_uses_neutral_success_for_non_admin(self):+ sent = {}++ async def fake_send_message(base_url, token, to_user_id, context_token, item_list):+ sent["text"] = item_list[0]["text_item"]["text"]+ return {}++ config = SimpleNamespace(language="zh")++ with patch("vibe.api.load_config", return_value=config), patch(+ "modules.im.wechat_api.send_message",+ new=AsyncMock(side_effect=fake_send_message),+ ):+ result = await vibe_api.send_wechat_bind_success_hint(+ user_id="wx-user",+ bot_token="token",+ base_url="https://wechat.example.com",+ is_admin=False,+ )++ self.assertTrue(result)+ self.assertIn("绑定成功", sent["text"])+ self.assertNotIn("第一个用户", sent["text"])+ self.assertIn("/start", sent["text"])++ async def test_send_wechat_bind_success_hint_handles_existing_binding(self):+ sent = {}++ async def fake_send_message(base_url, token, to_user_id, context_token, item_list):+ sent["text"] = item_list[0]["text_item"]["text"]+ return {}++ config = SimpleNamespace(language="zh")++ with patch("vibe.api.load_config", return_value=config), patch(+ "modules.im.wechat_api.send_message",+ new=AsyncMock(side_effect=fake_send_message),+ ):+ result = await vibe_api.send_wechat_bind_success_hint(+ user_id="wx-user",+ bot_token="token",+ base_url="https://wechat.example.com",+ already_bound=True,+ )++ self.assertTrue(result)+ self.assertIn("已经绑定过了", sent["text"])+ self.assertIn("/start", sent["text"])diff --git a/ui/src/components/Dashboard.tsx b/ui/src/components/Dashboard.tsxindex 7755f63b3..7b26728aa 100644--- a/ui/src/components/Dashboard.tsx+++ b/ui/src/components/Dashboard.tsx@@ -2,9 +2,9 @@ import React, { useEffect, useMemo, useState } from 'react';import {Activity,ArrowRight,+ Cloud,Clock,Cpu,- Gauge,Hash,MessageSquare,Play,@@ -56,15 +56,19 @@ const StatCard: React.FC<{value: string;hint: string;icon: React.ReactNode;-}> = ({ label, value, hint, icon }) => (- <div className="flex flex-col gap-1.5 rounded-xl border border-border bg-background p-5">+ to: string;+}> = ({ label, value, hint, icon, to }) => (+ <Link+ to={to}+ className="group flex min-h-[126px] flex-col gap-1.5 rounded-xl border border-border bg-background p-5 transition hover:border-border-strong hover:bg-surface-2/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mint/45"+ ><div className="flex items-center justify-between gap-2"><span className="text-[13px] font-medium text-muted">{label}</span>- <span className="text-muted">{icon}</span>+ <span className="text-muted transition group-hover:text-foreground">{icon}</span></div><div className="text-[28px] font-bold leading-tight tracking-[-0.4px] text-foreground">{value}</div><div className="text-[12px] font-medium text-muted">{hint}</div>- </div>+ </Link>);export const Dashboard: React.FC = () => {@@ -73,6 +77,7 @@ export const Dashboard: React.FC = () => {const { status, control } = useStatus();const [config, setConfig] = useState<any>(null);const [doctor, setDoctor] = useState<any>(null);+ const [remoteAccess, setRemoteAccess] = useState<any>(null);const [settingsByPlatform, setSettingsByPlatform] = useState<Record<string, any>>({});const [usersCount, setUsersCount] = useState(0);const [recentLogs, setRecentLogs] = useState<LogEntry[]>([]);@@ -88,8 +93,9 @@ export const Dashboard: React.FC = () => {setConfig(nextConfig);const enabledPlatforms = getEnabledPlatforms(nextConfig);- const [doctorRes, logsRes, settingsEntries, usersEntries] = await Promise.all([+ const [doctorRes, remoteAccessRes, logsRes, settingsEntries, usersEntries] = await Promise.all([api.doctor(),+ api.remoteAccessStatus().catch(() => null),api.getLogs(8, 'service'),Promise.all(enabledPlatforms.map(async (platform) => [platform, await api.getSettings(platform)] as const)),Promise.all(enabledPlatforms.map(async (platform) => [platform, await api.getUsers(platform)] as const)),@@ -97,6 +103,7 @@ export const Dashboard: React.FC = () => {if (cancelled) return;setDoctor(doctorRes);+ setRemoteAccess(remoteAccessRes);setRecentLogs((logsRes.logs || []).slice(-5).reverse());setSettingsByPlatform(Object.fromEntries(settingsEntries));setUsersCount(@@ -170,7 +177,17 @@ export const Dashboard: React.FC = () => {});const isRunning = status.state === 'running';- const issuesCount = (doctor?.summary?.fail || 0) + (doctor?.summary?.warn || 0);+ const cloudPublicUrl = String(remoteAccess?.public_url || '').replace(/^https?:\/\//, '');+ const cloudValue = remoteAccess?.paired+ ? remoteAccess?.running+ ? t('dashboard.metricCloudConnected')+ : t('dashboard.metricCloudConfigured')+ : t('dashboard.metricCloudDisconnected');+ const cloudHint = remoteAccess?.paired+ ? remoteAccess?.running+ ? t('dashboard.metricCloudHintConnected', { url: cloudPublicUrl || 'avibe.bot' })+ : t('dashboard.metricCloudHintConfigured')+ : t('dashboard.metricCloudHintDisconnected');const enabledPlatformTitles = platformCards.filter((p) => p.enabled)@@ -312,24 +329,28 @@ export const Dashboard: React.FC = () => {value={`${enabledPlatforms.length} / ${platformCatalog.length}`}hint={enabledPlatformTitles || t('dashboard.metricPlatformsHint')}icon={<PlugZap className="size-4" />}+ to="/settings/platforms"/><StatCardlabel={t('dashboard.metricGroups')}value={String(totalActiveGroups)}hint={t('dashboard.metricGroupsHint').replace('{{count}}', String(totalDiscoveredGroups))}icon={<Hash className="size-4" />}+ to="/groups"/><StatCardlabel={t('dashboard.metricUsers')}value={String(usersCount)}hint={t('dashboard.metricUsersHint')}icon={<MessageSquare className="size-4" />}+ to="/users"/><StatCard- label={t('dashboard.metricHealth')}- value={String(issuesCount)}- hint={doctor?.ok ? t('dashboard.metricHealthHealthy') : t('dashboard.metricHealthIssues')}- icon={<Gauge className="size-4" />}+ label={t('dashboard.metricCloud')}+ value={cloudValue}+ hint={cloudHint}+ icon={<Cloud className="size-4" />}+ to="/settings/service"/></div>diff --git a/ui/src/components/steps/UserList.tsx b/ui/src/components/steps/UserList.tsxindex 8a82782d1..db75404b5 100644--- a/ui/src/components/steps/UserList.tsx+++ b/ui/src/components/steps/UserList.tsx@@ -83,6 +83,11 @@ const getInitials = (name: string, fallback: string): string => {return (onlyAlpha || trimmed).slice(0, 2).toUpperCase();};+const displayNameForUser = (u: AggregatedUser): string => {+ const name = (u.config.display_name || '').trim();+ return name || u.userId;+};+const formatExpiry = (expiresAt: string | null): string => {if (!expiresAt) return '';const ms = new Date(expiresAt).getTime() - Date.now();@@ -526,7 +531,7 @@ export const UserList: React.FC = () => {return flat.sort((a, b) =>Number(b.config.is_admin) - Number(a.config.is_admin) ||- a.config.display_name.localeCompare(b.config.display_name) ||+ displayNameForUser(a).localeCompare(displayNameForUser(b)) ||a.userId.localeCompare(b.userId));}, [usersByPlatform]);@@ -728,6 +733,10 @@ export const UserList: React.FC = () => {: effectiveBackend === 'codex'? userConfig.routing.codex_model: userConfig.routing.opencode_model;+ const displayName = displayNameForUser(u);+ const metaPrefix = userConfig.enabled+ ? `${backendLabel(effectiveBackend)}${backendModel ? `/${backendModel}` : ''}`+ : t('userList.disabled', { defaultValue: 'Disabled' });const updateRow = (patch: Partial<UserConfig>) => updateUser(u.platform, u.userId, patch);const toggleEnabled = () => updateRow({ enabled: !userConfig.enabled });@@ -770,32 +779,30 @@ export const UserList: React.FC = () => {{/* Avatar — tone-colored ring with platform corner badge */}<span className="relative shrink-0"><span- className="flex size-[34px] items-center justify-center rounded-full border font-mono text-[12px] font-bold"+ className="flex size-[40px] items-center justify-center rounded-full border font-mono text-[13px] font-bold"style={{ backgroundColor: tone.bg, borderColor: tone.border }}>{isBot ? (- <Bot size={14} className="text-muted" />+ <Bot size={17} className="text-muted" />) : (<span className={tone.textCls}>{initials}</span>)}</span><span- className="absolute -bottom-0.5 -right-0.5 flex size-[14px] items-center justify-center rounded-full border border-border bg-background"+ className="absolute -bottom-1 -right-1 flex size-[20px] items-center justify-center rounded-full border border-border bg-background shadow-[0_0_0_2px_var(--color-background)]"title={t(`platform.${u.platform}.title`)}>- <PlatformIcon platform={u.platform} size={9} />+ <PlatformIcon platform={u.platform} size={13} /></span></span>{/* Name + meta */}<span className="min-w-0 flex-1"><span className="block truncate text-[13px] font-semibold text-foreground">- {userConfig.display_name || u.userId}+ {displayName}</span><span className="block truncate font-mono text-[11px] text-muted">- {userConfig.enabled- ? `${backendLabel(effectiveBackend)}${backendModel ? `/${backendModel}` : ''} · ${u.userId}`- : u.userId}+ {metaPrefix} · {u.userId}</span></span>diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex 335f86982..44fc325d7 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -878,6 +878,13 @@"metricGroupsHint": "{{count}} discovered total","metricUsers": "Bound users","metricUsersHint": "authorized to access this node",+ "metricCloud": "avibe.bot cloud",+ "metricCloudConnected": "Connected",+ "metricCloudConfigured": "Configured",+ "metricCloudDisconnected": "Off",+ "metricCloudHintConnected": "{{url}} is reachable through avibe.bot",+ "metricCloudHintConfigured": "Start the connector to make this node reachable",+ "metricCloudHintDisconnected": "Recommended: enable cloud access for this node","metricHealth": "Health warnings","metricHealthHealthy": "all checks green","metricHealthIssues": "warnings or failures need review",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 401c1b4cc..cb05cb255 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -878,6 +878,13 @@"metricGroupsHint": "总共发现了 {{count}} 个群组","metricUsers": "已绑定用户","metricUsersHint": "允许访问当前节点的用户数",+ "metricCloud": "avibe.bot cloud",+ "metricCloudConnected": "已连接",+ "metricCloudConfigured": "已配置",+ "metricCloudDisconnected": "未开启",+ "metricCloudHintConnected": "{{url}} 已可通过 avibe.bot 访问",+ "metricCloudHintConfigured": "启动连接器后即可远程访问当前节点",+ "metricCloudHintDisconnected": "推荐开启 cloud 访问,让当前节点随时可达","metricHealth": "健康告警","metricHealthHealthy": "所有检查均正常","metricHealthIssues": "存在告警或失败项需要处理",diff --git a/vibe/api.py b/vibe/api.pyindex 0f7a34165..dd2a5f10c 100644--- a/vibe/api.py+++ b/vibe/api.py@@ -4300,12 +4300,14 @@ def auto_bind_wechat_user(user_id: str) -> dict:# Skip if already boundif store.is_bound_user(user_id, platform=platform):logger.info("WeChat user %s already bound, skipping auto-bind", user_id)- return {"ok": True, "already_bound": True}+ existing = store.get_user(user_id, platform=platform)+ return {"ok": True, "already_bound": True, "is_admin": bool(getattr(existing, "is_admin", False))}config = load_config()+ is_admin = not store.has_any_admin(platform=platform)user = UserSettings(display_name=user_id,- is_admin=True,+ is_admin=is_admin,bound_at=_now_iso(),enabled=True,custom_cwd=config.runtime.default_cwd or None,@@ -4317,8 +4319,59 @@ def auto_bind_wechat_user(user_id: str) -> dict:store.set_users_for_platform(platform, current_users)store.save()- logger.info("Auto-bound WeChat user %s as admin", user_id)- return {"ok": True, "already_bound": False}+ logger.info("Auto-bound WeChat user %s (admin=%s)", user_id, is_admin)+ return {"ok": True, "already_bound": False, "is_admin": is_admin}+++async def send_wechat_bind_success_hint(+ *,+ user_id: str,+ bot_token: str,+ base_url: str,+ context_token: str = "",+ already_bound: bool = False,+ is_admin: bool = False,+) -> bool:+ """Best-effort post-bind hint for WeChat QR login.++ QR login is WeChat's bind flow, so users do not send a bind code. Send the+ same menu-discovery hint immediately when the upstream API accepts it.+ """+ if not user_id or not bot_token:+ return False++ from modules.im import wechat_api+ from modules.im.wechat import WeChatConfig, WeChatBot+ from vibe.i18n import t as i18n_t++ config = load_config()+ lang = getattr(config, "language", "en")+ status_line = (+ i18n_t("bind.alreadyBound", lang)+ if already_bound+ else i18n_t("bind.successAdmin" if is_admin else "bind.success", lang, name=user_id)+ )+ message = "\n\n".join(+ [+ status_line,+ i18n_t("bind.menuHintStart", lang),+ ]+ )+ text = WeChatBot(WeChatConfig(bot_token=bot_token, base_url=base_url)).format_markdown(message)+ item_list = [{"type": 1, "text_item": {"text": text}}]++ try:+ await wechat_api.send_message(+ base_url,+ bot_token,+ user_id,+ context_token,+ item_list,+ )+ return True+ except Exception as exc:+ logger.warning("Failed to send WeChat bind success hint to %s: %s", user_id, exc)+ return False# ---------------------------------------------------------------------------diff --git a/vibe/i18n/en.json b/vibe/i18n/en.jsonindex 56c80edde..07d08c707 100644--- a/vibe/i18n/en.json+++ b/vibe/i18n/en.json@@ -331,6 +331,8 @@"bind": {"success": "✅ Bind successful! Welcome, {name}. You can now use Vibe Remote via DM.","successAdmin": "✅ Bind successful! Welcome, {name}. You are the first user and have been granted admin privileges.",+ "menuHintButtons": "To open the action menu, mention the bot with no extra text, for example `@bot`.",+ "menuHintStart": "Send `/start` to open more action menus.","alreadyBound": "You are already bound. No action needed.","invalidCode": "❌ Invalid or expired bind code. Please check and try again.","usage": "Usage: `bind <code>`\n\n`/bind <code>` also works. Please enter the bind code provided by an admin.",diff --git a/vibe/i18n/zh.json b/vibe/i18n/zh.jsonindex a7f9cc3d4..13a294376 100644--- a/vibe/i18n/zh.json+++ b/vibe/i18n/zh.json@@ -331,6 +331,8 @@"bind": {"success": "✅ 绑定成功!欢迎,{name}。你现在可以通过私信使用 Vibe Remote。","successAdmin": "✅ 绑定成功!欢迎,{name}。你是第一个用户,已被自动授予管理员权限。",+ "menuHintButtons": "要打开操作菜单,直接 @bot 即可,不需要加任何内容。",+ "menuHintStart": "发送 `/start` 即可唤起更多操作菜单。","alreadyBound": "你已经绑定过了,无需再次操作。","invalidCode": "❌ 无效或已过期的绑定码,请检查后重试。","usage": "用法:`bind <绑定码>`\n\n也兼容 `/bind <绑定码>`。请输入管理员提供的绑定码。",diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex e307e1c60..b5431aa93 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -1,3 +1,4 @@+import asyncioimport base64import hashlibimport hmac@@ -35,6 +36,9 @@ app = CompatApp(title="Vibe Remote UI", docs_url=None, redoc_url=None, openapi_u# Global server instance for graceful shutdown on reload_server = None+_wechat_hint_loop: asyncio.AbstractEventLoop | None = None+_wechat_hint_loop_thread: threading.Thread | None = None+_wechat_hint_loop_lock = threading.Lock()STRUCTURED_LOG_PATTERN = re.compile(r"^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})\s+-\s+([\w.]+)\s+-\s+(\w+)\s+-\s+(.*)$")LEVEL_HINT_PATTERN = re.compile(r"\b(DEBUG|INFO|WARNING|ERROR|CRITICAL)\b")@@ -780,6 +784,60 @@ def _is_remote_access_request(config: V2Config) -> bool:return _normalized_host(request.host) == public_host+def _ensure_wechat_hint_loop() -> asyncio.AbstractEventLoop:+ global _wechat_hint_loop, _wechat_hint_loop_thread+ with _wechat_hint_loop_lock:+ if _wechat_hint_loop is not None and not _wechat_hint_loop.is_closed():+ return _wechat_hint_loop++ loop = asyncio.new_event_loop()++ def _runner() -> None:+ asyncio.set_event_loop(loop)+ loop.run_forever()++ _wechat_hint_loop = loop+ _wechat_hint_loop_thread = threading.Thread(target=_runner, daemon=True, name="wechat-bind-hints")+ _wechat_hint_loop_thread.start()+ return loop+++def _schedule_wechat_bind_success_hint(+ *,+ user_id: str,+ bot_token: str,+ base_url: str,+ already_bound: bool,+ is_admin: bool,+) -> None:+ if not user_id or not bot_token:+ return++ async def _send_hint() -> None:+ try:+ from vibe import api as vibe_api++ await vibe_api.send_wechat_bind_success_hint(+ user_id=user_id,+ bot_token=bot_token,+ base_url=base_url,+ already_bound=already_bound,+ is_admin=is_admin,+ )+ except Exception as exc:+ logger.warning("Failed to send WeChat bind success hint in background: %s", exc)++ future = asyncio.run_coroutine_threadsafe(_send_hint(), _ensure_wechat_hint_loop())++ def _log_failure(done_future) -> None:+ try:+ done_future.result()+ except Exception as exc:+ logger.warning("WeChat bind success hint task failed: %s", exc)++ future.add_done_callback(_log_failure)++def _remote_access_public_host(config: V2Config) -> str | None:public_url = (config.remote_access.vibe_cloud.public_url or "").strip()if not public_url:@@ -1669,7 +1727,14 @@ async def wechat_qr_login_poll():try:from vibe import api as vibe_api- vibe_api.auto_bind_wechat_user(user_id)+ bind_result = vibe_api.auto_bind_wechat_user(user_id)+ _schedule_wechat_bind_success_hint(+ user_id=user_id,+ bot_token=result.get("bot_token", ""),+ base_url=result.get("base_url") or payload.get("base_url", "https://ilinkai.weixin.qq.com"),+ already_bound=bool(bind_result.get("already_bound")),+ is_admin=bool(bind_result.get("is_admin")),+ )except Exception as e:logger.warning("Failed to auto-bind WeChat user: %s", e)