fix: prevent flash of unfiltered list when pressing Enter to open app by monotykamary · Pull Request #371 · SuperCmdLabs/SuperCmd · GitHub
Skip to content

fix: prevent flash of unfiltered list when pressing Enter to open app#371

Merged
shobhit99 merged 5 commits into
SuperCmdLabs:mainfrom
monotykamary:fix/launcher-flash-on-enter
May 13, 2026
Merged

fix: prevent flash of unfiltered list when pressing Enter to open app#371
shobhit99 merged 5 commits into
SuperCmdLabs:mainfrom
monotykamary:fix/launcher-flash-on-enter

Conversation

@monotykamary

@monotykamary monotykamary commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes a visible flash of the default (unfiltered) command list that appears when pressing Enter to open an application from search, and the corresponding flash of stale search results when reopening the launcher.

Closes #370

Problem

Two related flash issues:

On close: When pressing Enter on a search result, the renderer clears searchQuery after the IPC call returns, triggering a React re-render of the unfiltered list while the window is still visible (the main process hides it on a 50ms delay).

On reopen: If the search state is not cleared before hiding, the filtered list persists while the window is hidden — and when the window reopens, onWindowShown resets the search, causing a flash of the old filtered state before it clears.

Before:

Screen.Recording.2026-05-09.at.01.54.12.mov

After:

Screen.Recording.2026-05-09.at.01.56.43.mov

Fix

Clear the search state (searchQuery and selectedIndex) in the window-hidden handler instead. The window is already invisible at that point, so the React re-render happens offscreen — no flash on close. When the window reopens, the state is already empty — no flash on open.

In onWindowShown, search state is only set when there is a pendingQuery (pre-filled search for hotkey-triggered commands with missing args). The redundant setSearchQuery("") / setSelectedIndex(0) calls throughout the hide-and-clear code paths are removed entirely.

Additionally, the return value of executeCommand() is now checked for system commands with native confirmation dialogs (system-close-all-apps, system-restart, system-logout) — if the user cancels, the launcher stays open.

Changes in App.tsx

Change Details
onWindowHidden handler Added setSearchQuery("") and setSelectedIndex(0) — clears state while window is invisible
onWindowShown handler Removed unconditional setSearchQuery("") / setSelectedIndex(0) from routed system command, direct-launch guard, and default reopen paths; only sets search when pendingQuery is present
handleCommandExecute — generic app commands Removed setSearchQuery("") / setSelectedIndex(0) after hideWindow()
handleCommandExecute — system commands with confirmation Check executeCommand() return value; removed redundant search clear
handleCommandExecute — menu-bar extension toggle Removed setSearchQuery("") / setSelectedIndex(0) after hideWindow()
handleCommandExecute — file result path Removed setSearchQuery("") / setSelectedIndex(0) (already calls hideWindow() via openFileResultByPath)
submitBrowserSearch Removed setSearchQuery("") / setSelectedIndex(0) after hideWindow()
executeQuickLinkCommand (×2) Removed setSearchQuery("") / setSelectedIndex(0) after hideWindow()
runScriptCommand — hidden result mode Removed setSearchQuery("") / setSelectedIndex(0) after hideWindow()
ExtensionPreferenceSetupView save callback Removed setSearchQuery("") and setSelectedIndex(0)

Testing

  • Search for an application, press Enter → no flash, window hides cleanly
  • Reopen launcher → no flash, empty search shown immediately
  • Browser search (Tab → Enter) → no flash on close or reopen
  • Quick link execution → no flash
  • Menu-bar extension toggle → no flash
  • Script command with inline result → no flash
  • Cancel native confirmation dialog (e.g. Restart) → launcher stays open
  • Hotkey-triggered command with missing args → reopens with pre-filled search

Reorder hide-then-clear sequences so window.electron.hideWindow() is
awaited before setSearchQuery('') and setSelectedIndex(0). Without this,
React re-renders the unfiltered command list between the IPC return and
the main process's 50ms hideWindow() timer, producing a visible flash.

Closes SuperCmdLabs#370

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: add1147d78

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/renderer/src/App.tsx Outdated
Check the return value of executeCommand() before hiding the window
and clearing search. When the user cancels the native confirmation
dialog for system-close-all-apps, system-restart, or system-logout,
the IPC returns false — the launcher should stay open and keep the
current search state rather than disappearing.

Addresses PR review feedback on SuperCmdLabs#371
@monotykamary monotykamary marked this pull request as draft May 8, 2026 18:49
…out flash

Don't clear searchQuery/selectedIndex when hiding the window. The
onWindowShown handler already resets them on reopen, so the clears
are redundant. Worse, they cause a React re-render showing the
unfiltered list during the window's blur/fade-out animation — still
visible as a 2-3 frame flash even when hideWindow() is awaited
first.

Instead, keep the filtered list rendered while the window animates
out. No re-render = no flash.
Moving setSearchQuery('') and setSelectedIndex(0) into the
window-hidden handler clears the state while the window is still
invisible, eliminating the flash of the old filtered list that
appeared on reopen before onWindowShown could reset it.

In onWindowShown, search state is only set when there's a
pendingQuery (pre-filled search for commands with missing args).
@monotykamary monotykamary marked this pull request as ready for review May 8, 2026 18:58
@monotykamary

Copy link
Copy Markdown
Collaborator Author

@shobhit99 shobhit99 merged commit 8afb8fa into SuperCmdLabs:main May 13, 2026
0 of 2 checks passed
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.

Flash of unfiltered command list when pressing Enter to open an application

2 participants