Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .jules/palette.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2024-05-18 - Added "Clear Search" Action to Empty State
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor | ⚑ Quick win

Incorrect date β€” should be 2026, not 2024

The heading reads 2024-05-18 but the PR was opened in May 2026. Consider updating to 2026-05-08 (or the actual merge date) to keep the changelog accurate.

πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.jules/palette.md at line 1, Update the changelog heading that currently
reads "## 2024-05-18 - Added "Clear Search" Action to Empty State" to the
correct 2026 date (e.g. "## 2026-05-08 - Added "Clear Search" Action to Empty
State") so the entry matches the PR timing; edit the heading string in
.jules/palette.md to replace "2024-05-18" with the correct merge date.

**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.
25 changes: 24 additions & 1 deletion vscode-extension/src/search-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -1528,6 +1529,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 query change to show history again since onDidChangeValue won't fire programmatically
this.handleQueryChange(
quickPick,
'',
() => {},
() => {},
);
return true;
}
Comment on lines +1532 to +1542
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚑ Quick win

await missing on handleQueryChange β€” unhandled rejection risk

handleQueryChange is async, and handleEmptyStateAction is also async, yet the call at line 1535 is fire-and-forget. If showRecentHistory (invoked inside handleQueryChange) rejects, the error silently becomes an unhandled promise rejection.

πŸ› Proposed fix
-        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_CLEAR_SEARCH) {
+            quickPick.value = '';
+            // Manually trigger query change to show history again since onDidChangeValue won't fire programmatically
+            await this.handleQueryChange(
+                quickPick,
+                '',
+                () => {},
+                () => {},
+            );
+            return true;
+        }

As per coding guidelines: "Prefer async/await over raw promises for handling asynchronous code" and "Always handle potential rejections in background tasks to prevent unhandled promise rejections."

πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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_CLEAR_SEARCH) {
quickPick.value = '';
// Manually trigger query change to show history again since onDidChangeValue won't fire programmatically
await this.handleQueryChange(
quickPick,
'',
() => {},
() => {},
);
return true;
}
πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@vscode-extension/src/search-provider.ts` around lines 1532 - 1542, The call
to the async method handleQueryChange inside handleEmptyStateAction is currently
fire-and-forget, risking unhandled promise rejections (showRecentHistory called
inside handleQueryChange can reject); update the call to await handleQueryChange
and wrap it in a try/catch (or otherwise handle the rejection) so any errors are
caught and logged/handled before returning from handleEmptyStateAction; ensure
you keep the same quickPick/value behavior and return true after the awaited
call.


if (selected.result.item.id === this.CMD_NATIVE_SEARCH) {
await vscode.commands.executeCommand('workbench.action.findInFiles', {
query: quickPick.value,
Expand Down Expand Up @@ -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",
Expand Down
Loading