Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

πŸ› fix: slack connect error & slash commands (#14591)

Rdmclin28274be0d1d32
diff --git a/src/features/NavPanel/index.tsx b/src/features/NavPanel/index.tsx
index 9017d1f0d58..dad6ccaf1c5 100644
--- a/src/features/NavPanel/index.tsx
+++ b/src/features/NavPanel/index.tsx
@@ -28,6 +28,13 @@ const setNavPanelSnapshot = (snapshot: NavPanelSnapshot) => {
listeners.forEach((listener) => listener());
};
+const FALLBACK_NAV_KEY = 'home';
+
+const getActiveNavKey = () => currentSnapshot?.key ?? FALLBACK_NAV_KEY;
+
+export const useActiveNavKey = () =>
+ useSyncExternalStore(subscribeNavPanel, getActiveNavKey, getActiveNavKey);
+
const NavPanel = memo(() => {
const panelContent = useSyncExternalStore(
subscribeNavPanel,
@@ -36,7 +43,7 @@ const NavPanel = memo(() => {
);
// Use home Content as fallback when no portal content is provided
- const activeContent = panelContent || { key: 'home', node: <Sidebar /> };
+ const activeContent = panelContent || { key: FALLBACK_NAV_KEY, node: <Sidebar /> };
return (
<>
diff --git a/src/routes/(main)/home/_layout/Footer/index.tsx b/src/routes/(main)/home/_layout/Footer/index.tsx
index 884d03e2f90..7c0731e906a 100644
--- a/src/routes/(main)/home/_layout/Footer/index.tsx
+++ b/src/routes/(main)/home/_layout/Footer/index.tsx
@@ -27,6 +27,7 @@ import HighlightNotification from '@/components/HighlightNotification';
import { DOCUMENTS_REFER_URL, GITHUB } from '@/const/url';
import Billboard from '@/features/Billboard';
import { useBillboardMenuItems } from '@/features/Billboard/MenuItems';
+import { useActiveNavKey } from '@/features/NavPanel';
import ThemeButton from '@/features/User/UserPanel/ThemeButton';
import { useFeedbackModal } from '@/hooks/useFeedbackModal';
import { useNavLayout } from '@/hooks/useNavLayout';
@@ -66,6 +67,8 @@ const Footer = memo(() => {
const navigate = useNavigate();
const { analytics } = useAnalytics();
const { footer } = useNavLayout();
+ const activeNavKey = useActiveNavKey();
+ const isHomeSidebar = activeNavKey === 'home';
const billboardMenuItems = useBillboardMenuItems();
const enableAgentOnboarding = useServerConfigStore((s) => s.featureFlags.enableAgentOnboarding);
const isMobile = useServerConfigStore((s) => !!s.isMobile);
@@ -335,7 +338,7 @@ const Footer = memo(() => {
},
]
: []),
- ...(billboardMenuItems && billboardMenuItems.length > 0
+ ...(isHomeSidebar && billboardMenuItems && billboardMenuItems.length > 0
? [{ type: 'divider' as const }, ...billboardMenuItems]
: []),
],
@@ -350,6 +353,7 @@ const Footer = memo(() => {
shouldShowProductHuntMenuEntry,
t,
billboardMenuItems,
+ isHomeSidebar,
],
);
@@ -413,7 +417,7 @@ const Footer = memo(() => {
onClose={activePromotion.onClose}
/>
)}
- <Billboard />
+ {isHomeSidebar && <Billboard />}
</>
);
});
diff --git a/src/server/services/bot/AgentBridgeService.ts b/src/server/services/bot/AgentBridgeService.ts
index 4f3bb84a7a9..f37f38d384c 100644
--- a/src/server/services/bot/AgentBridgeService.ts
+++ b/src/server/services/bot/AgentBridgeService.ts
@@ -1067,7 +1067,7 @@ export class AgentBridgeService {
await this.setReaction(thread, userMessage, client, desiredEmoji, botContext);
}
- if (!event.shouldContinue || !progressMessage || displayToolCalls === false) return;
+ if (!event.shouldContinue || !progressMessage || displayToolCalls !== true) return;
const msgBody = renderStepProgress(
{
diff --git a/src/server/services/bot/BotCallbackService.ts b/src/server/services/bot/BotCallbackService.ts
index 17043e9812e..db0153d8a11 100644
--- a/src/server/services/bot/BotCallbackService.ts
+++ b/src/server/services/bot/BotCallbackService.ts
@@ -108,7 +108,7 @@ export class BotCallbackService {
const replyLocale = getBotReplyLocale(platform);
if (type === 'step') {
- if (canEdit && progressMessageId && settings.displayToolCalls !== false) {
+ if (canEdit && progressMessageId && settings.displayToolCalls === true) {
await this.handleStep(body, messenger, progressMessageId, client, replyLocale);
}
// Swap the user-message reaction to match the current step type (tool
diff --git a/src/server/services/bot/BotMessageRouter.ts b/src/server/services/bot/BotMessageRouter.ts
index 9035c1f251a..1cdd382f6fb 100644
--- a/src/server/services/bot/BotMessageRouter.ts
+++ b/src/server/services/bot/BotMessageRouter.ts
@@ -478,7 +478,7 @@ export class BotMessageRouter {
const { agentId, applicationId, platform, userId } = info;
const bridge = new AgentBridgeService(serverDB, userId);
const charLimit = (info.settings?.charLimit as number) || undefined;
- const displayToolCalls = info.settings?.displayToolCalls !== false;
+ const displayToolCalls = info.settings?.displayToolCalls === true;
const dmSettings: DmSettings = extractDmSettings(info.settings);
const groupSettings: GroupSettings = extractGroupSettings(info.settings);
const userAllowlist: UserAllowlist = extractUserAllowlist(info.settings);
diff --git a/src/server/services/bot/__tests__/BotCallbackService.test.ts b/src/server/services/bot/__tests__/BotCallbackService.test.ts
index 6dc89cc627c..0b291783263 100644
--- a/src/server/services/bot/__tests__/BotCallbackService.test.ts
+++ b/src/server/services/bot/__tests__/BotCallbackService.test.ts
@@ -153,7 +153,15 @@ const FAKE_BOT_TOKEN = 'fake-bot-token-123';
const FAKE_CREDENTIALS = JSON.stringify({ botToken: FAKE_BOT_TOKEN });
function setupCredentials(credentials = FAKE_CREDENTIALS, extra?: Record<string, unknown>) {
- mockFindByPlatformAndAppId.mockResolvedValue({ credentials, ...extra });
+ // Step rendering is opt-in (schema default: false). The legacy bot path
+ // tests in this file all exercise step rendering, so the default fixture
+ // turns it on. Tests that need to exercise the off-path can override
+ // `settings` via `extra`.
+ mockFindByPlatformAndAppId.mockResolvedValue({
+ credentials,
+ settings: { displayToolCalls: true },
+ ...extra,
+ });
mockInitWithEnvKey.mockResolvedValue({ decrypt: mockDecrypt });
mockDecrypt.mockResolvedValue({ plaintext: credentials });
}
@@ -276,7 +284,11 @@ describe('BotCallbackService', () => {
expect(mockMessengerGetInstallationStore).toHaveBeenCalledWith('telegram');
expect(mockMessengerStoreResolveByKey).toHaveBeenCalledWith('telegram:singleton');
expect(mockMessengerBinderCreateClient).toHaveBeenCalled();
- expect(mockEditMessage).toHaveBeenCalled();
+ // `displayToolCalls` defaults to off (schema default + runtime gate),
+ // so step events don't edit the progress message β€” only completion does.
+ // This test only asserts the credential-resolution path; the gating is
+ // implicit confirmation that no `editMessage` side-effect leaked.
+ expect(mockEditMessage).not.toHaveBeenCalled();
});
it('should pass through the messenger install key verbatim for slack workspaces', async () => {
@@ -354,7 +366,10 @@ describe('BotCallbackService', () => {
});
it('should fall back to raw credentials when decryption fails', async () => {
- mockFindByPlatformAndAppId.mockResolvedValue({ credentials: FAKE_CREDENTIALS });
+ mockFindByPlatformAndAppId.mockResolvedValue({
+ credentials: FAKE_CREDENTIALS,
+ settings: { displayToolCalls: true },
+ });
mockInitWithEnvKey.mockResolvedValue({
decrypt: vi.fn().mockRejectedValue(new Error('decrypt failed')),
});
diff --git a/src/server/services/messenger/platforms/slack/oauth.test.ts b/src/server/services/messenger/platforms/slack/oauth.test.ts
index e31c2eb3584..a4b74b75941 100644
--- a/src/server/services/messenger/platforms/slack/oauth.test.ts
+++ b/src/server/services/messenger/platforms/slack/oauth.test.ts
@@ -48,20 +48,30 @@ describe('slackOAuthAdapter.buildAuthorizeUrl', () => {
});
const parsed = new URL(url);
const scope = parsed.searchParams.get('scope') ?? '';
- // Spot-check the messenger v1 scope shape β€” DM-only, includes
- // reactions:write but not :read.
+ // Spot-check the messenger scope shape β€” aligned with the per-agent bot
+ // (channels/groups/mpim history, slash commands, assistant) plus the
+ // messenger-specific extras (im:write, users:read.email).
expect(scope.split(',')).toEqual(
expect.arrayContaining([
+ 'app_mentions:read',
+ 'assistant:write',
+ 'channels:history',
+ 'channels:read',
'chat:write',
+ 'commands',
+ 'groups:history',
+ 'groups:read',
'im:history',
'im:read',
'im:write',
+ 'mpim:history',
+ 'mpim:read',
+ 'reactions:read',
'reactions:write',
'users:read',
'users:read.email',
]),
);
- expect(scope.split(',')).not.toContain('reactions:read');
expect(parsed.searchParams.get('state')).toBe('nonce-1');
});
});
diff --git a/src/server/services/messenger/platforms/slack/oauth.ts b/src/server/services/messenger/platforms/slack/oauth.ts
index 4de7d312eb7..2ef022d5e2c 100644
--- a/src/server/services/messenger/platforms/slack/oauth.ts
+++ b/src/server/services/messenger/platforms/slack/oauth.ts
@@ -9,32 +9,39 @@ import type {
} from '../types';
/**
- * Bot scopes requested at install. Keep in sync with
- * `docs/development/messenger/slack-app-manifest.yaml` β€” Slack rejects the
- * install with `invalid_scope` if the App's manifest doesn't authorise
- * everything we ask for.
+ * Bot scopes requested at install. The Slack App's manifest must declare
+ * every scope listed here, otherwise Slack rejects the install with
+ * `invalid_scope`.
*
- * Deliberately narrower than the per-agent bot path documented at
- * `docs/usage/channels/slack.zh-CN.mdx`. The two products are different:
+ * Aligned with the per-agent bot path (`docs/usage/channels/slack.zh-CN.mdx`)
+ * so messenger v1 supports the full surface (channel @mention, slash
+ * commands, channel/group/DM history, reactions, Slack AI assistant) instead
+ * of the narrower DM-only set we shipped initially.
*
- * - per-agent bot = user installs their own Slack App for a single agent;
- * wants @mention in channels, slash commands, channel/group history,
- * reactions, Slack AI assistant β€” needs the full set
- * - LobeHub messenger v1 = official LobeHub-distributed Marketplace App,
- * DM-only, agent-as-coworker (Manus pattern). Channel @mention / slash
- * commands / channel history land in PR3 (LOBE-8424); each addition
- * triggers Marketplace re-review so we batch them
+ * Messenger-specific extras kept on top of the per-agent set:
+ * - `im:write` β€” open a DM with the linker to deliver the account-link
+ * button privately when a slash command is invoked from a public channel
+ * - `users:read.email` β€” match Slack identity to a LobeHub account during
+ * the link flow
*
- * `reactions:write` is included because `AgentBridgeService.handleMention`
- * uses emoji reactions (πŸ‘€ "processing" β†’ βœ… "done") for inline feedback β€”
- * this is core UX even in DM-only mode. `reactions:read` is NOT needed: we
- * never react to users' own reactions in v1.
+ * `reactions:write` powers the inline feedback in
+ * `AgentBridgeService.handleMention` (πŸ‘€ processing β†’ βœ… done).
*/
const SLACK_BOT_SCOPES = [
+ 'app_mentions:read',
+ 'assistant:write',
+ 'channels:history',
+ 'channels:read',
'chat:write',
+ 'commands',
+ 'groups:history',
+ 'groups:read',
'im:history',
'im:read',
'im:write',
+ 'mpim:history',
+ 'mpim:read',
+ 'reactions:read',
'reactions:write',
'users:read',
'users:read.email',