Repository navigation
refactor(app): move the Settings dialog navigation state into a hook - #1754
Conversation
The Settings dialog state, its two history effects and its callbacks move verbatim into src/lib/useSettingsDialog.ts. App calls the hook where they stood, so hook and effect order are unchanged. src/app-hooks.test.ts caps App.tsx's hook calls at the new count (179). Plan .omo/plans/app-stores-split.md wave 1.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
|
Merge-pass review (head 2d0134a): a gate reviewer on a different model than the author's checked this. The extraction preserves behaviour.
Checks run: 56 focused tests, 45 convention tests, typecheck, and the A nit on the guard, not blocking:
The second case is contrived, and the guard does its job for ordinary code. The repo already ships the TypeScript API, so counting the call expressions on a TypeScript AST would make it exact. That's worth folding into a later wave, which lowers this ceiling anyway. Approved. It merges once its checks are green. |
Wave 2 of the App.tsx split. The plan is `.omo/plans/app-stores-split.md` in the maintainer's workspace. It follows #1754. This wave moves the layout notice out of `src/App.tsx` into `src/lib/useLayoutNotice.ts`. That is the line shown over the pane when a PC's bridge refuses a palette layout call. Both hooks run inside App's render, so updates and effect order are unchanged. ## What changes - **Moved verbatim into two hooks:** - `useLayoutNotice()` holds the `layoutNotice` state and its 6-second timer effect, with their comment. It returns `{ layoutNotice, setLayoutNotice }`. - `useLayoutRefused(setLayoutNotice, t)` holds the `layoutRefused` callback with its comment and its `[t]` dependency list. - **Stays in `App.tsx`:** each block becomes one call at its own former position, so effect order is unchanged. - The first sits between the `error` state and the authentication state. - The second sits just before the notification-target block. - **Imports:** `routeMissing` leaves App's `./lib/api.ts` import, because only the moved callback used it. - **Hook ceiling:** `APP_HOOK_CEILING` in `src/app-hooks.test.ts` drops from 179 to 176. That is App's new count, after moving one `useState`, one `useEffect` and one `useCallback`. ## Checks - **`--color-moved`:** `git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEAD` shows 28 lines as moved. The other lines are: - the `./lib/api.ts` import line, without `routeMissing`; - the new import; - the two call lines; - the ceiling value; - the new file's imports, doc comments, signatures and returns. - **Typecheck:** `bun run typecheck` passes. - **Ceiling test:** `HERDR_TEST_MODE=unit bun test src/app-hooks.test.ts` passes. Adding `const zz = useState(false);` to App.tsx makes it fail. - **Browser regressions:** each run with `bun run check run --build bun scripts/<name>.ts`, and each exited 0. - `ui-contexts-regression.ts` (it runs the update-notice check) - revision-bound-update-demo - telemetry - lan-exposure-notice - machine-conflict - `bun run check fast`: passes (unit 6245 pass, 0 fail, 13 skip in 443 files, 8 at a time, 57.7s) ## Outside PRs that touch the same files No other maintainer PR touches these files. One outside contributor's PR touches `src/App.tsx`: #1427. It already conflicts with main in `App.tsx`, and conflicts the same way with this branch, so it needs a rebase either way. Move-only: moved lines plus imports, two hook signatures, two calls and the lowered ceiling. No changelog fragment: users see no change.
Wave 1 of the App.tsx split. The plan is
.omo/plans/app-stores-split.mdin the maintainer's workspace. It was approved by plan-reviewer, and 형 confirmed the hook approach.This wave moves the Settings dialog navigation state out of
src/App.tsxinto a hook that App calls in the same place. App still owns the state, because the hook runs inside App's own render. So the same updates happen in the same commits, and hook, effect and listener order are unchanged.What changes
Moved, verbatim (only the indentation changes), into the new
src/lib/useSettingsDialog.ts:settingsOpen,settingsLinkPage,settingsLinkSection,settingsPage,settingsSection);closeSettings,settingsLinkPageRefandonSettingsPage;onSettingsHistory,recordSettings).Every initializer and dependency list is unchanged.
Stays in
App.tsx: one line at line 516,const { settingsOpen, … } = useSettingsDialog(initialLink);. It replaces the block at the same position: after theviewFilecallback and beforenewSessionOpen. App no longer usesonSettingsHistoryorrecordSettings, so those two names leave its import.New
src/app-hooks.test.ts: a ceiling on the number of hook calls in App.tsx, set to 179, its count after this move.useState,useRef,useReducer,useEffect,useLayoutEffect,useMemo,useCallbackanduseSyncExternalStorecalls, including calls with type arguments.useRef<() => Promise<void>>counts too.Checks
--color-moved:git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEADshows 46 lines as moved. The other lines are:bun run typecheckpasses.HERDR_TEST_MODE=unit bun test src/app-hooks.test.ts src/lib/settingsHistory.test.ts src/lib/sheetHistory.test.ts src/lib/deepLink.test.tsgives 56 pass, 0 fail.useState(false),useRef<number>(0)oruseRef<() => void>(() => {})to App.tsx each makessrc/app-hooks.test.tsfail (180 > 179).bun run check run --build bun scripts/<name>.ts, and each exited 0.settings=,section=, Back and Forward)bun run check fast: passes (unit 6245 pass, 0 fail, 13 skip in 443 files, 8 at a time, 57.4s)Outside PRs that touch the same files
No other maintainer PR touches these files. One outside contributor's PR touches
src/App.tsx: #1427.git merge-treeshows it already conflicts with main insrc/App.tsx.Move-only: moved lines plus the hook's signature and imports, one call and the new ceiling test. No changelog fragment: users see no change.