From 0b7ef0458b6d35c85f1580c3785997c1475714f1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 8 May 2026 22:41:18 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Add=20Clear=20Search?= =?UTF-8?q?=20action=20to=20empty=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: AhmmedSamier <17784876+AhmmedSamier@users.noreply.github.com> --- .jules/palette.md | 3 +++ vscode-extension/src/search-provider.ts | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 .jules/palette.md diff --git a/.jules/palette.md b/.jules/palette.md new file mode 100644 index 00000000..25949d31 --- /dev/null +++ b/.jules/palette.md @@ -0,0 +1,3 @@ +## 2024-05-18 - Added "Clear Search" Action to Empty State +**Learning:** When users encounter an empty search state, providing an actionable recovery path directly in the list (like a "Clear Search" command) significantly reduces friction compared to requiring manual deletion. Additionally, programmatically clearing a `QuickPick.value` in VS Code does not trigger `onDidChangeValue`, so the associated search/refresh logic must be called manually to reset the UI state. +**Action:** Always include an actionable "Clear" or "Reset" option directly within empty state UI elements, and remember to manually trigger update handlers when programmatically modifying VS Code `QuickPick` input values. \ No newline at end of file diff --git a/vscode-extension/src/search-provider.ts b/vscode-extension/src/search-provider.ts index 577b3faa..e832420c 100644 --- a/vscode-extension/src/search-provider.ts +++ b/vscode-extension/src/search-provider.ts @@ -76,6 +76,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 = { @@ -1528,6 +1529,18 @@ export class SearchProvider { selected: SearchResultItem, quickPick: vscode.QuickPick, ): Promise { + if (selected.result.item.id === this.CMD_CLEAR_SEARCH) { + quickPick.value = ''; + // Manually trigger query change to show history again since onDidChangeValue won't fire programmatically + this.handleQueryChange( + quickPick, + '', + () => {}, + () => {}, + ); + return true; + } + if (selected.result.item.id === this.CMD_NATIVE_SEARCH) { await vscode.commands.executeCommand('workbench.action.findInFiles', { query: quickPick.value, @@ -1654,7 +1667,17 @@ export class SearchProvider { }); }; - // 3. Native Search Action + // 3. Clear Search Action (if query is not empty) + if (query.trim().length > 0) { + 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",