From 714a28ac29629227def4fa99d11f8bdc7008edb8 Mon Sep 17 00:00:00 2001 From: Phantom Date: Mon, 3 Nov 2025 20:34:24 +0800 Subject: [PATCH] fix(QuickPanel): Hide the options that should be hidden in the quick panel. (#10931) * feat(QuickPanel): add hidden property to list items Add support for hiding QuickPanel items by introducing a hidden property. This allows conditional visibility of items like the knowledge base button based on application state. * docs(types): clarify settings field comment in Assistant type --- src/renderer/src/components/QuickPanel/types.ts | 1 + src/renderer/src/components/QuickPanel/view.tsx | 3 ++- src/renderer/src/pages/home/Inputbar/InputbarTools.tsx | 3 ++- src/renderer/src/types/index.ts | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/QuickPanel/types.ts b/src/renderer/src/components/QuickPanel/types.ts index 812ec153a6..519180c5b7 100644 --- a/src/renderer/src/components/QuickPanel/types.ts +++ b/src/renderer/src/components/QuickPanel/types.ts @@ -64,6 +64,7 @@ export type QuickPanelListItem = { isSelected?: boolean isMenu?: boolean disabled?: boolean + hidden?: boolean /** * 固定显示项:不参与过滤,始终出现在列表顶部。 * 例如“清除”按钮可设置为 alwaysVisible,从而在有匹配项时始终可见; diff --git a/src/renderer/src/components/QuickPanel/view.tsx b/src/renderer/src/components/QuickPanel/view.tsx index 47a0c6299e..5c6afcbf61 100644 --- a/src/renderer/src/components/QuickPanel/view.tsx +++ b/src/renderer/src/components/QuickPanel/view.tsx @@ -143,7 +143,8 @@ export const QuickPanelView: React.FC = ({ setInputText }) => { prevSymbolRef.current = ctx.symbol // 固定项置顶 + 过滤后的普通项 - return [...pinnedItems, ...filteredNormalItems] + const pinnedFiltered = [...pinnedItems, ...filteredNormalItems] + return pinnedFiltered.filter((item) => !item.hidden) }, [ctx.isVisible, ctx.symbol, ctx.list, searchText]) const canForwardAndBackward = useMemo(() => { diff --git a/src/renderer/src/pages/home/Inputbar/InputbarTools.tsx b/src/renderer/src/pages/home/Inputbar/InputbarTools.tsx index a24d63e8ba..4dee55b167 100644 --- a/src/renderer/src/pages/home/Inputbar/InputbarTools.tsx +++ b/src/renderer/src/pages/home/Inputbar/InputbarTools.tsx @@ -245,6 +245,7 @@ const InputbarTools = ({ icon: , isMenu: true, disabled: files.length > 0, + hidden: !showKnowledgeBaseButton, action: () => { knowledgeBaseButtonRef.current?.openQuickPanel() } @@ -312,7 +313,7 @@ const InputbarTools = ({ translate() } } - ] + ] satisfies QuickPanelListItem[] } const handleDragEnd = (result: DropResult) => { diff --git a/src/renderer/src/types/index.ts b/src/renderer/src/types/index.ts index 2026a935ab..c86e80a157 100644 --- a/src/renderer/src/types/index.ts +++ b/src/renderer/src/types/index.ts @@ -36,6 +36,7 @@ export type Assistant = { description?: string model?: Model defaultModel?: Model + // This field should be considered as not Partial and not optional in v2 settings?: Partial messages?: AssistantMessage[] /** enableWebSearch 代表使用模型内置网络搜索功能 */