Repository navigation
refactor(app): move the layout notice state into a hook - #1757
Conversation
The layout notice state with its 6s timer, and the layout refusal callback, move verbatim into src/lib/useLayoutNotice.ts as two hooks, called in App where each block stood. APP_HOOK_CEILING is lowered from 179 to 176. Plan .omo/plans/app-stores-split.md wave 2.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
|
Merge pass: move-only PR (wave 2 of the App.tsx split). It is merged on its checks without waiting for a CodeRabbit review, as AGENTS.md allows. A gate reviewer on a different model than the author's approved it:
All required checks are green and no review thread is open. |
Wave 3 of the App.tsx split. The plan is `.omo/plans/app-stores-split.md` in the maintainer's workspace. It follows PR #1757. This wave moves the connection chip's state out of `src/App.tsx` into `src/lib/useConnectionChip.ts`, along with the callback that reads output stalls from server messages. Both hooks run inside App's render, so updates and effect order are unchanged. ## What changes - **Moved verbatim into two hooks:** - `useConnectionChip()` holds the `connected`, `connectedBefore` and `outputStopped` states and the `paneLost` callback, with their comments. It returns all seven names App uses. - `useServerMessageHandler(setOutputStopped)` holds the `handleServerMessage` callback with its `[]` dependency list. - **Stays in `App.tsx`:** each block becomes one call at its own former position: - The first sits between the `sessionHistory` state and the notifications state. - The second sits right after the event-stream effect, before `enableNotifications`. `connWord` and the inline `onConnectionChange` lambda also stay in App. - **Imports:** `ServerMessage` leaves App's `../shared/protocol.ts` type import, because only the moved callback used it. - **Hook ceiling:** `APP_HOOK_CEILING` in `src/app-hooks.test.ts` drops from 176 to 171. That is App's new count, after moving three `useState` and two `useCallback` calls. ## Checks - **`--color-moved`:** `git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEAD` shows 20 lines as moved. The other 19 lines are: - the narrowed type import; - 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 lane:** `bun run check integration browser`: browser lane exit 0 (every browser script passed, 1990 s). The integration lane's only failure is `server/api.contract.test.ts` "creates, edits, searches, inspects, and closes an owned workspace" (line 1540, `/api/pane/files` returns `[]`), which fails the same way on unchanged `origin/main` on this PC; this PR changes no server code, and CI runs that lane in its own environment. - `bun run check fast`: passes (unit 6253 pass, 0 fail, 13 skip in 443 files, 8 at a time, 78.6s) ## 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 2 of the App.tsx split. The plan is
.omo/plans/app-stores-split.mdin the maintainer's workspace. It follows #1754.This wave moves the layout notice out of
src/App.tsxintosrc/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
useLayoutNotice()holds thelayoutNoticestate and its 6-second timer effect, with their comment. It returns{ layoutNotice, setLayoutNotice }.useLayoutRefused(setLayoutNotice, t)holds thelayoutRefusedcallback with its comment and its[t]dependency list.App.tsx: each block becomes one call at its own former position, so effect order is unchanged.errorstate and the authentication state.routeMissingleaves App's./lib/api.tsimport, because only the moved callback used it.APP_HOOK_CEILINGinsrc/app-hooks.test.tsdrops from 179 to 176. That is App's new count, after moving oneuseState, oneuseEffectand oneuseCallback.Checks
--color-moved:git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEADshows 28 lines as moved. The other lines are:./lib/api.tsimport line, withoutrouteMissing;bun run typecheckpasses.HERDR_TEST_MODE=unit bun test src/app-hooks.test.tspasses. Addingconst zz = useState(false);to App.tsx makes it fail.bun run check run --build bun scripts/<name>.ts, and each exited 0.ui-contexts-regression.ts(it runs the update-notice check)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 inApp.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.