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(discord): preserve multiple guild selections in UI
cyhe48c9af8f0a2
diff --git a/ui/src/components/steps/ChannelList.tsx b/ui/src/components/steps/ChannelList.tsxindex 5a592d555..d613743ea 100644--- a/ui/src/components/steps/ChannelList.tsx+++ b/ui/src/components/steps/ChannelList.tsx@@ -63,6 +63,19 @@ interface TelegramDiscoverySummary {forum_count: number;}+const getDiscordGuildAllowlist = (source: any): string[] => {+ const allowlist = source?.discord?.guild_allowlist;+ return Array.isArray(allowlist) ? allowlist : [];+};++const mergeDiscordGuildAllowlist = (allowlist: string[], selectedGuild: string): string[] => {+ const merged = [...allowlist];+ if (selectedGuild && !merged.includes(selectedGuild)) {+ merged.push(selectedGuild);+ }+ return merged;+};+export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onBack, isPage, forcedPlatform, wizardPlatforms }) => {const { t } = useTranslation();const api = useApi();@@ -89,7 +102,8 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onBconst [codexModels, setCodexModels] = useState<string[]>([]);const [selectedModels, setSelectedModels] = useState<Record<string, string>>({});const [guilds, setGuilds] = useState<any[]>([]);- const [selectedGuild, setSelectedGuild] = useState<string>(data.discord?.guild_allowlist?.[0] || '');+ const [selectedGuildIds, setSelectedGuildIds] = useState<string[]>(getDiscordGuildAllowlist(data));+ const [selectedGuild, setSelectedGuild] = useState<string>(getDiscordGuildAllowlist(data)[0] || '');const [telegramSummary, setTelegramSummary] = useState<TelegramDiscoverySummary | null>(null);// Directory browser state — tracks which channel's cwd picker is openconst [browsingCwdFor, setBrowsingCwdFor] = useState<string | null>(null);@@ -126,7 +140,9 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onBuseEffect(() => {if (!isPage) {- setSelectedGuild(data.discord?.guild_allowlist?.[0] || '');+ const allowlist = getDiscordGuildAllowlist(data);+ setSelectedGuildIds(allowlist);+ setSelectedGuild(allowlist[0] || '');}}, [data.discord?.guild_allowlist, isPage]);@@ -135,6 +151,9 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onBif (isPage) {api.getConfig().then(c => {setConfig(c);+ const allowlist = getDiscordGuildAllowlist(c);+ setSelectedGuildIds(allowlist);+ setSelectedGuild(allowlist[0] || '');const defaultPlatform = forcedPlatform || getEnabledPlatforms(c).find(platformSupportsChannels) || c?.platform || 'slack';setPagePlatform(defaultPlatform);api.getSettings(defaultPlatform).then(s => {@@ -148,6 +167,12 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB? wizardActivePlatform: (forcedPlatform || pagePlatform || config.platform || data.platform || 'slack');const channelPlatforms = getEnabledPlatforms(config).filter(platformSupportsChannels);+ const knownDiscordGuilds = [+ ...guilds,+ ...selectedGuildIds+ .filter((id) => !guilds.some((guild) => guild.id === id))+ .map((id) => ({ id, name: id })),+ ];// Switch platforms in wizard multi-platform modeconst switchWizardPlatform = (newPlatform: string) => {@@ -184,12 +209,58 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onBuseEffect(() => {if (platform !== 'discord') return;if (selectedGuild) return;- const preferredGuild = config.discord?.guild_allowlist?.[0] || data.discord?.guild_allowlist?.[0] || '';+ const preferredGuild = getDiscordGuildAllowlist(config)[0] || getDiscordGuildAllowlist(data)[0] || '';if (preferredGuild) {setSelectedGuild(preferredGuild);}}, [platform, config.discord?.guild_allowlist, data.discord?.guild_allowlist, selectedGuild]);+ useEffect(() => {+ if (platform !== 'discord') return;+ const allowlist = getDiscordGuildAllowlist(config);+ if (allowlist.length > 0) {+ setSelectedGuildIds(allowlist);+ }+ }, [platform, config.discord?.guild_allowlist]);++ const updateSelectedGuild = (guildId: string) => {+ setSelectedGuild(guildId);+ if (guildId) {+ const next = mergeDiscordGuildAllowlist(selectedGuildIds, guildId);+ setSelectedGuildIds(next);+ void persistDiscordGuildAllowlist(next);+ }+ };++ const toggleAllowedGuild = (guildId: string, checked: boolean) => {+ const next = checked+ ? mergeDiscordGuildAllowlist(selectedGuildIds, guildId)+ : selectedGuildIds.filter(id => id !== guildId);+ setSelectedGuildIds(next);+ if (selectedGuild === guildId && !checked) {+ setSelectedGuild(next[0] || '');+ }+ void persistDiscordGuildAllowlist(next);+ };++ const persistDiscordGuildAllowlist = async (allowlist: string[]) => {+ if (!isPage) return;+ const updated = {+ ...config,+ discord: {+ ...(config.discord || {}),+ guild_allowlist: allowlist,+ },+ };+ setConfig(updated);+ try {+ await api.saveConfig(updated);+ showToast(t('common.saved'), 'success');+ } catch {+ showToast(t('channelList.settingsSaveFailed'), 'error');+ }+ };+const loadGuilds = async () => {if (!botToken) return;try {@@ -700,18 +771,53 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB<span className="text-sm text-muted font-mono">{t('channelList.enabledCount', { count: selectedCount })}</span></div>{platform === 'discord' && (- <div className="flex flex-wrap items-center gap-3 text-sm">- <label className="text-muted">{t('channelList.guild')}</label>- <select- value={selectedGuild}- onChange={(e) => setSelectedGuild(e.target.value)}- className="bg-bg border border-border rounded px-3 py-2 text-sm focus:outline-none focus:border-accent text-text"- >- <option value="">{t('channelList.guildPlaceholder')}</option>- {guilds.map((g) => (- <option key={g.id} value={g.id}>{g.name}</option>- ))}- </select>+ <div className="rounded-lg border border-border bg-panel p-3 text-sm">+ <div className="grid gap-3 md:grid-cols-[minmax(220px,280px)_1fr]">+ <div className="space-y-1">+ <label className="font-medium text-text">{t('channelList.guildBrowse')}</label>+ <select+ value={selectedGuild}+ onChange={(e) => updateSelectedGuild(e.target.value)}+ className="w-full bg-bg border border-border rounded px-3 py-2 text-sm focus:outline-none focus:border-accent text-text"+ >+ <option value="">{t('channelList.guildPlaceholder')}</option>+ {knownDiscordGuilds.map((g) => (+ <option key={g.id} value={g.id}>{g.name}</option>+ ))}+ </select>+ </div>+ <div className="space-y-2">+ <div className="flex flex-wrap items-center justify-between gap-2">+ <span className="font-medium text-text">{t('channelList.guildAccess')}</span>+ <span className="text-xs text-muted">+ {t('channelList.guildAccessCount', { count: selectedGuildIds.length })}+ </span>+ </div>+ {knownDiscordGuilds.length > 0 && (+ <div className="flex flex-wrap gap-2">+ {knownDiscordGuilds.map((g) => (+ <label+ key={g.id}+ className={clsx(+ 'inline-flex items-center gap-2 rounded border px-2 py-1 text-xs transition-colors',+ selectedGuildIds.includes(g.id)+ ? 'border-accent bg-accent/10 text-text'+ : 'border-border bg-bg text-muted hover:text-text'+ )}+ >+ <input+ type="checkbox"+ checked={selectedGuildIds.includes(g.id)}+ onChange={(e) => toggleAllowedGuild(g.id, e.target.checked)}+ className="h-3.5 w-3.5 accent-accent"+ />+ <span>{g.name}</span>+ </label>+ ))}+ </div>+ )}+ </div>+ </div></div>)}{isPage && (@@ -1180,6 +1286,16 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB</button><buttononClick={() => {+ const discordGuildAllowlist = mergeDiscordGuildAllowlist(selectedGuildIds, selectedGuild);+ const discordPayload = getEnabledPlatforms(data).includes('discord') || platform === 'discord'+ ? {+ discord: {+ ...(data.discord || {}),+ ...(config.discord || {}),+ guild_allowlist: discordGuildAllowlist,+ },+ }+ : {};if (isWizardMultiPlatform) {// Merge configs from all visited platformsconst allConfigs = { ...wizardConfigsMap, [wizardActivePlatform]: configs };@@ -1188,6 +1304,7 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB...(data.channelConfigsByPlatform || {}),...allConfigs,},+ ...discordPayload,});} else {onNext && onNext({@@ -1196,7 +1313,12 @@ export const ChannelList: React.FC<ChannelListProps> = ({ data = {}, onNext, onB[platform]: configs,},settingsPlatform: platform,- ...(platform === 'discord' ? { discord: { ...config.discord, guild_allowlist: selectedGuild ? [selectedGuild] : [] } } : {}),+ ...(platform === 'discord' ? {+ discord: {+ ...config.discord,+ guild_allowlist: discordGuildAllowlist,+ },+ } : {}),});}}}diff --git a/ui/src/components/steps/DiscordConfig.tsx b/ui/src/components/steps/DiscordConfig.tsxindex 9676ea402..e4ea29f9e 100644--- a/ui/src/components/steps/DiscordConfig.tsx+++ b/ui/src/components/steps/DiscordConfig.tsx@@ -20,7 +20,9 @@ export const DiscordConfig: React.FC<DiscordConfigProps> = ({ data, onNext, onBaconst [checking, setChecking] = useState(false);const [authResult, setAuthResult] = useState<any>(null);const [guilds, setGuilds] = useState<any[]>([]);- const [selectedGuild, setSelectedGuild] = useState<string>(data.discord?.guild_allowlist?.[0] || '');+ const [selectedGuilds, setSelectedGuilds] = useState<string[]>(+ Array.isArray(data.discord?.guild_allowlist) ? data.discord.guild_allowlist : []+ );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 || '');@@ -83,6 +85,19 @@ export const DiscordConfig: React.FC<DiscordConfigProps> = ({ data, onNext, onBasetExpandedSteps(prev => ({ ...prev, [step]: !prev[step] }));};+ const toggleGuild = (guildId: string, checked: boolean) => {+ setSelectedGuilds(prev => {+ if (checked) {+ return prev.includes(guildId) ? prev : [...prev, guildId];+ }+ return prev.filter(id => id !== guildId);+ });+ };++ const selectAllGuilds = () => {+ setSelectedGuilds(guilds.map((g) => g.id));+ };+const openDiscordDeveloperPortal = () => {window.open('https://discord.com/developers/applications', '_blank');};@@ -318,16 +333,49 @@ export const DiscordConfig: React.FC<DiscordConfigProps> = ({ data, onNext, onBa<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>+ {guilds.length > 0 && (+ <div className="flex flex-wrap items-center justify-between gap-2">+ <span className="text-xs text-muted">+ {t('discordConfig.selectedGuilds', { count: selectedGuilds.length })}+ </span>+ <div className="flex items-center gap-2">+ <button+ type="button"+ onClick={selectAllGuilds}+ className="text-xs font-medium text-accent hover:text-accent/80"+ >+ {t('discordConfig.selectAllGuilds')}+ </button>+ <button+ type="button"+ onClick={() => setSelectedGuilds([])}+ className="text-xs font-medium text-muted hover:text-text"+ >+ {t('discordConfig.clearGuilds')}+ </button>+ </div>+ </div>+ )}+ <div className="max-h-52 overflow-y-auto rounded-lg border border-border bg-bg">+ {guilds.length === 0 ? (+ <div className="p-3 text-sm text-muted">{t('discordConfig.guildPlaceholder')}</div>+ ) : (+ guilds.map((g) => (+ <label+ key={g.id}+ className="flex items-center gap-3 border-b border-border/70 px-3 py-2 last:border-b-0"+ >+ <input+ type="checkbox"+ checked={selectedGuilds.includes(g.id)}+ onChange={(e) => toggleGuild(g.id, e.target.checked)}+ className="h-4 w-4 accent-accent"+ />+ <span className="text-sm text-text">{g.name}</span>+ </label>+ ))+ )}+ </div><p className="text-xs text-muted">{t('discordConfig.guildHint')}</p></div>)}@@ -346,7 +394,7 @@ export const DiscordConfig: React.FC<DiscordConfigProps> = ({ data, onNext, onBadiscord: {...(data.discord || {}),bot_token: botToken,- guild_allowlist: selectedGuild ? [selectedGuild] : [],+ guild_allowlist: selectedGuilds,},})}disabled={!isValid}diff --git a/ui/src/components/steps/Summary.tsx b/ui/src/components/steps/Summary.tsxindex c621f29b3..7c0530116 100644--- a/ui/src/components/steps/Summary.tsx+++ b/ui/src/components/steps/Summary.tsx@@ -208,7 +208,10 @@ export const Summary: React.FC<SummaryProps> = ({ data, onBack }) => {{enabledPlatforms.includes('discord') && (<><Section title={t('summary.discordBotToken')} value={mask(data.discord?.bot_token || '')} />- <Section title={t('summary.discordGuild')} value={(data.discord?.guild_allowlist || [])[0] || t('summary.notSet')} />+ <Section+ title={t('summary.discordGuild')}+ value={(data.discord?.guild_allowlist || []).join(', ') || t('summary.notSet')}+ /></>)}{enabledPlatforms.includes('telegram') && (diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex fcc345e44..8616cf745 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -101,9 +101,12 @@"validateToken": "Validate Token","tokenValidated": "Token validated","authFailed": "Validation failed",- "guild": "Guild",- "guildPlaceholder": "Select a guild",- "guildHint": "Choose the guild where the bot is installed.",+ "guild": "Guilds",+ "guildPlaceholder": "No guilds loaded",+ "guildHint": "Choose every guild where the bot should respond.",+ "selectedGuilds": "{{count}} selected",+ "selectAllGuilds": "Select all",+ "clearGuilds": "Clear","step1Title": "Create Discord App","step1Description": "Create a new application in the Developer Portal.","step1Item1": "Open the Discord Developer Portal",@@ -368,6 +371,9 @@"wechatInviteBotHint": "Send a message to your WeChat bot account to start a conversation.","guild": "Guild","guildPlaceholder": "Select a guild",+ "guildBrowse": "Configure channels from",+ "guildAccess": "Bot responds in",+ "guildAccessCount": "{{count}} selected","discordText": "Text","discordNews": "News","telegramForum": "Forum",@@ -424,7 +430,7 @@"telegramBotToken": "Telegram Bot Token","larkAppId": "Lark App ID","wechatBotToken": "WeChat Bot Token",- "discordGuild": "Discord Guild",+ "discordGuild": "Discord Guilds","notSet": "Not set","enabledAgents": "Enabled Agents","channelsConfigured": "Groups Configured",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 5424d1e3e..120abd545 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -102,8 +102,11 @@"tokenValidated": "令牌验证成功","authFailed": "验证失败","guild": "服务器",- "guildPlaceholder": "选择服务器",- "guildHint": "选择已安装机器人的服务器。",+ "guildPlaceholder": "未加载到服务器",+ "guildHint": "选择所有需要机器人响应的服务器。",+ "selectedGuilds": "已选择 {{count}} 个",+ "selectAllGuilds": "全选",+ "clearGuilds": "清空","step1Title": "创建 Discord 应用","step1Description": "在开发者后台创建新应用。","step1Item1": "打开 Discord Developer Portal",@@ -368,6 +371,9 @@"wechatInviteBotHint": "向微信机器人账号发送消息即可开始对话。","guild": "服务器","guildPlaceholder": "选择服务器",+ "guildBrowse": "正在配置的服务器",+ "guildAccess": "机器人响应范围",+ "guildAccessCount": "已选择 {{count}} 个","discordText": "文本","discordNews": "公告","telegramForum": "Forum",