From 66bcb7e71c8ba2c7b3f82353084add277fde0fab Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 7 May 2026 22:17:11 +0000 Subject: [PATCH] feat: add Clear Search action to QuickPick empty state Co-authored-by: AhmmedSamier <17784876+AhmmedSamier@users.noreply.github.com> --- .Jules/palette.md | 4 ++++ vscode-extension/src/search-provider.ts | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.Jules/palette.md b/.Jules/palette.md index 83b4b40..b8466c7 100644 --- a/.Jules/palette.md +++ b/.Jules/palette.md @@ -2,3 +2,7 @@ **Learning:** When clearing the VS Code QuickPick input, if `quickPick.busy` is true from a previous pending search phase, it will spin indefinitely unless explicitly disabled since empty search queries simply clear results array and exit early. **Action:** When handling early returns for empty search states or error states in a QuickPick workflow, always explicitly reset `quickPick.busy = false` to prevent confusing infinite loading states. + +## 2024-05-07 - Actionable Empty States in Search QuickPick +**Learning:** When users encounter an empty state in a search interface (like a VS Code QuickPick), they often need to manually erase their query to recover. Providing an explicit, actionable recovery path (such as a 'Clear Search' button) directly within the empty state context significantly reduces interaction friction. +**Action:** When designing empty state UI components (e.g. no results found), always ensure there is an immediate, actionable way to clear the current filter/query context built directly into the empty state container rather than relying on external input modifications. diff --git a/vscode-extension/src/search-provider.ts b/vscode-extension/src/search-provider.ts index 00be302..c62944e 100644 --- a/vscode-extension/src/search-provider.ts +++ b/vscode-extension/src/search-provider.ts @@ -74,6 +74,7 @@ export class SearchProvider { private readonly CMD_REBUILD_INDEX = 'command:rebuild-index'; private readonly CMD_CLEAR_CACHE = 'command:clear-cache'; private readonly CMD_SETTINGS = 'command:open-settings'; + private readonly CMD_CLEAR_SEARCH = 'command:clear-search'; private readonly ID_EMPTY_STATE = 'empty-state'; private static readonly CANCEL_BUTTON: vscode.QuickInputButton = { @@ -1526,6 +1527,18 @@ export class SearchProvider { selected: SearchResultItem, quickPick: vscode.QuickPick, ): Promise { + if (selected.result.item.id === this.CMD_CLEAR_SEARCH) { + quickPick.value = ''; + // Manually trigger handleQueryChange as programmatic update won't fire onDidChangeValue + this.handleQueryChange( + quickPick, + '', + () => {}, + () => {}, + ); + return true; + } + if (selected.result.item.id === this.CMD_NATIVE_SEARCH) { await vscode.commands.executeCommand('workbench.action.findInFiles', { query: quickPick.value, @@ -1652,7 +1665,15 @@ export class SearchProvider { }); }; - // 3. Native Search Action + // 3. Clear Search Action + addCommandItem( + 'Clear Search', + 'Clear current query and start over', + new vscode.ThemeIcon('clear-all'), + this.CMD_CLEAR_SEARCH, + ); + + // 4. Native Search Action addCommandItem( 'Search in Files (Native)', "Use VS Code's native search", @@ -1660,7 +1681,7 @@ export class SearchProvider { this.CMD_NATIVE_SEARCH, ); - // 4. Rebuild Index Action + // 5. Rebuild Index Action addCommandItem('Rebuild Index', 'Fix missing files', new vscode.ThemeIcon('refresh'), this.CMD_REBUILD_INDEX); // 5. Clear Cache Action