Skip to content

refactor(runtime): extract bisect-candidate hydration from app.ts (#1237)#1277

Merged
gfargo merged 1 commit into
mainfrom
feat/app-decompose-bisect-candidate-hydration
Jun 15, 2026
Merged

refactor(runtime): extract bisect-candidate hydration from app.ts (#1237)#1277
gfargo merged 1 commit into
mainfrom
feat/app-decompose-bisect-candidate-hydration

Conversation

@gfargo

@gfargo gfargo commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Item 2 (cont.) — app.ts decomposition (#1237)

Follows #1273, #1275, #1276 (all merged). The last clean item-2 move: lifts the bisectCandidateDetail / bisectCandidateLoading cluster (#879) — the useState pair and the effect that loads getCommitDetail for the active bisect's current candidate — into a new useBisectCandidateHydration module.

Why this pair can move

setBisectCandidateDetail / setBisectCandidateLoading are written only by this effect — no staging callback or reset effect touches them.

Position-preserving split (same template as item 1a)

The useState pair and the effect straddle a useBlameLoadingState call, so neither may move to a single site:

  • useBisectCandidateState(React) — issues the useState pair at its original slot.
  • useBisectCandidateHydration(React, {...}) — the loader effect, reproduced verbatim (empty-sha guard, active flag, safe() wrapper, loading toggles, [git, bisectCandidateSha] deps), at its original slot just below.

Nothing moves → hook order preserved → render-snapshot suite is sufficient.

Changes

  • New hooks/useBisectCandidateHydration.ts (state hook + effect hook).
  • app.ts: bare useState pair → useBisectCandidateState(React); inline effect → useBisectCandidateHydration(...); drop now-unused getCommitDetail / GitCommitDetail import (this was app.ts's last getCommitDetail caller).
  • New hooks/useBisectCandidateHydration.test.ts — behavioral tests for the empty-sha, load, and cancellation paths.

Validation

  • jest (workstation): 109 suites / 1866 tests pass, 68 snapshots no diffs
  • tsc --noEmit: clean · eslint: 0 errors · rollup -c: builds dist/

This completes the clean hydration-state-ownership moves. The remaining item-2 pairs (worktreeDiff, worktreeHunks, stashDiff, compareDiff) have setters shared with the staging callbacks / compare-reset effect, so they're blocked on a larger change (or stay in app.ts). See the plan doc.

)

Final clean item-2 move of the app.ts decomposition. Lifts the
`bisectCandidateDetail` / `bisectCandidateLoading` cluster (#879) — the
`useState` pair and the effect that loads `getCommitDetail` for the active
bisect's current candidate — into a new `useBisectCandidateHydration` module.

`setBisectCandidateDetail` / `setBisectCandidateLoading` are written only by
this effect, so the pair is owned in the hook module via the position-
preserving two-hook split (the `useState` pair and the effect straddle a
`useBlameLoadingState` call, so neither may move):

- `useBisectCandidateState` issues the `useState` pair in its original slot;
- `useBisectCandidateHydration` issues the effect in its original slot, handed
  the setters.

The effect is reproduced verbatim — same empty-sha guard, `active`
cancellation flag, `safe()` wrapper, loading toggles, and
`[git, bisectCandidateSha]` dependency array. Drops the now-unused
`getCommitDetail` / `GitCommitDetail` import from app.ts (this was the last
`getCommitDetail` caller there). Mirrors the item-1a `useCommitDetailState`
split; adds behavioral tests for the empty-sha, load, and cancellation paths.
@gfargo gfargo merged commit 3f081a9 into main Jun 15, 2026
16 checks passed
@gfargo gfargo deleted the feat/app-decompose-bisect-candidate-hydration branch June 15, 2026 14:12
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