🎨 Palette: Add Clear Search action to empty state#422
🎨 Palette: Add Clear Search action to empty state#422AhmmedSamier wants to merge 1 commit intomasterfrom
Conversation
Co-authored-by: AhmmedSamier <17784876+AhmmedSamier@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
📝 WalkthroughWalkthroughThis 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. ChangesClear Search Empty-State Action
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winDuplicate 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 duplicate4.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
📒 Files selected for processing (2)
.jules/palette.mdvscode-extension/src/search-provider.ts
| @@ -0,0 +1,3 @@ | |||
| ## 2024-05-18 - Added "Clear Search" Action to Empty State | |||
There was a problem hiding this comment.
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.
| 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; | ||
| } |
There was a problem hiding this comment.
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.
| 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.
💡 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