refactor(runtime): extract commit-detail hydration from app.ts (#1237)#1273
Merged
Conversation
Item 1a of the app.ts decomposition. Lifts the `detail` / `detailLoading` cluster into a new `useCommitDetailHydration` module, split into two position-preserving hooks so React's hook order is preserved exactly: - `useCommitDetailState` issues the `useState` pair in its original slot (top of the hydration-state block), returning values + setters. - `useCommitDetailHydration` issues the loader effect in its original slot (~600 lines below), handed the setters. The effect is reproduced verbatim — same `!selected` guard, `active` cancellation flag, `safe()` wrapper, `detailLoading` toggles, and `[git, selected?.hash]` dependency array. Nothing moves, so there is no effect-reordering risk and the render-snapshot suite is sufficient. Mirrors the established `useBlameLoadingState` + `useDetailHydration` split. Adds behavioral tests for the guard, load, and cancellation paths.
This was referenced Jun 15, 2026
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 1a —
app.tsdecomposition (#1237)Lifts the
detail/detailLoadinghydration cluster out ofapp.tsinto a newuseCommitDetailHydrationmodule. This is the one remaining hydration cluster whose loader effect was still inline (the other diff/detail loaders were extracted in the 0.72 series).Approach — position-preserving two-hook split
The
useStatepair (top of the hydration-state block) and its loader effect are ~600 lines apart, withselecteddeclared in between. Collapsing them into one call site would reorder hooks. So, mirroring the establisheduseBlameLoadingState+useDetailHydrationprecedent, the module exports two hooks, each called at the original position:useCommitDetailState(React)— issues thedetail/detailLoadinguseStatepair in its original slot; returns values + setters.useCommitDetailHydration(React, { git, selected, setDetail, setDetailLoading })— issues the loader effect in its original slot.The effect is reproduced verbatim — same
!selectedguard,activecancellation flag,safe()wrapper,detailLoadingtoggles, and[git, selected?.hash]dependency array. Nothing moves, so there is no effect-reordering risk and the render-snapshot suite is fully sufficient to prove behavior preservation.Changes
app.ts: bareuseStatepair →useCommitDetailState(React); inlineloadDetaileffect →useCommitDetailHydration(...). Net −8 LOC.hooks/useCommitDetailHydration.ts.hooks/useCommitDetailHydration.test.ts— behavioral tests for the guard (no fetch), load (toggle + fetch + store), and cancellation (stale-write suppression) paths.Validation
jest(full): 282 suites / 3512 tests pass, 68 snapshots no diffstsc --noEmit: cleaneslint: 0 errorsrollup -c: buildsdist/