Repository navigation
refactor(app): move the dialogs', files' and palette's state into hooks - #1770
Conversation
The machine dialog, new session, session history, file panels, command palette and pane coverage blocks move into five files under src/lib, seven hooks in all, each called in App at its block's own line so effect and listener order stay the same. The pendingCreate effect, paneInFront and contentKey stay in App. APP_HOOK_CEILING is lowered to 113. Plan .omo/plans/app-stores-split.md wave 6.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
|
Merge pass: move-only PR (wave 6 of the App.tsx split). It is merged on its checks, without waiting for a CodeRabbit review, as AGENTS.md allows. Line-level diff check. Comparing removed and added lines as multisets, the only differences are imports, the seven calls, the ceiling, and the new files' wrapper and interface lines. Gate review (on a different model than the author's):
Tests at this head:
All required checks are green and no review thread is open. |
Wave 7 of the App.tsx split. The plan is `.omo/plans/app-stores-split.md` in the maintainer's workspace, and plan-reviewer approved it. It follows PR #1770. This wave moves the access state out of `src/App.tsx` into `src/lib/useAccess.ts`, as two hooks. Each is called at its own block's line, per the plan's rule R1: - **`useAccessState()`**, where the access state stood: `locked`, `lockReason`, `pairCode`, `auth`, `canSignOut` and `pairedFromAddress`, with their comments. - `pairCode`'s initializer still runs `takePairCode()` at the same point in App's render. - It also returns `readBridgeHealth`: the bridge-health read that opened `loadHealth`, now a `useCallback(..., [])`. Its body is the original two lines (the `fetchBridgeHealth()` try and its catch), and it uses only stable setters. - **`useLockedRef({ locked })`**, where `lockedRef` stood. It returns the same ref object, with the render-time assignment. **Not purely moved code:** in `loadHealth`, the two bridge-health lines become `await readBridgeHealth();`. `loadHealth`'s dependency list stays `[]`. `readBridgeHealth` is stable, so the closure `loadHealth` holds from the first render runs the same code as before. `loadHealth`'s identity, which the polling effect and `unlock`/`lock` depend on, is unchanged. **Stays in App, as the plan says:** - the pairing effect; - `unlock`; - the hashchange effect; - `lock`. **Hook ceiling:** `APP_HOOK_CEILING` drops from 113 to 107, after moving four `useState` and two `useRef` calls. ## Checks - **`--color-moved`:** `git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEAD` shows 30 lines as moved. The other 26 lines are: - App's narrowed imports and the new import; - the two calls and the `await readBridgeHealth();` line; - the new file's imports, signatures, the `readBridgeHealth` wrapper lines and the returns; - the ceiling. - **Moved lines are exact:** the moved blocks match `App.tsx` on `705dcb8ff` byte for byte, at lines 257-267, 403-404 and 413-414. - **Positions:** the line before and after each call is the line that surrounded its block. - **Typecheck:** `bun run typecheck` passes. - **Unit tests:** `HERDR_TEST_MODE=unit bun test src/app-hooks.test.ts src/conventions.test.ts src/lib/authLink.test.ts src/lib/phone.test.ts src/lib/i18n.test.ts`: 41 pass, 0 fail. - **Ceiling test:** adding `const zz = useState(false);` to App.tsx makes `src/app-hooks.test.ts` fail. - `bun run check fast`: passes (unit 6253 pass, 0 fail, 13 skip in 443 files, 8 at a time, 57.9s) - **`bun run check integration browser`:** the browser lane exits 0 (every browser script passed, 1795 s), including the access gate and sign-out checks in ui-regression, herdr profiles, and every script that loads through the gate. The integration lane's only failure is `server/api.contract.test.ts` "creates, edits, searches, inspects, and closes an owned workspace" (line 1540), which fails the same way on unchanged `origin/main` on this PC; CI runs that lane in its own environment. ## 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, and needs a rebase either way. No changelog fragment: users see no change.
Wave 6 of the App.tsx split. The plan is
.omo/plans/app-stores-split.mdin the maintainer's workspace, and plan-reviewer approved it. It follows PR #1768 and PR #1769.This wave moves the state behind the dialogs, the file panels, the command palette and the pane-coverage check out of
src/App.tsx. That is seven blocks, into five new files.Following the plan's rule R1:
Effect and listener registration order stay identical. That includes the
popstatelisteners thatuseFileVieweranduseRepoDiffViewerregister, and the coverage MutationObserver.What moves
41189ee36)src/lib/useMachineDialog.tsuseMachineDialog()machineDialog,addPcFocusReturn,closeMachineDialogsrc/lib/useNewSessionDialog.tsuseNewSessionMachine()newSessionMachineIdsrc/lib/useCommandPalette.tsuseCommandPalette()paletteOpen,paletteQuery,openPalettesrc/lib/useFilePanels.tsuseFilePanels({ settings, filePanelAvailable, selectedPaneId, selectedMachineId })filesOpen; theuseFileViewer,useRepoDiffVieweranduseFocusReturncalls;presentation,fileDockedand both docked-close effects;webPageandopenWebPage;collapsingand its effect;presentFile,reportFileKind,toggleFilePresentation,viewFilesrc/lib/useNewSessionDialog.tsuseNewSessionState({ initialLink })newSessionOpen,newPrefill,newFields,pendingCreate,newTab,sessionHistorysrc/lib/usePaneCoverage.tsusePaneCoverage({ contentKey })dialogCover,contentReady, the MutationObserver effectsrc/lib/useNewSessionDialog.tsuseSessionHistoryList({ … })closeNewSession,closeSessionHistory,useRecentResumes, the away-PC probe effect,sessionHistoryWorkspaceand its effectpendingCreateeffect, whose deps includeactions;contentKey;paneInFront;useCallback/useMemodependency list is unchanged.openWebPageandviewFileare context values, and keep their exact deps. Refs (addPcFocusReturn,pendingCreate,collapsing) are returned as the same objects.APP_HOOK_CEILINGdrops from 144 to 113, after moving 31 builtin hook calls.Checks
--color-moved:git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEADshows 228 lines as moved. The other 99 lines are:41189ee36.bun run typecheckpasses.HERDR_TEST_MODE=unit bun test src/app-hooks.test.ts src/conventions.test.ts src/lib/i18n.test.ts src/lib/filePresentation.test.ts src/lib/webPanel.test.ts src/lib/paletteSeed.test.ts: 42 pass, 0 fail.const zz = useState(false);to App.tsx makessrc/app-hooks.test.tsfail.bun run check fast: passes (unit 6253 pass, 0 fail, 13 skip in 443 files, 8 at a time, 57.9s)bun run check integration browser: the browser lane exits 0 (every browser script passed, 1815 s), including the file viewer, repo diff, files prompt, palette, machine dialog, session history, new-session, recent folders, deep link and sidebar activity scripts. The integration lane's only failure isserver/api.contract.test.ts"creates, edits, searches, inspects, and closes an owned workspace" (line 1540), which fails the same way on unchangedorigin/mainon this PC; CI runs that lane in its own environment.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, and needs a rebase either way.Move-only: moved blocks plus imports, hook signatures and returns, seven calls and the lowered ceiling. No changelog fragment: users see no change.