diff --git a/.jules/palette.md b/.jules/palette.md new file mode 100644 index 0000000..517b0a0 --- /dev/null +++ b/.jules/palette.md @@ -0,0 +1,3 @@ +## 2024-05-09 - Providing Actionable Recovery Paths in Empty States +**Learning:** When users encounter an empty search state, simply showing a "No results" message creates friction, forcing them to manually clear the input to try again. By providing an actionable recovery path directly within the empty state container (like a 'Clear Search' button), the interface becomes much more intuitive and reduces the number of interactions required to recover from a failed search. +**Action:** When designing empty states in the UI (e.g., no search results, empty lists), always provide an actionable recovery path directly within the empty state container to reduce interaction friction. diff --git a/vscode-extension/src/search-provider.ts b/vscode-extension/src/search-provider.ts index 577b3fa..b7e89f3 100644 --- a/vscode-extension/src/search-provider.ts +++ b/vscode-extension/src/search-provider.ts @@ -75,6 +75,7 @@ export class SearchProvider { private readonly CMD_SWITCH_SCOPE = 'command:switch-scope-everything'; private readonly CMD_REBUILD_INDEX = 'command:rebuild-index'; private readonly CMD_CLEAR_CACHE = 'command:clear-cache'; + private readonly CMD_CLEAR_SEARCH = 'command:clear-search'; private readonly CMD_SETTINGS = 'command:open-settings'; private readonly ID_EMPTY_STATE = 'empty-state'; @@ -1578,6 +1579,17 @@ export class SearchProvider { return true; } + if (selected.result.item.id === this.CMD_CLEAR_SEARCH) { + quickPick.value = ''; + this.handleQueryChange( + quickPick, + '', + () => {}, + () => {}, + ); + return true; + } + return selected.result.item.id === this.ID_EMPTY_STATE; } @@ -1662,13 +1674,16 @@ export class SearchProvider { this.CMD_NATIVE_SEARCH, ); - // 4. Rebuild Index Action + // 4. Clear Search Action + addCommandItem('Clear Search', 'Start a new search', new vscode.ThemeIcon('clear-all'), this.CMD_CLEAR_SEARCH); + + // 5. Rebuild Index Action addCommandItem('Rebuild Index', 'Fix missing files', new vscode.ThemeIcon('refresh'), this.CMD_REBUILD_INDEX); - // 5. Clear Cache Action + // 6. Clear Cache Action addCommandItem('Clear Index Cache', 'Fix corruption', new vscode.ThemeIcon('trash'), this.CMD_CLEAR_CACHE); - // 6. Settings Action + // 7. Settings Action addCommandItem( 'Configure Settings', 'Check exclusion rules', diff --git a/vscode-extension/src/test/suite/reference-code-lens.test.ts b/vscode-extension/src/test/suite/reference-code-lens.test.ts index 5efdd8e..a798eef 100644 --- a/vscode-extension/src/test/suite/reference-code-lens.test.ts +++ b/vscode-extension/src/test/suite/reference-code-lens.test.ts @@ -413,7 +413,7 @@ export const variable = 42; if (args && args.length >= 3 && Array.isArray(args[2])) { const locations = args[2]; const hasDeclaration = locations.some( - (loc: any) => + (loc: vscode.Location) => loc.uri.toString() === mockDocument.uri.toString() && loc.range.isEqual(lenses[0].range), );