Skip to content

perf(hooks): stabilize Raycast hook signatures - #613

Closed
JustYannicc wants to merge 121 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-hooks-raycast-runtime-signatures
Closed

perf(hooks): stabilize Raycast hook signatures#613
JustYannicc wants to merge 121 commits into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-hooks-raycast-runtime-signatures

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Added a shared Raycast hook args signature helper that catches circular data and caches repeat signatures for same-identity args.
  • Switched usePromise and useCachedPromise to the shared stable args helper, removing the direct render-time JSON.stringify(args || []) crash path in useCachedPromise.
  • Keyed useExec revalidation on command, argv, and execution-affecting options so dynamic hook inputs trigger execution again.
  • Added focused hook regression coverage and a small signature measurement script.

Why

useCachedPromise could stringify hook args directly during render, which made large arg arrays hot and crashed on circular args. useExec also passed an empty dependency args list into usePromise, so command, args, or execution option changes could be missed until manual revalidation.

Compatibility impact

Raycast hook API shapes and exports are unchanged. Callback and option refs continue flowing through the existing usePromise ref path. useSQL already keys dynamic database/query inputs, and useFetch already has a guarded request key. useStreamJSON option-signature invalidation was left as a non-actionable candidate for this PR to avoid broadening behavior beyond the requested hook invalidation fix.

How tested

  • node --test scripts/test-raycast-hook-signatures.mjs
  • node --test scripts/test-raycast-hook-signatures.mjs scripts/test-abortable-promise-hooks.mjs scripts/test-use-fetch-stale-runs.mjs scripts/test-use-stream-json-lifecycle.mjs
  • ./node_modules/.bin/tsc -p tsconfig.renderer.json --noEmit --pretty false
  • node scripts/run-node-tests.mjs --exclude-perf passed with 317 passing, 1 skipped, 0 failures.
  • Codex LSP diagnostics reported no errors for use-stable-args.ts, use-promise.ts, use-cached-promise.ts, and use-exec.ts.

Performance evidence

node scripts/measure-raycast-hook-signatures.mjs with 500 iterations over 10,000 large rows:

  • direct repeated JSON.stringify: 463.667 ms
  • cached getStableArgsKey repeated same identity: 0.061 ms
  • cyclic args signature generation: 2.13 ms without throwing
  • measured same-identity speedup: 7601.1x

Stack validation

Started from codex/perf-wave4-integrated-stack-20260705 base SHA ac90ce403aeddab98d0a1b245afce268c48b8bfd and created codex/perf-hooks-raycast-runtime-signatures from that exact commit. The local npm command is intentionally disabled on this Mac, so dependencies were populated with runtime pnpm for validation only; node scripts/check-package-manager-parity.mjs cannot pass in this environment because that install resolved several package versions differently than package-lock.json expects. No dependency files are included in the PR.

Replaces

N/A

(cherry picked from commit 83c2a89)
(cherry picked from commit 0a7560b)
# Conflicts:
#	src/renderer/src/raycast-api/hooks/use-cached-promise.ts
…launcher surfaces

# Conflicts:
#	src/renderer/src/raycast-api/list-runtime-renderers.tsx
#	src/renderer/src/raycast-api/list-runtime.tsx
…IO stalls

# Conflicts:
#	src/renderer/src/CameraExtension.tsx
# Conflicts:
#	src/renderer/src/raycast-api/list-runtime.tsx
…resh overhead

# 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
…hurn

# 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
… hot paths

# Conflicts:
#	scripts/test-use-frecency-sorting.mjs
#	src/renderer/src/raycast-api/form-runtime.tsx
#	src/renderer/src/raycast-api/grid-runtime-hooks.ts
#	src/renderer/src/raycast-api/grid-runtime-items.tsx
#	src/renderer/src/raycast-api/hooks/use-frecency-sorting.ts
# Conflicts:
#	.github/workflows/project-checks.yml
#	package.json
#	scripts/file-search-perf-harness.mjs
#	scripts/test-browser-search-performance.mjs
#	scripts/test-file-search-perf-harness.mjs
#	scripts/test-root-search-perf.mjs
#	src/renderer/src/CameraExtension.tsx
#	src/renderer/src/hooks/useBrowserSearch.ts
#	src/renderer/src/raycast-api/list-runtime.tsx
…cle and media fixes

# Conflicts:
#	scripts/lib/ts-import.mjs
#	scripts/measure-extension-bundle-cache.mjs
#	src/main/commands.ts
#	src/main/extension-runner.ts
#	src/main/main.ts
#	src/renderer/src/ExtensionView.tsx
#	src/renderer/src/raycast-api/grid-runtime-hooks.ts
#	src/renderer/src/raycast-api/list-runtime-hooks.ts
@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by consolidated renderer/Raycast wave5 PR #621: #621

@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