Repository navigation
refactor(website): move ChatPage hook logic into page owners - #20388
Conversation
edbad5f to
227533b
Compare
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Check one non-English draft-restore notice in Japanese or Chinese: the call site puts a space before the translated sentence, and those languages don't separate sentences with spaces. Suggestions
[UX-REVIEWED] 4c43498 Description read[DESCRIPTION-READ] f76c7aaa6196272434d65b5bdf3b5f48c5f652bb020aa6f613f271a2c939b2eb That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the 42 re-pointed source pins, which now match text anywhere in the page plus every owner file, can still fail when a construct leaves its intended owner. [DESIGN-REVIEWED] 4c43498 Description read[DESCRIPTION-READ] 3f80d0320f22c519b61ae002b20c4342857dde3cc099ac5a496b2deaccad2aff That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The same union-source loader is pasted into 42 test files, next to the existing Not justified as shipped
What this change shipsInventory (8 items) — 6 justifiedIntent: shrink
[FIRST-PRINCIPLES-REVIEWED] 4c43498 Description read[DESCRIPTION-READ] 7377ebf970d8812b253cd31e2f40376d0ed47f7254d7718c0786dca3dce75d7c That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
|
|
Answers to the PASS punchlines on 227533b:
|
227533b to
1938323
Compare
|
|
|
Answers to the PASS punchlines on 1938323:
|
|
/ai-review override fable 1938323: Opus discovery failed closed on two runs at this head (38632956362; no [OPUS-DISCOVERY] marker, no review content), an infrastructure fault rather than a finding; I verified this head myself — range-diff against the previously reviewed head changes only import lines ported from #20369, one ru catalog string for the style check, and the line-cap baseline row, and GPT, Design, First Principles and UX lanes pass. |
Human judgment recorded@bolichen97 marked the fable AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
821b781 to
4c43498
Compare
|
Rebased: the PR went DIRTY after the 04:55Z merges, #20524 (ChatSidebar owners) among them (9163daf -> fec3e98). No upstream change touched ChatPage.tsx. Three files carried both PRs' edits and keep both: |
|
|
|
|
|
|
|
Answers to the PASS punchlines on 4c43498:
|
cruisercohen
left a comment
There was a problem hiding this comment.
Re-approving on 4c43498 after the rebase onto main.
git range-diff against the previous head (821b781) shows the PR's own change is unchanged: comparing the added and removed lines of both diffs, the only difference is the two node:fs import edits in ChatPage.remoteBoundGates.test.tsx and useInteractiveModels.test.ts, which main already carries from #20524. Everything else that differs is context. My review on 821b781 still applies: hook order, dependency arrays and moved bodies are as reviewed.
Required checks are green on this head, and the Sensitive Change Review run reports no sensitive path changed.
…#21054) ChatPage.tsx is still 2,775 lines after its hooks moved to owners (#20388), over the 2,000-line cap (#20192). Its layout regions move, verbatim, into eight view components under pages/chat/page/ (the page frame, sessions chrome, pane chrome, empty state, title row, transcript column, composer dock and side panels), and its own slot switches (fork, the signed chat link, the follow-up session, a split pane's Side Chat) into hooks in pages/useChatPageSlotSwitches.ts, beside the page and outside the owners that never switch slots. Each hook is called where its statements ran, so effect order is unchanged; the views are pure functions of the props the page hands them. ChatPage.tsx drops to 1,089 lines and leaves the line-cap baseline. Source pins that read the page now also find what moved, and new tests cover the views directly and pin that the composer keeps its node, focus and caret across re-renders and the sidebar toggle, and its node across a slot switch. Part of #20192
Problem / Motivation
Goal:
website/src/pages/ChatPage.tsxshrinks from 6,990 to 2,774 lines with unchanged behaviour, by moving its hook logic into 14 owner modules underpages/chat/page/(step 1 of 2 toward the 2,000-line file cap).ChatPage.tsxis the second-largest hand-written file in the repo and gets about 38 commits a week. Every feature PR that touches the chat page edits a 7,000-line component, and the campaign rule in #20192 caps a hand-written file at 2,000 lines.Why it matters
A file this size is where merge conflicts and missed side effects pile up: one function body can sit 4,000 lines away from the effect it races. Splitting by responsibility gives each part of the page (composer send, transcript paging, pins, the sessions drawer, ...) one module that new work for it goes to, and lets the line-cap guard hold the file under the cap.
Not a goal
ChatPage.tsxunder 2,000 lines in this PR. The JSX views and the page's own slot switches move in the stacked follow-up (PR 2 of the series), which takes the page to about 1,200 lines.What changed (motivation → approach → change)
ChatPage already composes 26 owner hooks under
pages/chat/page/, but about 4,300 lines of state, effects and callbacks were still inline. This PR moves them out in contiguous runs: each run of statements becomes one owner hook, called from the exact position those statements held. React registers effects in call order, so the order is unchanged;ChatPage.pageOwners.test.tspins it.pages/chat/page/)pageEnvironment.tsactiveSlotState.tscomposerHost.tssessionPicks.tsturnActions.tstranscriptPaging.tspanelTabs.tscomposerSend.tssend(): the composer's whole turn submission and its recoveriesfollowupCardActions.tspaneLayout.tsxmessageActions.tstranscriptPins.tstranscriptRendering.tsxrenderMessage, turn and measurement-farm rowssessionsDrawer.tsChatPage.tsx(2,776 lines at this head:mainhas since split one of its imports into two lines and added the project-chip lock prop) keeps the composition, everydispatch(switchSlot(site, the slot controllers, the listbox keyboards and the remaining JSX. It still re-exportsshouldAutoFillOlder(now defined intranscriptPaging.ts) and keeps its default export andPREFILL_STORAGE_KEY.Three effect-free statements are hoisted a few lines so each run stays contiguous:
inputRef(afterinputNonBlank),refusedPress(afterplanTaskId) andshowRefusedPress(afterrefusedPress). Each is auseRef,useStateoruseCallback, so nothing React schedules moves.react-hooks/exhaustive-depscannot see across a hook boundary that auseStatesetter oruseRefobject is stable, so those names are appended to the dependency arrays that read them. Adding a stable identity never changes when a hook re-runs. The full list is under Tests.The draft-restore notice's knowledge sentence was an English literal appended to a translated string. It becomes the catalog key
pages.chatPage.knowledge_context_not_kept, added to all 12 catalogs underwebsite/src/i18n/locales/(en-XA regenerated withnpm run i18n:pseudo). English stays byte-identical; the call site prepends the leading space, because a catalog value may not start with one. User-visible: non-English users now read that sentence translated.Docs and comments that name where this code lives now name its owner: the ChatPage owner rows in
learn-cron-dashboard.md,file-search.md,turn-stats-footer.md,workflow-chat-cards.md, two rows ofdocs/feature-map/README.md, and the code comments listed under Tests.Backwards compatibility
Compatible:
pages/ChatPagekeeps its module id, default export and named exports (shouldAutoFillOlderre-exported from its new owner,PREFILL_STORAGE_KEY), so every importer and everyvi.mock('../pages/ChatPage')works unchanged. No owner imports the facade, and nothing outside it imports an owner.Removes nothing: every construct moves into a module that the facade composes; no route, export, key or behaviour is dropped.
Tests
New unit tests for owners that the page suites cover below 80% on their own (deterministic: fake timers with
vi.setSystemTime, no sleeps):ChatPage.transcriptPaging.test.tsx: the top sentinel, earlier-messages bar, walk poll, failed-page retry, gesture budget, slot-entry reset.ChatPage.transcriptPins.test.tsx: jump to pin, quote and last edit; paging until the target lands; the not-found and load-error wording; pin and unpin.ChatPage.transcriptRendering.test.tsx: hidden rows, content-column wrapper, group approval routing, the measurement farm.ChatPage.panelTabs.test.tsx: run-in-terminal config and app panel reveal.ChatPage.knowledgeNote.test.ts: the English sentence is byte-identical, and the call site composes it once.Source pins re-pointed (L30, path only, assertions unchanged). 42 test files that read
ChatPage.tsxas text now read the unionChatPage.tsx+ sortedpages/chat/page/*+ sortedpages/useChatPage*. Each re-point carries a mutation of the pinned construct in its new home that turns the test red (95 of 95 mutations killed; one pinned string occurs twice in its new home, so that pair is applied together). Four files change only a relative specifier, in five regexes, because the import they pin moved intopages/chat/page/:systemNoticeScans(./chat/CompactionCard→../CompactionCard),RecoveryCardandtranscriptRenderers(each./chat/transcriptRenderers→../transcriptRenderers) andchatRolesParity(../app-sdk→../../../app-sdk, two regexes).11 of the re-points are anticipatory for PR 2 of this series: their constructs are still in
ChatPage.tsxtoday, and the union read keeps PR 2's view move from editing them. Each still carries a killing mutation:test/AgentDropdownList.test.tsx,test/ChatPage.composerChromeOcclusion.test.tsx,test/ChatPage.queueBandReanchor.test.tsx,test/ChatPage.scrollShell.recipe.test.tsx,test/ChatPage.scrollShell.render.test.tsx,test/ChatPage.statusStackLayering.test.tsx,test/filterInputFont.test.tsx,test/narrowFirstBaseline.test.ts,test/papyrusNarrow.test.ts,test/reasoningBurst.contract.test.tsx,test/sessionTitleSqueeze.test.ts.Re-pointed files
guide/revealScopes.test.tsxstore/chatSlice.abortOlderOnSwitch.test.tstest/AgentDropdownList.test.tsxtest/ChatPage.collapsedGroupTrust.test.tsxtest/ChatPage.composerChromeOcclusion.test.tsxtest/ChatPage.dockClearance.test.tsxtest/ChatPage.footerNotRetracted.test.tstest/ChatPage.idlePrefetchAuth.test.tstest/ChatPage.mcpOAuth.test.tsxtest/ChatPage.newSessionModel.test.tstest/ChatPage.overlaySelection.test.tsxtest/ChatPage.queueBandReanchor.test.tsxtest/ChatPage.remoteBoundGates.test.tsxtest/ChatPage.scrollShell.recipe.test.tsxtest/ChatPage.scrollShell.render.test.tsxtest/ChatPage.sessionChipOffline.test.tsxtest/ChatPage.sid.test.tsxtest/ChatPage.statusStackLayering.test.tsxtest/ChatPage.systemNoticeScans.test.tstest/ChatPageDrafts.test.tsxtest/NoticeCard.test.tsxtest/RecoveryCard.test.tsxtest/TurnBlock.rowMemo.test.tsxtest/chatPins.test.tsxtest/chatRolesParity.contract.test.tstest/chatTableBreakout.test.tsxtest/chatTableHeightScope.test.tsxtest/filterInputFont.test.tsxtest/injectBubbleWhitespace.test.tstest/invisibleText.test.tstest/jevRoute.test.tsxtest/mobilePanels.compositor.test.tstest/mobileSessionsDrawerViewport.test.tstest/narrowFirstBaseline.test.tstest/olderHistoryTrigger.test.tsxtest/pagination.earlierAdmission.test.tstest/papyrusNarrow.test.tstest/reasoningBurst.contract.test.tsxtest/sessionTitleSqueeze.test.tstest/transcriptRenderers.test.tsxtest/useInteractiveModels.test.tstest/userBubbleMobileOverflow.test.tsxChatPage.pageOwners.test.ts: the pinned hook order gains the 27 new owner hooks at their call positions; the existing order is unchanged.Dependency arrays (setters and refs only):
23 sites
ChatPage.tsx:866+activeSlotRefChatPage.tsx:1253+setSplitModechat/page/composerHost.ts:213+composerSlotRef,inputRefchat/page/composerHost.ts:260+activeSlotRef,composerSlotRefchat/page/composerHost.ts:274+composerSlotRef,inputRefchat/page/sessionPicks.ts:331+modelPickerReturnsFocusRefchat/page/turnActions.ts:255+setRefusedPresschat/page/turnActions.ts:258+setRefusedPresschat/page/transcriptPaging.ts:208+vScrollerElRefchat/page/transcriptPaging.ts:286+lastRealInputAtRef,sentinelPagesSinceInputRef,vFarmIsMeasuredRef,vScrollerElRefchat/page/transcriptPaging.ts:621+setRefusedPresschat/page/followupCardActions.ts:51+inputRefchat/page/followupCardActions.ts:120+followupTsRefchat/page/paneLayout.tsx:109+setSplitAnchor,setSplitModechat/page/paneLayout.tsx:212+setSidebarPinnedchat/page/messageActions.ts:115+setRegeneratingchat/page/messageActions.ts:192+filteredSlotsRef,setSidebarPinned,sidebarAutoHiddenchat/page/messageActions.ts:286+activeSlotRefchat/page/transcriptPins.ts:187+editSeqRef,messagesRef,setEditLastchat/page/transcriptRendering.tsx:414+farmPassRef,messagesRefchat/page/transcriptRendering.tsx:515+farmPassRefchat/page/sessionsDrawer.ts:272+setSidebarPinned,sidebarAutoHiddenchat/page/sessionsDrawer.ts:597+setSidebarPinned,sidebarAutoHidden,sidebarPinnedRefOne justified edit, a new suppression:
renderMessage's deps intranscriptRendering.tsx.messagesRefbecame a parameter and is identity-stable, but listing it would put the substringmessagesback in the array thatTurnBlock.rowMemo.test.tsxbans, so the line carries aneslint-disable-next-linewith that reason instead.panelTabs.tsis 118 lines because it owns one small responsibility, the run-in-terminal bridge's event-time config and the MCP App tab reveal, which neither neighbouring owner holds.Citations (comments only, L29):
utils/chatDrafts.ts,utils/channelOrigin.ts,utils/offline.ts,hooks/useDrawerSwipe.ts,components/DetailPanel.tsx,chat/page/composerDrafts.ts,chat/page/busyTurnControls.ts(three) and the header oftest/ChatPage.handleFork.test.tsxnow name the owner file instead of ChatPage. Moved comments that said "above" / "below" about code that is now in another file name that file (26 phrases, applied as recipe prepatches so the move stays reproducible)..github/file-line-cap-baseline.txt: theChatPage.tsxrow drops from 6990 to 2776, by hand (own row only);scripts/check_file_line_cap.pyreports 0 failures. PR 2 deletes the row.website/scripts/mutation-check-scroll-shell.mjs(one line, granted by the campaign's integration owner): theshell-importregion now ends atimport TurnNavigationMinimap, becauseimport { useVirtualChatmoved totranscriptPaging.ts.--listexits 0 with all 8 regions; the region covers the one shell import line instead of the six lines up to the old anchor.Runs (local,
gate_slot): All at this head, against its merge-base withmain:tsconfig.app.json) 0; eslint--max-warnings 0on the 72 changed source files 0;i18n:check: 19 checks PASS;gen-ui-index --check0; jscpd 0 clones; phantom classes 0;check_file_line_cap.py0 failures; focus-cue, brand, feature-map and comment-history gates 0;docs_lint.py0; the take-away check finds no take-away shape.src/i18n(the catalog, parity and per-language style checks): 43 more files, 888 tests passed.followupCardActions.ts83.3%,sessionPicks.ts83.7%, the rest 87–100%), andChatPage.tsxis 82.1%.semgrep/,--baseline-committhe merge-base): 0 new findings, no parse errors.git diffandgit diff --minimaladd the same lines (ChatPage.tsx: 198 added, 4,412 deleted both ways).scripts/local-gate.py --dry-runselects 825 backend + 475 frontend files, over the ~600 limit, so the floor above ran instead; CI owns the broad matrix.Manual verification
N/A — unit coverage sufficient: the change is a move with effect order pinned by
ChatPage.pageOwners.test.ts, and the ChatPage render suites run unmodified against the composed page.Screenshots / video
Why no screenshot: layout, styling and English text are byte-identical; the one rendered delta is the draft-restore notice's knowledge sentence now appearing translated in non-English locales, described in What changed.
Move audit
website/src/pages/ChatPage.tsx: 6992 → 2776 lines; 4328 removed lines, 4151 found unchanged in the new files (95.91%); the 177 unmatched are glue: 121 import lines, 23 dependency arrays extended with the stable names listed under Tests, 5 module declarations that gainexportin their new owner (DRAWER_UNCOVERED_PX,REFUSED_PRESS_TITLE_KEYS,RefusedPressAction,slashRefusal,ComposerDraftSync), the one English literal that becamepages.chatPage.knowledge_context_not_kept, and 27 comment lines whose "above" / "below" now name the owner file (Citations, under Tests).CI path references
None: no workflow,
AUTOSDE.yamlglob or sensitive-change glob namesChatPage.tsx.Related Issues
Part of #20192
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)