From e0fe0e1a3e8cf8f6fafa5b399457daa8405eb140 Mon Sep 17 00:00:00 2001 From: lyzno1 <92089059+lyzno1@users.noreply.github.com> Date: Wed, 13 Aug 2025 13:55:25 +0800 Subject: [PATCH] fix: goto-anything command filter should only match shortcut (#23862) --- .../goto-anything/command-selector.test.tsx | 32 +++++++++---------- .../goto-anything/command-selector.tsx | 1 - 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/web/__tests__/goto-anything/command-selector.test.tsx b/web/__tests__/goto-anything/command-selector.test.tsx index 1073b9d48..1db4be31f 100644 --- a/web/__tests__/goto-anything/command-selector.test.tsx +++ b/web/__tests__/goto-anything/command-selector.test.tsx @@ -37,7 +37,7 @@ describe('CommandSelector', () => { }, knowledge: { key: '@knowledge', - shortcut: '@knowledge', + shortcut: '@kb', title: 'Search Knowledge', description: 'Search knowledge bases', search: jest.fn(), @@ -75,7 +75,7 @@ describe('CommandSelector', () => { ) expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() - expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() + expect(screen.getByTestId('command-item-@kb')).toBeInTheDocument() expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() }) @@ -90,7 +90,7 @@ describe('CommandSelector', () => { ) expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() - expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() + expect(screen.getByTestId('command-item-@kb')).toBeInTheDocument() expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() }) @@ -107,7 +107,7 @@ describe('CommandSelector', () => { ) expect(screen.queryByTestId('command-item-@app')).not.toBeInTheDocument() - expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() + expect(screen.getByTestId('command-item-@kb')).toBeInTheDocument() expect(screen.queryByTestId('command-item-@plugin')).not.toBeInTheDocument() expect(screen.queryByTestId('command-item-@node')).not.toBeInTheDocument() }) @@ -122,7 +122,7 @@ describe('CommandSelector', () => { ) expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() - expect(screen.queryByTestId('command-item-@knowledge')).not.toBeInTheDocument() + expect(screen.queryByTestId('command-item-@kb')).not.toBeInTheDocument() expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() expect(screen.queryByTestId('command-item-@node')).not.toBeInTheDocument() }) @@ -137,7 +137,7 @@ describe('CommandSelector', () => { ) expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() - expect(screen.queryByTestId('command-item-@knowledge')).not.toBeInTheDocument() + expect(screen.queryByTestId('command-item-@kb')).not.toBeInTheDocument() }) it('should match partial strings', () => { @@ -145,14 +145,14 @@ describe('CommandSelector', () => { , ) expect(screen.queryByTestId('command-item-@app')).not.toBeInTheDocument() - expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() + expect(screen.queryByTestId('command-item-@kb')).not.toBeInTheDocument() expect(screen.queryByTestId('command-item-@plugin')).not.toBeInTheDocument() - expect(screen.queryByTestId('command-item-@node')).not.toBeInTheDocument() + expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() }) }) @@ -167,7 +167,7 @@ describe('CommandSelector', () => { ) expect(screen.queryByTestId('command-item-@app')).not.toBeInTheDocument() - expect(screen.queryByTestId('command-item-@knowledge')).not.toBeInTheDocument() + expect(screen.queryByTestId('command-item-@kb')).not.toBeInTheDocument() expect(screen.queryByTestId('command-item-@plugin')).not.toBeInTheDocument() expect(screen.queryByTestId('command-item-@node')).not.toBeInTheDocument() @@ -210,7 +210,7 @@ describe('CommandSelector', () => { />, ) - expect(mockOnCommandValueChange).toHaveBeenCalledWith('@knowledge') + expect(mockOnCommandValueChange).toHaveBeenCalledWith('@kb') }) it('should not call onCommandValueChange if current value still exists', () => { @@ -246,10 +246,10 @@ describe('CommandSelector', () => { />, ) - const knowledgeItem = screen.getByTestId('command-item-@knowledge') + const knowledgeItem = screen.getByTestId('command-item-@kb') fireEvent.click(knowledgeItem) - expect(mockOnCommandSelect).toHaveBeenCalledWith('@knowledge') + expect(mockOnCommandSelect).toHaveBeenCalledWith('@kb') }) }) @@ -276,7 +276,7 @@ describe('CommandSelector', () => { ) expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() - expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() + expect(screen.getByTestId('command-item-@kb')).toBeInTheDocument() expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() }) @@ -312,7 +312,7 @@ describe('CommandSelector', () => { ) expect(screen.getByTestId('command-item-@app')).toBeInTheDocument() - expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() + expect(screen.getByTestId('command-item-@kb')).toBeInTheDocument() expect(screen.getByTestId('command-item-@plugin')).toBeInTheDocument() expect(screen.getByTestId('command-item-@node')).toBeInTheDocument() }) @@ -326,7 +326,7 @@ describe('CommandSelector', () => { />, ) - expect(screen.getByTestId('command-item-@knowledge')).toBeInTheDocument() + expect(screen.getByTestId('command-item-@kb')).toBeInTheDocument() expect(screen.queryByTestId('command-item-@app')).not.toBeInTheDocument() }) }) diff --git a/web/app/components/goto-anything/command-selector.tsx b/web/app/components/goto-anything/command-selector.tsx index d13421a0e..6ec179c3e 100644 --- a/web/app/components/goto-anything/command-selector.tsx +++ b/web/app/components/goto-anything/command-selector.tsx @@ -20,7 +20,6 @@ const CommandSelector: FC = ({ actions, onCommandSelect, searchFilter, co return true const filterLower = searchFilter.toLowerCase() return action.shortcut.toLowerCase().includes(filterLower) - || action.key.toLowerCase().includes(filterLower) }) useEffect(() => {