Skip to content

Convert eligible ref-mirror effects to useEffectEvent (bd-t18384ia) - #938

Merged
shikokuchuo merged 3 commits into
refactor/useeffect-phase4from
refactor/useeffect-phase5
Oct 27, 2026
Merged

shikokuchuo merged 3 commits into
refactor/useeffect-phase4from
refactor/useeffect-phase5

Conversation

@shikokuchuo

@shikokuchuo shikokuchuo commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Stacked on #936. Phase 5 (final) of claude-notes/plans/2026-10-24-hub-client-useeffect-refactor.md (bd-t18384ia).

What changed

Converted the 3 ref-mirror effects whose call sites sit lexically inside an effect:

  • useAuthProbe
  • useSessionKeepAlive (both callbacks)
  • useWindowFileDrop

What didn't change, and why

The other 9 audited sites fail the useEffectEvent contract enforced by eslint-plugin-react-hooks v7 rules-of-hooks: an effect event may only be referenced from effect scope in the same component, and render-phase calls throw. They stay as ref-mirrors; per-site rationale is recorded in the plan.

  • useRouting — read inside a setState updater (runs during render)
  • useDownloadAs — read inside a click handler
  • Preview / ReactPreview — read inside render-scope useCallbacks
  • useSlideThumbnails — recursive re-invocation from inside a useCallback
  • Editor.tsx (3 refs) — cross hook / Monaco-callback boundaries

Tests

  • useAuthProbe / useSessionKeepAlive gained "latest callback without re-arming the interval" characterization tests, pinned green before converting; useWindowFileDrop already had one.
  • Full npm run test:ci green (unit, integration, WASM); npm run build:all green; eslint clean on the five touched files.

Browser smoke

  • File drop: 13/13 import-document.spec.ts tests on chromium, including the four window-fallback drops (top bar, dialog backdrop, preview pane ×2).
  • Auth probe: a throwaway Playwright spec on the auth-on e2e stack drove the probe live — disconnect armed it, two /auth/me probes fired through the converted effect event, no logout on network errors, reconnect restored the online pill.

No user-visible behavior change, so no changelog entry (same call as Phases 2–4).

Phase 5 of the hub-client useEffect refactor: triaged all 12 audited
ref-mirror sites and converted the 3 whose call sites sit lexically
inside an effect (useAuthProbe, useSessionKeepAlive, useWindowFileDrop).
The other 9 fail the useEffectEvent contract enforced by
eslint-plugin-react-hooks v7 rules-of-hooks (references only from effect
scope in the same component; render-phase calls throw): useRouting reads
inside a setState updater, useDownloadAs inside a click handler,
Preview/ReactPreview inside render-scope useCallbacks, useSlideThumbnails
recursively, and the three Editor refs cross hook/Monaco-callback
boundaries. They stay as ref-mirrors, with the rationale recorded in the
plan.

useAuthProbe and useSessionKeepAlive gained 'latest callback without
re-arming' characterization tests (pinned green before the conversion);
useWindowFileDrop already had one.

Verified: npm run test:ci all three legs green; npm run build:all green;
eslint clean on the five touched files.
@shikokuchuo
shikokuchuo added this pull request to stack #926 October 27, 2026 16:40
@posit-snyk-bot

posit-snyk-bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@shikokuchuo
shikokuchuo merged commit 875e7fd into main Oct 27, 2026
12 of 22 checks passed
@shikokuchuo
shikokuchuo deleted the refactor/useeffect-phase5 branch October 27, 2026 17:33
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.

2 participants