Skip to content

The agent that grows with you

fix(desktop): clear the theme preview at palette close start

ethernetae162f7e5c94
diff --git a/apps/desktop/src/app/command-palette/index.tsx b/apps/desktop/src/app/command-palette/index.tsx
index 55b2f85fda7..6a457aa6c1e 100644
--- a/apps/desktop/src/app/command-palette/index.tsx
+++ b/apps/desktop/src/app/command-palette/index.tsx
@@ -1424,12 +1424,24 @@ function CommandPaletteBody({ onExited }: { onExited: () => void }) {
[clearThemePreview, itemByValue]
)
- // A preview lives only while its rows show. If the page changes or the
- // palette retires, give the paint back to the committed appearance.
+ // A preview lives only while its rows show. If the page changes, give the
+ // paint back to the committed appearance.
useEffect(() => {
clearThemePreview()
}, [page, clearThemePreview])
+ // Clear at close START, not at unmount. The body stays mounted through the
+ // whole exit animation (see CommandPalette), so an unmount clear would
+ // revert the theme only after the fade. The unmount return is the backstop
+ // for a body that dies without a close (a remount on reopen).
+ const paletteOpen = useStore($commandPaletteOpen)
+
+ useEffect(() => {
+ if (!paletteOpen) {
+ clearThemePreview()
+ }
+ }, [paletteOpen, clearThemePreview])
+
useEffect(() => clearThemePreview, [clearThemePreview])
const handleSelect = (item: PaletteItem) => {