Skip to content

🎨 Palette: Add Clear Search action to empty state#422

Open
AhmmedSamier wants to merge 1 commit intomasterfrom
palette-clear-search-11297952691671506105
Open

🎨 Palette: Add Clear Search action to empty state#422
AhmmedSamier wants to merge 1 commit intomasterfrom
palette-clear-search-11297952691671506105

Conversation

@AhmmedSamier
Copy link
Copy Markdown
Owner

@AhmmedSamier AhmmedSamier commented May 8, 2026

💡 What: Added an actionable "Clear Search" command directly inside the empty state item list when a query yields no results.
🎯 Why: Previously, users hitting an empty state had to manually backspace or select all and delete their query to recover. Providing an inline "Clear Search" button significantly reduces friction and provides a clear, 1-click recovery path.
📸 Before/After: (Visual change inside the QuickPick list for empty states)
Accessibility: Provides a direct, keyboard-navigable action to reset the search without relying on standard text input manipulation, making recovery faster and more explicit.


PR created automatically by Jules for task 11297952691671506105 started by @AhmmedSamier

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a "Clear Search" action to the empty search state, enabling users to quickly reset their search query.

Co-authored-by: AhmmedSamier <17784876+AhmmedSamier@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a "Clear Search" action to the QuickPick empty-state UI that clears the query field and refreshes the display. The implementation includes a command constant, conditional UI insertion, manual event handler invocation to work around a VS Code QuickPick behavior, and process documentation.

Changes

Clear Search Empty-State Action

Layer / File(s) Summary
Command Definition
vscode-extension/src/search-provider.ts
New private constant CMD_CLEAR_SEARCH identifies the "Clear Search" action.
Empty-State UI Integration
vscode-extension/src/search-provider.ts
getEmptyStateItems conditionally inserts a "Clear Search" item when the query is non-empty, before the native "Search in Files" action.
Action Handler
vscode-extension/src/search-provider.ts
handleEmptyStateAction clears quickPick.value and calls handleQueryChange manually, since programmatic value changes do not fire onDidChangeValue.
Implementation Learning
.jules/palette.md
Dated note documenting the empty-state UX pattern and the VS Code QuickPick behavior requiring manual refresh when clearing values programmatically.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A search field clear, a query done,
When empty results and hope has run,
One click removes the query's weight,
And starts anew—no need to wait!
~Rabbit's refresh, no event to show.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a 'Clear Search' action to the empty state, which is the primary modification across both changed files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch palette-clear-search-11297952691671506105

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
vscode-extension/src/search-provider.ts (1)

1680-1700: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Duplicate comment numbering after inserting step 3

After adding // 3. Clear Search Action, the comment at line 1688 (// 4. Rebuild Index Action) and line 1691 (// 5. Clear Cache Action) retain their old numbering, but line 1680 (// 4. Native Search Action) now creates a duplicate 4. label. Steps 5 and 6 are also off-by-one.

✏️ Proposed fix
-        // 4. Native Search Action
+        // 4. Native Search Action  (unchanged — already correct)
         addCommandItem(
             'Search in Files (Native)',
             ...
         );

-        // 4. Rebuild Index Action
+        // 5. Rebuild Index Action
         addCommandItem('Rebuild Index', ...);

-        // 5. Clear Cache Action
+        // 6. Clear Cache Action
         addCommandItem('Clear Index Cache', ...);

-        // 6. Settings Action
+        // 7. Settings Action
         addCommandItem('Configure Settings', ...);
🤖 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 1680 - 1700, Update the
numbered inline comments to maintain a correct sequential list after the
inserted "// 3. Clear Search Action": change the comment before addCommandItem
for CMD_NATIVE_SEARCH to "// 4. Native Search Action", then rename the comment
for CMD_REBUILD_INDEX to "// 5. Rebuild Index Action", the one for
CMD_CLEAR_CACHE to "// 6. Clear Index Cache", and the one for CMD_SETTINGS to
"// 7. Settings Action" so the numbering matches the new order; locate these
comments near the addCommandItem calls and identifiers addCommandItem,
CMD_NATIVE_SEARCH, CMD_REBUILD_INDEX, CMD_CLEAR_CACHE, and CMD_SETTINGS.
🤖 Prompt for all review comments with 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.

Inline comments:
In @.jules/palette.md:
- 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.

In `@vscode-extension/src/search-provider.ts`:
- Around line 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.

---

Outside diff comments:
In `@vscode-extension/src/search-provider.ts`:
- Around line 1680-1700: Update the numbered inline comments to maintain a
correct sequential list after the inserted "// 3. Clear Search Action": change
the comment before addCommandItem for CMD_NATIVE_SEARCH to "// 4. Native Search
Action", then rename the comment for CMD_REBUILD_INDEX to "// 5. Rebuild Index
Action", the one for CMD_CLEAR_CACHE to "// 6. Clear Index Cache", and the one
for CMD_SETTINGS to "// 7. Settings Action" so the numbering matches the new
order; locate these comments near the addCommandItem calls and identifiers
addCommandItem, CMD_NATIVE_SEARCH, CMD_REBUILD_INDEX, CMD_CLEAR_CACHE, and
CMD_SETTINGS.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d87de2d1-78ee-4d8c-8955-20a3594d1fb5

📥 Commits

Reviewing files that changed from the base of the PR and between c197a9f and 0b7ef04.

📒 Files selected for processing (2)
  • .jules/palette.md
  • vscode-extension/src/search-provider.ts

Comment thread .jules/palette.md
@@ -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.

Comment on lines +1532 to +1542
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;
}
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant