perf: isolate hotkey registry updates from binding consumers - #6
Conversation
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Committed and pushed successfully. The Version Bump SummaryPackage: @humanlayer/react-hotkeys-hook |
|
|
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Committed and pushed successfully. The Version Bump SummaryPackage: @humanlayer/react-hotkeys-hook |
|
|
Summary
Registering or unregistering one shortcut currently broadcasts through both the public hotkeys context and the bound-registration context. Every unrelated
useHotkeysconsumer rerenders, even when active scopes have not changed.useHotkeysScopeContextand itsHotkeysScopeContextTypeexport for scope-only consumers; makeuseHotkeyssubscribe to this separate context.useHotkeysContextbackward-compatible and reactive to registry changes.This is a library-source fix. No dependency patches, application changes, listener ordering changes, registry-removal redesign, or dependency updates are included. Parent renders and genuine scope transitions can still rerender consumers. No application latency improvement is claimed by this PR.
Validation
bun --bun run --cwd packages/react-hotkeys-hook test: 162 passed, 4 skipped across 6 files.05a2780; all 13 new cases pass with the implementation. No mocked contexts or export aliases.useHotkeys.ts.git diff --check: passed.Existing validation limitations
bun --bun run --cwd packages/react-hotkeys-hook buildemits the bundle/declarations and exits 0, butvite:dtsreportsTS2503: Cannot find namespace 'NodeJS'for the existing sequence timer type. Reproduced the same diagnostic on unchanged05a2780; this is not a diagnostic-free build claim.The existing Bun lockfile still identifies the old unscoped package name/version, so a frozen install fails before this change. Used
bun install --ignore-scripts --no-savefor local validation; neither manifest nor lockfile was changed. Documentation-site build and application integration remain unverified.