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(im): point chats without settings forms at their Web settings row (#3059)

Call White8c9eba70b231
diff --git a/core/auth.py b/core/auth.py
index d8bfc2bf1..c3f076684 100644
--- a/core/auth.py
+++ b/core/auth.py
@@ -30,6 +30,7 @@ ADMIN_PROTECTED_ACTIONS: frozenset = frozenset(
"setup",
"set_cwd",
"settings",
+ "agent",
}
)
diff --git a/core/controller.py b/core/controller.py
index 6df70229a..6139da152 100644
--- a/core/controller.py
+++ b/core/controller.py
@@ -893,6 +893,7 @@ class Controller:
"resume": inbound(self.command_handler.handle_resume),
"setup": inbound(self.command_handler.handle_setup),
"settings": inbound(self.settings_handler.handle_settings),
+ "agent": inbound(self.settings_handler.handle_routing),
"stop": inbound(self.command_handler.handle_stop),
"bind": inbound(self.command_handler.handle_bind),
}
diff --git a/core/handlers/command_handlers.py b/core/handlers/command_handlers.py
index caa1b7c2e..fb4f0f3bc 100644
--- a/core/handlers/command_handlers.py
+++ b/core/handlers/command_handlers.py
@@ -79,6 +79,7 @@ class CommandHandlers(BaseHandler):
self._t("command.start.commandStart"),
self._t("command.start.commandCwd"),
self._t("command.start.commandSetCwd"),
+ self._t("command.start.commandAgent"),
self._t("command.start.commandResume"),
self._t("command.start.commandSetup"),
self._t("command.start.commandStop", agent=agent_display_name),
diff --git a/core/handlers/settings_handler.py b/core/handlers/settings_handler.py
index 89d6666da..f54bbb11c 100644
--- a/core/handlers/settings_handler.py
+++ b/core/handlers/settings_handler.py
@@ -4,6 +4,7 @@ import asyncio
import logging
import sys
from typing import Optional
+from urllib.parse import urlencode
from modules.agents import get_agent_display_name
from modules.agents.catalog import (
@@ -13,6 +14,7 @@ from modules.agents.catalog import (
implicit_default_rank,
is_builtin_backend,
)
+from config.platform_registry import get_platform_descriptor
from modules.im import MessageContext, InlineKeyboard, InlineButton
from config.v2_settings import normalize_routing_settings
from core.modals import (
@@ -46,6 +48,13 @@ def _effort_options(entries) -> list[RouteOption]:
]
+def _platform_supports_buttons(platform: str) -> bool:
+ try:
+ return get_platform_descriptor(platform).capabilities.supports_buttons
+ except ValueError:
+ return True
+
+
class SettingsHandler(BaseHandler):
"""Handles settings and configuration operations"""
@@ -102,6 +111,10 @@ class SettingsHandler(BaseHandler):
"""Handle settings command - show settings menu"""
try:
platform = context.platform or (context.platform_specific or {}).get("platform") or self.config.platform
+ if not _platform_supports_buttons(platform):
+ # A settings menu needs buttons; the Web settings page is the form.
+ await self._send_web_settings_link(context)
+ return
# For Slack, use modal dialog
if platform == "slack":
await self._handle_settings_slack(context)
@@ -121,6 +134,28 @@ class SettingsHandler(BaseHandler):
context, f"❌ {self._t('error.showSettings', error=str(e))}"
)
+ async def _send_web_settings_link(self, context: MessageContext) -> None:
+ """Point a chat that cannot show a settings form at its row on the Web settings page.
+
+ The link opens through Avibe Cloud; without it, the reply says where the page is.
+ """
+ from core.avibe_cloud import workbench_url
+
+ platform = context.platform or (context.platform_specific or {}).get("platform") or self.config.platform
+ is_dm = bool((context.platform_specific or {}).get("is_dm"))
+ if is_dm:
+ query = urlencode({"platform": platform, "user": context.user_id})
+ path, page = f"/settings/platforms/users?{query}", self._t("scopeSettings.pageUsers")
+ else:
+ path, page = "/settings/platforms/groups", self._t("scopeSettings.pageGroups")
+ url = workbench_url(path, self.config)
+ text = (
+ self._t("scopeSettings.openInWebUrl", url=url)
+ if url
+ else self._t("scopeSettings.openInWeb", page=page)
+ )
+ await self._get_im_client(context).send_message(context, text)
+
async def _handle_settings_traditional(self, context: MessageContext):
"""Handle settings for non-Slack platforms"""
im_client = self._get_im_client(context)
@@ -422,13 +457,13 @@ class SettingsHandler(BaseHandler):
logger.error(f"Error in handle_info_how_it_works: {e}", exc_info=True)
await self._get_im_client(context).send_message(context, f"❌ {self._t('error.helpInfoFailed')}")
- async def handle_routing(self, context: MessageContext):
+ async def handle_routing(self, context: MessageContext, args: str = ""):
"""Handle routing command - show agent/model selection"""
try:
platform = context.platform or (context.platform_specific or {}).get("platform") or self.config.platform
im_client = self._get_im_client(context)
if not hasattr(im_client, "open_routing_modal"):
- await im_client.send_message(context, self._t("routing.slackOnly"))
+ await self._send_web_settings_link(context)
return
platform_specific = context.platform_specific or {}
if platform == "slack":
diff --git a/docs/COMMANDS.md b/docs/COMMANDS.md
index 2d2cfbcb1..b7f494eba 100644
--- a/docs/COMMANDS.md
+++ b/docs/COMMANDS.md
@@ -49,6 +49,7 @@ These commands are registered by the controller today:
| `/resume` | Resume a recent session |
| `/setup` | Repair backend login/auth |
| `/settings` | Open settings UI |
+| `/agent` | Choose the Agent, model, and reasoning effort |
| `/stop` | Interrupt the active backend execution |
| `/bind <code>` | Bind a DM user to this Avibe instance |
| `bind <code>` | Plain-text DM alias for unbound users only |
@@ -71,6 +72,7 @@ Authorization is centralized in `core/auth.py`.
- `/setcwd <path>`
- `/set_cwd <path>`
- `/settings`
+- `/agent`
- `/setup`
Notes:
@@ -113,6 +115,7 @@ Notes:
- Commands are parsed from normal text messages that start with `/`.
- `/resume` uses a text-first flow instead of modals.
- `/resume 1`, `/resume more`, `/resume latest ...`, and manual resume syntax are especially relevant on WeChat.
+- WeChat shows no buttons or forms, so `/agent` and `/settings` reply with where to change this chat's settings: a link to its row on the Web settings page when Avibe Cloud remote access is set up, otherwise the page to open in the Avibe Workbench.
### 2.4 Parser normalization and aliases
@@ -436,6 +439,7 @@ Open the settings UI for the current scope.
- opens or routes to the settings menu for the current platform
- allows changing settings such as routing and other scope-level controls through UI flows
+- on a platform without buttons (WeChat), replies with a link to this chat's row on the Web settings page instead
#### Permission
@@ -446,6 +450,25 @@ Open the settings UI for the current scope.
- This command is registered even though the exact UI differs by platform.
- Prefer it when users want a guided configuration flow instead of raw commands.
+### `/agent`
+
+Choose the Agent, model, and reasoning effort for the current scope.
+
+#### Syntax
+
+```text
+/agent
+```
+
+#### What it does
+
+- opens the same Agent settings form as the `Agent Settings` button from `/start`
+- on a platform without forms (WeChat), replies with a link to this chat's row on the Web settings page instead
+
+#### Permission
+
+- admin-only
+
### `/stop`
Interrupt the active backend execution for the current scope.
diff --git a/modules/im/telegram.py b/modules/im/telegram.py
index 5e5f8d038..d0a08fe86 100644
--- a/modules/im/telegram.py
+++ b/modules/im/telegram.py
@@ -948,6 +948,7 @@ class TelegramBot(BaseIMClient):
"resume",
"settings",
"routing",
+ "agent",
"cwd",
"setcwd",
"set_cwd",
diff --git a/tests/test_auth_pipeline.py b/tests/test_auth_pipeline.py
index 98bd2041b..089da6db1 100644
--- a/tests/test_auth_pipeline.py
+++ b/tests/test_auth_pipeline.py
@@ -234,8 +234,8 @@ def test_require_bind_null_allows_any_member_regardless_of_platform_default():
assert result.allowed is True
[email protected]("action", ["auth_setup:codex", "routing_submit:claude"])
-def test_admin_guard_denies_non_admin_for_a_protected_action_with_a_suffix(action):
[email protected]("action", ["agent", "auth_setup:codex", "routing_submit:claude"])
+def test_admin_guard_denies_non_admin_a_protected_action(action):
store = _Store()
store.settings.channels["C1"] = SimpleNamespace(enabled=True)
store._bound_users.add("U5")
diff --git a/tests/test_controller_dispatch_loop.py b/tests/test_controller_dispatch_loop.py
index 61ea8da35..a2e285580 100644
--- a/tests/test_controller_dispatch_loop.py
+++ b/tests/test_controller_dispatch_loop.py
@@ -271,6 +271,7 @@ def test_dispatch_im_message_to_controller_loop_gates_admission_on_recovery():
def test_setup_callbacks_gates_work_admission_but_not_runtime_evidence():
controller = Controller.__new__(Controller)
callback = AsyncMock()
+ open_routing = AsyncMock()
controller.command_handler = SimpleNamespace(
handle_start=callback,
handle_new=callback,
@@ -284,6 +285,7 @@ def test_setup_callbacks_gates_work_admission_but_not_runtime_evidence():
)
controller.settings_handler = SimpleNamespace(
handle_settings=callback,
+ handle_routing=open_routing,
handle_settings_update=callback,
handle_routing_update=callback,
handle_routing_modal_update=callback,
@@ -317,6 +319,8 @@ def test_setup_callbacks_gates_work_admission_but_not_runtime_evidence():
Controller._setup_callbacks(controller)
assert all(value[2] is True for value in registered["on_command"].values())
+ # `/agent` opens the Agent settings the button does, on every platform.
+ assert registered["on_command"]["agent"][1] is open_routing
assert registered["on_message"][0::2] == ("message", True)
for name in (
"on_callback_query",
diff --git a/tests/test_controller_platform_reconcile.py b/tests/test_controller_platform_reconcile.py
index 7addaf02f..e22d14034 100644
--- a/tests/test_controller_platform_reconcile.py
+++ b/tests/test_controller_platform_reconcile.py
@@ -160,6 +160,7 @@ def _handler(**overrides):
"handle_bind",
"handle_change_cwd_submission",
"handle_settings",
+ "handle_routing",
"handle_settings_update",
"handle_routing_update",
"handle_routing_modal_update",
diff --git a/tests/test_settings_handler.py b/tests/test_settings_handler.py
index eb81084b1..4605310e5 100644
--- a/tests/test_settings_handler.py
+++ b/tests/test_settings_handler.py
@@ -6,6 +6,8 @@ from types import SimpleNamespace
from unittest.mock import AsyncMock
from unittest.mock import patch
+import pytest
+
from config.v2_settings import RoutingSettings
from core.handlers.settings_handler import SettingsHandler
from core.modals import (
@@ -18,6 +20,7 @@ from core.modals import (
)
from modules.agents.catalog import AGENT_BACKENDS, NATIVE_CLI_BACKENDS
from modules.im import MessageContext
+from vibe.i18n import t
def _values(options) -> list[str]:
@@ -982,3 +985,41 @@ def test_scope_needs_new_session_answers_for_the_scope_the_web_saved() -> None:
assert handler_for(threaded=True, routing_agent="vibey").scope_needs_new_session(
platform="discord", kind="user", native_id="U1"
) is False
+
+
[email protected]("entry", ["handle_routing", "handle_settings"])
+ ("is_dm", "public_url", "expected"),
+ [
+ # Through Avibe Cloud the reply links to this chat's own row.
+ (True, "https://team.avibe.bot", ("scopeSettings.openInWebUrl", {
+ "url": "https://team.avibe.bot/settings/platforms/users?platform=wechat&user=wx%40im.wechat",
+ })),
+ (False, "https://team.avibe.bot", ("scopeSettings.openInWebUrl", {
+ "url": "https://team.avibe.bot/settings/platforms/groups",
+ })),
+ # Without it, the reply says where the page is.
+ (True, None, ("scopeSettings.openInWeb", {"page": t("scopeSettings.pageUsers", "en")})),
+ ],
+)
+def test_a_chat_without_a_settings_form_is_pointed_at_the_web_settings_page(entry, is_dm, public_url, expected) -> None:
+ """WeChat shows neither buttons nor forms: `/agent` and `/settings` answer with where to change them."""
+ send_message = AsyncMock()
+ cloud = SimpleNamespace(enabled=public_url is not None, public_url=public_url or "")
+ controller = SimpleNamespace(
+ config=SimpleNamespace(platform="wechat", language="en", remote_access=SimpleNamespace(vibe_cloud=cloud)),
+ im_client=SimpleNamespace(send_message=send_message),
+ settings_manager=SimpleNamespace(),
+ _get_lang=lambda: "en",
+ )
+ context = MessageContext(
+ user_id="[email protected]",
+ channel_id="[email protected]",
+ platform="wechat",
+ platform_specific={"platform": "wechat", "is_dm": is_dm},
+ )
+
+ asyncio.run(getattr(SettingsHandler(controller), entry)(context))
+
+ key, params = expected
+ send_message.assert_awaited_once_with(context, t(key, "en", **params))
diff --git a/ui/src/components/steps/UserList.tsx b/ui/src/components/steps/UserList.tsx
index f419774c1..455ae4417 100644
--- a/ui/src/components/steps/UserList.tsx
+++ b/ui/src/components/steps/UserList.tsx
@@ -2,6 +2,7 @@ import { platformText } from '@/lib/platforms';
import type { TFunction } from 'i18next';
import { useInstanceAuthorization } from '@/context/InstanceAuthorizationContext';
import React, { useEffect, useMemo, useRef, useState } from 'react';
+import { useSearchParams } from 'react-router-dom';
import {
Bot,
Check,
@@ -446,6 +447,8 @@ export const UserList: React.FC = () => {
const [searchQuery, setSearchQuery] = useState('');
const [showDisabled, setShowDisabled] = useState(false);
const [expandedKey, setExpandedKey] = useState<string | null>(null);
+ const [searchParams, setSearchParams] = useSearchParams();
+ const rowRefs = useRef<Record<string, HTMLDivElement | null>>({});
const [refreshTrigger, setRefreshTrigger] = useState(0);
const userSaveVersionRef = useRef<Record<string, number>>({});
const routeSaveVersionRef = useRef<Record<string, number>>({});
@@ -484,8 +487,35 @@ export const UserList: React.FC = () => {
const next: Record<string, Record<string, UserConfig>> = {};
for (const [p, u] of results) next[p] = u as Record<string, UserConfig>;
setUsersByPlatform(next);
+ openLinkedUser(next);
};
+ // A chat that cannot show a settings form links to its row (`?platform=…&user=…`):
+ // open it once it loads, then drop the link so a reload doesn't reopen it.
+ const linkedScrollRef = useRef<string | null>(null);
+ const openLinkedUser = (users: Record<string, Record<string, UserConfig>>) => {
+ const platform = searchParams.get('platform');
+ const userId = searchParams.get('user');
+ const linked = platform && userId ? users[platform]?.[userId] : undefined;
+ if (!platform || !userId || !linked) return;
+ const key = `${platform}::${userId}`;
+ setSearchQuery('');
+ if (!linked.enabled) setShowDisabled(true);
+ setExpandedKey(key);
+ linkedScrollRef.current = key;
+ setSearchParams((prev) => {
+ const params = new URLSearchParams(prev);
+ params.delete('platform');
+ params.delete('user');
+ return params;
+ }, { replace: true });
+ };
+ useEffect(() => {
+ if (!expandedKey || linkedScrollRef.current !== expandedKey) return;
+ linkedScrollRef.current = null;
+ rowRefs.current[expandedKey]?.scrollIntoView?.({ block: 'center' });
+ }, [expandedKey]);
+
useEffect(() => { loadAllUsers(); }, [enabledPlatforms.join(','), refreshTrigger]);
// Aggregate users
@@ -701,6 +731,7 @@ export const UserList: React.FC = () => {
return (
<div
key={u.key}
+ ref={(element) => { rowRefs.current[u.key] = element; }}
className={clsx(
'rounded-xl border transition-colors',
expanded
diff --git a/ui/src/components/steps/scopeRouteVisibility.test.tsx b/ui/src/components/steps/scopeRouteVisibility.test.tsx
index d579e9dd0..de9ef9f49 100644
--- a/ui/src/components/steps/scopeRouteVisibility.test.tsx
+++ b/ui/src/components/steps/scopeRouteVisibility.test.tsx
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { cleanup, render, screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import { MemoryRouter } from 'react-router-dom';
+import { MemoryRouter, useLocation } from 'react-router-dom';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { ChannelList } from './ChannelList';
import { UserList } from './UserList';
@@ -76,18 +76,38 @@ describe('users page rows', () => {
ou_custom: { ...user({ agent_name: null, model: 'gpt-6-astra', reasoning_effort: 'high' }), display_name: 'Custom' },
ou_agent: { ...user({ agent_name: 'reviewer', model: null, reasoning_effort: null }), display_name: 'Agent' },
});
- render(<UserList />);
+ render(<MemoryRouter><UserList /></MemoryRouter>);
expect(await screen.findByText('common.default · vibey/claude-sonnet-5-5 · ou_default')).toBeTruthy();
expect(screen.getByText('vibey/gpt-6-astra · chat.picker.effortOptions.high · ou_custom')).toBeTruthy();
expect(screen.getByText('reviewer/gpt-6-astra · chat.picker.effortOptions.low · ou_agent')).toBeTruthy();
});
+ it('opens the row a chat links to, even a disabled one, and drops the link', async () => {
+ serveUsers({
+ ou_1: user({ agent_name: 'vibey', model: null, reasoning_effort: null }),
+ ou_2: { ...user({ agent_name: 'vibey', model: null, reasoning_effort: null }), display_name: 'Wang', enabled: false },
+ });
+ let search = '';
+ const Location = () => { search = useLocation().search; return null; };
+ render(
+ <MemoryRouter initialEntries={['/settings/platforms/users?platform=lark&user=ou_2']}>
+ <UserList />
+ <Location />
+ </MemoryRouter>
+ );
+
+ const panel = await screen.findByTestId('panel');
+ expect(screen.getByText('Wang').closest('.rounded-xl')?.contains(panel)).toBe(true);
+ // The router applies the navigation in a later render than the row's state.
+ await waitFor(() => expect(search).toBe(''));
+ });
+
it('shows a save on its row, announces only failures, and says when the session keeps its Agent', async () => {
serveUsers({ ou_1: user({ agent_name: 'vibey', model: null, reasoning_effort: null }) });
const pending = deferred<object>();
api.patchScopeSettings.mockReturnValueOnce(pending.promise);
- render(<UserList />);
+ render(<MemoryRouter><UserList /></MemoryRouter>);
await userEvent.click(await screen.findByText('Liu'));
await userEvent.click(screen.getByText('route:reviewer'));
@@ -108,7 +128,7 @@ describe('users page rows', () => {
const route = deferred<object>();
api.patchScopeSettings.mockReturnValueOnce(route.promise)
.mockResolvedValueOnce({ ok: true, settings: { ...user({ agent_name: 'reviewer' }), show_message_types: ['assistant', 'toolcall'] } });
- render(<UserList />);
+ render(<MemoryRouter><UserList /></MemoryRouter>);
await userEvent.click(await screen.findByText('Liu'));
await userEvent.click(screen.getByText('route:reviewer'));
diff --git a/ui/src/components/steps/scopeRoutingSave.test.tsx b/ui/src/components/steps/scopeRoutingSave.test.tsx
index d20347be1..ef86738a8 100644
--- a/ui/src/components/steps/scopeRoutingSave.test.tsx
+++ b/ui/src/components/steps/scopeRoutingSave.test.tsx
@@ -67,7 +67,7 @@ describe('users page', () => {
const larkReads = () => api.getUsers.mock.calls.filter(([platform]) => platform === 'lark').length;
async function openUser() {
- render(<UserList />);
+ render(<MemoryRouter><UserList /></MemoryRouter>);
await waitFor(() => expect(larkReads()).toBe(1));
await userEvent.click(await screen.findByText('Liu'));
}
diff --git a/vibe/i18n/en.json b/vibe/i18n/en.json
index 7415c1477..ad13d7df3 100644
--- a/vibe/i18n/en.json
+++ b/vibe/i18n/en.json
@@ -657,6 +657,7 @@
"commandStart": "/start - Show this welcome message",
"commandCwd": "/cwd - Show current working directory",
"commandSetCwd": "/setcwd <path> - Set working directory",
+ "commandAgent": "/agent - Switch the Agent, model, and reasoning effort",
"commandResume": "/resume - Restore a recent session for this working directory",
"commandSetup": "/setup [claude|codex|opencode] - Repair backend login/auth",
"commandStop": "/stop - Interrupt {agent} execution",
@@ -769,7 +770,6 @@
"resultDesc": "Final execution result (always sent)"
},
"routing": {
- "slackOnly": "🤖 Agent switching is currently only available in Slack. Use Slack Agent Settings to configure routing.",
"introTitle": "Agent & Model Settings",
"introDesc": "Choose which Agent this channel uses.",
"noAgents": "No Agent is available for this channel.",
@@ -779,6 +779,12 @@
"reasoningEffort": "Reasoning Effort"
}
},
+ "scopeSettings": {
+ "openInWebUrl": "🔗 Change this chat's Agent, model, and other settings on the Web settings page: {url}",
+ "openInWeb": "🔗 On the computer running Avibe, open the Avibe Workbench and go to Settings → Messaging Platforms → {page} to change this chat's Agent, model, and other settings.",
+ "pageUsers": "Direct Messages",
+ "pageGroups": "Groups"
+ },
"message": {
"ack": "{agent} received, processing...",
"quickReplyNote": "Reply: {text}",
diff --git a/vibe/i18n/zh.json b/vibe/i18n/zh.json
index f6f29eaaa..47337239b 100644
--- a/vibe/i18n/zh.json
+++ b/vibe/i18n/zh.json
@@ -657,6 +657,7 @@
"commandStart": "/start - 显示欢迎消息",
"commandCwd": "/cwd - 显示当前工作目录",
"commandSetCwd": "/setcwd <路径> - 设置工作目录",
+ "commandAgent": "/agent - 切换 Agent、模型和推理强度",
"commandResume": "/resume - 恢复当前目录下最近的会话",
"commandSetup": "/setup [claude|codex|opencode] - 修复后端登录/认证",
"commandStop": "/stop - 中断 {agent} 当前执行",
@@ -769,7 +770,6 @@
"resultDesc": "最终执行结果(始终发送)"
},
"routing": {
- "slackOnly": "🤖 Agent 切换目前仅在 Slack 可用。请使用 Slack Agent 设置进行配置。",
"introTitle": "Agent 与模型设置",
"introDesc": "选择该频道使用的 Agent。",
"noAgents": "该频道没有可用的 Agent。",
@@ -779,6 +779,12 @@
"reasoningEffort": "推理强度"
}
},
+ "scopeSettings": {
+ "openInWebUrl": "🔗 在 Web 设置页修改这个对话的 Agent、模型和其他设置:{url}",
+ "openInWeb": "🔗 在运行 Avibe 的电脑上打开 Avibe 工作台,进入「设置 → 通讯平台 → {page}」,即可修改这个对话的 Agent、模型和其他设置。",
+ "pageUsers": "私聊",
+ "pageGroups": "群组"
+ },
"message": {
"ack": "{agent} 已收到,正在处理...",
"quickReplyNote": "回复:{text}",