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
This commit is contained in:
Phantom 2025-11-03 20:34:24 +08:00 committed by GitHub
parent 0cf81c04c8
commit 714a28ac29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 2 deletions

View File

@ -64,6 +64,7 @@ export type QuickPanelListItem = {
isSelected?: boolean
isMenu?: boolean
disabled?: boolean
hidden?: boolean
/**
*
* alwaysVisible

View File

@ -143,7 +143,8 @@ export const QuickPanelView: React.FC<Props> = ({ 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(() => {

View File

@ -245,6 +245,7 @@ const InputbarTools = ({
icon: <FileSearch />,
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) => {

View File

@ -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<AssistantSettings>
messages?: AssistantMessage[]
/** enableWebSearch 代表使用模型内置网络搜索功能 */