Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
25 changes: 23 additions & 2 deletions vscode-extension/src/search-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -1526,6 +1527,18 @@ export class SearchProvider {
selected: SearchResultItem,
quickPick: vscode.QuickPick<SearchResultItem>,
): Promise<boolean> {
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,
Expand Down Expand Up @@ -1652,15 +1665,23 @@ 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",
new vscode.ThemeIcon('search-fuzzy'),
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
Expand Down
Loading