Repository navigation
refactor(app): move the selection and address bar state into hooks - #1774
Conversation
Eleven hooks in two files: ten selection hooks in src/lib/useSelection.ts and useAddressBar in src/lib/useAddressBar.ts, each called at its block's own line. Listener and effect order unchanged; dependency lists byte-identical. APP_HOOK_CEILING lowered to 24. Plan .omo/plans/app-stores-split.md wave 10.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
|
Merge pass: move-only PR (wave 10, the last of the App.tsx split). It merges on its checks without waiting for a CodeRabbit review, as AGENTS.md allows. Pure move. Comparing removed and added lines as multisets, the only differences are imports, the eleven 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. 82 unit tests pass (deep link, selection mark, notification target, sheet and settings history, app-hooks, conventions). The typecheck passes, and the desktop and mobile deep-link browser regression passes on a fresh build. All required checks are green and no review thread is open. |
Wave 10, the last wave 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 #1773.This wave moves the selection, link landing, notification targets and the address bar out of
src/App.tsxinto two files. The selection code is interleaved with code that stays in App, such asuseSplitRecheck,useSidebarLayout,useScreenWakeLockand 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:popstatelistener still registers before the New-workspace dialog'spopstatelistener, which stays in App.selectionRefis still marked in itsuseLayoutEffectat commit.What moves
3f0cfcee8useSelectedMachine(useSelection.ts)selectedMachineId,selectedMachine,snapshotuseSelectionStateselectedPaneId,notificationViewTarget,terminalPeek/endPeek,pendingLink,linkLanded,rosterSeq/linkSince/selectionSince,rosterTick/linkTickuseLinkLandingrosterIn,pendingFile,selectionHint, the header note and its timer,note,autoSelecteduseSelectionMarkselectionRefand its layout effectuseSelectTargetselectedMachineRef,selectTargetand its ref, the selection validation effect, the stored-selection effectuseSelectPaneselectPaneuseNotificationTargetstakeNotificationTarget, its ref, theonNotificationTargeteffectuseSelectedPaneselectedPane(useScreenWakeLockat 453 stays in App)useSelectedLayoutselectedWorkspace,selectedLayout,presentedPaneId, the zoom-redirect layout effectuseAddressBar(useAddressBar.ts)writtenLink,poppedTo,newSessionOpenRef, the link inputs, the file release effect, the URL-writing effect, the link's pending-file effect, the panepopstateeffectuseMachineGone(useSelection.ts)Unchanged:
selectedMachineRef.current = …,selectTargetRef.current = …,takeNotificationTargetRef.current = …andnewSessionOpenRef.current = …stay render-time.storedSelectionandstoreSelectionare imported fromuseSplitView.ts(PR refactor(app): move the pane lens and split view state into hooks #1773), not copied.Hook ceiling:
APP_HOOK_CEILINGdrops from 62 to 24.Checks
--color-moved:git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEADshows 671 lines as moved. The other 184 lines are:SelectionHint,SelectTarget), signatures and returns;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 typecheckpasses.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.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, 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 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.