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: patch for CMDK and Resource (#11812)

René Wangb112f6ecf73c
diff --git a/locales/en-US/common.json b/locales/en-US/common.json
index b13e959b27c..88d85c982e6 100644
--- a/locales/en-US/common.json
+++ b/locales/en-US/common.json
@@ -165,6 +165,30 @@
"cmdk.themeLight": "Light",
"cmdk.toOpen": "Open",
"cmdk.toSelect": "Select",
+ "cmdk.keywords.contactUs": "feedback issue bug problem",
+ "cmdk.keywords.submitIssue": "issue bug problem feedback",
+ "cmdk.keywords.starGitHub": "github star favorite like",
+ "cmdk.keywords.discord": "discord help support customer service",
+ "cmdk.keywords.community": "discover market assistant model provider mcp",
+ "cmdk.keywords.painting": "painting art generate draw",
+ "cmdk.keywords.resources": "knowledge files library documents",
+ "cmdk.keywords.pages": "documents write notes",
+ "cmdk.keywords.memory": "identities contexts preferences experiences",
+ "cmdk.keywords.settings": "settings preferences configuration options",
+ "cmdk.keywords.profile": "profile user account personal",
+ "cmdk.keywords.appearance": "common appearance theme display",
+ "cmdk.keywords.provider": "provider llm model ai",
+ "cmdk.keywords.hotkey": "hotkey shortcut keyboard",
+ "cmdk.keywords.image": "image picture photo",
+ "cmdk.keywords.proxy": "proxy network connection",
+ "cmdk.keywords.stats": "stats statistics analytics",
+ "cmdk.keywords.apikey": "apikey api key token",
+ "cmdk.keywords.about": "about version info",
+ "cmdk.keywords.plans": "subscription plan upgrade pricing",
+ "cmdk.keywords.funds": "funds balance credit money",
+ "cmdk.keywords.usage": "usage statistics consumption quota",
+ "cmdk.keywords.billing": "billing payment invoice transaction",
+ "cmdk.keywords.referral": "referral rewards invite bonus",
"confirm": "Confirm",
"contact": "Contact Us",
"copy": "Copy",
diff --git a/locales/zh-CN/common.json b/locales/zh-CN/common.json
index e85662b753c..dcb40fdcab1 100644
--- a/locales/zh-CN/common.json
+++ b/locales/zh-CN/common.json
@@ -165,6 +165,30 @@
"cmdk.themeLight": "浅色模式",
"cmdk.toOpen": "打开",
"cmdk.toSelect": "选择",
+ "cmdk.keywords.contactUs": "反馈 问题 错误 建议 联系",
+ "cmdk.keywords.submitIssue": "问题 错误 反馈 建议 提交",
+ "cmdk.keywords.starGitHub": "github star 收藏 喜欢 点赞",
+ "cmdk.keywords.discord": "discord 帮助 支持 客服 社区",
+ "cmdk.keywords.community": "发现 市场 助理 模型 提供商 mcp",
+ "cmdk.keywords.painting": "绘画 艺术 生成 画图 绘图",
+ "cmdk.keywords.resources": "知识 文件 库 文档 资源",
+ "cmdk.keywords.pages": "文档 写作 笔记 文稿",
+ "cmdk.keywords.memory": "身份 上下文 偏好 经验 记忆",
+ "cmdk.keywords.settings": "设置 偏好 配置 选项",
+ "cmdk.keywords.profile": "个人资料 用户 账户 账号",
+ "cmdk.keywords.appearance": "通用 外观 主题 显示",
+ "cmdk.keywords.provider": "提供商 llm 模型 ai 大模型",
+ "cmdk.keywords.hotkey": "热键 快捷键 键盘",
+ "cmdk.keywords.image": "图像 图片 照片",
+ "cmdk.keywords.proxy": "代理 网络 连接",
+ "cmdk.keywords.stats": "统计 数据 分析",
+ "cmdk.keywords.apikey": "apikey api 密钥 令牌",
+ "cmdk.keywords.about": "关于 版本 信息",
+ "cmdk.keywords.plans": "订阅 计划 升级 定价 会员",
+ "cmdk.keywords.funds": "资金 余额 积分 充值",
+ "cmdk.keywords.usage": "用量 统计 消耗 配额",
+ "cmdk.keywords.billing": "账单 支付 发票 交易",
+ "cmdk.keywords.referral": "推荐 奖励 邀请 返利",
"confirm": "确认",
"contact": "联系我们",
"copy": "复制",
diff --git a/packages/database/src/repositories/search/index.ts b/packages/database/src/repositories/search/index.ts
index 250974d4c43..8abe0910677 100644
--- a/packages/database/src/repositories/search/index.ts
+++ b/packages/database/src/repositories/search/index.ts
@@ -1,6 +1,14 @@
import { sql } from 'drizzle-orm';
-import { agents, documents, files, knowledgeBaseFiles, messages, topics } from '../../schemas';
+import {
+ agents,
+ documents,
+ files,
+ knowledgeBaseFiles,
+ messages,
+ topics,
+ userMemories,
+} from '../../schemas';
import { LobeChatDatabase } from '../../type';
export type SearchResultType =
@@ -76,6 +84,11 @@ export interface MessageSearchResult extends BaseSearchResult {
type: 'message';
}
+export interface MemorySearchResult extends BaseSearchResult {
+ memoryLayer: string | null;
+ type: 'memory';
+}
+
export interface MCPSearchResult extends BaseSearchResult {
author: string;
avatar?: string | null;
@@ -115,6 +128,7 @@ export type SearchResult =
| FileSearchResult
| FolderSearchResult
| MessageSearchResult
+ | MemorySearchResult
| MCPSearchResult
| PluginSearchResult
| AssistantSearchResult;
@@ -181,6 +195,9 @@ export class SearchRepo {
if ((!type || type === 'page') && limits.page > 0) {
queries.push(this.buildPageQuery(searchTerm, exactQuery, prefixQuery, limits.page));
}
+ if ((!type || type === 'memory') && limits.memory > 0) {
+ queries.push(this.buildMemoryQuery(searchTerm, exactQuery, prefixQuery, limits.memory));
+ }
if (queries.length === 0) return [];
@@ -215,6 +232,7 @@ export class SearchRepo {
agent: number;
file: number;
folder: number;
+ memory: number;
message: number;
page: number;
pageContent: number;
@@ -226,6 +244,7 @@ export class SearchRepo {
agent: type === 'agent' ? baseLimit : 0,
file: type === 'file' ? baseLimit : 0,
folder: type === 'folder' ? baseLimit : 0,
+ memory: type === 'memory' ? baseLimit : 0,
message: type === 'message' ? baseLimit : 0,
page: type === 'page' ? baseLimit : 0,
pageContent: type === 'pageContent' ? baseLimit : 0,
@@ -239,6 +258,7 @@ export class SearchRepo {
agent: 3,
file: 3,
folder: 3,
+ memory: 3,
message: 3,
page: 6,
pageContent: 0, // Not available yet
@@ -252,6 +272,7 @@ export class SearchRepo {
agent: 3,
file: 6,
folder: 6,
+ memory: 3,
message: 3,
page: 3,
pageContent: 0, // Not available yet
@@ -265,6 +286,7 @@ export class SearchRepo {
agent: 3,
file: 3,
folder: 3,
+ memory: 3,
message: 6,
page: 3,
pageContent: 0, // Not available yet
@@ -277,6 +299,7 @@ export class SearchRepo {
agent: 3,
file: 3,
folder: 3,
+ memory: 3,
message: 3,
page: 3,
pageContent: 0, // Not available yet
@@ -756,6 +779,57 @@ export class SearchRepo {
`;
}
+ /**
+ * Build memory search query
+ * Searches: title, summary, details
+ */
+ private buildMemoryQuery(
+ searchTerm: string,
+ exactQuery: string,
+ prefixQuery: string,
+ limit: number,
+ ): ReturnType<typeof sql> {
+ return sql`
+ SELECT
+ m.id,
+ 'memory' as type,
+ COALESCE(m.title, 'Untitled Memory') as title,
+ CASE
+ WHEN length(COALESCE(m.summary, '')) > 200 THEN substring(COALESCE(m.summary, ''), 1, 200) || '...'
+ ELSE m.summary
+ END as description,
+ NULL::varchar(100) as slug,
+ NULL::text as avatar,
+ NULL::text as background_color,
+ NULL::jsonb as tags,
+ m.created_at,
+ m.updated_at,
+ CASE
+ WHEN COALESCE(m.title, '') ILIKE ${exactQuery} THEN 1
+ WHEN COALESCE(m.title, '') ILIKE ${prefixQuery} THEN 2
+ ELSE 3
+ END as relevance,
+ NULL::boolean as favorite,
+ NULL::text as session_id,
+ NULL::text as agent_id,
+ NULL::text as name,
+ NULL::varchar(255) as file_type,
+ NULL::integer as size,
+ NULL::text as url,
+ NULL::text as knowledge_base_id,
+ m.memory_layer
+ FROM ${userMemories} m
+ WHERE m.user_id = ${this.userId}
+ AND (
+ COALESCE(m.title, '') ILIKE ${searchTerm}
+ OR COALESCE(m.summary, '') ILIKE ${searchTerm}
+ OR COALESCE(m.details, '') ILIKE ${searchTerm}
+ )
+ ORDER BY relevance ASC, m.updated_at DESC
+ LIMIT ${limit}
+ `;
+ }
+
/**
* Map raw SQL results to typed SearchResult objects
* Parse JSONB strings and convert snake_case to camelCase
@@ -848,6 +922,13 @@ export class SearchRepo {
type: 'message' as const,
};
}
+ case 'memory': {
+ return {
+ ...base,
+ memoryLayer: row.memory_layer,
+ type: 'memory' as const,
+ };
+ }
default: {
throw new Error(`Unknown search result type: ${row.type}`);
}
diff --git a/src/app/[variants]/(main)/resource/(home)/index.tsx b/src/app/[variants]/(main)/resource/(home)/index.tsx
index ee1f7599ecd..7b6853c0efe 100644
--- a/src/app/[variants]/(main)/resource/(home)/index.tsx
+++ b/src/app/[variants]/(main)/resource/(home)/index.tsx
@@ -12,7 +12,10 @@ import { useResourceManagerStore } from '../features/store';
const ResourceHomePage = memo(() => {
const [searchParams] = useSearchParams();
const location = useLocation();
- const [setCategory, setLibraryId] = useResourceManagerStore((s) => [s.setCategory, s.setLibraryId]);
+ const [setCategory, setLibraryId] = useResourceManagerStore((s) => [
+ s.setCategory,
+ s.setLibraryId,
+ ]);
const categoryParam = (searchParams.get('category') as FilesTabs) || FilesTabs.All;
diff --git a/src/app/[variants]/(main)/resource/library/_layout/Header/LibraryHead.tsx b/src/app/[variants]/(main)/resource/library/_layout/Header/LibraryHead.tsx
index 3ee2002f581..5bdac9f8e60 100644
--- a/src/app/[variants]/(main)/resource/library/_layout/Header/LibraryHead.tsx
+++ b/src/app/[variants]/(main)/resource/library/_layout/Header/LibraryHead.tsx
@@ -33,6 +33,9 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
`,
}));
+/**
+ * Quickly switch between libraries
+ */
const Head = memo<{ id: string }>(({ id }) => {
const navigate = useNavigate();
const name = useKnowledgeBaseStore(knowledgeBaseSelectors.getKnowledgeBaseNameById(id));
diff --git a/src/app/[variants]/(main)/resource/library/_layout/Header/index.tsx b/src/app/[variants]/(main)/resource/library/_layout/Header/index.tsx
index 09c336883fc..20819b1727f 100644
--- a/src/app/[variants]/(main)/resource/library/_layout/Header/index.tsx
+++ b/src/app/[variants]/(main)/resource/library/_layout/Header/index.tsx
@@ -13,9 +13,10 @@ const Header = memo(() => {
const { t } = useTranslation('common');
return (
<SideBarHeaderLayout
+ backTo="/resource"
breadcrumb={[
{
- href: '/resource',
+ href: `/resource/library/${id}`,
title: t('tab.resource'),
},
]}
diff --git a/src/components/DragUpload/index.tsx b/src/components/DragUpload/index.tsx
index ffedaffc8d9..37f327a473d 100644
--- a/src/components/DragUpload/index.tsx
+++ b/src/components/DragUpload/index.tsx
@@ -83,7 +83,7 @@ const DragUpload = memo<DragUploadProps>(({ enabledFiles = true, onUploadFiles }
const isDragging = useDragUpload(onUploadFiles);
- if (!isDragging) return;
+ if (isDragging) return;
return createPortal(
<Center className={styles.wrapper}>
diff --git a/src/config/routes/index.ts b/src/config/routes/index.ts
index 98ae775957e..f16e5821b4f 100644
--- a/src/config/routes/index.ts
+++ b/src/config/routes/index.ts
@@ -17,8 +17,10 @@ export interface NavigationRoute {
icon: LucideIcon;
/** Unique route identifier */
id: string;
- /** Keywords for CMDK search */
+ /** Keywords for CMDK search (fallback) */
keywords?: string[];
+ /** i18n key for CMDK keywords in common namespace */
+ keywordsKey?: string;
/** Route path */
path: string;
/** Path prefix for checking current location */
@@ -38,6 +40,7 @@ export const NAVIGATION_ROUTES: NavigationRoute[] = [
icon: ShapesIcon,
id: 'community',
keywords: ['discover', 'market', 'assistant', 'model', 'provider', 'mcp'],
+ keywordsKey: 'cmdk.keywords.community',
path: '/community',
pathPrefix: '/community',
},
@@ -47,6 +50,7 @@ export const NAVIGATION_ROUTES: NavigationRoute[] = [
icon: Image,
id: 'image',
keywords: ['painting', 'art', 'generate', 'draw'],
+ keywordsKey: 'cmdk.keywords.painting',
path: '/image',
pathPrefix: '/image',
},
@@ -56,6 +60,7 @@ export const NAVIGATION_ROUTES: NavigationRoute[] = [
icon: LibraryBigIcon,
id: 'resource',
keywords: ['knowledge', 'files', 'library', 'documents'],
+ keywordsKey: 'cmdk.keywords.resources',
path: '/resource',
pathPrefix: '/resource',
},
@@ -65,6 +70,7 @@ export const NAVIGATION_ROUTES: NavigationRoute[] = [
icon: FilePenIcon,
id: 'page',
keywords: ['documents', 'write', 'notes'],
+ keywordsKey: 'cmdk.keywords.pages',
path: '/page',
pathPrefix: '/page',
useDynamicTitle: true,
@@ -75,6 +81,7 @@ export const NAVIGATION_ROUTES: NavigationRoute[] = [
icon: BrainCircuit,
id: 'memory',
keywords: ['identities', 'contexts', 'preferences', 'experiences'],
+ keywordsKey: 'cmdk.keywords.memory',
path: '/memory',
pathPrefix: '/memory',
},
@@ -84,6 +91,7 @@ export const NAVIGATION_ROUTES: NavigationRoute[] = [
icon: Settings,
id: 'settings',
keywords: ['settings', 'preferences', 'configuration', 'options'],
+ keywordsKey: 'cmdk.keywords.settings',
path: '/settings',
pathPrefix: '/settings',
},
diff --git a/src/features/CommandMenu/ContextCommands.tsx b/src/features/CommandMenu/ContextCommands.tsx
index 32fa26c18ce..32221b821f4 100644
--- a/src/features/CommandMenu/ContextCommands.tsx
+++ b/src/features/CommandMenu/ContextCommands.tsx
@@ -56,7 +56,11 @@ const ContextCommands = memo(() => {
label = t(cmd.labelKey, { defaultValue: cmd.label });
}
}
- const searchValue = `${contextName} ${label} ${cmd.keywords.join(' ')}`;
+ // Get localized keywords
+ const keywords = cmd.keywordsKey
+ ? tCommon(cmd.keywordsKey as any, { defaultValue: cmd.keywords.join(' ') })
+ : cmd.keywords.join(' ');
+ const searchValue = `${contextName} ${label} ${keywords}`;
return (
<CommandItem
@@ -98,7 +102,11 @@ const ContextCommands = memo(() => {
label = t(cmd.labelKey, { defaultValue: cmd.label });
}
}
- const searchValue = `${settingsContextName} ${label} ${cmd.keywords.join(' ')}`;
+ // Get localized keywords
+ const keywords = cmd.keywordsKey
+ ? tCommon(cmd.keywordsKey as any, { defaultValue: cmd.keywords.join(' ') })
+ : cmd.keywords.join(' ');
+ const searchValue = `${settingsContextName} ${label} ${keywords}`;
return (
<CommandItem
diff --git a/src/features/CommandMenu/MainMenu.tsx b/src/features/CommandMenu/MainMenu.tsx
index 0de95768235..7461c23dfbd 100644
--- a/src/features/CommandMenu/MainMenu.tsx
+++ b/src/features/CommandMenu/MainMenu.tsx
@@ -3,10 +3,10 @@ import { DiscordIcon } from '@lobehub/ui/icons';
import { Command } from 'cmdk';
import {
Bot,
+ FeatherIcon,
FilePen,
Github,
LibraryBig,
- MailIcon,
MessageSquarePlusIcon,
Monitor,
Star,
@@ -85,20 +85,24 @@ const MainMenu = memo(() => {
{t('cmdk.newLibrary')}
</CommandItem>
- {menuContext !== 'settings' && (() => {
- const settingsRoute = getRouteById('settings');
- const SettingsIcon = settingsRoute?.icon;
- return (
- <CommandItem
- icon={SettingsIcon && <SettingsIcon />}
- keywords={settingsRoute?.keywords}
- onSelect={() => handleNavigate(settingsRoute?.path || '/settings')}
- value="settings"
- >
- {t('cmdk.settings')}
- </CommandItem>
- );
- })()}
+ {menuContext !== 'settings' &&
+ (() => {
+ const settingsRoute = getRouteById('settings');
+ const SettingsIcon = settingsRoute?.icon;
+ const keywords = settingsRoute?.keywordsKey
+ ? t(settingsRoute.keywordsKey as any).split(' ')
+ : settingsRoute?.keywords;
+ return (
+ <CommandItem
+ icon={SettingsIcon && <SettingsIcon />}
+ keywords={keywords}
+ onSelect={() => handleNavigate(settingsRoute?.path || '/settings')}
+ value="settings"
+ >
+ {t('cmdk.settings')}
+ </CommandItem>
+ );
+ })()}
<CommandItem
icon={<Monitor />}
@@ -112,12 +116,15 @@ const MainMenu = memo(() => {
<Command.Group heading={t('cmdk.navigate')}>
{getNavigableRoutes().map((route) => {
const RouteIcon = route.icon;
+ const keywords = route.keywordsKey
+ ? t(route.keywordsKey as any).split(' ')
+ : route.keywords;
return (
!pathname?.startsWith(route.pathPrefix) && (
<CommandItem
icon={<RouteIcon />}
key={route.id}
- keywords={route.keywords}
+ keywords={keywords}
onSelect={() => handleNavigate(route.path)}
value={route.id}
>
@@ -130,16 +137,16 @@ const MainMenu = memo(() => {
<Command.Group heading={t('cmdk.about')}>
<CommandItem
- icon={<MailIcon />}
- keywords={['feedback', 'issue', 'bug', 'problem']}
+ icon={<FeatherIcon />}
+ keywords={t('cmdk.keywords.contactUs').split(' ')}
onSelect={openFeedbackModal}
value="contact-via-email"
>
- {t('cmdk.contactViaEmail')}
+ {t('cmdk.contactUs')}
</CommandItem>
<CommandItem
icon={<Github />}
- keywords={['issue', 'bug', 'problem', 'feedback']}
+ keywords={t('cmdk.keywords.submitIssue').split(' ')}
onSelect={() => handleExternalLink(FEEDBACK)}
value="submit-issue"
>
@@ -147,7 +154,7 @@ const MainMenu = memo(() => {
</CommandItem>
<CommandItem
icon={<Star />}
- keywords={['github', 'star', 'favorite', 'like']}
+ keywords={t('cmdk.keywords.starGitHub').split(' ')}
onSelect={() => handleExternalLink(SOCIAL_URL.github)}
value="star-github"
>
@@ -155,7 +162,7 @@ const MainMenu = memo(() => {
</CommandItem>
<CommandItem
icon={<DiscordIcon />}
- keywords={['discord', 'help', 'support', 'customer service']}
+ keywords={t('cmdk.keywords.discord').split(' ')}
onSelect={() => handleExternalLink(SOCIAL_URL.discord)}
value="discord"
>
diff --git a/src/features/CommandMenu/SearchResults.tsx b/src/features/CommandMenu/SearchResults.tsx
index 3de421945ec..8e94dc1e0c8 100644
--- a/src/features/CommandMenu/SearchResults.tsx
+++ b/src/features/CommandMenu/SearchResults.tsx
@@ -2,6 +2,7 @@ import { Command } from 'cmdk';
import dayjs from 'dayjs';
import {
Bot,
+ Brain,
ChevronRight,
FileText,
Folder,
@@ -104,6 +105,10 @@ const SearchResults = memo<SearchResultsProps>(
navigate(`/community/agent/${result.identifier}`);
break;
}
+ case 'memory': {
+ navigate(`/memory`);
+ break;
+ }
}
onClose();
};
@@ -137,6 +142,9 @@ const SearchResults = memo<SearchResultsProps>(
case 'communityAgent': {
return <Bot size={16} />;
}
+ case 'memory': {
+ return <Brain size={16} />;
+ }
}
};
@@ -169,6 +177,9 @@ const SearchResults = memo<SearchResultsProps>(
case 'communityAgent': {
return t('cmdk.search.assistant');
}
+ case 'memory': {
+ return t('cmdk.search.memory');
+ }
}
};
@@ -219,6 +230,7 @@ const SearchResults = memo<SearchResultsProps>(
const fileResults = results.filter((r) => r.type === 'file');
const folderResults = results.filter((r) => r.type === 'folder');
const pageResults = results.filter((r) => r.type === 'page');
+ const memoryResults = results.filter((r) => r.type === 'memory');
const mcpResults = results.filter((r) => r.type === 'mcp');
const pluginResults = results.filter((r) => r.type === 'plugin');
const assistantResults = results.filter((r) => r.type === 'communityAgent');
@@ -328,6 +340,13 @@ const SearchResults = memo<SearchResultsProps>(
</Command.Group>
)}
+ {memoryResults.length > 0 && (
+ <Command.Group>
+ {memoryResults.map((result) => renderResultItem(result))}
+ {renderSearchMore('memory', memoryResults.length)}
+ </Command.Group>
+ )}
+
{fileResults.length > 0 && (
<Command.Group>
{fileResults.map((result) => renderResultItem(result))}
diff --git a/src/features/CommandMenu/components/CommandInput.tsx b/src/features/CommandMenu/components/CommandInput.tsx
index 3316a8f10e1..fb38b41a69f 100644
--- a/src/features/CommandMenu/components/CommandInput.tsx
+++ b/src/features/CommandMenu/components/CommandInput.tsx
@@ -83,6 +83,7 @@ const CommandInput = memo(() => {
)}
<Command.Input
autoFocus
+ maxLength={500}
onValueChange={setSearch}
placeholder={getPlaceholder()}
value={search}
diff --git a/src/features/CommandMenu/index.tsx b/src/features/CommandMenu/index.tsx
index 2af417a13eb..6e1a3b7efd8 100644
--- a/src/features/CommandMenu/index.tsx
+++ b/src/features/CommandMenu/index.tsx
@@ -3,7 +3,7 @@
import { Avatar } from '@lobehub/ui';
import { Command } from 'cmdk';
import { CornerDownLeft } from 'lucide-react';
-import { memo, useEffect, useState } from 'react';
+import { memo, useEffect, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';
@@ -37,9 +37,29 @@ const CommandMenuContent = memo(() => {
selectedAgent,
} = useCommandMenu();
- const { setPages, page, pages, search, setTypeFilter, setSelectedAgent, typeFilter } =
+ const { setPages, page, pages, search, setSearch, setTypeFilter, setSelectedAgent, typeFilter } =
useCommandMenuContext();
+ // Ref for Command.List to control scroll position
+ const listRef = useRef<HTMLDivElement>(null);
+ // State for controlled selection value (undefined lets cmdk auto-select first item)
+ const [value, setValue] = useState<string | undefined>();
+
+ // Reset scroll position and selection when search, page, or selectedAgent changes
+ useEffect(() => {
+ if (listRef.current) {
+ listRef.current.scrollTop = 0;
+ }
+ setValue(undefined);
+ }, [search, page, selectedAgent]);
+
+ // Clear search input when entering certain submenu pages (but not ask-ai)
+ useEffect(() => {
+ if (page && page !== 'ask-ai') {
+ setSearch('');
+ }
+ }, [page, setSearch]);
+
return (
<div className={styles.overlay} onClick={closeCommandMenu}>
<div onClick={(e) => e.stopPropagation()}>
@@ -80,11 +100,13 @@ const CommandMenuContent = memo(() => {
}
}
}}
+ onValueChange={setValue}
shouldFilter={page !== 'ask-ai' && !selectedAgent && !search.trimStart().startsWith('@')}
+ value={value}
>
<CommandInput />
- <Command.List>
+ <Command.List ref={listRef}>
<Command.Empty>{t('cmdk.noResults')}</Command.Empty>
{/* Show send command when agent is selected */}
diff --git a/src/features/CommandMenu/styles.ts b/src/features/CommandMenu/styles.ts
index d569d8a2805..95cc878103e 100644
--- a/src/features/CommandMenu/styles.ts
+++ b/src/features/CommandMenu/styles.ts
@@ -267,6 +267,7 @@ export const styles = createStaticStyles(({ css, cssVar }) => ({
inset: 0;
display: flex;
+ align-items: flex-start;
justify-content: center;
padding-block-start: 15vh;
diff --git a/src/features/CommandMenu/useCommandMenu.ts b/src/features/CommandMenu/useCommandMenu.ts
index 1e682936f7f..e13d46cf203 100644
--- a/src/features/CommandMenu/useCommandMenu.ts
+++ b/src/features/CommandMenu/useCommandMenu.ts
@@ -5,10 +5,12 @@ import { useNavigate } from 'react-router-dom';
import useSWR from 'swr';
import { useCreateMenuItems } from '@/app/[variants]/(main)/home/_layout/hooks';
+import { isDesktop } from '@/const/version';
import type { SearchResult } from '@/database/repositories/search';
import { useCreateNewModal } from '@/features/LibraryModal';
import { useGroupWizard } from '@/layout/GlobalProvider/GroupWizardProvider';
import { lambdaClient } from '@/libs/trpc/client';
+import { electronSystemService } from '@/services/electron/system';
import { useAgentStore } from '@/store/agent';
import { builtinAgentSelectors } from '@/store/agent/selectors/builtinAgentSelectors';
import { useChatStore } from '@/store/chat';
@@ -107,8 +109,12 @@ export const useCommandMenu = () => {
);
const handleExternalLink = useCallback(
- (url: string) => {
- window.open(url, '_blank', 'noopener,noreferrer');
+ async (url: string) => {
+ if (isDesktop) {
+ await electronSystemService.openExternalLink(url);
+ } else {
+ window.open(url, '_blank', 'noopener,noreferrer');
+ }
setOpen({ showCommandMenu: false });
},
[setOpen],
diff --git a/src/features/CommandMenu/utils/contextCommands.ts b/src/features/CommandMenu/utils/contextCommands.ts
index 0866554d4f5..9b14f38394a 100644
--- a/src/features/CommandMenu/utils/contextCommands.ts
+++ b/src/features/CommandMenu/utils/contextCommands.ts
@@ -22,9 +22,10 @@ import type { ContextType, MenuContext } from '../types';
export interface ContextCommand {
icon: LucideIcon;
keywords: string[];
+ keywordsKey?: string;
label: string;
- labelKey?: string; // i18n key for the label
- labelNamespace?: 'setting' | 'auth' | 'subscription'; // i18n namespace for the label
+ labelKey?: string;
+ labelNamespace?: 'setting' | 'auth' | 'subscription';
path: string;
subPath: string;
}
@@ -42,6 +43,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: UserCircle,
keywords: ['profile', 'user', 'account', 'personal'],
+ keywordsKey: 'cmdk.keywords.profile',
label: 'Profile',
labelKey: 'tab.profile',
labelNamespace: 'auth',
@@ -51,6 +53,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: PaletteIcon,
keywords: ['common', 'appearance', 'theme', 'display'],
+ keywordsKey: 'cmdk.keywords.appearance',
label: 'Appearance',
labelKey: 'tab.common',
labelNamespace: 'setting',
@@ -60,6 +63,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: Brain,
keywords: ['provider', 'llm', 'model', 'ai'],
+ keywordsKey: 'cmdk.keywords.provider',
label: 'Model Provider',
labelKey: 'tab.provider',
labelNamespace: 'setting',
@@ -69,6 +73,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: KeyboardIcon,
keywords: ['hotkey', 'shortcut', 'keyboard'],
+ keywordsKey: 'cmdk.keywords.hotkey',
label: 'Hotkeys',
labelKey: 'tab.hotkey',
labelNamespace: 'setting',
@@ -78,6 +83,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: ImageIcon,
keywords: ['image', 'picture', 'photo'],
+ keywordsKey: 'cmdk.keywords.image',
label: 'Image Settings',
labelKey: 'tab.image',
labelNamespace: 'setting',
@@ -87,6 +93,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: EthernetPort,
keywords: ['proxy', 'network', 'connection'],
+ keywordsKey: 'cmdk.keywords.proxy',
label: 'Proxy',
labelKey: 'tab.proxy',
labelNamespace: 'setting',
@@ -96,6 +103,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: ChartColumnBigIcon,
keywords: ['stats', 'statistics', 'analytics'],
+ keywordsKey: 'cmdk.keywords.stats',
label: 'Statistics',
labelKey: 'tab.stats',
labelNamespace: 'auth',
@@ -105,6 +113,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: KeyIcon,
keywords: ['apikey', 'api', 'key', 'token'],
+ keywordsKey: 'cmdk.keywords.apikey',
label: 'API Keys',
labelKey: 'tab.apikey',
labelNamespace: 'auth',
@@ -114,6 +123,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: Info,
keywords: ['about', 'version', 'info'],
+ keywordsKey: 'cmdk.keywords.about',
label: 'About',
labelKey: 'tab.about',
labelNamespace: 'setting',
@@ -125,6 +135,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: Map,
keywords: ['subscription', 'plan', 'upgrade', 'pricing'],
+ keywordsKey: 'cmdk.keywords.plans',
label: 'Subscription Plans',
labelKey: 'tab.plans',
labelNamespace: 'subscription' as const,
@@ -134,6 +145,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: Coins,
keywords: ['funds', 'balance', 'credit', 'money'],
+ keywordsKey: 'cmdk.keywords.funds',
label: 'Funds',
labelKey: 'tab.funds',
labelNamespace: 'subscription' as const,
@@ -143,6 +155,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: PieChart,
keywords: ['usage', 'statistics', 'consumption', 'quota'],
+ keywordsKey: 'cmdk.keywords.usage',
label: 'Usage',
labelKey: 'tab.usage',
labelNamespace: 'subscription' as const,
@@ -152,6 +165,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: CreditCard,
keywords: ['billing', 'payment', 'invoice', 'transaction'],
+ keywordsKey: 'cmdk.keywords.billing',
label: 'Billing',
labelKey: 'tab.billing',
labelNamespace: 'subscription' as const,
@@ -161,6 +175,7 @@ export const CONTEXT_COMMANDS: Record<ContextType, ContextCommand[]> = {
{
icon: Gift,
keywords: ['referral', 'rewards', 'invite', 'bonus'],
+ keywordsKey: 'cmdk.keywords.referral',
label: 'Referral Rewards',
labelKey: 'tab.referral',
labelNamespace: 'subscription' as const,
diff --git a/src/features/CommandMenu/utils/queryParser.ts b/src/features/CommandMenu/utils/queryParser.ts
index 54724b0d13b..a1b89d973cd 100644
--- a/src/features/CommandMenu/utils/queryParser.ts
+++ b/src/features/CommandMenu/utils/queryParser.ts
@@ -18,6 +18,7 @@ const VALID_TYPES = [
'file',
'folder',
'page',
+ 'memory',
'mcp',
'plugin',
'communityAgent',
diff --git a/src/features/FileViewer/index.tsx b/src/features/FileViewer/index.tsx
index 84da5df2ea0..dad3d0af0cd 100644
--- a/src/features/FileViewer/index.tsx
+++ b/src/features/FileViewer/index.tsx
@@ -183,7 +183,23 @@ const MSDOC_MIME_TYPES = new Set([
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
- 'application/octet-stream',
+]);
+
+// Archive file types - not supported for preview
+const ARCHIVE_EXTENSIONS = ['.zip', '.rar', '.7z', '.tar', '.gz', '.bz2', '.xz', '.tgz'];
+const ARCHIVE_MIME_TYPES = new Set([
+ 'zip',
+ 'rar',
+ '7z',
+ 'application/zip',
+ 'application/x-zip-compressed',
+ 'application/x-rar-compressed',
+ 'application/x-7z-compressed',
+ 'application/x-tar',
+ 'application/gzip',
+ 'application/x-gzip',
+ 'application/x-bzip2',
+ 'application/x-xz',
]);
// Helper function to check file type
@@ -238,16 +254,23 @@ const FileViewer = memo<FileViewerProps>(({ id, style, fileType, url, name }) =>
return <VideoViewer fileId={id} url={url} />;
}
- // Code files (JavaScript, TypeScript, Python, Java, C++, Go, Rust, Markdown, etc.)
- if (matchesFileType(fileType, name, CODE_EXTENSIONS, CODE_MIME_TYPES)) {
- return <CodeViewer fileId={id} fileName={name} url={url} />;
+ // Archive files (zip, rar, 7z, etc.) - not supported for preview
+ // Check before code files to avoid false matches
+ if (matchesFileType(fileType, name, ARCHIVE_EXTENSIONS, ARCHIVE_MIME_TYPES)) {
+ return <NotSupport fileName={name} style={style} url={url} />;
}
- // Microsoft Office documents
+ // Microsoft Office documents - check before code files to avoid false matches
+ // (e.g., 'doc' contains 'c' which would match CODE_EXTENSIONS)
if (matchesFileType(fileType, name, MSDOC_EXTENSIONS, MSDOC_MIME_TYPES)) {
return <MSDocViewer fileId={id} url={url} />;
}
+ // Code files (JavaScript, TypeScript, Python, Java, C++, Go, Rust, Markdown, etc.)
+ if (matchesFileType(fileType, name, CODE_EXTENSIONS, CODE_MIME_TYPES)) {
+ return <CodeViewer fileId={id} fileName={name} url={url} />;
+ }
+
// Unsupported file type
return <NotSupport fileName={name} style={style} url={url} />;
});
diff --git a/src/features/ModelSwitchPanel/components/List/ListItemRenderer.tsx b/src/features/ModelSwitchPanel/components/List/ListItemRenderer.tsx
index fe82fa06f74..dd0203f3c0b 100644
--- a/src/features/ModelSwitchPanel/components/List/ListItemRenderer.tsx
+++ b/src/features/ModelSwitchPanel/components/List/ListItemRenderer.tsx
@@ -147,15 +147,16 @@ export const ListItemRenderer = memo<ListItemRendererProps>(
case 'model-item-multiple': {
return (
- <MultipleProvidersModelItem
- activeKey={activeKey}
- data={item.data}
- isScrolling={isScrolling}
- key={item.data.displayName}
- newLabel={newLabel}
- onClose={onClose}
- onModelChange={onModelChange}
- />
+ <Flexbox key={item.data.displayName} style={{ marginBlock: 1, marginInline: 4 }}>
+ <MultipleProvidersModelItem
+ activeKey={activeKey}
+ data={item.data}
+ isScrolling={isScrolling}
+ newLabel={newLabel}
+ onClose={onClose}
+ onModelChange={onModelChange}
+ />
+ </Flexbox>
);
}
diff --git a/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx b/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx
index 63c6f57fefc..21f990d1ed5 100644
--- a/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx
+++ b/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx
@@ -53,6 +53,7 @@ export const MultipleProvidersModelItem = memo<MultipleProvidersModelItemProps>(
<DropdownMenuSubmenuRoot onOpenChange={setSubmenuOpen} open={submenuOpen}>
<DropdownMenuSubmenuTrigger
className={cx(menuSharedStyles.item, isActive && styles.menuItemActive)}
+ style={{ paddingBlock: 8, paddingInline: 8 }}
>
<ModelItemRender
{...data.model}
diff --git a/src/features/ModelSwitchPanel/components/Toolbar.tsx b/src/features/ModelSwitchPanel/components/Toolbar.tsx
index 059fb8087e6..bc39a1a9438 100644
--- a/src/features/ModelSwitchPanel/components/Toolbar.tsx
+++ b/src/features/ModelSwitchPanel/components/Toolbar.tsx
@@ -19,7 +19,7 @@ export const Toolbar = memo<ToolbarProps>(
const { t } = useTranslation('components');
return (
- <Flexbox className={styles.toolbar} gap={4} horizontal paddingBlock={8} paddingInline={8}>
+ <Flexbox align="center" className={styles.toolbar} gap={4} horizontal paddingBlock={8} paddingInline={8}>
<SearchBar
allowClear
onChange={(e) => onSearchKeywordChange(e.target.value)}
diff --git a/src/features/ResourceManager/components/Editor/index.tsx b/src/features/ResourceManager/components/Editor/index.tsx
index dfbead21c23..ddab3738f3b 100644
--- a/src/features/ResourceManager/components/Editor/index.tsx
+++ b/src/features/ResourceManager/components/Editor/index.tsx
@@ -19,7 +19,6 @@ import { fileManagerSelectors, useFileStore } from '@/store/file';
import { downloadFile } from '@/utils/client/downloadFile';
import FileContent from './FileContent';
-import FileCopilot from './FileCopilot';
interface FileEditorProps {
onBack?: () => void;
@@ -40,14 +39,18 @@ const FileEditorCanvas = memo<FileEditorProps>(({ onBack }) => {
<Flexbox flex={1} height={'100%'}>
<NavHeader
left={
- <Flexbox align={'center'} gap={12} horizontal style={{ minHeight: 32 }}>
+ <Flexbox align={'center'} gap={12} horizontal style={{ minHeight: 32, minWidth: 0, overflow: 'hidden' }}>
<ActionIcon icon={ArrowLeftIcon} onClick={onBack} title={t('back')} />
<span
style={{
color: theme.colorText,
fontSize: 14,
fontWeight: 500,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
}}
+ title={fileDetail?.name}
>
{fileDetail?.name}
</span>
@@ -74,14 +77,14 @@ const FileEditorCanvas = memo<FileEditorProps>(({ onBack }) => {
borderBottom: `1px solid ${cssVar.colorBorderSecondary}`,
}}
styles={{
- left: { padding: 0 },
+ left: { flex: 1, minWidth: 0, overflow: 'hidden', padding: 0 },
}}
/>
<Flexbox flex={1} style={{ overflow: 'hidden' }}>
<FileContent fileId={currentViewItemId} />
</Flexbox>
</Flexbox>
- <FileCopilot />
+ {/* <FileCopilot /> */}
</Flexbox>
<Modal
diff --git a/src/features/ResourceManager/components/Explorer/Header/index.tsx b/src/features/ResourceManager/components/Explorer/Header/index.tsx
index c988b940245..c05f05d36fa 100644
--- a/src/features/ResourceManager/components/Explorer/Header/index.tsx
+++ b/src/features/ResourceManager/components/Explorer/Header/index.tsx
@@ -87,7 +87,7 @@ const Header = memo(() => {
<Flexbox style={{ marginLeft: 8 }}>
{category === FilesTabs.All
? t('resource', { defaultValue: 'Resource' })
- : t(`tab.${category as FilesTabs}` as any)}
+ : t(`tab.${category as FilesTabs}` as any, { ns: 'file' })}
</Flexbox>
) : (
<Flexbox style={{ marginLeft: 8 }}>
diff --git a/src/features/ResourceManager/components/Explorer/ItemDropdown/useFileItemDropdown.tsx b/src/features/ResourceManager/components/Explorer/ItemDropdown/useFileItemDropdown.tsx
index ee755de553c..3faede62812 100644
--- a/src/features/ResourceManager/components/Explorer/ItemDropdown/useFileItemDropdown.tsx
+++ b/src/features/ResourceManager/components/Explorer/ItemDropdown/useFileItemDropdown.tsx
@@ -77,7 +77,18 @@ export const useFileItemDropdown = ({
const isInLibrary = !!libraryId;
const isFolder = fileType === 'custom/folder';
- const isPage = sourceType === 'document' || fileType === PAGE_FILE_TYPE;
+ // PDF and Office files should not be treated as pages
+ const lowerFilename = filename?.toLowerCase();
+ const isPDF = fileType?.toLowerCase() === 'pdf' || lowerFilename?.endsWith('.pdf');
+ const isOfficeFile =
+ lowerFilename?.endsWith('.xls') ||
+ lowerFilename?.endsWith('.xlsx') ||
+ lowerFilename?.endsWith('.doc') ||
+ lowerFilename?.endsWith('.docx') ||
+ lowerFilename?.endsWith('.ppt') ||
+ lowerFilename?.endsWith('.pptx') ||
+ lowerFilename?.endsWith('.odt');
+ const isPage = !isPDF && !isOfficeFile && (sourceType === 'document' || fileType === PAGE_FILE_TYPE);
const menuItems = useCallback(() => {
// Filter out current knowledge base and create submenu items
diff --git a/src/features/ResourceManager/components/Explorer/ListView/ListItem/index.tsx b/src/features/ResourceManager/components/Explorer/ListView/ListItem/index.tsx
index ea61720089b..fe7488ff035 100644
--- a/src/features/ResourceManager/components/Explorer/ListView/ListItem/index.tsx
+++ b/src/features/ResourceManager/components/Explorer/ListView/ListItem/index.tsx
@@ -7,7 +7,6 @@ import { isNull } from 'es-toolkit/compat';
import { FileBoxIcon, FileText, FolderIcon } from 'lucide-react';
import { type DragEvent, memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { useNavigate, useSearchParams } from 'react-router-dom';
import { shallow } from 'zustand/shallow';
import {
@@ -24,6 +23,7 @@ import { type FileListItem as FileListItemType } from '@/types/files';
import { formatSize } from '@/utils/format';
import { isChunkingUnsupported } from '@/utils/isChunkingUnsupported';
+import { useFileItemClick } from '../../hooks/useFileItemClick';
import DropdownMenu from '../../ItemDropdown/DropdownMenu';
import { useFileItemDropdown } from '../../ItemDropdown/useFileItemDropdown';
import ChunksBadge from './ChunkTag';
@@ -159,9 +159,6 @@ const FileListItem = memo<FileListItemProps>(
}) => {
const { t } = useTranslation(['components', 'file']);
const { message } = App.useApp();
- const navigate = useNavigate();
- const [, setSearchParams] = useSearchParams();
-
// Consolidate all FileStore subscriptions with shallow equality
const fileStoreState = useFileStore(
(s) => ({
@@ -177,8 +174,6 @@ const FileListItem = memo<FileListItemProps>(
const resourceManagerState = useResourceManagerStore(
(s) => ({
libraryId: s.libraryId,
- setCurrentViewItemId: s.setCurrentViewItemId,
- setMode: s.setMode,
setPendingRenameItemId: s.setPendingRenameItemId,
}),
shallow,
@@ -194,12 +189,23 @@ const FileListItem = memo<FileListItemProps>(
const [isOver, setIsOver] = useState(false);
const computedValues = useMemo(() => {
- const isPDF = fileType?.toLowerCase() === 'pdf' || name?.toLowerCase().endsWith('.pdf');
+ const lowerFileType = fileType?.toLowerCase();
+ const lowerName = name?.toLowerCase();
+ const isPDF = lowerFileType === 'pdf' || lowerName?.endsWith('.pdf');
+ // Office files should use the MSDoc viewer, not the page editor
+ const isOfficeFile =
+ lowerName?.endsWith('.xls') ||
+ lowerName?.endsWith('.xlsx') ||
+ lowerName?.endsWith('.doc') ||
+ lowerName?.endsWith('.docx') ||
+ lowerName?.endsWith('.ppt') ||
+ lowerName?.endsWith('.pptx') ||
+ lowerName?.endsWith('.odt');
return {
emoji: sourceType === 'document' || fileType === PAGE_FILE_TYPE ? metadata?.emoji : null,
isFolder: fileType === 'custom/folder',
- // PDF files should not be treated as pages, even if they have sourceType='document'
- isPage: !isPDF && (sourceType === 'document' || fileType === PAGE_FILE_TYPE),
+ // PDF and Office files should not be treated as pages, even if they have sourceType='document'
+ isPage: !isPDF && !isOfficeFile && (sourceType === 'document' || fileType === PAGE_FILE_TYPE),
isSupportedForChunking: !isChunkingUnsupported(fileType),
};
}, [fileType, sourceType, metadata?.emoji, name]);
@@ -333,40 +339,14 @@ const FileListItem = memo<FileListItemProps>(
setRenamingValue(name);
}, [name]);
- // Memoize click handler to prevent recreation on every render
- const handleItemClick = useCallback(() => {
- if (isFolder) {
- // Navigate to folder using slug-based routing (Google Drive style)
- const folderSlug = slug || id;
-
- if (resourceManagerState.libraryId) {
- navigate(`/resource/library/${resourceManagerState.libraryId}/${folderSlug}`);
- }
- } else if (isPage) {
- resourceManagerState.setCurrentViewItemId(id);
- resourceManagerState.setMode('page');
- setSearchParams(
- (prev) => {
- const newParams = new URLSearchParams(prev);
- newParams.set('file', id);
- return newParams;
- },
- { replace: true },
- );
- } else {
- resourceManagerState.setCurrentViewItemId(id);
- resourceManagerState.setMode('editor');
- // Also update URL query parameter for shareable links
- setSearchParams(
- (prev) => {
- const newParams = new URLSearchParams(prev);
- newParams.set('file', id);
- return newParams;
- },
- { replace: true },
- );
- }
- }, [isFolder, slug, id, resourceManagerState, navigate, isPage, setSearchParams]);
+ // Use shared click handler hook
+ const handleItemClick = useFileItemClick({
+ id,
+ isFolder,
+ isPage,
+ libraryId: resourceManagerState.libraryId,
+ slug,
+ });
// Auto-start renaming if this is the pending rename item
useEffect(() => {
diff --git a/src/features/ResourceManager/components/Explorer/MasonryView/MasonryFileItem/ImageFileItem.tsx b/src/features/ResourceManager/components/Explorer/MasonryView/MasonryFileItem/ImageFileItem.tsx
index cb798c7f8bc..e0dce336b94 100644
--- a/src/features/ResourceManager/components/Explorer/MasonryView/MasonryFileItem/ImageFileItem.tsx
+++ b/src/features/ResourceManager/components/Explorer/MasonryView/MasonryFileItem/ImageFileItem.tsx
@@ -59,6 +59,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
imageWrapper: css`
position: relative;
width: 100%;
+ min-height: 120px;
background: ${cssVar.colorFillQuaternary};
img {
diff --git a/src/features/ResourceManager/components/Explorer/MasonryView/MasonryFileItem/index.tsx b/src/features/ResourceManager/components/Explorer/MasonryView/MasonryFileItem/index.tsx
index f88eb032880..0f1274aee00 100644
--- a/src/features/ResourceManager/components/Explorer/MasonryView/MasonryFileItem/index.tsx
+++ b/src/features/ResourceManager/components/Explorer/MasonryView/MasonryFileItem/index.tsx
@@ -1,17 +1,16 @@
import { Checkbox, showContextMenu } from '@lobehub/ui';
import { createStaticStyles, cssVar, cx } from 'antd-style';
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
-import { useNavigate, useSearchParams } from 'react-router-dom';
import {
getTransparentDragImage,
useDragActive,
useDragState,
} from '@/app/[variants]/(main)/resource/features/DndContextWrapper';
-import { useResourceManagerStore } from '@/app/[variants]/(main)/resource/features/store';
import { documentService } from '@/services/document';
import { type FileListItem } from '@/types/files';
+import { useFileItemClick } from '../../hooks/useFileItemClick';
import DropdownMenu from '../../ItemDropdown/DropdownMenu';
import { useFileItemDropdown } from '../../ItemDropdown/useFileItemDropdown';
import DefaultFileItem from './DefaultFileItem';
@@ -45,10 +44,19 @@ const isMarkdownFile = (name: string, fileType?: string) => {
};
// Helper to check if it's a custom page that should be rendered
-// PDF files should not be treated as pages even if they have fileType='custom/document'
+// PDF and Office files should not be treated as pages even if they have fileType='custom/document'
const isCustomPage = (fileType?: string, name?: string) => {
- const isPDF = fileType?.toLowerCase() === 'pdf' || name?.toLowerCase().endsWith('.pdf');
- return !isPDF && fileType === CUSTOM_NOTE_TYPE;
+ const lowerName = name?.toLowerCase();
+ const isPDF = fileType?.toLowerCase() === 'pdf' || lowerName?.endsWith('.pdf');
+ const isOfficeFile =
+ lowerName?.endsWith('.xls') ||
+ lowerName?.endsWith('.xlsx') ||
+ lowerName?.endsWith('.doc') ||
+ lowerName?.endsWith('.docx') ||
+ lowerName?.endsWith('.ppt') ||
+ lowerName?.endsWith('.pptx') ||
+ lowerName?.endsWith('.odt');
+ return !isPDF && !isOfficeFile && fileType === CUSTOM_NOTE_TYPE;
};
// Helper function to extract text from editor's JSON format for preview
@@ -194,10 +202,6 @@ const MasonryFileItem = memo<MasonryFileItemProps>(
}) => {
const [markdownContent, setMarkdownContent] = useState<string>('');
const [isLoadingMarkdown, setIsLoadingMarkdown] = useState(false);
- const navigate = useNavigate();
- const [searchParams, setSearchParams] = useSearchParams();
- const setMode = useResourceManagerStore((s) => s.setMode);
- const setCurrentViewItemId = useResourceManagerStore((s) => s.setCurrentViewItemId);
const isDragActive = useDragActive();
const { setCurrentDrag } = useDragState();
@@ -217,6 +221,16 @@ const MasonryFileItem = memo<MasonryFileItemProps>(
const { isImage, isMarkdown, isPage, isFolder } = computedValues;
+ // Use shared click handler hook
+ const handleItemClick = useFileItemClick({
+ id,
+ isFolder,
+ isPage,
+ libraryId: knowledgeBaseId,
+ onOpen,
+ slug,
+ });
+
// Memoize drag data to prevent recreation
const dragData = useMemo(
() => ({
@@ -401,41 +415,7 @@ const MasonryFileItem = memo<MasonryFileItemProps>(
styles.content,
!isImage && !isMarkdown && !isPage && styles.contentWithPadding,
)}
- onClick={() => {
- if (isFolder) {
- // Navigate to folder using slug-based routing (Google Drive style)
- const folderSlug = slug || id;
- if (knowledgeBaseId) {
- // Preserve existing query parameters (view and sort preferences)
- const newParams = new URLSearchParams(searchParams);
- // Remove 'file' parameter when navigating to folder
- newParams.delete('file');
-
- const queryString = newParams.toString();
- const basePath = `/resource/library/${knowledgeBaseId}/${folderSlug}`;
- navigate(queryString ? `${basePath}?${queryString}` : basePath);
- }
- } else if (isPage) {
- // Switch to page view mode instead of opening modal
- setCurrentViewItemId(id);
- setMode('page');
- } else {
- // Set mode to file and store the file ID
- setCurrentViewItemId(id);
- setMode('editor');
- // Also update URL query parameter for shareable links
- setSearchParams(
- (prev) => {
- const newParams = new URLSearchParams(prev);
- newParams.set('file', id);
- return newParams;
- },
- { replace: true },
- );
- // Still call onOpen if provided for backwards compatibility
- onOpen?.(id);
- }
- }}
+ onClick={handleItemClick}
>
{(() => {
switch (true) {
diff --git a/src/features/ResourceManager/components/Explorer/hooks/useFileItemClick.ts b/src/features/ResourceManager/components/Explorer/hooks/useFileItemClick.ts
new file mode 100644
index 00000000000..483737a3f82
--- /dev/null
+++ b/src/features/ResourceManager/components/Explorer/hooks/useFileItemClick.ts
@@ -0,0 +1,78 @@
+import { useCallback } from 'react';
+import { useNavigate, useSearchParams } from 'react-router-dom';
+
+import { useResourceManagerStore } from '@/app/[variants]/(main)/resource/features/store';
+
+export interface UseFileItemClickOptions {
+ id: string;
+ isFolder: boolean;
+ isPage: boolean;
+ libraryId?: string | null;
+ onOpen?: (id: string) => void;
+ slug?: string | null;
+}
+
+/**
+ * Shared hook for handling file item click across different view modes (list/masonry)
+ */
+export const useFileItemClick = ({
+ id,
+ slug,
+ libraryId,
+ isFolder,
+ isPage,
+ onOpen,
+}: UseFileItemClickOptions) => {
+ const navigate = useNavigate();
+ const [searchParams, setSearchParams] = useSearchParams();
+ const setMode = useResourceManagerStore((s) => s.setMode);
+ const setCurrentViewItemId = useResourceManagerStore((s) => s.setCurrentViewItemId);
+
+ const handleClick = useCallback(() => {
+ if (isFolder) {
+ // Navigate to folder using slug-based routing (Google Drive style)
+ const folderSlug = slug || id;
+
+ if (libraryId) {
+ // Preserve existing query parameters (view and sort preferences)
+ const newParams = new URLSearchParams(searchParams);
+ // Remove 'file' parameter when navigating to folder
+ newParams.delete('file');
+
+ const queryString = newParams.toString();
+ const basePath = `/resource/library/${libraryId}/${folderSlug}`;
+ navigate(queryString ? `${basePath}?${queryString}` : basePath);
+ }
+ } else if (isPage) {
+ // Switch to page view mode
+ setCurrentViewItemId(id);
+ setMode('page');
+ // Update URL query parameter for shareable links
+ setSearchParams(
+ (prev) => {
+ const newParams = new URLSearchParams(prev);
+ newParams.set('file', id);
+ return newParams;
+ },
+ { replace: true },
+ );
+ } else {
+ // Set mode to editor for regular files
+ setCurrentViewItemId(id);
+ setMode('editor');
+ // Update URL query parameter for shareable links
+ setSearchParams(
+ (prev) => {
+ const newParams = new URLSearchParams(prev);
+ newParams.set('file', id);
+ return newParams;
+ },
+ { replace: true },
+ );
+ // Call onOpen if provided for backwards compatibility
+ onOpen?.(id);
+ }
+ }, [isFolder, slug, id, libraryId, isPage, navigate, searchParams, setSearchParams, setMode, setCurrentViewItemId, onOpen]);
+
+ return handleClick;
+};
diff --git a/src/features/ResourceManager/components/Header/AddButton.tsx b/src/features/ResourceManager/components/Header/AddButton.tsx
index c26e0627883..6204902e406 100644
--- a/src/features/ResourceManager/components/Header/AddButton.tsx
+++ b/src/features/ResourceManager/components/Header/AddButton.tsx
@@ -10,7 +10,6 @@ import { useTranslation } from 'react-i18next';
import { useResourceManagerStore } from '@/app/[variants]/(main)/resource/features/store';
import { message } from '@/components/AntdStaticMethods';
-import DragUpload from '@/components/DragUpload';
import GuideModal from '@/components/GuideModal';
import GuideVideo from '@/components/GuideVideo';
import { useFileStore } from '@/store/file';
@@ -227,10 +226,6 @@ const AddButton = () => {
open={notionGuideOpen}
title={t('header.actions.notionGuide.title')}
/>
- <DragUpload
- enabledFiles
- onUploadFiles={(files) => pushDockFileList(files, libraryId, currentFolderId ?? undefined)}
- />
<input
id="folder-upload-input"
multiple
diff --git a/src/features/ResourceManager/index.tsx b/src/features/ResourceManager/index.tsx
index 19889817240..bc0f2b58956 100644
--- a/src/features/ResourceManager/index.tsx
+++ b/src/features/ResourceManager/index.tsx
@@ -3,10 +3,11 @@
import { BRANDING_NAME } from '@lobechat/business-const';
import { Flexbox } from '@lobehub/ui';
import { createStaticStyles, useTheme } from 'antd-style';
-import { memo, useEffect, useMemo } from 'react';
+import { memo, useCallback, useEffect, useMemo } from 'react';
import { useSearchParams } from 'react-router-dom';
import { useResourceManagerStore } from '@/app/[variants]/(main)/resource/features/store';
+import DragUploadZone from '@/components/DragUploadZone';
import { PageEditor } from '@/features/PageEditor';
import dynamic from '@/libs/next/dynamic';
import { documentService } from '@/services/document';
@@ -58,16 +59,23 @@ export type ResourceManagerMode = 'editor' | 'explorer' | 'page';
const ResourceManager = memo(() => {
const theme = useTheme();
const [, setSearchParams] = useSearchParams();
- const [mode, currentViewItemId, libraryId, setMode, setCurrentViewItemId] =
+ const [mode, currentViewItemId, libraryId, currentFolderId, setMode, setCurrentViewItemId] =
useResourceManagerStore((s) => [
s.mode,
s.currentViewItemId,
s.libraryId,
+ s.currentFolderId,
s.setMode,
s.setCurrentViewItemId,
]);
const currentDocument = useFileStore(documentSelectors.getDocumentById(currentViewItemId));
+ const pushDockFileList = useFileStore((s) => s.pushDockFileList);
+
+ const handleUploadFiles = useCallback(
+ (files: File[]) => pushDockFileList(files, libraryId, currentFolderId ?? undefined),
+ [currentFolderId, libraryId, pushDockFileList],
+ );
const cssVariables = useMemo<Record<string, string>>(
() => ({
@@ -105,28 +113,34 @@ const ResourceManager = memo(() => {
return (
<>
- <Flexbox className={styles.container} height={'100%'} style={cssVariables}>
- {/* Explorer is always rendered to preserve its state */}
- <Explorer />
-
- {/* Editor overlay */}
- {mode === 'editor' && (
- <Flexbox className={styles.editorOverlay}>
- <Editor onBack={handleBack} />
- </Flexbox>
- )}
-
- {/* PageEditor overlay */}
- {mode === 'page' && (
- <Flexbox className={styles.pageEditorOverlay}>
- <PageEditor
- knowledgeBaseId={libraryId}
- onBack={handleBack}
- pageId={currentViewItemId}
- />
- </Flexbox>
- )}
- </Flexbox>
+ <DragUploadZone
+ enabledFiles
+ onUploadFiles={handleUploadFiles}
+ style={{ height: '100%' }}
+ >
+ <Flexbox className={styles.container} height={'100%'} style={cssVariables}>
+ {/* Explorer is always rendered to preserve its state */}
+ <Explorer />
+
+ {/* Editor overlay */}
+ {mode === 'editor' && (
+ <Flexbox className={styles.editorOverlay}>
+ <Editor onBack={handleBack} />
+ </Flexbox>
+ )}
+
+ {/* PageEditor overlay */}
+ {mode === 'page' && (
+ <Flexbox className={styles.pageEditorOverlay}>
+ <PageEditor
+ knowledgeBaseId={libraryId}
+ onBack={handleBack}
+ pageId={currentViewItemId}
+ />
+ </Flexbox>
+ )}
+ </Flexbox>
+ </DragUploadZone>
<UploadDock />
<ChunkDrawer />
</>
diff --git a/src/locales/default/common.ts b/src/locales/default/common.ts
index 059611c9010..e654682b3ad 100644
--- a/src/locales/default/common.ts
+++ b/src/locales/default/common.ts
@@ -118,7 +118,7 @@ export default {
'cmdk.askLobeAI': 'Ask Lobe AI',
'cmdk.community': 'Community',
'cmdk.communitySupport': 'Community Support',
- 'cmdk.contactViaEmail': 'Contact Us',
+ 'cmdk.contactUs': 'Contact Us',
'cmdk.context.agent': 'Agent',
'cmdk.context.community': 'Community',
'cmdk.context.general': 'General',
@@ -132,32 +132,109 @@ export default {
'cmdk.keyboard.ESC': 'ESC',
'cmdk.keyboard.Enter': 'Enter',
'cmdk.keyboard.Tab': 'Tab',
+
+ 'cmdk.keywords.about': 'about version info',
+
+ 'cmdk.keywords.apikey': 'apikey api key token',
+
+ 'cmdk.keywords.appearance': 'common appearance theme display',
+
+ 'cmdk.keywords.billing': 'billing payment invoice transaction',
+
+ 'cmdk.keywords.community': 'discover market assistant model provider mcp',
+
+ // CMDK search keywords (space-separated for i18n)
+ 'cmdk.keywords.contactUs': 'feedback issue bug problem',
+
+ 'cmdk.keywords.discord': 'discord help support customer service',
+
+ 'cmdk.keywords.funds': 'funds balance credit money',
+
+ 'cmdk.keywords.hotkey': 'hotkey shortcut keyboard',
+
+ 'cmdk.keywords.image': 'image picture photo',
+
+ 'cmdk.keywords.memory': 'identities contexts preferences experiences',
+
+ 'cmdk.keywords.pages': 'documents write notes',
+
+ 'cmdk.keywords.painting': 'painting art generate draw',
+
+ 'cmdk.keywords.plans': 'subscription plan upgrade pricing',
+
+ 'cmdk.keywords.profile': 'profile user account personal',
+
+ 'cmdk.keywords.provider': 'provider llm model ai',
+
+ 'cmdk.keywords.proxy': 'proxy network connection',
+
+ 'cmdk.keywords.referral': 'referral rewards invite bonus',
+
+ 'cmdk.keywords.resources': 'knowledge files library documents',
+
+ 'cmdk.keywords.settings': 'settings preferences configuration options',
+
+ 'cmdk.keywords.starGitHub': 'github star favorite like',
+
+ 'cmdk.keywords.stats': 'stats statistics analytics',
+
+ 'cmdk.keywords.submitIssue': 'issue bug problem feedback',
+
+ 'cmdk.keywords.usage': 'usage statistics consumption quota',
+
'cmdk.memory': 'Memory',
+
'cmdk.mentionAgent': 'Mention Agent',
+
'cmdk.navigate': 'Navigate',
+
'cmdk.newAgent': 'Create New Agent',
+
'cmdk.newAgentTeam': 'Create New Group',
+
'cmdk.newLibrary': 'Create New Library',
+
'cmdk.newPage': 'Create New Page',
- 'cmdk.newTopic': 'New topic in current Agent',
- 'cmdk.noResults': 'No results found',
+
+ 'cmdk.newTopic': 'New Topic in Current Agent',
+
+ 'cmdk.noResults': 'No Results found',
+
'cmdk.openSettings': 'Open Settings',
+
'cmdk.pages': 'Pages',
+
'cmdk.painting': 'Painting',
+
'cmdk.resource': 'Resources',
+
'cmdk.search.agent': 'Agent',
+
'cmdk.search.agents': 'Agents',
+
'cmdk.search.assistant': 'Agent',
+
'cmdk.search.assistants': 'Agents',
+
'cmdk.search.communityAgent': 'Community Agent',
+
'cmdk.search.file': 'File',
+
'cmdk.search.files': 'Files',
+
'cmdk.search.folder': 'Folder',
+
'cmdk.search.folders': 'Folders',
+
'cmdk.search.loading': 'Searching...',
+
'cmdk.search.market': 'Community',
+
'cmdk.search.mcp': 'MCP Server',
+
'cmdk.search.mcps': 'MCP Servers',
+ 'cmdk.search.memories': 'Memories',
+ 'cmdk.search.memory': 'Memory',
'cmdk.search.message': 'Message',
'cmdk.search.messages': 'Messages',
'cmdk.search.page': 'Page',
@@ -179,11 +256,12 @@ export default {
'cmdk.themeLight': 'Light',
'cmdk.toOpen': 'Open',
'cmdk.toSelect': 'Select',
+
'confirm': 'Confirm',
'contact': 'Contact Us',
'copy': 'Copy',
'copyFail': 'Copy failed',
- 'copySuccess': 'Copied successfully',
+ 'copySuccess': 'Copied',
'dataStatistics.messages': 'Messages',
'dataStatistics.sessions': 'Agents',
'dataStatistics.today': "Today's New",
diff --git a/src/server/routers/lambda/search.ts b/src/server/routers/lambda/search.ts
index b86596ed89a..8a118c601a2 100644
--- a/src/server/routers/lambda/search.ts
+++ b/src/server/routers/lambda/search.ts
@@ -52,6 +52,7 @@ export const searchRouter = router({
'folder',
'message',
'page',
+ 'memory',
'mcp',
'plugin',
'communityAgent',
@@ -68,8 +69,8 @@ export const searchRouter = router({
// Build search promises based on type filter
const searchPromises: Promise<any>[] = [];
- // Database searches (agent, topic, file, folder, message, page)
- if (!type || ['agent', 'topic', 'file', 'folder', 'message', 'page'].includes(type)) {
+ // Database searches (agent, topic, file, folder, message, page, memory)
+ if (!type || ['agent', 'topic', 'file', 'folder', 'message', 'page', 'memory'].includes(type)) {
searchPromises.push(ctx.searchRepo.search(input));
}