Skip to content

perf: target extension command refresh#586

Closed
JustYannicc wants to merge 115 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/targeted-extension-command-refresh
Closed

perf: target extension command refresh#586
JustYannicc wants to merge 115 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/targeted-extension-command-refresh

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Added refreshCommandsForExtensionChange() to rebuild the command cache from an existing cached/stale base while refreshing only installed extension command entries.
  • Shared extension, script, quick-link, deeplink, metadata, and disk-cache publishing logic between full discovery and the targeted extension refresh path.
  • Updated install/uninstall IPC handlers to run the targeted refresh before existing broadcasts, preserving renderer follow-up get-commands freshness.
  • Added focused command-cache tests and a benchmark for extension install/uninstall refresh behavior.

Why

Extension install/uninstall previously invalidated the command cache and synchronously called the full refreshCommandsNow() path. That rediscovered apps, System Settings, quick links, scripts, extension commands, app/settings icons, metadata overlays, and saved the full disk cache even though the extension registry already invalidates runner caches narrowly and only extension command presence changed.

Compatibility impact

  • Broadcast semantics remain compatible: install still sends extensions-updated then commands-updated; uninstall still sends extension-uninstalled, extensions-updated, then commands-updated.
  • Renderer follow-up get-commands sees fresh extension command presence/absence before broadcasts are sent.
  • If no command cache exists, the targeted path falls back to the existing full refreshCommandsNow() behavior.
  • Raycast-compatible extension discovery and command metadata/deeplink behavior are preserved via shared mapping/publishing helpers.

How tested

  • node --test scripts/test-extension-command-refresh-cache.mjs
  • node --test scripts/test-command-metadata-cache.mjs scripts/test-command-ipc-payload-cache.mjs
  • node --test scripts/test-extension-command-refresh-cache.mjs scripts/test-command-metadata-cache.mjs scripts/test-command-ipc-payload-cache.mjs
  • npm run build:main (local npm wrapper delegates to pnpm)
  • Codex LSP diagnostics on src/main/commands.ts and src/main/main.ts: no diagnostics found.

Performance evidence

Focused benchmark from scripts/test-extension-command-refresh-cache.mjs with a warm command cache and 2,006 cached base commands:

  • Before/legacy invalidation + full refresh: 40 structural discovery starts; median refresh 10.361ms with an 8ms simulated app/settings discovery cost.
  • After targeted extension refresh: 0 structural discovery starts; 40 extension discovery starts; median refresh 3.284ms.
  • Avoided structural discovery starts: 40/40. The add/remove tests also assert command list freshness and that structural discovery is not invoked when a cache exists.

Stack validation

  • Started from 206eab8280a2eb91a57e4e74ea6df99e45a55cb4, contained by codex/perf-wave3-integration-stack-20260704.
  • Implementation branch: codex/targeted-extension-command-refresh.
  • Read docs/extension-install-flow.md before changing install/backend-adjacent extension refresh code.

Replaces

Replaces the install/uninstall IPC post-success full command rediscovery with a targeted extension command refresh when an in-memory or stale command cache is available.

…perf-wave2-integration-stack-20260704

# Conflicts:
#	src/renderer/src/raycast-api/hooks/use-cached-promise.ts
…perf-wave2-integration-stack-20260704

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime-renderers.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…perf-wave2-integration-stack-20260704

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
…perf-wave2-integration-stack-20260704

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime.tsx
…perf-wave2-integration-stack-20260704

# Conflicts:
#	scripts/bench-script-command-discovery.mjs
#	scripts/benchmark-file-search-delete-batch.mjs
#	scripts/lib/script-command-runner-harness.mjs
#	scripts/lib/ts-import.mjs
#	scripts/test-file-search-delete-batch.mjs
#	scripts/test-script-command-runner.mjs
#	src/main/file-search-index.ts
#	src/main/main.ts
…perf-wave2-integration-stack-20260704

# Conflicts:
#	scripts/lib/script-command-runner-harness.mjs
#	scripts/lib/ts-import.mjs
#	scripts/test-extension-lifecycle-sandbox.mjs
#	scripts/test-script-command-runner.mjs
#	src/main/main.ts
#	src/renderer/src/ExtensionView.tsx
…perf-wave2-integration-stack-20260704

# Conflicts:
#	.github/workflows/project-checks.yml
#	scripts/test-root-search-perf.mjs
#	src/renderer/src/CameraExtension.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…erf-wave3-integration-stack-20260704

# Conflicts:
#	package.json
#	scripts/measure-extension-bundle-cache.mjs
#	scripts/test-icon-runtime-file-icon-cache.mjs
#	src/main/extension-runner.ts
#	src/renderer/src/components/HiddenExtensionRunners.tsx
#	src/renderer/src/raycast-api/icon-runtime-render.tsx
…/perf-wave3-integration-stack-20260704

# Conflicts:
#	scripts/test-browser-search-performance.mjs
#	scripts/test-root-search-perf.mjs
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #601, which fully replaces this granular PR in the wave4 runtime/main consolidation. Literal validation now passes with /opt/homebrew/opt/node@22/bin/npm run build:main, and #601 is ready for review.

@JustYannicc JustYannicc closed this Jul 5, 2026
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.

1 participant