Repository navigation
refactor(app): call each alerts hook where its block stood - #1769
Conversation
PR #1768 moved six separate blocks of App.tsx into one useAlerts call at the notifications line, which ran three effects earlier in a commit than before. useAlerts.ts now exports one hook per block (useAlertPrefs, useNotificationState, useAlertRefs, useAlertSignals, useNotificationSwitch) and a plain alertsBell, each called at its block's original line, so effect and listener order match the code before #1768. No moved line changes. Plan .omo/plans/app-stores-split.md rule R1.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
|
That test covers the Windows plugin launcher's process lifecycle on a GitHub-hosted Windows runner. This PR changes only I'm rerunning only the failed job once the run finishes. |
|
Merge pass: follow-up to #1768. A gate reviewer on a different model than the author's approved it.
Native Windows install first failed on the known flaky stop/restart test ( All required checks are green and no review thread is open. |
…ks (#1770) Wave 6 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 #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: - Each contiguous block becomes one hook, called at that block's own line. - The new-session area has three separate blocks, so its file exports three hooks. Effect and listener registration order stay identical. That includes the `popstate` listeners that `useFileViewer` and `useRepoDiffViewer` register, and the coverage MutationObserver. ## What moves | File | Hook | Block (App.tsx on `41189ee36`) | Contents | |---|---|---|---| | `src/lib/useMachineDialog.ts` | `useMachineDialog()` | 246-255 | `machineDialog`, `addPcFocusReturn`, `closeMachineDialog` | | `src/lib/useNewSessionDialog.ts` | `useNewSessionMachine()` | 256 | `newSessionMachineId` | | `src/lib/useCommandPalette.ts` | `useCommandPalette()` | 395-397 | `paletteOpen`, `paletteQuery`, `openPalette` | | `src/lib/useFilePanels.ts` | `useFilePanels({ settings, filePanelAvailable, selectedPaneId, selectedMachineId })` | 405-463 | `filesOpen`; the `useFileViewer`, `useRepoDiffViewer` and `useFocusReturn` calls; `presentation`, `fileDocked` and both docked-close effects; `webPage` and `openWebPage`; `collapsing` and its effect; `presentFile`, `reportFileKind`, `toggleFilePresentation`, `viewFile` | | `src/lib/useNewSessionDialog.ts` | `useNewSessionState({ initialLink })` | 465-475 | `newSessionOpen`, `newPrefill`, `newFields`, `pendingCreate`, `newTab`, `sessionHistory` | | `src/lib/usePaneCoverage.ts` | `usePaneCoverage({ contentKey })` | 866-879 | `dialogCover`, `contentReady`, the MutationObserver effect | | `src/lib/useNewSessionDialog.ts` | `useSessionHistoryList({ … })` | 1352-1367 | `closeNewSession`, `closeSessionHistory`, `useRecentResumes`, the away-PC probe effect, `sessionHistoryWorkspace` and its effect | - **What stays in App, as the plan says:** - the `pendingCreate` effect, whose deps include `actions`; - `contentKey`; - `paneInFront`; - every call site. - **Dependency lists and returned refs:** every `useCallback`/`useMemo` dependency list is unchanged. `openWebPage` and `viewFile` are context values, and keep their exact deps. Refs (`addPcFocusReturn`, `pendingCreate`, `collapsing`) are returned as the same objects. - **Imports:** App drops the imports only the moved code used. - **Hook ceiling:** `APP_HOOK_CEILING` drops 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...HEAD` shows 228 lines as moved. The other 99 lines are: - App's narrowed imports, the five new imports and the seven calls; - the ceiling; - the new files' imports, params types, signatures and returns. - **Moved blocks are exact:** all seven blocks appear byte for byte in their hooks. - **Positions:** the line before and after each call is the line that surrounded its block on `41189ee36`. - **Typecheck:** `bun run typecheck` passes. - **Unit tests:** `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. - **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, 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 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. Move-only: moved blocks plus imports, hook signatures and returns, seven calls and the lowered ceiling. No changelog fragment: users see no change.
A follow-up to PR #1768, wave 5 of the App.tsx split. The plan is
.omo/plans/app-stores-split.mdin the maintainer's workspace.The plan's rule R1 says every contiguous block moved out of
src/App.tsxbecomes its own hook call, placed at that block's original line, so effect and listener order stay exactly as they were. PR #1768 broke that rule:useAlertscall at thenotificationsline.This PR restores the exact order anyway, so no such argument is needed.
What changes
src/lib/useAlerts.tsnow exports one hook per block. Each is called inApp.tsxat its block's original line (the line numbers are from before PR #1768):alerts,alertsRef,alertsOn,alertsOnRef)useAlertPrefs({ settings })useSettings()notifications,pushOn,pushOnRefuseNotificationState()useAlertRefs({ settings })lockedRef, beforefollowFocusRefdropIn, the sound player effect,chime, the sound-unlock effect, plus the three event-stream callbacksuseAlertSignals({ … })enableNotifications,disableNotifications, the push re-registration effectuseNotificationSwitch({ … })handleServerMessagebellVisible,alertsOffDot(no hooks)alertsBell({ … })onRoster,onPaneStatus,onPaneExited) areuseCallback([])hooks without effects, so where they sit insideuseAlertSignalschanges no order.Checks
--color-moved:git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEADshows only:useAlertssplit into hook signatures, params interfaces, doc comments and returns.The block bodies show as moved, or as unchanged in place.
Moved blocks are exact: all six blocks match
App.tsxbefore PR refactor(app): move the alerts and notification state into a hook #1768 (53b85127e) byte for byte, at lines 225-232, 496-500, 509-518, 604-647, 744-787 and 1317-1343.Positions: the line before each new call is the line that came before its block on
53b85127e.Typecheck:
bun run typecheckpasses.Unit tests: 129 pass, 0 fail across 9 files, from:
HERDR_TEST_MODE=unit bun test src/app-hooks.test.ts src/conventions.test.ts src/lib/notifications.test.ts src/lib/droplet.test.ts src/lib/alertTurns.test.ts src/lib/alertSound.test.ts src/lib/push.test.ts src/lib/notificationTarget.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, 68.4s)Alert browser scripts: each run with
bun run check run --build bun scripts/<name>.ts:alert-sound-regression,droplet-regression,droplet-demo-regression,notification-startup-regression,notification-view-regressionandpush-settings-regressioneach exit 0.No changelog fragment: users see no change.