fix: update search flow - first tool search

This commit is contained in:
2026-08-26 12:34:41 +05:00
parent 84cc56cc6c
commit 3c1c5b2b3a
3 changed files with 29 additions and 3 deletions
+1 -1
View File
@@ -364,7 +364,7 @@
</button> </button>
</header> </header>
<ToolSearch onSelect={(id) => applyChainTool(index, id)} /> <ToolSearch onSelect={(id) => applyChainTool(index, id)} chainableOnly />
</div> </div>
{:else if getTool(step.toolId)} {:else if getTool(step.toolId)}
{@const stepTool = getTool(step.toolId)!} {@const stepTool = getTool(step.toolId)!}
@@ -9,11 +9,13 @@
interface Props { interface Props {
onSelect: (toolId: string) => void; onSelect: (toolId: string) => void;
/** true — только инструменты, пригодные в шаг цепочки (слот добавления шага). */
chainableOnly?: boolean;
} }
let { onSelect }: Props = $props(); let { onSelect, chainableOnly = false }: Props = $props();
const candidates = TOOLS.filter(isChainable); const candidates = chainableOnly ? TOOLS.filter(isChainable) : TOOLS;
let query = $state(''); let query = $state('');
let activeIndex = $state(0); let activeIndex = $state(0);
+24
View File
@@ -0,0 +1,24 @@
import { describe, expect, it } from 'vitest';
import { TOOLS } from '../registry';
import { normalizeForSearch, scoreDoc } from './matching';
import { toolSearchDoc } from './tool-strings';
import { isChainable } from '../registry';
function hits(q: string): string[] {
const nq = normalizeForSearch(q);
return TOOLS.filter((t) => {
const s = scoreDoc(toolSearchDoc(t), nq);
return s !== null && s > 0;
}).map((t) => t.id);
}
describe('полнота поиска', () => {
it('генератор (не chainable) находится поиском — раньше отфильтровывался', () => {
expect(isChainable(TOOLS.find((t) => t.id === 'color-wheel-png')!)).toBe(false);
expect(hits('color wheel')).toContain('color-wheel-png');
});
it('анализатор-маска тоже ищется', () => {
expect(hits('уникальных цветов')).toContain('unique-color-mask-png');
});
});