refactor(runtime): extract bisect-candidate hydration from app.ts (#1237)#1277
Merged
Merged
Conversation
) 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Item 2 (cont.) —
app.tsdecomposition (#1237)Follows #1273, #1275, #1276 (all merged). The last clean item-2 move: lifts the
bisectCandidateDetail/bisectCandidateLoadingcluster (#879) — theuseStatepair and the effect that loadsgetCommitDetailfor the active bisect's current candidate — into a newuseBisectCandidateHydrationmodule.Why this pair can move
setBisectCandidateDetail/setBisectCandidateLoadingare written only by this effect — no staging callback or reset effect touches them.Position-preserving split (same template as item 1a)
The
useStatepair and the effect straddle auseBlameLoadingStatecall, so neither may move to a single site:useBisectCandidateState(React)— issues theuseStatepair at its original slot.useBisectCandidateHydration(React, {...})— the loader effect, reproduced verbatim (empty-sha guard,activeflag,safe()wrapper, loading toggles,[git, bisectCandidateSha]deps), at its original slot just below.Nothing moves → hook order preserved → render-snapshot suite is sufficient.
Changes
hooks/useBisectCandidateHydration.ts(state hook + effect hook).app.ts: bareuseStatepair →useBisectCandidateState(React); inline effect →useBisectCandidateHydration(...); drop now-unusedgetCommitDetail/GitCommitDetailimport (this was app.ts's lastgetCommitDetailcaller).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 diffstsc --noEmit: clean ·eslint: 0 errors ·rollup -c: buildsdist/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 inapp.ts). See the plan doc.