Skip to content

Commit f865bbb

Browse files
shobhit99claude
andcommitted
fix: rebuild commands cache before broadcasting after install/uninstall
The previous fix added broadcastCommandsUpdated() after install, but the launcher still showed the stale list. Root cause: invalidateCache() stashes the old list as staleCommandsFallback so getAvailableCommands() returns it immediately while a background discovery runs — the renderer's follow-up get-commands fetch lands on that stale fallback and never re-fetches when the background rebuild finishes. Await refreshCommandsNow() between invalidate and broadcast so the cache is fresh before the renderer asks for it. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 1db0781 commit f865bbb

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/main/main.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16195,8 +16195,12 @@ return appURL's |path|() as text`,
1619516195
if (!success) {
1619616196
throw new Error(`Failed to install extension "${name}". Check SuperCmd main-process logs for details.`);
1619716197
}
16198-
// Invalidate command cache so new extensions appear in the launcher
16198+
// Invalidate the command cache and rebuild it BEFORE we broadcast, so
16199+
// the renderer's follow-up get-commands fetch lands on fresh data
16200+
// rather than the stale fallback that getAvailableCommands() returns
16201+
// immediately after an invalidation.
1619916202
invalidateCache();
16203+
try { await refreshCommandsNow(); } catch (e) { console.warn('refreshCommandsNow after install failed:', e); }
1620016204
broadcastExtensionsUpdated();
1620116205
// The launcher's root list listens for 'commands-updated', not
1620216206
// 'extensions-updated' — without this, the new extension wouldn't
@@ -16214,8 +16218,10 @@ return appURL's |path|() as text`,
1621416218
async (_event: any, name: string) => {
1621516219
const success = await uninstallExtension(name);
1621616220
if (success) {
16217-
// Invalidate command cache so removed extensions disappear
16221+
// Invalidate the command cache and rebuild synchronously before
16222+
// broadcasting — see install-extension handler for context.
1621816223
invalidateCache();
16224+
try { await refreshCommandsNow(); } catch (e) { console.warn('refreshCommandsNow after uninstall failed:', e); }
1621916225
// Tell the launcher renderer to tear down any live runners (menu-bar
1622016226
// tray, background no-view loop, interval re-runner) for this
1622116227
// extension before its bundle keeps trying to re-mount itself.

0 commit comments

Comments
 (0)