Repository navigation
refactor(app): move the pane lens and split view state into hooks - #1773
Conversation
Six hooks in two files (src/lib/usePaneLens.ts, src/lib/useSplitView.ts), each called at its block's own line. The lens is still settled during App's render, inside usePaneLens; plain split functions stay plain. storedView, storedSelection and storeSelection moved verbatim and App imports them back. Ceiling lowered to 62; four type-only split! assertions replace the narrowing through splitOn. Plan .omo/plans/app-stores-split.md wave 9.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
|
Merge pass: move-only PR (wave 9 of the App.tsx split). It merges on its checks without waiting for a CodeRabbit review, as AGENTS.md allows. The only non-move change is four type-only Line check. Comparing removed and added lines, the only differences are:
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. |
…1774) Wave 10, the last wave 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 #1773. This wave moves the selection, link landing, notification targets and the address bar out of `src/App.tsx` into two files. The selection code is interleaved with code that stays in App, such as `useSplitRecheck`, `useSidebarLayout`, `useScreenWakeLock` and the auth callbacks. So each contiguous block becomes one hook called at that block's own line (rule R1). Effect, layout-effect and listener order are unchanged. In particular: - The pane `popstate` listener still registers before the New-workspace dialog's `popstate` listener, which stays in App. - `selectionRef` is still marked in its `useLayoutEffect` at commit. ## What moves | Hook (file) | Block in App.tsx on `3f0cfcee8` | |---|---| | `useSelectedMachine` (`useSelection.ts`) | 158-163: `selectedMachineId`, `selectedMachine`, `snapshot` | | `useSelectionState` | 178-207: `selectedPaneId`, `notificationViewTarget`, `terminalPeek`/`endPeek`, `pendingLink`, `linkLanded`, `rosterSeq`/`linkSince`/`selectionSince`, `rosterTick`/`linkTick` | | `useLinkLanding` | 209-234: `rosterIn`, `pendingFile`, `selectionHint`, the header note and its timer, `note`, `autoSelected` | | `useSelectionMark` | 236-242: `selectionRef` and its layout effect | | `useSelectTarget` | 323-415: `selectedMachineRef`, `selectTarget` and its ref, the selection validation effect, the stored-selection effect | | `useSelectPane` | 417-424: `selectPane` | | `useNotificationTargets` | 428-449: `takeNotificationTarget`, its ref, the `onNotificationTarget` effect | | `useSelectedPane` | 452: `selectedPane` (`useScreenWakeLock` at 453 stays in App) | | `useSelectedLayout` | 454-472: `selectedWorkspace`, `selectedLayout`, `presentedPaneId`, the zoom-redirect layout effect | | `useAddressBar` (`useAddressBar.ts`) | 507-603: `writtenLink`, `poppedTo`, `newSessionOpenRef`, the link inputs, the file release effect, the URL-writing effect, the link's pending-file effect, the pane `popstate` effect | | `useMachineGone` (`useSelection.ts`) | 749-763: the removed-PC effect | **Unchanged:** - **Dependency lists:** every one is byte-identical. - **Render-time assignments:** `selectedMachineRef.current = …`, `selectTargetRef.current = …`, `takeNotificationTargetRef.current = …` and `newSessionOpenRef.current = …` stay render-time. - **Stored-selection helpers:** `storedSelection` and `storeSelection` are imported from `useSplitView.ts` (PR #1773), not copied. - **Follow-focus:** the block the plan listed here already moved, verbatim, with the event stream in PR #1772. **Hook ceiling:** `APP_HOOK_CEILING` drops from 62 to 24. ## Checks - **`--color-moved`:** `git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEAD` shows 671 lines as moved. The other 184 lines are: - App's narrowed imports, the two new imports and the eleven calls; - the new files' imports, params types, two local type aliases (`SelectionHint`, `SelectTarget`), signatures and returns; - the ceiling. - **Moved blocks are exact:** all eleven blocks above appear byte for byte in the new files. - **Positions:** the line before and after each call is the line that surrounded its block on main. - **Typecheck:** `bun run typecheck` passes. - **Unit tests:** **119 pass, 0 fail across 10 files**, from: `HERDR_TEST_MODE=unit bun test src/app-hooks.test.ts src/conventions.test.ts scripts/conventions.test.ts src/lib/deepLink.test.ts src/lib/notificationTarget.test.ts src/lib/selectionMark.test.ts src/lib/followFocus.test.ts src/lib/sheetHistory.test.ts src/lib/settingsHistory.test.ts src/lib/i18n.test.ts` - `bun run check fast`: passes (unit 6253 pass, 0 fail, 13 skip in 443 files, 8 at a time, 57.8s) - **`bun run check integration browser`:** the browser lane exits 0 (every browser script passed, 1801 s), including the deep link, notification startup and view, pending pane switch, machine dialog and conflict, file viewer Back/Forward, settings pages, sidebar activity, mobile tabs and ui regressions. 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. Outside contributor PRs that touch `src/App.tsx` and will need a rebase: #1427. No changelog fragment: users see no change.
Wave 9 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 #1772.This wave moves the pane lens and the split view out of
src/App.tsxinto two files. Each contiguous block becomes one hook called at that block's own line (rule R1), so hook order is unchanged. In particular, thelastKeyAtkeydown capture listener still registers after the sidebar's Escape listener, and the split validation and drag-listener effects run where they did.What moves
3a449c96cuseSplitRecheck()(useSplitView.ts)otherRecheck,otherRosterTickusePaneLensState()(usePaneLens.ts)lens,viewPicksuseSplitState()(useSplitView.ts)soloSlot,endSplit,splitRef,splitShownRef,lastKeyAtRefand its listener, the drop preview state,paneAreaRef,tabDragusePaneLens({ … })(usePaneLens.ts)lenses,lensKey,notificationView, the lens settled during render, the alert's lens overrideusePaneViewPicks({ … })(usePaneLens.ts)pickView,setViewuseSplitLayout({ … })(useSplitView.ts)applySplit/activateSlot/closeSlot/selectInSlot/dockSide/dockAt, theonDropeffect, the tab-drag effect, the drag handlers, the window drag listenersUnchanged structure:
usePaneLensstill callssetLensandsetTerminalPeekduring render. It runs on App's fiber, exactly as the inline code did.useCallback.splitShownRef.current = splitOnand theotherTabReflines stay render-time.usePhoneSheetBackfor the peek stays in App at its line. Line 262 insiderosterInalso stays: it reads the ref and setter thatuseSplitRecheckreturns.Module-level helpers move verbatim with their comments:
storedViewtousePaneLens.ts, andSELECTION_KEY,StoredSelection,storedSelectionandstoreSelectiontouseSplitView.ts. App imports back the ones it still calls. No copies are left behind.Not purely moved code (type-only): four
split!non-null assertions in the pane-area JSX (split!.active,split!.other.machineId,split!.other.paneId,slotSide(split!, slot)).splitOnused to be computed in App, and itssplit !== nullnarrowedsplitfor TypeScript in the JSX. Returned from the hook, it is a plain boolean, so the narrowing is gone.splitOn(or!active) holds, sosplitis non-null there. The emitted JavaScript is unchanged.Hook ceiling:
APP_HOOK_CEILINGdrops from 90 to 62.Checks
--color-moved:git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEADshows 590 lines as moved. The other 108 lines are:split!lines;exportkeywords on the moved helpers;Moved blocks are exact: all six blocks above appear byte for byte in the new files.
Positions: the line before and after each call is the line that surrounded its block. Two pairs of blocks were adjacent, so their calls are adjacent too.
Typecheck:
bun run typecheckpasses.Unit tests: 109 pass, 0 fail across 8 files, from:
HERDR_TEST_MODE=unit bun test src/app-hooks.test.ts src/conventions.test.ts scripts/conventions.test.ts src/lib/split.test.ts src/lib/paneLens.test.ts src/lib/terminalPeek.test.ts src/lib/panePresentation.test.ts src/lib/i18n.test.tsbun run check fast: passes (unit 6253 pass, 0 fail, 13 skip in 443 files, 8 at a time, 57.8s)bun run check integration browser: the browser lane exits 0 (every browser script passed, 1786 s), including the split view, header lens switch, default view, phone split grid, tab menu, notification view, pane find, render crash, terminal autoswitch and ui regressions. 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. Outside contributor PRs that touch
src/App.tsxand will need a rebase: #1427.No changelog fragment: users see no change.