Skip to content

perf(commands): avoid rediscovery for metadata updates#571

Closed
JustYannicc wants to merge 71 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-command-metadata-cache
Closed

perf(commands): avoid rediscovery for metadata updates#571
JustYannicc wants to merge 71 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-command-metadata-cache

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Added a command metadata patch path that updates cached runtime subtitles by command id, including Raycast extension path ids such as extension/command.
  • Replaced subtitle-only invalidateCache() calls for inline script completion and update-command-metadata with the metadata cache patch helper.
  • Kept the command disk cache structural by saving base subtitles and reapplying current runtime metadata on cache load.
  • Added a focused metadata-cache harness that compares the legacy invalidation path with the optimized patch path.

Why

Runtime subtitle updates were persisted into commandMetadata and then invalidated the whole command cache. The next getAvailableCommands() could therefore start full app/settings/extension/script/quick-link discovery even though only one command subtitle changed.

Compatibility impact

Settings format is unchanged. Aliases, installed apps, settings panes, extensions, quick links, scripts, and structural invalidation paths keep their existing behavior. Non-inline script commands still ignore runtime subtitle metadata. Raycast updateCommandMetadata path-style ids now apply consistently during live cache patches and command discovery.

How tested

  • node --test scripts/test-command-metadata-cache.mjs
  • ./node_modules/.bin/tsc -p tsconfig.main.json --noEmit
  • Codex LSP diagnostics for src/main/commands.ts: no errors
  • Codex LSP diagnostics for src/main/main.ts: no errors
  • git diff --check

Performance evidence

Focused harness output for 5,000 cached commands over 60 metadata updates:

  • Legacy invalidation path: structuralDiscoveryStarts=60, median getCommandsMs=0.115
  • Optimized metadata patch path: structuralDiscoveryStarts=0, median getCommandsMs=0.014
  • Avoided structural discovery starts: 60

The harness uses a fake discovery runner so the measurement counts discovery starts deterministically without scanning the local machine.

Stack validation

Started from codex/perf-consolidated-integration-stack / fork/codex/perf-consolidated-integration-stack at 264fb89dc5c867d6c3d77bc4b95e26e235e326ea. Implementation branch is codex/perf-command-metadata-cache, pushed to JustYannicc/SuperCmd, targeting SuperCmdLabs/SuperCmd:main. Dependency setup used pnpm install --ignore-scripts --no-frozen-lockfile --lockfile=false; no package metadata changes were staged.

Replaces

No prior PR. Replaces the subtitle-only runtime metadata paths that broadly invalidated the structural command discovery cache.

…ated-integration-stack

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

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

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
…ated-integration-stack

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime.tsx
… into codex/perf-consolidated-integration-stack
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated upstream PR #573: #573. Closing this smaller PR to keep the command/file wave consolidated.

@JustYannicc JustYannicc closed this Jul 4, 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