Skip to content

Commit 89318e6

Browse files
committed
fix: search tool enabled when nothing selected
1 parent 9f707f1 commit 89318e6

File tree

2 files changed

+28
-57
lines changed

2 files changed

+28
-57
lines changed

web/src/refresh-components/popovers/ActionsPopover/ActionLineItem.tsx

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export interface ActionItemProps {
3333
onForceToggle: () => void;
3434
onSourceManagementOpen?: () => void;
3535
hasNoConnectors?: boolean;
36-
hasNoKnowledgeSources?: boolean;
3736
toolAuthStatus?: ToolAuthStatus;
3837
onOAuthAuthenticate?: () => void;
3938
onClose?: () => void;
@@ -56,7 +55,6 @@ export default function ActionLineItem({
5655
onForceToggle,
5756
onSourceManagementOpen,
5857
hasNoConnectors = false,
59-
hasNoKnowledgeSources = false,
6058
toolAuthStatus,
6159
onOAuthAuthenticate,
6260
onClose,
@@ -78,11 +76,6 @@ export default function ActionLineItem({
7876
tool?.in_code_tool_id === SEARCH_TOOL_ID &&
7977
hasNoConnectors;
8078

81-
const isSearchToolWithNoKnowledgeSources =
82-
!currentProjectId &&
83-
tool?.in_code_tool_id === SEARCH_TOOL_ID &&
84-
hasNoKnowledgeSources;
85-
8679
const isSearchToolAndNotInProject =
8780
tool?.in_code_tool_id === SEARCH_TOOL_ID && !currentProjectId;
8881

@@ -95,22 +88,14 @@ export default function ActionLineItem({
9588
sourceCounts.enabled > 0 &&
9689
sourceCounts.enabled < sourceCounts.total;
9790

98-
const tooltipText = isSearchToolWithNoKnowledgeSources
99-
? "No knowledge sources are available. Contact your admin to add a knowledge source to this agent."
100-
: isUnavailable
101-
? unavailableReason
102-
: tool?.description;
91+
const tooltipText = isUnavailable ? unavailableReason : tool?.description;
10392

10493
return (
10594
<SimpleTooltip tooltip={tooltipText} className="max-w-[30rem]">
10695
<div data-testid={`tool-option-${toolName}`}>
10796
<LineItem
10897
onClick={() => {
109-
if (
110-
isSearchToolWithNoConnectors ||
111-
isSearchToolWithNoKnowledgeSources
112-
)
113-
return;
98+
if (isSearchToolWithNoConnectors) return;
11499
if (isUnavailable) {
115100
if (isForced) onForceToggle();
116101
return;
@@ -123,10 +108,7 @@ export default function ActionLineItem({
123108
}}
124109
selected={isForced}
125110
strikethrough={
126-
disabled ||
127-
isSearchToolWithNoConnectors ||
128-
isSearchToolWithNoKnowledgeSources ||
129-
isUnavailable
111+
disabled || isSearchToolWithNoConnectors || isUnavailable
130112
}
131113
icon={Icon}
132114
rightChildren={
@@ -201,31 +183,28 @@ export default function ActionLineItem({
201183
</span>
202184
)}
203185

204-
{isSearchToolAndNotInProject &&
205-
!isSearchToolWithNoKnowledgeSources && (
206-
<IconButton
207-
icon={
208-
isSearchToolWithNoConnectors
209-
? SvgSettings
210-
: SvgChevronRight
211-
}
212-
onClick={noProp(() => {
213-
if (isSearchToolWithNoConnectors)
214-
router.push("/admin/add-connector");
215-
else onSourceManagementOpen?.();
216-
})}
217-
internal
218-
className={cn(
219-
isSearchToolWithNoConnectors &&
220-
"invisible group-hover/LineItem:visible"
221-
)}
222-
tooltip={
223-
isSearchToolWithNoConnectors
224-
? "Add Connectors"
225-
: "Configure Connectors"
226-
}
227-
/>
228-
)}
186+
{isSearchToolAndNotInProject && (
187+
<IconButton
188+
icon={
189+
isSearchToolWithNoConnectors ? SvgSettings : SvgChevronRight
190+
}
191+
onClick={noProp(() => {
192+
if (isSearchToolWithNoConnectors)
193+
router.push("/admin/add-connector");
194+
else onSourceManagementOpen?.();
195+
})}
196+
internal
197+
className={cn(
198+
isSearchToolWithNoConnectors &&
199+
"invisible group-hover/LineItem:visible"
200+
)}
201+
tooltip={
202+
isSearchToolWithNoConnectors
203+
? "Add Connectors"
204+
: "Configure Connectors"
205+
}
206+
/>
207+
)}
229208
</Section>
230209
}
231210
>

web/src/refresh-components/popovers/ActionsPopover/index.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,23 +210,16 @@ export default function ActionsPopover({
210210
sourceSet.add(normalized);
211211
});
212212

213+
// No specific sources selected means everything is searchable
214+
if (sourceSet.size === 0) return null;
215+
213216
return sourceSet;
214217
}, [
215218
isDefaultAgent,
216219
selectedAssistant.document_sets,
217220
selectedAssistant.knowledge_sources,
218221
]);
219222

220-
// Check if non-default agent has no knowledge sources (Internal Search should be disabled)
221-
// Knowledge sources include document sets and hierarchy nodes (folders, spaces, channels)
222-
// Check if non-default agent has no knowledge sources (Internal Search should be disabled)
223-
// Knowledge sources include document sets, hierarchy nodes, and attached documents
224-
const hasNoKnowledgeSources =
225-
!isDefaultAgent &&
226-
selectedAssistant.document_sets.length === 0 &&
227-
(selectedAssistant.hierarchy_node_count ?? 0) === 0 &&
228-
(selectedAssistant.attached_document_count ?? 0) === 0;
229-
230223
// Store MCP server auth/loading state (tools are part of selectedAssistant.tools)
231224
const [mcpServerData, setMcpServerData] = useState<{
232225
[serverId: number]: {
@@ -905,7 +898,6 @@ export default function ActionsPopover({
905898
setSecondaryView({ type: "sources" })
906899
}
907900
hasNoConnectors={hasNoConnectors}
908-
hasNoKnowledgeSources={hasNoKnowledgeSources}
909901
toolAuthStatus={getToolAuthStatus(tool)}
910902
onOAuthAuthenticate={() => authenticateTool(tool)}
911903
onClose={() => setOpen(false)}

0 commit comments

Comments
 (0)