Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
feat(groups): per-platform default for require-mention & bound-only (#741)
Qi Qiac015451367b
diff --git a/config/v2_config.py b/config/v2_config.pyindex 985838f20..e3ec48758 100644--- a/config/v2_config.py+++ b/config/v2_config.py@@ -91,6 +91,10 @@ class SlackConfig(BaseIMConfig):team_name: Optional[str] = Noneapp_id: Optional[str] = Nonerequire_mention: bool = False+ # Global default for the per-channel require_bind gate (allowed users).+ # False=any channel member may drive the agent, True=only bound users.+ # Channels whose per-channel require_bind is None inherit this value.+ require_bind: bool = Falsedisable_link_unfurl: bool = Falsedef validate(self) -> None:@@ -110,6 +114,8 @@ class DiscordConfig(BaseIMConfig):guild_allowlist: Optional[List[str]] = Noneguild_denylist: Optional[List[str]] = Nonerequire_mention: bool = False+ # Global default for the per-channel require_bind gate (allowed users).+ require_bind: bool = False# Auto-archive duration (minutes) for threads created by vibe-remote.# Discord only accepts 60, 1440, 4320, or 10080 (1h / 1d / 3d / 7d).# Defaults to 10080 (7d) to match Discord's longest native inactivity window@@ -133,6 +139,8 @@ class DiscordConfig(BaseIMConfig):class TelegramConfig(BaseIMConfig):bot_token: str = ""require_mention: bool = True+ # Global default for the per-channel require_bind gate (allowed users).+ require_bind: bool = Falseforum_auto_topic: bool = Trueuse_webhook: bool = Falsewebhook_url: Optional[str] = None@@ -151,6 +159,8 @@ class LarkConfig(BaseIMConfig):app_id: str = ""app_secret: str = ""require_mention: bool = False+ # Global default for the per-channel require_bind gate (allowed users).+ require_bind: bool = Falsedomain: str = "feishu" # "feishu" for domestic (open.feishu.cn), "lark" for international (open.larksuite.com)def validate(self) -> None:@@ -171,6 +181,7 @@ class WeChatConfig(BaseIMConfig):base_url: str = "https://ilinkai.weixin.qq.com"cdn_base_url: str = "https://novac2c.cdn.weixin.qq.com/c2c"require_mention: bool = False # unused for WeChat DM-only, kept for interface compat+ require_bind: bool = False # unused for WeChat DM-only, kept for interface compatdef validate(self) -> None:# bot_token can be empty during setup wizard (filled after QR login)diff --git a/core/auth.py b/core/auth.pyindex c60a1557c..5c2c69691 100644--- a/core/auth.py+++ b/core/auth.py@@ -136,6 +136,9 @@ def check_auth(# users may drive the agent in this channel. Unbound senders are denied# with a denial type that maps to no message (silent ignore), so other# members' chatter does not trigger the bot or spam the channel.+ # Only an explicit per-channel True enforces this; None/False mean+ # "anyone" (the platform default is a seed for copy-on-enable, not a+ # runtime fallback — so flipping it never retro-denies existing groups).if getattr(ch, "require_bind", None):if not _is_enabled_user(store, user_id, platform):return AuthResult(allowed=False, denial="not_bound_channel", is_dm=False)diff --git a/tests/test_auth_pipeline.py b/tests/test_auth_pipeline.pyindex 3316f9cc4..d8604523b 100644--- a/tests/test_auth_pipeline.py+++ b/tests/test_auth_pipeline.py@@ -180,6 +180,25 @@ def test_require_bind_off_allows_any_channel_member():assert result.allowed is True+def test_require_bind_null_allows_any_member_regardless_of_platform_default():+ # Legacy channels store require_bind=None ("Anyone" in the old UI). The+ # platform default is a copy-on-enable seed, NOT a runtime fallback, so a+ # None channel must keep allowing unbound members even if the platform+ # default is later flipped on.+ store = _Store()+ store.settings.channels["C1"] = SimpleNamespace(enabled=True, require_bind=None)++ result = check_auth(+ user_id="U-stranger",+ channel_id="C1",+ is_dm=False,+ action="",+ store=store,+ )++ assert result.allowed is True++def test_admin_guard_denies_non_admin_for_auth_setup_callback():store = _Store()store.settings.channels["C1"] = SimpleNamespace(enabled=True)diff --git a/ui/src/components/shared/RoutingConfigPanel.tsx b/ui/src/components/shared/RoutingConfigPanel.tsxindex 1c33091b6..3a81b5e99 100644--- a/ui/src/components/shared/RoutingConfigPanel.tsx+++ b/ui/src/components/shared/RoutingConfigPanel.tsx@@ -3,7 +3,7 @@ import { Bot, FolderOpen, HelpCircle } from 'lucide-react';import { useTranslation } from 'react-i18next';import clsx from 'clsx';import { Input } from '@/components/ui/input';-import { Button } from '@/components/ui/button';+import { ToggleSwitch } from '../settings/SettingsPrimitives';import { AgentRoutePicker } from '../workbench/AgentRoutePicker';import type { VibeAgentBrief } from '../../context/ApiContext';@@ -42,7 +42,7 @@ export interface RoutingConfigPanelProps {onChange: (patch: Partial<RoutingConfigValue>) => void;onBrowseDirectory: () => void;globalConfig: any;- /** Show the require-@mention segmented control (Inherit / On / Off). */+ /** Show the require-@mention and bound-only on/off switches (channels only). */showRequireMention?: boolean;/** Platform key used to derive inherited @mention default (e.g., 'slack', 'discord'). */inheritsFromKey?: string;@@ -142,106 +142,43 @@ export const RoutingConfigPanel: React.FC<RoutingConfigPanelProps> = ({</div></div>- {/* Require @mention (channels only) */}+ {/* Require @mention (channels only). Simple on/off switch. When the+ per-group value is unset (null), the switch reflects the platform+ group default; toggling writes an explicit boolean for this group. */}{showRequireMention && (() => {- const current: 'inherit' | 'on' | 'off' =+ const effective =value.require_mention === null || value.require_mention === undefined- ? 'inherit'- : value.require_mention- ? 'on'- : 'off';- const setMention = (next: 'inherit' | 'on' | 'off') => {- onChange({ require_mention: next === 'inherit' ? null : next === 'on' });- };- const inheritedOn = !!(globalConfig as any)?.[inheritsFromKey || '']?.require_mention;- const segs: { id: 'inherit' | 'on' | 'off'; label: string }[] = [- {- id: 'inherit',- label: `${t('common.inherit')} (${- inheritedOn ? t('channelList.mentionStatusOn') : t('channelList.mentionStatusOff')- })`,- },- { id: 'on', label: t('channelList.requireMentionOn') },- { id: 'off', label: t('channelList.requireMentionOff') },- ];+ ? !!(globalConfig as any)?.[inheritsFromKey || '']?.require_mention+ : value.require_mention;return (<div className="space-y-1"><label className="text-xs font-medium uppercase text-muted">{t('channelList.requireMention')}</label>- <div- role="radiogroup"- aria-label={t('channelList.requireMention') as string}- className="flex h-9 items-stretch gap-0.5 rounded-md border border-border bg-foreground/[0.03] p-0.5"- >- {segs.map((seg) => {- const active = current === seg.id;- return (- <button- key={seg.id}- type="button"- role="radio"- aria-checked={active}- onClick={() => setMention(seg.id)}- className={clsx(- // The "inherit" label carries the inherited state in- // parentheses, so it needs more room than on/off to- // avoid wrapping.- 'whitespace-nowrap rounded-[4px] px-2 text-[12px] transition-colors',- seg.id === 'inherit' ? 'flex-[1.6]' : 'flex-1',- active- ? 'border border-mint/30 bg-mint-soft font-bold text-mint'- : 'font-medium text-muted hover:text-foreground'- )}- >- {seg.label}- </button>- );- })}+ <div className="flex h-9 items-center">+ <ToggleSwitch+ enabled={effective}+ onClick={() => onChange({ require_mention: !effective })}+ /></div></div>);})()}{/* Require bind (channels only): when On, only bound users can drive the- agent here; unbound members are silently ignored. */}+ agent here; unbound members are silently ignored. Unlike @mention,+ this does NOT inherit the platform default at runtime — the default+ only seeds newly-enabled groups (copy-on-enable), so an unset value+ means "anyone" and the switch shows off. Toggling writes an explicit+ boolean for this group. */}{showRequireMention && (() => {- const on = value.require_bind === true;- const setBind = (next: boolean) => {- onChange({ require_bind: next ? true : null });- };- const segs: { id: 'off' | 'on'; label: string }[] = [- { id: 'off', label: t('channelList.requireBindOff') },- { id: 'on', label: t('channelList.requireBindOn') },- ];+ const effective = value.require_bind === true;return (<div className="space-y-1"><label className="text-xs font-medium uppercase text-muted">{t('channelList.requireBind')}</label>- <div- role="radiogroup"- aria-label={t('channelList.requireBind') as string}- className="flex h-9 items-stretch gap-0.5 rounded-md border border-border bg-foreground/[0.03] p-0.5"- >- {segs.map((seg) => {- const active = (seg.id === 'on') === on;- return (- <Button- key={seg.id}- type="button"- variant="ghost"- size="sm"- role="radio"- aria-checked={active}- onClick={() => setBind(seg.id === 'on')}- className={clsx(- 'h-auto flex-1 rounded-[4px] px-2.5 text-[12px] shadow-none focus-visible:ring-1',- active- ? 'border border-mint/30 bg-mint-soft font-bold text-mint'- : 'font-medium text-muted hover:text-foreground'- )}- >- {seg.label}- </Button>- );- })}+ <div className="flex h-9 items-center">+ <ToggleSwitch+ enabled={effective}+ onClick={() => onChange({ require_bind: !effective })}+ /></div></div>);diff --git a/ui/src/components/steps/ChannelList.tsx b/ui/src/components/steps/ChannelList.tsxindex ba0d0b2ae..464e3239b 100644--- a/ui/src/components/steps/ChannelList.tsx+++ b/ui/src/components/steps/ChannelList.tsx@@ -2,7 +2,6 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';import {ArrowLeft,ArrowRight,- AtSign,CheckSquare,ChevronDown,ChevronUp,@@ -1082,6 +1081,70 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB);}+ // Toggle a platform-level group default (require_mention / require_bind).+ // The default seeds newly-enabled groups (copy-on-enable). A per-group value+ // always overrides it.+ //+ // require_mention still inherits at runtime for groups whose value is unset+ // (null), so before flipping that default we snapshot already-enabled null+ // groups with the OLD default — the change then only affects groups enabled+ // from now on, never existing ones. require_bind is seed-only (null = "anyone"+ // at runtime), so flipping it never affects existing groups and needs no+ // snapshot.+ const savePlatformFlag = async (+ key: string,+ field: 'require_mention' | 'require_bind',+ ) => {+ const currentConfig = configRef.current;+ const current = !!(currentConfig as any)[key]?.[field];++ if (field === 'require_mention') {+ // Fetch the target platform's authoritative settings before snapshotting.+ // In-memory maps (configs / allConfigsByPlatform[key]) can be stale or+ // empty right after a tab switch, and saving those back would clobber the+ // target platform's channel settings.+ let platformConfigs: Record<string, ChannelConfig>;+ try {+ const settings = await api.getSettings(key);+ platformConfigs = (settings.channels || {}) as Record<string, ChannelConfig>;+ } catch {+ showToast(t('channelList.settingsSaveFailed'), 'error');+ return;+ }+ let changed = false;+ const nextPlatformConfigs = { ...platformConfigs };+ for (const [cid, cfg] of Object.entries(platformConfigs)) {+ if (cfg?.enabled === true && (cfg.require_mention === null || cfg.require_mention === undefined)) {+ nextPlatformConfigs[cid] = { ...cfg, require_mention: current };+ changed = true;+ }+ }+ if (changed) {+ try {+ await api.saveSettings({ channels: nextPlatformConfigs }, key);+ } catch {+ showToast(t('channelList.settingsSaveFailed'), 'error');+ return;+ }+ setAllConfigsByPlatform((prev) => ({ ...prev, [key]: nextPlatformConfigs }));+ if (key === platform) setConfigs(nextPlatformConfigs);+ }+ }++ const updated = {+ ...currentConfig,+ [key]: { ...(currentConfig as any)[key], [field]: !current },+ };+ const version = applyConfig(updated);+ const saved = await saveLatestConfig();+ if (saved) {+ showToast(t('common.saved'), 'success');+ } else {+ if (configVersionRef.current === version) applyConfig(currentConfig);+ showToast(t('channelList.settingsSaveFailed'), 'error');+ }+ };+// ====================================================================// PAGE MODE: redesigned layout (matches design.pen frame A7h8Wv)// - Header with title + 240px search + Rescan@@ -1228,6 +1291,36 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB})}</div>+ {/* Group defaults for the selected platform — compact switch row.+ These seed newly-enabled groups (copy-on-enable); a per-group value+ overrides. Hidden on "All channels" since defaults are per-platform. */}+ {pageTab !== 'all' && (+ <div className="flex flex-wrap items-center gap-x-6 gap-y-2 rounded-xl border border-border bg-surface-2/40 px-4 py-2.5">+ <span+ className="text-[11px] font-medium uppercase tracking-[0.14em] text-muted"+ title={t('channelList.groupDefaultsHint') as string}+ >+ {t('channelList.groupDefaultsTitle')}+ </span>+ <label className="inline-flex items-center gap-2 text-[13px] text-foreground">+ <span>{t('channelList.requireMention')}</span>+ <ToggleSwitch+ enabled={!!(config as any)[pageTab]?.require_mention}+ onClick={() => savePlatformFlag(pageTab, 'require_mention')}+ />+ </label>+ {pageTab !== 'wechat' && (+ <label className="inline-flex items-center gap-2 text-[13px] text-foreground">+ <span>{t('channelList.requireBind')}</span>+ <ToggleSwitch+ enabled={!!(config as any)[pageTab]?.require_bind}+ onClick={() => savePlatformFlag(pageTab, 'require_bind')}+ />+ </label>+ )}+ </div>+ )}+{/* Discord guild picker — only on Discord tab */}{pageTab === 'discord' && (<div className="rounded-xl border border-border bg-surface-2/40 p-3 text-sm shadow-[0_18px_40px_-30px_rgba(0,0,0,0.8)]">@@ -1403,6 +1496,27 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onBvoid updateConfigForPlatform(channelPlatform, channel.id, patch);};+ // Enabling a group snapshots the current platform group defaults+ // into this group as explicit booleans (copy-on-enable), but only+ // for values not already explicitly set — preserving any prior+ // per-group override. Later changes to the platform default do not+ // retro-affect already-enabled groups.+ const toggleEnabled = () => {+ if (channelEnabled) {+ updateRow({ enabled: false });+ return;+ }+ const platformDefaults = (config as any)[channelPlatform] || {};+ const patch: Partial<ChannelConfig> = { enabled: true };+ if (rawConfig.require_mention === null || rawConfig.require_mention === undefined) {+ patch.require_mention = !!platformDefaults.require_mention;+ }+ if (rawConfig.require_bind === null || rawConfig.require_bind === undefined) {+ patch.require_bind = !!platformDefaults.require_bind;+ }+ updateRow(patch);+ };+const backendModel = channelConfig.routing.model || (effectiveBackend === 'claude'? channelConfig.routing.claude_model@@ -1442,7 +1556,7 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB<span onClick={(e) => e.stopPropagation()}><ToggleSwitchenabled={channelEnabled}- onClick={() => updateRow({ enabled: !channelEnabled })}+ onClick={toggleEnabled}/></span>@@ -1627,49 +1741,6 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB</div>)}- {/* Platform-level require @mention toggle (page mode only) */}- {isPage && (- <div className="mb-4 flex flex-wrap items-center justify-between gap-x-3 gap-y-2 rounded-xl border border-border bg-surface-2/40 p-3 shadow-[0_18px_40px_-30px_rgba(0,0,0,0.8)]">- <div className="flex flex-wrap items-center gap-x-2 gap-y-1 text-sm">- <AtSign size={14} className="text-accent" />- <span className="font-medium text-foreground">{t('dashboard.requireMention')}</span>- <span className="text-xs text-muted">{t('dashboard.requireMentionHint')}</span>- </div>- <button- onClick={async () => {- const key = platform as 'slack' | 'discord' | 'telegram' | 'lark' | 'wechat';- const currentConfig = configRef.current;- const current = !!(currentConfig as any)[key]?.require_mention;- const updated = {- ...currentConfig,- [key]: { ...(currentConfig as any)[key], require_mention: !current },- };- const version = applyConfig(updated);- const saved = await saveLatestConfig();- if (saved) {- showToast(t('common.saved'), 'success');- } else if (configVersionRef.current === version) {- applyConfig(currentConfig);- showToast(t('channelList.settingsSaveFailed'), 'error');- } else {- showToast(t('channelList.settingsSaveFailed'), 'error');- }- }}- className={clsx(- 'relative inline-flex h-6 w-11 items-center rounded-full transition-colors',- (config as any)[platform]?.require_mention ? 'bg-accent' : 'bg-border-strong'- )}- >- <span- className={clsx(- 'inline-block h-4 w-4 rounded-full bg-background transition-transform shadow-sm',- (config as any)[platform]?.require_mention ? 'translate-x-6' : 'translate-x-1'- )}- />- </button>- </div>- )}-<div className="mb-4 space-y-3 rounded-2xl border border-border bg-surface-2/40 p-4 shadow-[0_18px_40px_-30px_rgba(0,0,0,0.8)]"><div className="flex flex-wrap items-center justify-between gap-x-3 gap-y-2"><div className="flex flex-wrap items-center gap-x-3 gap-y-2">@@ -1835,7 +1906,23 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB<div className="flex items-center justify-between gap-2"><div className="flex min-w-0 flex-1 items-center gap-3"><button- onClick={() => updateConfig(channel.id, { enabled: !channelConfig.enabled })}+ onClick={() => {+ if (channelConfig.enabled) {+ updateConfig(channel.id, { enabled: false });+ return;+ }+ // Copy-on-enable: snapshot platform group defaults into+ // unset per-group values (preserve any prior override).+ const platformDefaults = (config as any)[platform] || {};+ const patch: Partial<ChannelConfig> = { enabled: true };+ if (rawConfig.require_mention === null || rawConfig.require_mention === undefined) {+ patch.require_mention = !!platformDefaults.require_mention;+ }+ if (rawConfig.require_bind === null || rawConfig.require_bind === undefined) {+ patch.require_bind = !!platformDefaults.require_bind;+ }+ updateConfig(channel.id, patch);+ }}className={clsx('shrink-0', channelConfig.enabled ? 'text-accent' : 'text-muted')}>{channelConfig.enabled ? <CheckSquare size={20} /> : <Square size={20} />}diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex b46f272af..5939269c2 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -42,7 +42,6 @@"disable": "Disable","disabled": "Disabled","default": "Default",- "inherit": "Inherit","running": "Running","stopped": "Stopped","unknown": "Unknown",@@ -1435,14 +1434,10 @@"searchModel": "Search model...","settingsSaved": "Settings saved","settingsSaveFailed": "Failed to save settings",- "requireMention": "Require @Mention",- "requireMentionOn": "Require @mention",- "requireMentionOff": "Don't require @mention",- "requireBind": "Allowed Users",- "requireBindOn": "Bound only",- "requireBindOff": "Anyone",- "mentionStatusOn": "Require @",- "mentionStatusOff": "Don't require @",+ "requireMention": "Require @mention",+ "requireBind": "Bound only",+ "groupDefaultsTitle": "Group defaults",+ "groupDefaultsHint": "Defaults for new groups on this platform. Each group can override its own value below.","allChannelsTab": "All channels","filterPlaceholder": "Filter groups…","rescan": "Rescan",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 9aaedbd4d..cb9c28bde 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -42,7 +42,6 @@"disable": "禁用","disabled": "已禁用","default": "默认",- "inherit": "继承","running": "运行中","stopped": "已停止","unknown": "未知",@@ -1436,13 +1435,9 @@"settingsSaved": "设置已保存","settingsSaveFailed": "保存设置失败","requireMention": "需要 @提及",- "requireMentionOn": "需要@",- "requireMentionOff": "不用@",- "requireBind": "允许对话的用户",- "requireBindOn": "仅绑定用户",- "requireBindOff": "所有人",- "mentionStatusOn": "需要 @",- "mentionStatusOff": "不需要 @",+ "requireBind": "仅绑定用户",+ "groupDefaultsTitle": "群组默认",+ "groupDefaultsHint": "本平台新群组的默认值;每个群组可在下方单独覆盖。","allChannelsTab": "全部群组","filterPlaceholder": "搜索群组…","rescan": "重新扫描",