Repository navigation
refactor(terminal): move the grid's and the pane's lifetimes, and the sends into hooks - #1764
Conversation
… sends into hooks The four blocks move verbatim into useTerminalRefits, usePaneAttach, useTerminalSends and useComposerSends, each called where its block stood so hook and effect order are unchanged. The order pin now checks useTerminalMount before usePaneAttach. PART_FILES gains lib/useComposerSends.ts, the file with t() keys. Plan .omo/plans/paneterminal-split.md PR 2.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Merge pass: move-only PR (PaneTerminal split, PR 2). As AGENTS.md allows, it merges on its checks without waiting for CodeRabbit. It moves the queued-input callbacks ( Diff
Gate review (on a different model than the author's): no findings.
Checks
Overlap: outside contributor #1639 touches All required checks, the browser lanes included, are green, and no review thread is open. |
…1767) PR 3 of 3 of the PaneTerminal.tsx split. The plan is `.omo/plans/paneterminal-split.md` in the maintainer's workspace, and plan-reviewer approved it. It follows PR #1758 and PR #1764. This PR moves the chat lens's terminal logic out of `src/components/PaneTerminal.tsx` into three hooks. Each block moves as one unchanged span. Effects keep their dependency lists, and callbacks keep their `useCallback` dependencies. `src/components/PaneTerminal.tsx` goes from 1,477 to 1,174 lines. Over the three PRs it went from 3,665. ## What moves | Hook | Block | Deps | Returns | Called | |---|---|---|---|---| | `src/lib/usePeekReturn.ts` | after a peek: the manual-peek and auto-return state, the still-open note, the input-row frame watch, and the peek-end layout effect (153 lines) | 29 | 12 names | where the block stood | | `src/lib/useChatCallbacks.ts` | the chat lens's callbacks and state: conversation watch, terminal output, sent and metadata, greeting room, prompt, suggestion, restore and pending answer (90 lines) | 12 | 28 names | where the block stood, right after `usePeekReturn` | | `src/lib/useTypedKeys.ts` | the key bar's `pressKey` and `toggleModifier` (30 lines), and Hermes' one-Ctrl+C stop guard with `abortTurn` (34 lines) | 16 | `pressKey`, `toggleModifier`, `abortTurn` | where the stop block stood | ### Hook and effect order - **`useTypedKeys`:** the key-bar callbacks used to sit about 15 lines above the stop block. They have no effects, and only JSX reads them, so creating them a few hooks later changes nothing. Nothing between the two old positions reads them. - **`usePeekReturn` and `useChatCallbacks`:** each sits exactly where its block was, so their effects run in the same order as before. ### Other changes - **`StillOpen`:** this was a local type alias inside the component. Two hooks now use it, so it moves to `src/lib/paneTerminalShared.ts` as an exported type. Types have no runtime effect. - **`src/lib/i18n.test.ts`:** `PART_FILES.terminal` gains `lib/usePeekReturn.ts` and `lib/useTypedKeys.ts`, because their `t()` keys belong to the terminal part. - **Imports:** `PaneTerminal.tsx` drops the imports only the moved code used. ## Checks - **`--color-moved`:** `git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEAD` shows 629 lines as moved. The other 116 lines are: - `PaneTerminal.tsx`'s narrowed imports, the three new imports and the three calls; - the hooks' imports, three `Deps` interfaces (57 field lines), signatures, destructuring lines and returns; - the `StillOpen` type's move; - the two `PART_FILES` entries. - **Moved blocks are exact:** lines 646-735, 819-848 and 863-896 of `PaneTerminal.tsx` on `2fa93ab49` appear byte for byte in their hooks. Lines 493-645 do too, apart from the one `StillOpen` line. - **Typecheck:** `bun run typecheck` passes. - **Unit tests:** `HERDR_TEST_MODE=unit bun test src/conventions.test.ts src/lib/i18n.test.ts src/lib/settings.test.ts scripts/conventions.test.ts src/lib/terminalPeek.test.ts src/lib/keyBar.test.ts src/lib/hermesStop.test.ts`: 163 pass, 0 fail. - `bun run check fast`: passes after the rebase (unit 6253 pass, 0 fail, 13 skip in 443 files, 8 at a time, 57.5s) - **`bun run check integration browser`:** the browser lane exits 0 (every browser script passed, 1895 s), run on this commit before its rebase onto the latest main (which changed only `src/App.tsx`, `src/app-hooks.test.ts`, `src/lib/useSidebarLayout.ts` and server files). 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. CI runs the integration 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/components/PaneTerminal.tsx`: #1639. It already conflicts with main (`src/lib/i18n.ja.ts`, `src/lib/i18n.ko.ts`, `src/lib/i18n.zh.ts`) and needs a rebase either way; against this branch it conflicts in `src/components/PaneTerminal.tsx`, `src/lib/i18n.ja.ts`, `src/lib/i18n.ko.ts`, `src/lib/i18n.zh.ts`. The moved blocks include the queued-input stop path, Hermes' stop guard and the peek's auto-return. A code-review agent's stand-in review may be wanted before the merge. Move-only: moved blocks plus imports, deps interfaces, three calls, one shared type and two `PART_FILES` entries. No changelog fragment: users see no change.
PR 2 of the PaneTerminal.tsx split. The plan is
.omo/plans/paneterminal-split.mdin the maintainer's workspace, and plan-reviewer approved it. It follows PR #1758, which moved the mount effect.This PR moves four blocks out of
src/components/PaneTerminal.tsxinto four hooks. Each block moves as one unchanged span. Each hook is called at the exact line its block occupied, so hook order, effect order and cleanup order stay as they are. Every effect keeps its dependency list, and every callback keeps itsuseCallbackdependencies.src/components/PaneTerminal.tsxgoes from 1,967 to 1,477 lines.What moves
src/lib/useTerminalRefits.tssrc/lib/usePaneAttach.ts[paneId, terminalId]) and the two one-line effects after it (80 lines)src/lib/useTerminalSends.tssendDraft,discardDraft,submitComposerMessage,sendComposerText,sendTerminalLine,reassertGrid,pressEnter,toggleDirectsrc/lib/useComposerSends.tscomposerSendandactOnPending(138 lines)composerSend,actOnPendinguseTerminalMount's pattern. A<Name>Depsinterface lists every name the block reads from the component, each typed as the component declares it, and the hook destructures it on its first line. A missed name would be a type error.PaneTerminal.tsx:useTerminalMount, thenuseTerminalRefits, thenusePaneAttach. Further down, where their blocks stood, comeuseTerminalSendsanduseComposerSends.usePaneLane(stackRef)does not move.src/conventions.test.tsused to check that the mount hook comes before the attach reset effect, found via}, [paneId, terminalId]);. That effect now lives inusePaneAttach, so the pin checks thatuseTerminalMount(comes beforeusePaneAttach(. Swapping the two calls fails it.src/lib/i18n.test.ts:PART_FILES.terminalgainslib/useComposerSends.ts, because the moved callbacks't()keys belong to the terminal part.Checks
--color-moved:git diff --color-moved=plain --color-moved-ws=allow-indentation-change origin/main...HEADshows 1,009 lines as moved. The other 229 lines are:Depsinterfaces (143 field lines), signatures, destructuring lines and returns;PART_FILESentry.PaneTerminal.tsxone3aec1528) appears byte for byte inside its hook.bun run typecheckpasses.HERDR_TEST_MODE=unit bun test src/conventions.test.ts src/lib/i18n.test.ts src/lib/settings.test.ts scripts/conventions.test.ts: 117 pass, 0 fail.bun run check fast: passes (unit 6253 pass, 0 fail, 13 skip in 443 files, 8 at a time, 61.1s)bun run check integration browser: the browser lane exits 0 (every browser script passed, 2085 s), run on this commit before its rebase onto the latest main (which changed onlysrc/App.tsx,src/app-hooks.test.tsand server files). The integration lane had three failures, none in code this PR touches:server/api.contract.test.ts"creates, edits, searches, inspects, and closes an owned workspace" (line 1540, fails the same way on unchangedorigin/mainon this PC), and two inserver/gjc.contract.test.ts("binds same-cwd panes independently by native PID…", "falls back to scrollback when the native GJC binding is missing":pane.process_infodid not yet list the isolated GJC process while another lane ran beside it). Rerun alone,server/gjc.contract.test.tspasses. CI runs the integration 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/components/PaneTerminal.tsx: #1639.git merge-treeshows it still merges cleanly with both main and this branch.The moved blocks include the attach reset, the queued-input sends and the pending-message actions. A code-review agent's stand-in review may be wanted before the merge.
Move-only: moved blocks plus imports, deps interfaces, four calls, the adapted order pin and one
PART_FILESentry. No changelog fragment: users see no change.