Skip to content

Remember search settings between reopenings#44

Open
subhajitlucky wants to merge 2 commits into
zigcBenx:masterfrom
subhajitlucky:remember-search-settings-31
Open

Remember search settings between reopenings#44
subhajitlucky wants to merge 2 commits into
zigcBenx:masterfrom
subhajitlucky:remember-search-settings-31

Conversation

@subhajitlucky
Copy link
Copy Markdown

Fixes #31.

Summary

  • Stores the latest search text, file mask, scope, and directory path while the webview is used.
  • Restores those settings when reopening the normal search panel after a result was opened and the panel closed.
  • Keeps selected-text searches and folder context-menu searches as explicit fresh searches.

Validation

  • npm run compile
  • git diff --check

Note: npm run lint still fails because the repository has no ESLint configuration file for the existing lint script.

Copilot AI review requested due to automatic review settings May 13, 2026 03:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 SearchState model and a new updateSearchState message 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 an updateSearchState message on every performSearch() 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 existing searchTimeout cadence 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 thread src/WebviewManager.ts
Comment on lines +134 to +141
if (restoreLastState && this.lastSearchState) {
setTimeout(() => {
panel.webview.postMessage({
command: 'restoreSearchState',
state: this.lastSearchState
});
}, 100);
}
Comment thread src/webview/script.ts
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 thread src/extension.ts
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();
}
@subhajitlucky
Copy link
Copy Markdown
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.

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.

Remember settings between searches

2 participants