ref(hooks): Replace HookStore with a plain hook registry#115811
Conversation
📊 Type Coverage Diff
🔍 2 new type safety issues introduced
Type assertions (
This is informational only and does not block the PR. |
9b265a7 to
92ade77
Compare
f55f531 to
3fb7591
Compare
Introduce static/app/hookRegistry.tsx — a simple Map-backed registry with registerHook() and getHook() exports. Replace all HookStore.get() and HookStore.set() call sites with the new functions. Hook and HookOrDefault components are simplified to plain render-time reads with no useState/useEffect/listen overhead. HookStore's Reflux machinery (trigger, listen, remove) is no longer used by any hook consumer.
3fb7591 to
74c586c
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 74c586c. Configure here.
| beforeEach(() => { | ||
| HookStore.init(); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Missing registry cleanup causes test order dependency
Low Severity
The beforeEach(() => { HookStore.init(); }) cleanup was removed, but hookRegistry.tsx exposes no way to clear or remove registered hooks. The first test ("should render default") relies on component:replay-onboarding-cta not being registered, while the second test registers it. Since the module-level Map persists across tests within a file, any reordering (or future test insertion) that places a registerHook call before this test will cause it to fail. A clearHooks() (or per-key removeHook()) export is needed for test isolation.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 74c586c. Configure here.
Follow-up to #115811, which introduced the override registry but kept the old "hook" terminology on the public-facing APIs. This change finishes the rename so the codebase consistently uses "override". ## What changed - `hookRegistry.tsx` is replaced by `overrideRegistry.tsx`; `registerHook` / `getHook` become `registerOverride` / `getOverride`. - `types/hooks.tsx` moves to `types/overrides.tsx`; `HookName`, `Hooks`, and the various `*Hook*` type aliases (e.g. `FeatureDisabledHooks`) are renamed to their `Override` equivalents. - The `Hook` component (`components/hook.tsx`) is replaced by `Override` (`components/override.tsx`). It is now a named export (`export {Override}`) rather than a default export, and the `memo()` wrapper has been dropped — the implementation is a single registry lookup, so memoization wasn't buying anything. - `HookOrDefault` is renamed to `OverrideOrDefault` (file, factory function, and its `hookName` parameter → `overrideName`). - `<Feature hookName=...>` is renamed to `<Feature overrideName=...>` and all call sites updated. - `gsApp/registerHooks.tsx` is renamed to `gsApp/registerOverrides.tsx`. - `gsApp/hooks/` is renamed to `gsApp/overrides/` and contains only override implementations now. The eleven pure React hooks that were previously mixed in (`useAM2ProfilingUpsellModal`, `useAM2UpsellModal`, `useBillingConfig`, `useBillingDetails`, `useCurrentBillingHistory`, `useIntentData`, `usePlanMigrations`, `useProductBillingMetadata`, `useRecurringCredits`, `useStripeInstance`, `useSubscription`) move to a new `gsApp/hooks/` directory. - The `no-calling-components-as-functions` ESLint rule's allowlist is updated from `HookOrDefault` to `OverrideOrDefault` (it's a factory, not a component). - Tests, JSDoc, and inline comments throughout are updated to match. This is a pure rename — no behavior changes.


Introduce
static/app/hookRegistry.tsx— a simpleMap-backed registry withregisterHook()andgetHook()exports — and deletehookStore.tsxentirely.What changed:
HookStore.get()/HookStore.set()→getHook()/registerHook()across all call sitesHookandHookOrDefaultcomponents simplified to plain render-time reads — nouseState, nouseEffect, no RefluxlistenHookStore.persistCallback/getCallbackreplaced by a plain module-level cell insetOrganizationCallback.tsxhookStore.tsxdeleted;HookStoreremoved from theSentryAppbrowser globalsregisterHook/getHook;HookStore.init()cleanup calls removed