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.

✨ feat(agent): list Lobe AI with the other agents and in search (#23728)

Rdmclin2f0c560a526f0
diff --git a/apps/server/src/routers/lambda/agent/lifecycle.test.ts b/apps/server/src/routers/lambda/agent/lifecycle.test.ts
index 69779ef5f9d..abc13a3f8c1 100644
--- a/apps/server/src/routers/lambda/agent/lifecycle.test.ts
+++ b/apps/server/src/routers/lambda/agent/lifecycle.test.ts
@@ -64,17 +64,19 @@ const agentId = 'agent-1';
const workspaceId = 'ws-1';
describe('lifecycleRouter.removeAgent', () => {
+ let getAgentVisibilityMeta: ReturnType<typeof vi.fn>;
let getDeleteImpact: ReturnType<typeof vi.fn>;
let trashAgent: ReturnType<typeof vi.fn>;
beforeEach(() => {
vi.clearAllMocks();
+ getAgentVisibilityMeta = vi.fn().mockResolvedValue({ slug: null });
getDeleteImpact = vi.fn().mockResolvedValue({ foreignTopicCount: 2, hasForeignContent: true });
trashAgent = vi.fn().mockResolvedValue({ id: agentId });
vi.mocked(AgentModel).mockImplementation(function () {
- return { getDeleteImpact } as any;
+ return { getAgentVisibilityMeta, getDeleteImpact } as any;
});
vi.mocked(TrashService).mockImplementation(function () {
return { trashAgent } as any;
@@ -97,6 +99,17 @@ describe('lifecycleRouter.removeAgent', () => {
.createCaller({ userId, workspaceId, workspaceRole } as any)
.removeAgent({ acknowledgeForeignContent, acknowledgeOtherCreator, agentId });
+ it('refuses to delete a builtin agent (Lobe AI) in either scope', async () => {
+ vi.mocked(getResourceMeta).mockResolvedValue({ userId, visibility: 'public', workspaceId });
+ getAgentVisibilityMeta.mockResolvedValue({ slug: 'inbox' });
+
+ await expect(callRemove('owner', true, true)).rejects.toMatchObject({ code: 'FORBIDDEN' });
+ await expect(
+ lifecycleRouter.createCaller({ userId } as any).removeAgent({ agentId }),
+ ).rejects.toMatchObject({ code: 'FORBIDDEN' });
+ expect(trashAgent).not.toHaveBeenCalled();
+ });
+
it("lets the agent's author delete it with teammates' topics once the impact is acknowledged", async () => {
vi.mocked(getResourceMeta).mockResolvedValue({ userId, visibility: 'public', workspaceId });
@@ -200,7 +213,10 @@ describe('lifecycleRouter.getAgentDeleteImpact', () => {
getDeleteImpact = vi.fn().mockResolvedValue({ foreignTopicCount: 3, hasForeignContent: true });
vi.mocked(AgentModel).mockImplementation(function () {
- return { getDeleteImpact } as any;
+ return {
+ getAgentVisibilityMeta: vi.fn().mockResolvedValue({ slug: null }),
+ getDeleteImpact,
+ } as any;
});
vi.mocked(hasWorkspaceScopedPermission).mockResolvedValue(true);
});
diff --git a/apps/server/src/routers/lambda/agent/lifecycle.ts b/apps/server/src/routers/lambda/agent/lifecycle.ts
index 2803d2d71ba..2d317f7a241 100644
--- a/apps/server/src/routers/lambda/agent/lifecycle.ts
+++ b/apps/server/src/routers/lambda/agent/lifecycle.ts
@@ -1,3 +1,4 @@
+import { BUILTIN_AGENT_SLUGS } from '@lobechat/builtin-agents';
import { type AgentDeleteImpact, CreateAgentSchema } from '@lobechat/types';
import { TRPCError } from '@trpc/server';
import { eq } from 'drizzle-orm';
@@ -320,6 +321,18 @@ export const lifecycleRouter = router({
}),
)
.mutation(async ({ input, ctx }) => {
+ // Builtin agents (Lobe AI) are the scope's defaults. A trashed row would
+ // keep holding its unique slug, so the default could never be recreated.
+ // Clients hide Delete on them; this is the backstop for older clients,
+ // the CLI and agent tools.
+ const builtinMeta = await ctx.agentModel.getAgentVisibilityMeta(input.agentId);
+ if (
+ builtinMeta?.slug &&
+ Object.values(BUILTIN_AGENT_SLUGS).includes(builtinMeta.slug as any)
+ ) {
+ throw new TRPCError({ code: 'FORBIDDEN', message: 'Builtin agents cannot be deleted' });
+ }
+
if (ctx.workspaceId) {
const { adminOverride, meta } = await resolveAgentDeleteAuthority(
{ ...ctx, workspaceId: ctx.workspaceId },
diff --git a/apps/server/src/routers/lambda/home.ts b/apps/server/src/routers/lambda/home.ts
index 4f1245433ab..cacc87efdb4 100644
--- a/apps/server/src/routers/lambda/home.ts
+++ b/apps/server/src/routers/lambda/home.ts
@@ -43,12 +43,19 @@ const homeSearchProcedure = homeProcedure.use(async (opts) => {
});
});
+/**
+ * Lobe AI (the inbox) is listed only for callers that ask for it. Released
+ * clients still draw it as their own fixed row and would show it twice β€” with
+ * the ordinary agent menu β€” if the list started returning it unasked.
+ */
+const includeInboxInput = z.object({ includeInbox: z.boolean().optional() }).optional();
+
export const homeRouter = router({
getDailyBrief: homeProcedure.query(({ ctx }): Promise<HomeBriefData> =>
ctx.homeService.getDailyBrief(),
),
- getSidebarAgentList: homeProcedure.query(async ({ ctx }) => {
+ getSidebarAgentList: homeProcedure.input(includeInboxInput).query(async ({ ctx, input }) => {
// The sidebar payload carries applied label names and colors, so it has to
// respect the same grant as the label registry itself β€” otherwise denying
// `agent_label:read` only closes the front door. Personal scope has no
@@ -76,13 +83,17 @@ export const homeRouter = router({
})
: true;
- return ctx.homeRepository.getSidebarAgentList(includeLabels, includeGroups);
+ return ctx.homeRepository.getSidebarAgentList(
+ includeLabels,
+ includeGroups,
+ input?.includeInbox ?? false,
+ );
}),
searchAgents: homeSearchProcedure
- .input(z.object({ keyword: z.string() }))
+ .input(z.object({ includeInbox: z.boolean().optional(), keyword: z.string() }))
.query(async ({ input, ctx }) => {
- return ctx.homeRepository.searchAgents(input.keyword);
+ return ctx.homeRepository.searchAgents(input.keyword, input.includeInbox ?? false);
}),
/**
diff --git a/packages/database/src/models/__tests__/agentLabel.test.ts b/packages/database/src/models/__tests__/agentLabel.test.ts
index 01cefadba03..879886fb821 100644
--- a/packages/database/src/models/__tests__/agentLabel.test.ts
+++ b/packages/database/src/models/__tests__/agentLabel.test.ts
@@ -149,6 +149,20 @@ describe('AgentLabelModel', () => {
expect(await personalModel.getAgentLabelIds('agt-set')).toEqual([]);
});
+ it('should label the inbox agent but still reject other virtual agents', async () => {
+ await serverDB.insert(agents).values([
+ { id: 'agt-inbox', slug: 'inbox', userId, virtual: true },
+ { id: 'agt-virtual', userId, virtual: true },
+ ]);
+ const label = await personalModel.create({ name: 'Daily' });
+
+ await personalModel.setAgentLabels('agt-inbox', [label.id]);
+ expect(await personalModel.getAgentLabelIds('agt-inbox')).toEqual([label.id]);
+ expect((await personalModel.query())[0].usageCount).toBe(1);
+
+ await expect(personalModel.setAgentLabels('agt-virtual', [label.id])).rejects.toThrow();
+ });
+
it('should reject agents outside the scope', async () => {
await createAgent('agt-scope');
const label = await workspaceModel.create({ name: 'WS' });
diff --git a/packages/database/src/models/agentLabel.ts b/packages/database/src/models/agentLabel.ts
index dbba2c89e18..3d57b244a72 100644
--- a/packages/database/src/models/agentLabel.ts
+++ b/packages/database/src/models/agentLabel.ts
@@ -1,8 +1,9 @@
-import { and, asc, count, eq, inArray, not } from 'drizzle-orm';
+import { and, asc, count, eq, inArray } from 'drizzle-orm';
import type { AgentLabelItem } from '../schemas';
import { agentLabelAssignments, agentLabels, agents } from '../schemas';
import type { LobeChatDatabase } from '../type';
+import { listedAgentWhere } from '../utils/inboxAgent';
import { buildWorkspacePayload, buildWorkspaceWhere } from '../utils/workspace';
export interface AgentLabelWithUsage extends AgentLabelItem {
@@ -72,7 +73,7 @@ export class AgentLabelModel {
agents,
and(
eq(agents.id, agentLabelAssignments.agentId),
- not(eq(agents.virtual, true)),
+ listedAgentWhere(),
this.agentOwnership(),
),
)
@@ -185,8 +186,9 @@ export class AgentLabelModel {
eq(agents.id, agentId),
// Virtual agents β€” chat-group supervisors and synthetic members β€” are
// filtered out of the agents list entirely, so a label on one could
- // never be seen while still inflating that label's usage count.
- not(eq(agents.virtual, true)),
+ // never be seen while still inflating that label's usage count. The
+ // inbox is the one virtual row the list shows.
+ listedAgentWhere(),
this.agentOwnership(),
),
)
diff --git a/packages/database/src/repositories/home/__tests__/inboxListed.test.ts b/packages/database/src/repositories/home/__tests__/inboxListed.test.ts
new file mode 100644
index 00000000000..da3c9e25746
--- /dev/null
+++ b/packages/database/src/repositories/home/__tests__/inboxListed.test.ts
@@ -0,0 +1,122 @@
+// Regression (T-14752): the default inbox agent (LobeAI) is a `virtual` row, and
+// the sidebar list used to drop every virtual row β€” so once a user hid Lobe AI
+// from the sidebar, nothing listed it again. The scope's inbox is now an
+// ordinary list item; other virtual rows and other scopes' inboxes stay out.
+import { DEFAULT_INBOX_TITLE, INBOX_SESSION_ID } from '@lobechat/const';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import * as Schema from '../../../schemas';
+import { HomeRepository } from '../index';
+
+const clientDB = await getTestDB();
+
+const memberA = 'u-inbox-a';
+const memberB = 'u-inbox-b';
+const ws = 'ws-inbox-listed';
+
+const ids = (items: { id: string }[]) => items.map((item) => item.id);
+
+beforeEach(async () => {
+ await clientDB.delete(Schema.users);
+ await clientDB.delete(Schema.workspaces);
+ await clientDB.insert(Schema.users).values([{ id: memberA }, { id: memberB }]);
+ await clientDB.insert(Schema.workspaces).values({
+ id: ws,
+ name: 'WS',
+ primaryOwnerId: memberA,
+ slug: ws,
+ });
+});
+
+afterEach(async () => {
+ await clientDB.delete(Schema.users);
+ await clientDB.delete(Schema.workspaces);
+});
+
+describe('inbox agent in the sidebar list', () => {
+ it('lists the personal inbox first, with its default title, and keeps other virtual rows out', async () => {
+ await clientDB.insert(Schema.agents).values([
+ {
+ id: 'a-inbox',
+ slug: INBOX_SESSION_ID,
+ updatedAt: new Date('2020-01-01'),
+ userId: memberA,
+ virtual: true,
+ },
+ { id: 'a-recent', title: 'Recent Agent', updatedAt: new Date('2026-01-01'), userId: memberA },
+ { id: 'a-supervisor', title: 'Supervisor', userId: memberA, virtual: true },
+ ]);
+
+ const result = await new HomeRepository(clientDB, memberA).getSidebarAgentList(
+ true,
+ true,
+ true,
+ );
+
+ expect(ids(result.ungrouped)).toEqual(['a-inbox', 'a-recent']);
+ expect(result.ungrouped[0]).toMatchObject({
+ slug: INBOX_SESSION_ID,
+ title: DEFAULT_INBOX_TITLE,
+ });
+ });
+
+ it('follows the inbox into the pinned bucket when the user pins it', async () => {
+ await clientDB.insert(Schema.agents).values({
+ id: 'a-inbox',
+ pinned: true,
+ slug: INBOX_SESSION_ID,
+ userId: memberA,
+ virtual: true,
+ });
+
+ const result = await new HomeRepository(clientDB, memberA).getSidebarAgentList(
+ true,
+ true,
+ true,
+ );
+
+ expect(ids(result.pinned)).toEqual(['a-inbox']);
+ expect(ids(result.ungrouped)).toEqual([]);
+ });
+
+ it("shares the workspace's single inbox with every member, and only that workspace's", async () => {
+ await clientDB.insert(Schema.workspaces).values({
+ id: 'ws-other',
+ name: 'Other',
+ primaryOwnerId: memberB,
+ slug: 'ws-other',
+ });
+ await clientDB.insert(Schema.agents).values([
+ { id: 'ws-inbox', slug: INBOX_SESSION_ID, userId: memberA, virtual: true, workspaceId: ws },
+ {
+ id: 'other-inbox',
+ slug: INBOX_SESSION_ID,
+ userId: memberB,
+ virtual: true,
+ workspaceId: 'ws-other',
+ },
+ { id: 'personal-inbox', slug: INBOX_SESSION_ID, userId: memberB, virtual: true },
+ ]);
+
+ for (const member of [memberA, memberB]) {
+ const view = await new HomeRepository(clientDB, member, ws).getSidebarAgentList(
+ true,
+ true,
+ true,
+ );
+ expect(ids(view.ungrouped)).toEqual(['ws-inbox']);
+ }
+ });
+
+ it('keeps the inbox out for callers that do not ask for it (released clients)', async () => {
+ await clientDB.insert(Schema.agents).values([
+ { id: 'a-inbox', slug: INBOX_SESSION_ID, userId: memberA, virtual: true },
+ { id: 'a-plain', title: 'Plain Agent', userId: memberA },
+ ]);
+
+ const result = await new HomeRepository(clientDB, memberA).getSidebarAgentList();
+
+ expect(ids(result.ungrouped)).toEqual(['a-plain']);
+ });
+});
diff --git a/packages/database/src/repositories/home/__tests__/index.test.ts b/packages/database/src/repositories/home/__tests__/index.test.ts
index 2acede4bef5..9b99f720845 100644
--- a/packages/database/src/repositories/home/__tests__/index.test.ts
+++ b/packages/database/src/repositories/home/__tests__/index.test.ts
@@ -721,6 +721,30 @@ describe('HomeRepository', () => {
expect(result).toHaveLength(0);
});
+ it('should find the inbox agent by its default name only when asked, ignoring case and spacing', async () => {
+ await clientDB.insert(Schema.agents).values({
+ id: 'search-inbox',
+ slug: 'inbox',
+ userId,
+ virtual: true,
+ });
+
+ expect((await homeRepo.searchAgents('LobeAI')).map((a) => a.id)).not.toContain(
+ 'search-inbox',
+ );
+
+ for (const keyword of ['LobeAI', 'lobe ai', 'Lobe']) {
+ const result = await homeRepo.searchAgents(keyword, true);
+ expect(result.map((a) => a.id)).toContain('search-inbox');
+ }
+
+ const [inbox] = await homeRepo.searchAgents('LobeAI', true);
+ expect(inbox).toMatchObject({ slug: 'inbox', title: 'Lobe AI' });
+ expect((await homeRepo.searchAgents('Searchable', true)).map((a) => a.id)).not.toContain(
+ 'search-inbox',
+ );
+ });
+
describe('agents.pinned is the only search pin source', () => {
it('should ignore sessions.pinned when agents.pinned is null', async () => {
// Create legacy agent with pinned on session only
diff --git a/packages/database/src/repositories/home/index.ts b/packages/database/src/repositories/home/index.ts
index 0ab294b8514..792b45e6558 100644
--- a/packages/database/src/repositories/home/index.ts
+++ b/packages/database/src/repositories/home/index.ts
@@ -1,3 +1,4 @@
+import { INBOX_SESSION_ID } from '@lobechat/const';
import {
type SidebarAgentItem,
type SidebarAgentLabel,
@@ -20,8 +21,14 @@ import {
} from '../../schemas';
import { type LobeChatDatabase } from '../../type';
import { sanitizeBm25Query } from '../../utils/bm25';
-import { normalizeInboxAgentMeta } from '../../utils/inboxAgent';
+import {
+ isInboxAgentIdentity,
+ keywordMatchesInboxTitle,
+ listedAgentWhere,
+ normalizeInboxAgentMeta,
+} from '../../utils/inboxAgent';
import { inJsonStringArray } from '../../utils/inJsonStringArray';
+import { ilikeContains } from '../../utils/like';
import { notShareVisitorTopic } from '../../utils/shareVisitor';
import { CHANNEL_TOPIC_TRIGGER } from '../../utils/topicVisibility';
import { buildWorkspaceWhere } from '../../utils/workspace';
@@ -86,12 +93,15 @@ export class HomeRepository {
* @param includeLabels - whether the caller holds `agent_label:read`. The
* router decides; defaulting to `true` keeps personal mode and every
* existing caller unchanged, since that grant only exists in a workspace.
+ * @param includeInbox - list the scope's inbox (Lobe AI) as an ordinary item.
+ * Off by default: released clients render the inbox as their own row.
*/
async getSidebarAgentList(
includeLabels = true,
includeGroups = true,
+ includeInbox = false,
): Promise<SidebarAgentListResponse> {
- // 1. Query all non-virtual agents.
+ // 1. Query all non-virtual agents, plus the scope's inbox (Lobe AI).
// `visibility` is selected so we can later bucket public vs. the
// current user's private rows; the WHERE already hides other members'
// private rows via the workspace-aware predicate.
@@ -122,7 +132,7 @@ export class HomeRepository {
workspaceId: agents.workspaceId,
visibility: agents.visibility,
}),
- not(eq(agents.virtual, true)),
+ includeInbox ? listedAgentWhere() : not(eq(agents.virtual, true)),
),
)
.orderBy(desc(agents.updatedAt));
@@ -465,8 +475,14 @@ export class HomeRepository {
}),
];
- // Sort all items by updatedAt descending
- allItems.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
+ // Sort all items by updatedAt descending. The inbox (LobeAI) leads its
+ // bucket: its row is rarely updated, so by recency alone the default
+ // Agent would sink below the page-size cut and vanish from the sidebar.
+ allItems.sort(
+ (a, b) =>
+ Number(isInboxAgentIdentity(b)) - Number(isInboxAgentIdentity(a)) ||
+ b.updatedAt.getTime() - a.updatedAt.getTime(),
+ );
// Categorize: pinned / grouped / ungrouped, split by visibility. Pinned
// wins over grouping, but stays within its visibility bucket β€” a pinned
@@ -540,8 +556,11 @@ export class HomeRepository {
/**
* Search agents and chat groups by keyword
* Searches in title and description fields
+ *
+ * @param includeInbox - also match the scope's inbox (Lobe AI); see
+ * {@link getSidebarAgentList}.
*/
- async searchAgents(keyword: string): Promise<SidebarAgentItem[]> {
+ async searchAgents(keyword: string, includeInbox = false): Promise<SidebarAgentItem[]> {
if (!keyword.trim()) return [];
const bm25Query = sanitizeBm25Query(keyword);
@@ -585,10 +604,30 @@ export class HomeRepository {
.where(
and(
buildWorkspaceWhere(this.scope, agents),
- not(eq(agents.virtual, true)),
- agentCandidateIds
- ? inJsonStringArray(agents.id, agentCandidateIds)
- : sql`(${agents.title} @@@ ${bm25Query} OR ${agents.description} @@@ ${bm25Query})`,
+ or(
+ and(
+ not(eq(agents.virtual, true)),
+ agentCandidateIds
+ ? inJsonStringArray(agents.id, agentCandidateIds)
+ : sql`(${agents.title} @@@ ${bm25Query} OR ${agents.description} @@@ ${bm25Query})`,
+ ),
+ // The inbox is a virtual row the search index skips, so it is matched by name
+ // here. Its stored title is usually blank and shown as Lobe AI, so a blank
+ // title also matches that default name.
+ includeInbox
+ ? and(
+ eq(agents.slug, INBOX_SESSION_ID),
+ or(
+ ilikeContains(agents.title, keyword.trim()),
+ ilikeContains(agents.name, keyword.trim()),
+ ilikeContains(agents.description, keyword.trim()),
+ keywordMatchesInboxTitle(keyword)
+ ? sql`nullif(trim(${agents.title}), '') is null`
+ : undefined,
+ ),
+ )
+ : undefined,
+ ),
),
)
.orderBy(desc(agents.updatedAt)),
@@ -638,6 +677,7 @@ export class HomeRepository {
id: a.id,
name: a.name,
pinned: a.pinned ?? false,
+ slug: a.slug,
title: meta.title,
type: 'agent' as const,
updatedAt: a.updatedAt,
diff --git a/packages/database/src/utils/inboxAgent.ts b/packages/database/src/utils/inboxAgent.ts
index 44abdc6b614..d600f98e806 100644
--- a/packages/database/src/utils/inboxAgent.ts
+++ b/packages/database/src/utils/inboxAgent.ts
@@ -1,6 +1,6 @@
import { DEFAULT_INBOX_AVATAR, DEFAULT_INBOX_TITLE, INBOX_SESSION_ID } from '@lobechat/const';
import { agentDisplayName } from '@lobechat/types';
-import { sql } from 'drizzle-orm';
+import { eq, not, or, type SQL, sql } from 'drizzle-orm';
import { agents } from '../schemas';
@@ -86,3 +86,25 @@ export const agentTitleSql = () =>
sql<
string | null
>`case when ${agents.slug} = ${INBOX_SESSION_ID} and nullif(trim(${agents.title}), '') is null then ${DEFAULT_INBOX_TITLE} else ${agents.title} end`;
+
+/**
+ * Which Agent rows the agent lists (sidebar, Agents page, search, labels) show: every non-virtual
+ * Agent, plus the inbox. The inbox is `virtual` so it stays out of chat-group supervisor
+ * bookkeeping, but to the user it is an ordinary Agent they can hide and find again. Combine it
+ * with the scope predicate: a scope holds one inbox (the user's own, or the workspace's single
+ * shared one β€” `agents_slug_workspace_id_unique`).
+ */
+export const listedAgentWhere = (): SQL =>
+ or(not(eq(agents.virtual, true)), eq(agents.slug, INBOX_SESSION_ID)) as SQL;
+
+/** Search text compared loosely: case and whitespace ignored, so "lobe ai" finds "LobeAI". */
+const compactSearchText = (value: string) => value.toLowerCase().replaceAll(/\s+/g, '');
+
+/**
+ * Whether a search keyword names the inbox by its default title. The inbox row usually stores a
+ * blank title and is only shown as `DEFAULT_INBOX_TITLE`, so a column match alone never finds it.
+ */
+export const keywordMatchesInboxTitle = (keyword: string): boolean => {
+ const needle = compactSearchText(keyword);
+ return needle.length > 0 && compactSearchText(DEFAULT_INBOX_TITLE).includes(needle);
+};
diff --git a/src/components/MemberSelectionModal/MemberSelectionModal.tsx b/src/components/MemberSelectionModal/MemberSelectionModal.tsx
index a4f3f6ee329..cf6881831dd 100644
--- a/src/components/MemberSelectionModal/MemberSelectionModal.tsx
+++ b/src/components/MemberSelectionModal/MemberSelectionModal.tsx
@@ -24,6 +24,7 @@ import { useTranslation } from 'react-i18next';
import AgentAvatar from '@/components/AgentAvatar';
import ImperativeModal from '@/components/ImperativeModal';
+import { isBuiltinAgentSlug } from '@/features/AddAgentMemberModal/selectAddableAgents';
import AgentSelectionEmpty from '@/features/AgentSelectionEmpty';
import ModelSelect from '@/features/ModelSelect';
import { useEnabledChatModels } from '@/hooks/useEnabledChatModels';
@@ -246,8 +247,11 @@ const MemberSelectionModal = memo<MemberSelectionModalProps>(
const isLogin = useUserStore(authSelectors.isLogin);
const useFetchAgentList = useHomeStore((s) => s.useFetchAgentList);
useFetchAgentList(open && isLogin);
+ // Builtins (Lobe AI) are listed in the sidebar but can never join a group.
const agents = useHomeStore((s) =>
- homeAgentListSelectors.allAgents(s).filter((item) => item.type === 'agent'),
+ homeAgentListSelectors
+ .allAgents(s)
+ .filter((item) => item.type === 'agent' && !isBuiltinAgentSlug(item.slug)),
);
const handleAgentToggle = (agentId: string) => {
diff --git a/src/features/AddAgentMemberModal/selectAddableAgents.ts b/src/features/AddAgentMemberModal/selectAddableAgents.ts
index 8b66aa89589..35a8ecd7df3 100644
--- a/src/features/AddAgentMemberModal/selectAddableAgents.ts
+++ b/src/features/AddAgentMemberModal/selectAddableAgents.ts
@@ -5,6 +5,10 @@ import { type AvailableAgentItem } from '@/services/agent';
const builtinAgentSlugs = new Set<string>(Object.values(BUILTIN_AGENT_SLUGS));
+/** Builtin agents (Lobe AI) can never join a group: `addAgentsToGroup` refuses them. */
+export const isBuiltinAgentSlug = (slug?: string | null): boolean =>
+ !!slug && builtinAgentSlugs.has(slug);
+
/**
* The picker's candidates from the sidebar agent list: agents only (no chat
* groups, no builtins), most recently updated first like `queryAgents`.
@@ -24,7 +28,7 @@ export const toPickableAgents = (items: SidebarAgentItem[]): AvailableAgentItem[
backgroundColor: item.backgroundColor ?? null,
description: item.description ?? null,
id: item.id,
- isInbox: !!item.slug && builtinAgentSlugs.has(item.slug),
+ isInbox: isBuiltinAgentSlug(item.slug),
name: item.name ?? null,
title: item.title,
}));
diff --git a/src/features/AgentViewAll/AgentViewAllPage.tsx b/src/features/AgentViewAll/AgentViewAllPage.tsx
index 2247e523b70..e62dae4381f 100644
--- a/src/features/AgentViewAll/AgentViewAllPage.tsx
+++ b/src/features/AgentViewAll/AgentViewAllPage.tsx
@@ -353,13 +353,15 @@ const AgentViewAllPage = memo(() => {
);
const filteredItems = useMemo(() => {
- const query = keyword.trim().toLowerCase();
+ // Case and spacing are ignored, so "lobeai" still finds "Lobe AI".
+ const fold = (value?: string | null) => value?.toLowerCase().replaceAll(/\s+/g, '') ?? '';
+ const query = fold(keyword);
let matched = query
? items.filter(
(item) =>
- item.name?.toLowerCase().includes(query) ||
- item.title?.toLowerCase().includes(query) ||
- item.description?.toLowerCase().includes(query),
+ fold(item.name).includes(query) ||
+ fold(item.title).includes(query) ||
+ fold(item.description).includes(query),
)
: items;
diff --git a/src/features/CommandMenu/AskAIMenu.tsx b/src/features/CommandMenu/AskAIMenu.tsx
index 30fd2c37a54..d4016c77286 100644
--- a/src/features/CommandMenu/AskAIMenu.tsx
+++ b/src/features/CommandMenu/AskAIMenu.tsx
@@ -1,3 +1,4 @@
+import { INBOX_SESSION_ID } from '@lobechat/const';
import { agentDisplayName } from '@lobechat/types';
import { GroupBotSquareIcon } from '@lobehub/ui/icons';
import { Command } from 'cmdk';
@@ -28,7 +29,10 @@ const AskAIMenu = memo(() => {
// Get agent list (limit to first 20 items for simplicity)
const allAgents = useHomeStore(homeAgentListSelectors.allAgents);
- const agents = allAgents.filter((item) => item.type === 'agent').slice(0, 20);
+ // Lobe AI has its own fixed row above, so its list item is left out.
+ const agents = allAgents
+ .filter((item) => item.type === 'agent' && item.slug !== INBOX_SESSION_ID)
+ .slice(0, 20);
const heading = search.trim()
? t('cmdk.askAIHeading', { query: `"${search.trim()}"` })
diff --git a/src/features/CommandMenu/AskAgentCommands.tsx b/src/features/CommandMenu/AskAgentCommands.tsx
index 0394e014bac..2de284bc146 100644
--- a/src/features/CommandMenu/AskAgentCommands.tsx
+++ b/src/features/CommandMenu/AskAgentCommands.tsx
@@ -1,3 +1,4 @@
+import { INBOX_SESSION_ID } from '@lobechat/const';
import { agentDisplayName } from '@lobechat/types';
import { preventDefault } from '@lobehub/ui';
import { Command } from 'cmdk';
@@ -34,7 +35,10 @@ const AskAgentCommands = memo(() => {
// Filter agents based on the query after "@"
const filteredAgents = useMemo(() => {
- const agents = allAgents.filter((item) => item.type === 'agent');
+ // Lobe AI has its own fixed `@` row, so its list item is left out.
+ const agents = allAgents.filter(
+ (item) => item.type === 'agent' && item.slug !== INBOX_SESSION_ID,
+ );
if (!mentionQuery) {
return agents.slice(0, 10);
}
diff --git a/src/features/HomeSidebar/Body/Agent/List/AgentItem/useDropdownMenu.test.tsx b/src/features/HomeSidebar/Body/Agent/List/AgentItem/useDropdownMenu.test.tsx
index e5531b9d880..61630eb900e 100644
--- a/src/features/HomeSidebar/Body/Agent/List/AgentItem/useDropdownMenu.test.tsx
+++ b/src/features/HomeSidebar/Body/Agent/List/AgentItem/useDropdownMenu.test.tsx
@@ -464,6 +464,34 @@ describe('useAgentDropdownMenu', () => {
]);
});
+ it('keeps Lobe AI (the inbox) organizable but never deletable, copyable or transferable', () => {
+ mocks.canEditResource = true;
+ mocks.canManage = true;
+ mocks.canManageResource = true;
+ mocks.transferMenuItems = [{ key: 'copy-agent', label: 'Copy to…' }];
+
+ const { result } = renderHook(() =>
+ useAgentDropdownMenu({
+ group: undefined,
+ id: 'inbox-agent',
+ openCreateGroupModal: vi.fn(),
+ pinned: false,
+ slug: 'inbox',
+ title: 'Lobe AI',
+ userId: 'member-1',
+ visibility: 'public',
+ }),
+ );
+
+ const keys = getMenuKeys(result.current());
+ expect(keys).toEqual(expect.arrayContaining(['pin', 'hideFromSidebar', 'rename', 'moveGroup']));
+ expect(keys).not.toContain('delete');
+ expect(keys).not.toContain('duplicate');
+ expect(keys).not.toContain('copy-agent');
+ expect(keys).not.toContain('permission');
+ expect(keys).not.toContain('visibility');
+ });
+
it('hides the Permission shortcut from a non-author member who can configure the agent', () => {
mocks.canEditResource = true;
diff --git a/src/features/HomeSidebar/Body/Agent/List/AgentItem/useDropdownMenu.tsx b/src/features/HomeSidebar/Body/Agent/List/AgentItem/useDropdownMenu.tsx
index 5772d130adb..5beb035cbc5 100644
--- a/src/features/HomeSidebar/Body/Agent/List/AgentItem/useDropdownMenu.tsx
+++ b/src/features/HomeSidebar/Body/Agent/List/AgentItem/useDropdownMenu.tsx
@@ -1,3 +1,4 @@
+import { INBOX_SESSION_ID } from '@lobechat/const';
import {
agentRenameField,
SessionDefaultGroup,
@@ -148,11 +149,14 @@ export const useAgentDropdownMenu = ({
// Delete also opens to a workspace Admin on another member's shared agent
// (server `canManage`); the confirmation then warns that someone else created
// it, and the server only accepts the delete with that acknowledgment.
- const canDelete = canManage || canManageResource;
+ // Lobe AI (the inbox) is listed like any Agent, but it is the scope's
+ // built-in default: it cannot be deleted, handed over or moved elsewhere.
+ const isInbox = slug === INBOX_SESSION_ID;
+ const canDelete = !isInbox && (canManage || canManageResource);
// Cross-workspace Transfer to… / Copy to… items (null when workspace
// feature is off or the viewer lacks permission for this agent)
- const transferMenuItems = useAgentTransferMenuItem(
+ const agentTransferMenuItems = useAgentTransferMenuItem(
id,
{
avatar,
@@ -163,12 +167,16 @@ export const useAgentDropdownMenu = ({
);
// Ownership handover to a workspace member (recipient must accept) β€” a
// separate entry from the cross-scope "Move to…" above.
- const transferToMemberItem = useAgentTransferToMemberMenuItem(
+ const agentTransferToMemberItem = useAgentTransferToMemberMenuItem(
id,
{ avatar, backgroundColor, title },
{ userId, visibility },
);
+ const transferMenuItems = isInbox ? null : agentTransferMenuItems;
+ const transferToMemberItem = isInbox ? null : agentTransferToMemberItem;
+ const canManagePermission = !isInbox && canManageResource;
+
const copyAgentIdItem = useCopyAgentIdMenuItem(id);
const isDefault = group === SessionDefaultGroup.Default;
@@ -262,7 +270,8 @@ export const useAgentDropdownMenu = ({
},
]
: []),
- ...(canCreate
+ // A copy of Lobe AI would come out nameless: its stored title is blank.
+ ...(canCreate && !isInbox
? [
{
icon: <Icon icon={LucideCopy} />,
@@ -446,7 +455,7 @@ export const useAgentDropdownMenu = ({
// Permissions live on their own page now β€” the sidebar keeps a
// shortcut so creators and workspace owners don't have to open
// the Agent first.
- ...(activeWorkspaceId && canManageResource
+ ...(activeWorkspaceId && canManagePermission
? [
{ type: 'divider' as const },
{
@@ -503,8 +512,9 @@ export const useAgentDropdownMenu = ({
canCreate,
canConfigure,
canEdit,
- canManageResource,
+ canManagePermission,
canDelete,
+ isInbox,
navigate,
pinned,
id,
diff --git a/src/features/HomeSidebar/Body/Agent/List/AgentListContent.tsx b/src/features/HomeSidebar/Body/Agent/List/AgentListContent.tsx
index 5d6e935f2e3..07c08071781 100644
--- a/src/features/HomeSidebar/Body/Agent/List/AgentListContent.tsx
+++ b/src/features/HomeSidebar/Body/Agent/List/AgentListContent.tsx
@@ -40,7 +40,8 @@ const AgentListContent = memo<AgentListContentProps>(({ hideInbox, onMoreClick }
isInit,
isLogin: !!isLogin,
});
- const { customList, pinnedList, defaultList } = useAgentList();
+ const hasInboxAgent = useHomeStore(homeAgentListSelectors.hasInboxAgent);
+ const { customList, pinnedList, defaultList, inboxItem } = useAgentList();
// Personal pins are the user's own, so they can always be reordered. A
// workspace caller (compact switchers) gets the team pins here, whose order
// only owners/admins may change from the sidebar's own section.
@@ -71,19 +72,29 @@ const AgentListContent = memo<AgentListContentProps>(({ hideInbox, onMoreClick }
};
}, [pinnedList?.length, customList?.length]);
+ // Signed-in lists carry Lobe AI (the inbox) as an ordinary item from the
+ // server, so it can be pinned, hidden and found again like any Agent. The
+ // standalone entry covers the moments no list row exists: a signed-out
+ // visitor, the first load, and a list cached or fetched before the inbox row.
+ const showStandaloneInbox = !hideInbox && (contentState !== 'ready' || !hasInboxAgent);
+
+ if (contentState === 'inbox') return showStandaloneInbox ? <InboxItem /> : null;
if (contentState !== 'ready')
return (
<>
- {!hideInbox && <InboxItem />}
- {contentState === 'loading' && <SkeletonList rows={3} />}
+ {showStandaloneInbox && <InboxItem />}
+ <SkeletonList rows={3} />
</>
);
// Always render the default SessionList so the "+ Create Agent" entry is visible
// even when the user has only the built-in Lobe AI inbox.
+ // Lobe AI's own row leads the list, ahead of the pins, like the standalone
+ // entry it replaces.
return (
<>
- {!hideInbox && <InboxItem />}
+ {showStandaloneInbox && <InboxItem />}
+ {inboxItem && <SessionList dataSource={[inboxItem]} />}
{showPinned &&
(isWorkspace ? (
<SessionList dataSource={pinnedList!} />
diff --git a/src/features/HomeSidebar/Body/Agent/List/WorkspaceAgentListContent.tsx b/src/features/HomeSidebar/Body/Agent/List/WorkspaceAgentListContent.tsx
index 8a66e19f6ec..c736f8826e5 100644
--- a/src/features/HomeSidebar/Body/Agent/List/WorkspaceAgentListContent.tsx
+++ b/src/features/HomeSidebar/Body/Agent/List/WorkspaceAgentListContent.tsx
@@ -21,6 +21,7 @@ import CreateAgentButton from '../CreateAgentButton';
import { resolveAgentListContentState } from './agentListContentState';
import Group from './Group';
import InboxItem from './InboxItem';
+import { liftInboxRow, withoutInboxInGroups } from './inboxRow';
import SessionList from './List';
import SortableList from './SortableList';
import { useWorkspaceAgentSections } from './useWorkspaceAgentSections';
@@ -59,7 +60,7 @@ SubHeader.displayName = 'WorkspaceAgentSubHeader';
/**
* The merged workspace "Agents" section body (replacing the former separate
- * "Workspace" and "Private" accordions): Inbox β†’ my pins β†’ team pins (fixed,
+ * "Workspace" and "Private" accordions): Lobe AI β†’ my pins β†’ team pins (fixed,
* set by owners/admins for everyone) β†’ folders β†’ the rest. Personal pins come
* first so the agents a member chose stay at the top instead of being pushed
* down by the (possibly long) team list. Private rows
@@ -77,6 +78,7 @@ const WorkspaceAgentListContent = memo<{ hideInbox?: boolean }>(({ hideInbox })
isLogin: !!isLogin,
});
+ const hasInboxAgent = useHomeStore(homeAgentListSelectors.hasInboxAgent);
const agentPageSize = useGlobalStore(systemStatusSelectors.agentPageSize);
const navigate = useWorkspaceAwareNavigate();
const [teamExpanded, setTeamExpanded] = useState(false);
@@ -88,7 +90,22 @@ const WorkspaceAgentListContent = memo<{ hideInbox?: boolean }>(({ hideInbox })
s.reorderMyPinned,
]);
- const resolved = useWorkspaceAgentSections();
+ const sectionsWithInbox = useWorkspaceAgentSections();
+ // Lobe AI (the inbox) leads the sidebar wherever its row sits β€” a pin, a
+ // folder or the rest β€” so it is taken out of the sections and rendered first.
+ const { inboxItem, resolved } = useMemo(() => {
+ const folders = withoutInboxInGroups(sectionsWithInbox.folders);
+ const { inbox, lists } = liftInboxRow({
+ myPinned: sectionsWithInbox.myPinned,
+ rest: sectionsWithInbox.rest,
+ teamPinned: sectionsWithInbox.teamPinned,
+ });
+
+ return {
+ inboxItem: inbox ?? folders.inbox,
+ resolved: { ...lists, folders: folders.groups },
+ };
+ }, [sectionsWithInbox]);
const { teamPinned } = resolved;
const teamOverflow = teamPinned.length > TEAM_PINNED_VISIBLE_LIMIT;
const visibleTeamPinned =
@@ -115,11 +132,18 @@ const WorkspaceAgentListContent = memo<{ hideInbox?: boolean }>(({ hideInbox })
[agentPageSize, resolved],
);
+ // Signed-in lists carry Lobe AI (the inbox) as an ordinary item from the
+ // server, so it can be pinned, hidden and found again like any Agent. The
+ // standalone entry covers the moments no list row exists: a signed-out
+ // visitor, the first load, and a list cached or fetched before the inbox row.
+ const showStandaloneInbox = !hideInbox && (contentState !== 'ready' || !hasInboxAgent);
+
+ if (contentState === 'inbox') return showStandaloneInbox ? <InboxItem /> : null;
if (contentState !== 'ready')
return (
<>
- {!hideInbox && <InboxItem />}
- {contentState === 'loading' && <SkeletonList rows={3} />}
+ {showStandaloneInbox && <InboxItem />}
+ <SkeletonList rows={3} />
</>
);
@@ -127,7 +151,8 @@ const WorkspaceAgentListContent = memo<{ hideInbox?: boolean }>(({ hideInbox })
return (
<>
- {!hideInbox && <InboxItem />}
+ {showStandaloneInbox && <InboxItem />}
+ {inboxItem && <SessionList dataSource={[inboxItem]} />}
{myPinned.length > 0 && (
<Flexbox data-testid={'sidebar-my-pinned'} gap={1}>
<SubHeader
diff --git a/src/features/HomeSidebar/Body/Agent/List/inboxRow.test.ts b/src/features/HomeSidebar/Body/Agent/List/inboxRow.test.ts
new file mode 100644
index 00000000000..ec673b79727
--- /dev/null
+++ b/src/features/HomeSidebar/Body/Agent/List/inboxRow.test.ts
@@ -0,0 +1,49 @@
+import { INBOX_SESSION_ID } from '@lobechat/const';
+import type { SidebarAgentItem } from '@lobechat/types';
+import { describe, expect, it } from 'vitest';
+
+import { liftInboxRow, withoutInboxInGroups } from './inboxRow';
+
+const item = (id: string, extra: Partial<SidebarAgentItem> = {}): SidebarAgentItem =>
+ ({
+ id,
+ pinned: false,
+ title: id,
+ type: 'agent',
+ updatedAt: new Date('2026-01-01'),
+ ...extra,
+ }) as SidebarAgentItem;
+
+const inbox = item('inbox-row', { slug: INBOX_SESSION_ID });
+
+describe('liftInboxRow', () => {
+ it('takes Lobe AI out of a pinned list so it can lead the sidebar', () => {
+ const { inbox: lifted, lists } = liftInboxRow({
+ defaultList: [item('a')],
+ pinnedList: [item('p1'), inbox, item('p2')],
+ });
+
+ expect(lifted).toBe(inbox);
+ expect(lists.pinnedList.map((i) => i.id)).toEqual(['p1', 'p2']);
+ expect(lists.defaultList.map((i) => i.id)).toEqual(['a']);
+ });
+
+ it('leaves the lists untouched when Lobe AI is hidden or absent', () => {
+ const { inbox: lifted, lists } = liftInboxRow({ defaultList: [item('a'), item('b')] });
+
+ expect(lifted).toBeUndefined();
+ expect(lists.defaultList.map((i) => i.id)).toEqual(['a', 'b']);
+ });
+});
+
+describe('withoutInboxInGroups', () => {
+ it('takes Lobe AI out of the folder it was moved into', () => {
+ const { groups, inbox: lifted } = withoutInboxInGroups([
+ { id: 'g1', items: [item('x')] },
+ { id: 'g2', items: [inbox, item('y')] },
+ ]);
+
+ expect(lifted).toBe(inbox);
+ expect(groups.map((g) => g.items.map((i) => i.id))).toEqual([['x'], ['y']]);
+ });
+});
diff --git a/src/features/HomeSidebar/Body/Agent/List/inboxRow.ts b/src/features/HomeSidebar/Body/Agent/List/inboxRow.ts
new file mode 100644
index 00000000000..da3299b53ab
--- /dev/null
+++ b/src/features/HomeSidebar/Body/Agent/List/inboxRow.ts
@@ -0,0 +1,49 @@
+import { INBOX_SESSION_ID } from '@lobechat/const';
+import type { SidebarAgentItem } from '@lobechat/types';
+
+const isInboxRow = (item: Pick<SidebarAgentItem, 'slug'>) => item.slug === INBOX_SESSION_ID;
+
+export interface LiftedInboxRow<T extends Record<string, SidebarAgentItem[]>> {
+ /** Lobe AI's row, when any of the lists carries it. */
+ inbox?: SidebarAgentItem;
+ /** The same lists with Lobe AI taken out. */
+ lists: T;
+}
+
+/**
+ * Lobe AI (the inbox), the default Agent, always leads the sidebar. It arrives
+ * as an ordinary list item, so it can be pinned, filed in a folder or hidden
+ * like any Agent; this takes its row out of whichever lists hold it so the
+ * caller can render it first. A hidden Lobe AI is already gone from the lists
+ * and stays gone.
+ */
+export const liftInboxRow = <T extends Record<string, SidebarAgentItem[]>>(
+ lists: T,
+): LiftedInboxRow<T> => {
+ let inbox: SidebarAgentItem | undefined;
+ const out = {} as Record<string, SidebarAgentItem[]>;
+
+ for (const [key, list] of Object.entries(lists)) {
+ out[key] = list.filter((item) => {
+ if (!isInboxRow(item)) return true;
+ inbox ??= item;
+ return false;
+ });
+ }
+
+ return { inbox, lists: out as T };
+};
+
+/** {@link liftInboxRow} for folders: their items lose Lobe AI's row. */
+export const withoutInboxInGroups = <G extends { items: SidebarAgentItem[] }>(
+ groups: G[],
+): { groups: G[]; inbox?: SidebarAgentItem } => {
+ let inbox: SidebarAgentItem | undefined;
+ const out = groups.map((group) => {
+ const { inbox: found, lists } = liftInboxRow({ items: group.items });
+ inbox ??= found;
+ return found ? { ...group, items: lists.items } : group;
+ });
+
+ return { groups: out, inbox };
+};
diff --git a/src/features/HomeSidebar/Body/Agent/List/useAgentList.tsx b/src/features/HomeSidebar/Body/Agent/List/useAgentList.tsx
index f222304323e..7ee60370ee2 100644
--- a/src/features/HomeSidebar/Body/Agent/List/useAgentList.tsx
+++ b/src/features/HomeSidebar/Body/Agent/List/useAgentList.tsx
@@ -10,6 +10,7 @@ import { homeAgentListSelectors } from '@/store/home/selectors';
import { useSidebarGroupVisibility } from '../useSidebarGroupVisibility';
import { useSidebarItemVisibility } from '../useSidebarItemVisibility';
+import { liftInboxRow, withoutInboxInGroups } from './inboxRow';
/**
* Filter predicate over the caller's effective sidebar membership: legacy
@@ -63,18 +64,35 @@ export const useAgentList = (limitDefault = true) => {
const keepGroups = useKeepSidebarGroupsListed();
return useMemo(() => {
+ // Filter BEFORE the page-size cut so an unpin doesn't shrink the page.
const filteredUngrouped = keep(ungroupedAgents);
+ // Cut BEFORE lifting Lobe AI out, so the page (Lobe AI included) matches the
+ // "More" row's count of the whole ungrouped list.
+ const pageUngrouped = limitDefault
+ ? filteredUngrouped.slice(0, agentPageSize)
+ : filteredUngrouped;
- return {
- customList: keepGroups(agentGroups).map((group) => ({ ...group, items: keep(group.items) })),
- // Filter BEFORE the page-size cut so an unpin doesn't shrink the page.
- defaultList: limitDefault ? filteredUngrouped.slice(0, agentPageSize) : filteredUngrouped,
+ // Lobe AI (the inbox) leads the sidebar wherever its row sits, so it is
+ // taken out of the sections and returned on its own.
+ const custom = withoutInboxInGroups(
+ keepGroups(agentGroups).map((group) => ({ ...group, items: keep(group.items) })),
+ );
+ const privateGroups = withoutInboxInGroups(
+ keepGroups(privateAgentGroups).map((group) => ({ ...group, items: keep(group.items) })),
+ );
+ const { inbox, lists } = liftInboxRow({
+ defaultList: pageUngrouped,
pinnedList: keep(pinnedAgents),
- privateGroupList: keepGroups(privateAgentGroups).map((group) => ({
- ...group,
- items: keep(group.items),
- })),
privateUngroupedList: keep(privateUngroupedAgents),
+ });
+
+ return {
+ customList: custom.groups,
+ defaultList: lists.defaultList,
+ inboxItem: inbox ?? custom.inbox ?? privateGroups.inbox,
+ pinnedList: lists.pinnedList,
+ privateGroupList: privateGroups.groups,
+ privateUngroupedList: lists.privateUngroupedList,
};
}, [
agentGroups,
diff --git a/src/features/HomeSidebar/Body/Agent/List/workspaceAgentSections.test.ts b/src/features/HomeSidebar/Body/Agent/List/workspaceAgentSections.test.ts
index 0ebf3919560..9f8bbe506d4 100644
--- a/src/features/HomeSidebar/Body/Agent/List/workspaceAgentSections.test.ts
+++ b/src/features/HomeSidebar/Body/Agent/List/workspaceAgentSections.test.ts
@@ -55,6 +55,18 @@ describe('isListedInWorkspaceSidebar', () => {
);
});
+ it('lists the shared Lobe AI for every member until they hide it', () => {
+ const inbox = item('inbox-agent', 'public', '2026-01-01', { slug: 'inbox' });
+
+ expect(isListedInWorkspaceSidebar(inbox, membership)).toBe(true);
+ expect(
+ isListedInWorkspaceSidebar(inbox, {
+ ...membership,
+ visibilityOverrides: { 'inbox-agent': false },
+ }),
+ ).toBe(false);
+ });
+
it('leaves a teammate’s shared row on the Agents page until the member adds it', () => {
expect(isListedInWorkspaceSidebar(item('t', 'public', '2026-01-01'), membership)).toBe(false);
});
@@ -178,3 +190,17 @@ describe('resolveWorkspaceAgentSections', () => {
expect(ids(sections.myPinned)).toEqual(['p']);
});
});
+
+describe('resolveWorkspaceAgentSections with Lobe AI', () => {
+ it('leads the rest with Lobe AI even when other rows are newer', () => {
+ const sections = resolveWorkspaceAgentSections({
+ ...base,
+ ungrouped: [
+ item('newer', 'public', '2026-03-01', mine),
+ item('inbox-agent', 'public', '2020-01-01', { slug: 'inbox' }),
+ ],
+ });
+
+ expect(ids(sections.rest)).toEqual(['inbox-agent', 'newer']);
+ });
+});
diff --git a/src/features/HomeSidebar/Body/Agent/List/workspaceAgentSections.ts b/src/features/HomeSidebar/Body/Agent/List/workspaceAgentSections.ts
index fc663899764..1e9b11323b0 100644
--- a/src/features/HomeSidebar/Body/Agent/List/workspaceAgentSections.ts
+++ b/src/features/HomeSidebar/Body/Agent/List/workspaceAgentSections.ts
@@ -1,3 +1,4 @@
+import { INBOX_SESSION_ID } from '@lobechat/const';
import type { SidebarAgentItem, SidebarGroup } from '@lobechat/types';
export interface WorkspaceSidebarMembership {
@@ -40,6 +41,12 @@ export interface WorkspaceAgentSections {
const updatedAtMs = (item: SidebarAgentItem) => new Date(item.updatedAt).getTime() || 0;
+const isInbox = (item: Pick<SidebarAgentItem, 'slug'>) => item.slug === INBOX_SESSION_ID;
+
+/** Newest first, with Lobe AI (the inbox), the default Agent, leading. */
+const byInboxThenRecency = (a: SidebarAgentItem, b: SidebarAgentItem) =>
+ Number(isInbox(b)) - Number(isInbox(a)) || updatedAtMs(b) - updatedAtMs(a);
+
/**
* Whether a row outside the pinned sections belongs in the member's sidebar.
*
@@ -50,15 +57,22 @@ const updatedAtMs = (item: SidebarAgentItem) => new Date(item.updatedAt).getTime
* row menu or the Agents page (`sidebarAgentVisibilityOverrides`) always wins;
* the release seeded such choices once for the shared rows each member was
* using. The legacy hidden-id list is applied separately by the caller.
+ *
+ * Lobe AI (the inbox) is the workspace's one shared default Agent, created by
+ * whichever member opened it first, so it is listed for everyone by default.
*/
export const isListedInWorkspaceSidebar = (
- item: Pick<SidebarAgentItem, 'id' | 'userId' | 'visibility'>,
+ item: Pick<SidebarAgentItem, 'id' | 'slug' | 'userId' | 'visibility'>,
{ currentUserId, visibilityOverrides }: WorkspaceSidebarMembership,
): boolean => {
const override = visibilityOverrides[item.id];
if (override !== undefined) return override;
- return item.visibility === 'private' || (!!currentUserId && item.userId === currentUserId);
+ return (
+ isInbox(item) ||
+ item.visibility === 'private' ||
+ (!!currentUserId && item.userId === currentUserId)
+ );
};
/**
@@ -73,8 +87,8 @@ export const isListedInWorkspaceSidebar = (
* 3. Folders β€” only the member's private folders. Public folders are shared
* catalogue structure browsed on the Agents page.
* 4. The rest β€” rows outside the private folders (including rows inside a
- * public folder) that {@link isListedInWorkspaceSidebar} keeps, newest
- * first.
+ * public folder) that {@link isListedInWorkspaceSidebar} keeps, Lobe AI
+ * first, then newest first.
*
* Every row appears at most once.
*/
@@ -127,7 +141,7 @@ export const resolveWorkspaceAgentSections = ({
const membership = { currentUserId, visibilityOverrides };
const rest = [...ungrouped, ...privateUngrouped, ...publicFolderItems]
.filter((item) => notPinned(item) && isListedInWorkspaceSidebar(item, membership))
- .sort((a, b) => updatedAtMs(b) - updatedAtMs(a));
+ .sort(byInboxThenRecency);
return { folders, myPinned, rest, teamPinned };
};
diff --git a/src/features/MobileHome/SessionListContent/DefaultMode.tsx b/src/features/MobileHome/SessionListContent/DefaultMode.tsx
index 04ca0762559..fdcd6727508 100644
--- a/src/features/MobileHome/SessionListContent/DefaultMode.tsx
+++ b/src/features/MobileHome/SessionListContent/DefaultMode.tsx
@@ -32,9 +32,10 @@ const DefaultMode = memo(() => {
}>({ open: false, scope: 'public' });
const isLogin = useUserStore(authSelectors.isLogin);
+ const hasInboxAgent = useHomeStore(homeAgentListSelectors.hasInboxAgent);
const useFetchAgentList = useHomeStore((s) => s.useFetchAgentList);
useFetchAgentList(isLogin);
- const { defaultList, pinnedList, customList, privateGroupList, privateUngroupedList } =
+ const { defaultList, inboxItem, pinnedList, customList, privateGroupList, privateUngroupedList } =
useAgentList(false);
const keep = useKeepSidebarListed();
const privatePinned = useHomeStore(homeAgentListSelectors.privatePinnedAgents, isEqual);
@@ -94,7 +95,11 @@ const DefaultMode = memo(() => {
return (
<>
<FeatureNav />
- <Inbox />
+ {/* Signed in, Lobe AI arrives as an ordinary list item from the server;
+ the standalone entry stands in until that list holds it. */}
+ {!hasInboxAgent && <Inbox />}
+ {/* Lobe AI's own row leads the list wherever it is pinned or filed. */}
+ {inboxItem && <SessionList dataSource={[inboxItem]} />}
<CollapseGroup
activeKey={sessionGroupKeys}
items={items}
diff --git a/src/features/MobileHome/SessionListContent/List/Item/Actions.tsx b/src/features/MobileHome/SessionListContent/List/Item/Actions.tsx
index b6143df8f1f..7ea0e246b5c 100644
--- a/src/features/MobileHome/SessionListContent/List/Item/Actions.tsx
+++ b/src/features/MobileHome/SessionListContent/List/Item/Actions.tsx
@@ -1,3 +1,4 @@
+import { INBOX_SESSION_ID } from '@lobechat/const';
import { type SidebarAgentItem } from '@lobechat/types';
import {
ActionIcon,
@@ -81,7 +82,7 @@ const Actions = ({
await refreshAgentList();
} else await updateAgentGroup(item.id, target);
});
- const items: DropdownItem[] = [
+ const organizeItems: DropdownItem[] = [
{
key: 'pin',
title: editReason,
@@ -137,6 +138,8 @@ const Actions = ({
},
],
},
+ ];
+ const deleteItems: DropdownItem[] = [
{ type: 'divider' },
{
key: 'delete',
@@ -181,6 +184,12 @@ const Actions = ({
},
},
];
+ // Lobe AI (the inbox) is the built-in default Agent: it cannot be deleted,
+ // and a copy would come out nameless (its stored title is blank).
+ const items =
+ item.slug === INBOX_SESSION_ID
+ ? organizeItems.filter((menuItem) => menuItem?.key !== 'duplicate')
+ : [...organizeItems, ...deleteItems];
return (
<div
role="presentation"
diff --git a/src/routes/(popup)/agent/[aid]/QuickChatAgentSwitcher.tsx b/src/routes/(popup)/agent/[aid]/QuickChatAgentSwitcher.tsx
index c16ca5f59ba..8432d00fbc3 100644
--- a/src/routes/(popup)/agent/[aid]/QuickChatAgentSwitcher.tsx
+++ b/src/routes/(popup)/agent/[aid]/QuickChatAgentSwitcher.tsx
@@ -116,7 +116,10 @@ const useSwitchItems = (): SwitchItem[] => {
title: agentDisplayName(a, 'Untitled'),
});
- const isAgent = (a: SidebarAgentItem): boolean => a.type === 'agent';
+ // The inbox leads as its own entry (routed by slug), so its list item β€”
+ // keyed by the real agent id, which the dedup below would miss β€” is dropped.
+ const isAgent = (a: SidebarAgentItem): boolean =>
+ a.type === 'agent' && a.slug !== INBOX_SESSION_ID;
const merged = [
inbox,
diff --git a/src/services/home/index.ts b/src/services/home/index.ts
index ee81c38e496..3e2679158c0 100644
--- a/src/services/home/index.ts
+++ b/src/services/home/index.ts
@@ -15,7 +15,7 @@ export class HomeService {
* Get sidebar agent list with pinned, grouped, and ungrouped items
*/
getSidebarAgentList = (): Promise<SidebarAgentListResponse> => {
- return lambdaClient.home.getSidebarAgentList.query();
+ return lambdaClient.home.getSidebarAgentList.query({ includeInbox: true });
};
/**
@@ -30,7 +30,7 @@ export class HomeService {
* Search agents by keyword
*/
searchAgents = (keyword: string): Promise<SidebarAgentItem[]> => {
- return lambdaClient.home.searchAgents.query({ keyword });
+ return lambdaClient.home.searchAgents.query({ includeInbox: true, keyword });
};
/**
diff --git a/src/store/home/slices/agentList/selectors.test.ts b/src/store/home/slices/agentList/selectors.test.ts
index dedbfe34523..6cb976fca91 100644
--- a/src/store/home/slices/agentList/selectors.test.ts
+++ b/src/store/home/slices/agentList/selectors.test.ts
@@ -43,3 +43,19 @@ describe('homeAgentListSelectors - private pinned', () => {
expect(homeAgentListSelectors.allAgents(state).map((a) => a.id)).toContain('a1');
});
});
+
+describe('homeAgentListSelectors.hasInboxAgent', () => {
+ it('finds Lobe AI in any bucket', () => {
+ const inbox = { ...agent('inbox-agent'), slug: 'inbox' };
+
+ expect(
+ homeAgentListSelectors.hasInboxAgent(createState({ ungroupedAgents: [agent('a')] })),
+ ).toBe(false);
+ expect(homeAgentListSelectors.hasInboxAgent(createState({ pinnedAgents: [inbox] }))).toBe(true);
+ expect(
+ homeAgentListSelectors.hasInboxAgent(
+ createState({ agentGroups: [{ id: 'g', items: [inbox], name: 'g' } as any] }),
+ ),
+ ).toBe(true);
+ });
+});
diff --git a/src/store/home/slices/agentList/selectors.ts b/src/store/home/slices/agentList/selectors.ts
index 135542b7718..e620af25d77 100644
--- a/src/store/home/slices/agentList/selectors.ts
+++ b/src/store/home/slices/agentList/selectors.ts
@@ -1,3 +1,5 @@
+import { INBOX_SESSION_ID } from '@lobechat/const';
+
import { type SidebarAgentItem, type SidebarGroup } from '@/database/repositories/home';
import { type HomeStore } from '@/store/home/store';
@@ -95,6 +97,14 @@ const allAgents = (s: HomeStore): SidebarAgentItem[] => {
];
};
+/**
+ * Whether the loaded list carries Lobe AI (the inbox). It can be missing from a
+ * list cached before the server started returning it, or one fetched before
+ * the inbox row was first created.
+ */
+const hasInboxAgent = (s: HomeStore): boolean =>
+ allAgents(s).some((item) => item.slug === INBOX_SESSION_ID);
+
/**
* Agents every workspace member can see: the sidebar list without the
* current user's private bucket.
@@ -134,6 +144,7 @@ export const homeAgentListSelectors = {
allAgents,
getAgentById,
hasCustomAgents,
+ hasInboxAgent,
hasPrivateAgents,
isAgentListConfirmed,
isAgentListInit,