Remember search settings between reopenings#44
Open
subhajitlucky wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements “remember last search settings” behavior for the Storm Search webview so reopening the normal search panel restores the prior query/filter/scope instead of starting from a blank state, addressing issue #31.
Changes:
- Added a
SearchStatemodel and a newupdateSearchStatemessage to persist search UI state from the webview to the extension host. - Restores the last known search state when reopening the default search panel (without selected text / folder-context fresh search).
- Updated the command fallback behavior to reopen the last search when no selection is present.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/WebviewManager.ts | Stores last SearchState and posts a restore message when creating the normal panel. |
| src/webview/script.ts | Captures/persists search UI state and applies restored state on reopen. |
| src/types.ts | Introduces SearchState and extends WebviewMessage with updateSearchState. |
| src/extension.ts | Adjusts command behavior to reopen last search when no selected text exists. |
Comments suppressed due to low confidence (1)
src/webview/script.ts:132
persistSearchState()posts anupdateSearchStatemessage on everyperformSearch()call (i.e., on each keypress in the search box, file mask, and scope path). This can create a lot of extension-host message traffic compared to the debounced search request itself. Consider debouncing/throttling state persistence (e.g., reuse the existingsearchTimeoutcadence or persist only after a short idle period) to reduce overhead.
function performSearch() {
const searchText = (searchInput as HTMLInputElement).value.trim();
persistSearchState();
if (!searchText) {
clearResults();
return;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+134
to
+141
| if (restoreLastState && this.lastSearchState) { | ||
| setTimeout(() => { | ||
| panel.webview.postMessage({ | ||
| command: 'restoreSearchState', | ||
| state: this.lastSearchState | ||
| }); | ||
| }, 100); | ||
| } |
Comment on lines
+501
to
+512
| scopeButtons.forEach(btn => { | ||
| btn.classList.toggle('active', btn.getAttribute('data-scope') === scope); | ||
| }); | ||
|
|
||
| currentScope = scope === 'directory' ? 'directory' : 'project'; | ||
|
|
||
| if (currentScope === 'directory') { | ||
| scopeInputContainer.style.display = 'flex'; | ||
| } else { | ||
| scopeInputContainer.style.display = 'none'; | ||
| scopePath = ''; | ||
| scopePathInput.value = ''; |
Comment on lines
+47
to
+52
| // Fallback: selected text starts a fresh search; otherwise return to the last search. | ||
| if (selectedText) { | ||
| webviewManager?.showNewTab(selectedText); | ||
| } else { | ||
| webviewManager?.show(); | ||
| } |
Author
|
Pushed a follow-up commit (844b8c9) that debounces search-driven state persistence. Typing still restores correctly, but rapid input no longer posts an updateSearchState message on every keypress. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #31.
Summary
Validation
npm run compilegit diff --checkNote:
npm run lintstill fails because the repository has no ESLint configuration file for the existing lint script.