From f560a99338c1bcbb6de1eb4b17156610c1e42415 Mon Sep 17 00:00:00 2001 From: TheManZooper Date: Tue, 19 May 2026 13:31:06 +0800 Subject: [PATCH] feat: command palette parity for per-instance reload/hibernate/wake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR #12 added Reload, Hibernate, and Wake to the sidebar right-click context menu. This adds the same operations to the CommandPalette (⌘K) so keyboard-only users get them too. Per instance, the palette now offers: - "Reload " — always shown. Refreshes the instance in place. - "Hibernate " — only when the hibernate feature is enabled AND the instance is not currently active AND it's not already hibernated. - "Wake " — only when the hibernate feature is enabled AND the instance is currently hibernated. The existing fuzzy scoring means typing "hib telegram" instantly surfaces the Hibernate Telegram command. Existing jump/mute commands are unchanged. 178/178 tests still pass, typecheck + build clean. --- src/renderer/components/CommandPalette.tsx | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/renderer/components/CommandPalette.tsx b/src/renderer/components/CommandPalette.tsx index ec8afce..be249ca 100644 --- a/src/renderer/components/CommandPalette.tsx +++ b/src/renderer/components/CommandPalette.tsx @@ -58,8 +58,15 @@ export function CommandPalette() { const openAccountManager = useNexus((s) => s.openAccountManager); const setTheme = useNexus((s) => s.setTheme); const reloadActiveInstance = useNexus((s) => s.reloadActiveInstance); + const reloadInstance = useNexus((s) => s.reloadInstance); + const hibernateInstance = useNexus((s) => s.hibernateInstance); + const wakeInstance = useNexus((s) => s.wakeInstance); const setInstanceMuted = useNexus((s) => s.setInstanceMuted); const lockProfile = useNexus((s) => s.lockProfile); + const activeInstanceId = useNexus((s) => s.state.activeInstanceId); + const hibernatedInstances = useNexus((s) => s.hibernatedInstances); + const hibernateEnabled = + useNexus((s) => s.state.hibernateAfterMinutes) !== undefined; const [query, setQuery] = useState(''); const [selected, setSelected] = useState(0); @@ -75,6 +82,7 @@ export function CommandPalette() { // Instances — jump shortcuts for (const inst of instances) { const mod = modules.find((m) => m.manifest.id === inst.moduleId); + const isHibernated = hibernatedInstances[inst.id] === true; cmds.push({ id: `jump:${inst.id}`, title: inst.name, @@ -95,6 +103,43 @@ export function CommandPalette() { close(); }, }); + cmds.push({ + id: `reload:${inst.id}`, + title: `Reload ${inst.name}`, + hint: 'Refresh this instance without switching to it', + icon: '🔄', + run: () => { + reloadInstance(inst.id).catch(() => {}); + close(); + }, + }); + // Hibernate / Wake commands only appear when the feature is on, + // and they're mutually exclusive based on current state. + if (hibernateEnabled) { + if (isHibernated) { + cmds.push({ + id: `wake:${inst.id}`, + title: `Wake ${inst.name}`, + hint: 'Recreate the view in the background', + icon: '☀️', + run: () => { + wakeInstance(inst.id).catch(() => {}); + close(); + }, + }); + } else if (inst.id !== activeInstanceId) { + cmds.push({ + id: `hibernate:${inst.id}`, + title: `Hibernate ${inst.name}`, + hint: 'Free this instance’s memory now', + icon: '💤', + run: () => { + hibernateInstance(inst.id).catch(() => {}); + close(); + }, + }); + } + } } // Profiles @@ -178,6 +223,12 @@ export function CommandPalette() { openSettings, openAddInstance, reloadActiveInstance, + reloadInstance, + hibernateInstance, + wakeInstance, + activeInstanceId, + hibernatedInstances, + hibernateEnabled, setTheme, close, ]);