mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 13:55:50 +00:00
- 新增 docs/design/tool-search-design-guide.md,涵盖架构、搜索算法、执行管道、演进历史 - 禁用 getTurnZeroSearchExtraToolsPrefetch,消除用户输入时的频繁弹窗 - inter-turn 发现机制保持不变 Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import * as React from 'react';
|
|
import { Box, Text } from '@anthropic/ink';
|
|
import { Select } from './CustomSelect/select.js';
|
|
import { PermissionDialog } from './permissions/PermissionDialog.js';
|
|
|
|
type SearchExtraToolsHintItem = {
|
|
name: string;
|
|
description: string;
|
|
score: number;
|
|
};
|
|
|
|
type Props = {
|
|
tools: SearchExtraToolsHintItem[];
|
|
onSelect: (toolName: string) => void;
|
|
onDismiss: () => void;
|
|
};
|
|
|
|
const AUTO_DISMISS_MS = 30_000;
|
|
|
|
export function SearchExtraToolsHint({ tools, onSelect, onDismiss }: Props): React.ReactNode {
|
|
const onSelectRef = React.useRef(onSelect);
|
|
const onDismissRef = React.useRef(onDismiss);
|
|
onSelectRef.current = onSelect;
|
|
onDismissRef.current = onDismiss;
|
|
|
|
React.useEffect(() => {
|
|
const timeoutId = setTimeout(ref => ref.current(), AUTO_DISMISS_MS, onDismissRef);
|
|
return () => clearTimeout(timeoutId);
|
|
}, []);
|
|
|
|
const options = tools.map(t => ({
|
|
label: `${t.name} — ${t.description.slice(0, 60)} (score: ${t.score.toFixed(2)})`,
|
|
value: t.name,
|
|
}));
|
|
|
|
options.push({ label: 'Dismiss', value: '__dismiss__' });
|
|
|
|
return (
|
|
<PermissionDialog title="Tool Recommendation">
|
|
<Select
|
|
options={options}
|
|
onChange={value => {
|
|
if (value === '__dismiss__') {
|
|
onDismissRef.current();
|
|
} else {
|
|
onDismissRef.current();
|
|
onSelectRef.current(value);
|
|
}
|
|
}}
|
|
/>
|
|
</PermissionDialog>
|
|
);
|
|
}
|