fixed qodo findings

Two issues addressed:

1. Plugin-loading useEffect unnecessarily depended on temporalState.
   After the #830 fix, no shouldLoad predicate reads temporalState, but
   the effect's dep array still included it, causing extra re-runs on
   every scrubber update. Removed temporalState from the dep array and
   the shouldLoad call site. Made temporalState optional in the
   LazyPluginRegistryEntry shouldLoad context type to match.

2. Regression test imported a local copy of shouldLoad instead of the
   production predicate. Extracted all three shouldLoad predicates into
   pluginRegistryPredicates.ts (pure module, no React/DOM dependencies),
   wired GraphWorkspace.tsx to use the imported functions, and updated
   the test to import and exercise the real production code via tsx.
   Verified: introducing the old broken condition causes the test to fail;
   the correct implementation passes all 7 assertions.
This commit is contained in:
Sameer6305
2026-08-05 17:37:33 +05:30
parent 8d52281cdf
commit 80de3652cf
4 changed files with 81 additions and 57 deletions
@@ -0,0 +1,29 @@
/**
* shouldLoad predicates for the GraphWorkspace lazy plugin registry.
*
* Extracted into a pure module so the predicates can be unit-tested without
* importing the full GraphWorkspace React component (which depends on sigma,
* React hooks, and browser globals). The corresponding registry entries in
* GraphWorkspace.tsx must use these functions directly.
*
* These predicates gate WHEN each plugin's module is lazily imported.
* None of them reference temporalState — temporal scrubber updates must not
* retrigger plugin loading (see issue #830 for the render-loop that resulted
* from the temporal-overlay entry originally reading temporalState?.currentTime).
*/
export type PluginShouldLoadContext = {
panelState: Record<string, boolean>;
};
export function explorationEffectsShouldLoad({ panelState }: PluginShouldLoadContext): boolean {
return Boolean(panelState["effects-panel"]);
}
export function neighborhoodPanelShouldLoad({ panelState }: PluginShouldLoadContext): boolean {
return Boolean(panelState["neighborhood-panel"]);
}
export function temporalOverlayShouldLoad({ panelState }: PluginShouldLoadContext): boolean {
return Boolean(panelState["temporal-panel"]);
}