Repository navigation
refactor(website): compose ChatPage from pages/chat/page owners - #15526
Conversation
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The order pin reads the new source only; its claimed equality with main's inline effect order rests on the author's out-of-diff machine check — verify once against base. What this change shipsInventory (9 items) — 9 justifiedIntent: split the 9,700-line chat page into per-concern modules with zero behavior change — a structural refactor (an ADDITION of internal structure, no new capability, no FIX).
Checks run: storage keys, testids and event listeners deleted from ChatPage reappear 1:1 in owners; no test file deleted; RFC edits are line-cite syncs, no status change; no default, label or capability moves, so lens 9 does not apply. [FIRST-PRINCIPLES-REVIEWED] f5dc59d Description read[DESCRIPTION-READ] e3ea05f6156acff7feb6117023a5323e26630b40dd18b384c5022d2f1587a4bc That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Fable 5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] f5dc59d Description read[DESCRIPTION-READ] a15530506832622645e2aaccb368f1221b9e61b25771e654ec55b99a2695cd6e 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 (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the dependency-array hand edits add only identity-stable refs and setters — the one edit class the machine-checked hook-sequence guarantee doesn't cover. [DESIGN-REVIEWED] f5dc59d Description read[DESCRIPTION-READ] aa96ff4035f14d4f19d83fd3a46469412644ec1c9da3eb144361dcc6c8c7d69e 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 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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: |
Opus 5 Review — ✅ human override acceptedReviewed Human judgment by @bolichen97 overrides the Opus 5 finding for [OPUS-OVERRIDE] f5dc59d Verdict recorded from an authorized human decision for commit False positive or not applicable? A repository writer can comment: |
e63f7c1 to
7c8b26a
Compare
|
Pushed
|
|
Rerunning one job once (flake): The single failure is
This is the one exact-job rerun; nothing else is being rerun. |
7c8b26a to
635bea8
Compare
|
Pushed
The effect-bearing hook sequence still matches main's ChatPage. #15493's own tests run unmodified and pass, and the Bundle Size Gate passes (App 2,057,313 B). |
|
CI status on
|
635bea8 to
0ccb93f
Compare
|
Infra rerun (SD21-3) on
The installation window reset at 02:42:34Z. Both runs were re-run once with |
|
buluoray
left a comment
There was a problem hiding this comment.
Review at f5dc59d8e2356433ffe2d2a7b29ebbe2b3088dfe: approve
I found nothing blocking. I checked the behaviour-preservation claim against the merge base fecca3ea5 independently, without relying on the author's checker or the bot verdicts.
Verified against source
- Hook order. I flattened base
ChatPageand newChatPagewith everypages/chat/page/*owner hook inlined. Both have 458 hook calls with an identical multiset, including 71useEffect/useLayoutEffect. All 144 effects and custom hooks (useComposerDraftSelector,useAnchoredTriggerRect,useVirtualChat, the controllers, and so on) map one-to-one to base and run in the same relative order. That includes the order-sensitive chain: the draft commit, then slot restore, then the three staged-persist effects, thencomposerSlotRefadvancing last (composerDrafts.ts:388-427). Only plainuseState/useRef/useCallbackdeclarations moved. The staging state block now comes before the draft lifecycle. That has no behavioural effect, andtsc -brules out any use-before-declaration. - Child components.
ChatPaneNotices,MobileTopBarand the dock JSX contain no hooks. Moving them into child components did not move any effects into child-first order. - No duplicated state. No
useStateoruseRefname is declared twice acrossChatPageand the owners. The hook multiset matches base, so no owner adds state. - Dependency-array hand edits (the design lane's headline). I diffed every changed dependency array against its base array. Each added entry is a
useRef, auseStatesetter,dispatch,queryClient, or auseCallbackwith stable deps. Examples aresetInput = composerDraft.setfrom auseState(() => …)[0]store, thedrafts/fileDrafts/pasteDrafts/pickedFileTokensrefs, andcurrentSlotTokens/recordSlotToken/mergeSlotTokens, which depend only on refs.location.keybecame thelocationKeyvalue, which is the same value. Two module functions are injected:activateHandoffSlotandcreateFailReason. TheuseMemodeps inChatPagegained onlysetAutomationOpen(a state setter). The empty-deps unmount cleanup (composerDrafts.ts:349) gained only refs, so it cannot fire early. - Dropped code. Every non-comment base line missing from the new tree is an import, a dependency array, a reworded comment, or an inline JSX handler that was hoisted to a named function with a verbatim body:
stopTurn,keepQuestionAnswer,answerQuestionCard,removeFileChip,removeDirChip,selectPickedFile,applyAutomationChangeandtoggleFollowUpOption. The error hand-off'sswitchSlot(...).unwrap()became the injectedactivateHandoffSlot(ChatPage.tsx:359) with the same arguments. - Opus override. I checked
git range-difffrom1425295366(the head Opus published "No findings" on) to this head. It contains only the #15359 Autopilot port (plan dispatch,usePlanActionMutationand comment pruning) plus the rebase. The override reasoning holds. - CI and tests.
cd website && npx tsc -bis clean. All 84ChatPage*/useChatPage*vitest files pass (928 tests). At this SHA, 86 check runs succeeded and 8 were skipped.
Mutation checks (all restored)
- I moved the
composerSlotRefadvance ahead of the persist effects.ChatPageDrafts.test.tsxfailed: "declares all three composer-persist effects before advancing composerSlotRef". - I swapped the
useErrorHandoffIntakeandusePendingInputIntakecalls.ChatPage.pageOwners.test.tsfailed: "are called by the page in the order their inline code ran". - I dropped the in-memory dedupe on the Web Preview marker (
eventBridges.ts:103).useChatPageEventBridges.test.tsxfailed: "dedupes on the in-memory key when the persisted write is lost".
Follow-ups (non-blocking)
- The squash commit message is wrong in a way that lands on main. The auto-merge
commit_messagesays "ChatPage.tsx had grown to 9,468 lines". At this base it is 9,732, which is also what the PR body's own table says. It also says "the only hand edits are dependency arrays … and comment re-pointers", but the edits also hoist the inline handlers listed above, injectactivateHandoffSlot, and moveuniqueNotificationTsintonotificationTs.ts. Please correct the count and widen that sentence. It also names only #14773 and #14756 of the six upstream ports the body lists. Separately, the PR body cites 9,500 and 9,810 in its prose. - The order pin covers the owner call sequence and one inline anchor. It does not cover effect order inside owners, or owners against the other inline page effects. Those currently hold only through the uncommitted one-off checker. A committed version of that comparison would keep the guarantee after this PR.
- The deferred stale
ChatPagecomment pointers listed in the body still need the docs-sync follow-up.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
A palette command fired from a non-chat page seeds pendingInput and navigates to /chat, which mounts fresh. On the old base the slot's draft-restore then overwrote the composer with the empty persisted draft (the probe fails there); the ChatPage split (kirodotdev#15526) fixed it as a side effect. Pin the observable behavior -- the composer holds the seed -- so it stays fixed. Replaces this PR's earlier keyed-prefill write, which is no longer needed and could resurrect a stale seed over an edited draft on the warm path.
Problem / Motivation
Goal: The chat page keeps working exactly as it does today while its 9,500-line component is split into focused owners that a contributor can read, test and change one responsibility at a time.
website/src/pages/ChatPage.tsxheld every chat-page responsibility inline: composer drafts and @-mention chips, launch and prefill intake, window and Electron event bridges, steer / queue / stop, turn recovery, transcript rows and jumps, the composer chips, the pane notices and the phone top bar. At 9,810 lines it was the frontend's highest-churn file; a change to one of those concerns meant reading and re-testing all of them, and 50+ open PRs touch it.Why it matters
Every chat fix lands in this one file, so its size is paid on every change: review diffs are hard to read, conflicts between unrelated PRs are routine, and a behaviour can only be tested through a full page render. Owners with one job each give the next change a small, testable surface without changing anything a user sees.
Not a goal
store/chat/**,hooks/virtualizer/**,hooks/websocket/**,components/chat-input/**, the sidebar, the API client).ChatPage.tsx(the send path, theswitchSlotsites, renderers andrenderMessage, paging and pins, the model picker, drawers and layout) stays there.What changed (motivation → approach → change)
Users see no change. Each chat-page concern now lives in its own small module, so a fix to one can be read, tested and reviewed without the other 9,000 lines.
ChatPage.tsx9,732 → 6,518 lines; 19 owners underpages/chat/page/ChatPage stays the page's one public surface: the default export, its props (
mode,embedded,embedMode,popout,noUrlSync),shouldAutoFillOlderand thePREFILL_STORAGE_KEYre-export. It composes its three existing controllers and the new owners, which own composer drafts, staging and @-mentions (composerDrafts.ts,composerStaging.ts,composerFileMentions.ts), text arriving from outside a keystroke (launchIntake.ts), window and Electron events (eventBridges.ts), a busy turn (busyTurnControls.ts), recovery (turnRecovery.ts), transcript rows and jumps (transcriptRows.ts,transcriptJumps.ts), the composer chips, rosters, session controls, automation, follow-up chips and welcome screen, and the dock, pane notices and phone top bar. The owner map is inlearn-cron-dashboard.md§ Frontend.React runs effects in declaration order and several page effects are ordered against each other, so every moved block is copied verbatim and called at the position it held; the only hand edits are dependency arrays gaining stable refs and setters, and comments that named ChatPage line numbers. Upstream #14773 (chip undo, persisted aliases), #14756 (prompt history), #15493 (the chip's
defaultmarker), #14220 (the phone menu's new-session item), #11744 (run-in-terminal tab reuse) and #15359 (Autopilot removal: the follow-up chips drop plan dispatch) are ported into their owners.The owning specs, the feature map, two RFC line cites (
rfc-transcript-section-markers.md,rfc-resumable-subagent-sessions.md) and one note indashboard-iframe-hosts.mdnow name the owners. The App chunk grows about 14 KB, entirely owner option, return and prop names that cannot be mangled: the chunk count stays 822 and no lazy chunk moves into or out of App. This PR does not edit the bundle budget: App measures 2,040,489 B, inside the 2094 KB ceiling main set in #15514.Comments in files outside this change's claim still name ChatPage for code that now lives in an owner. They are left for a docs-sync follow-up:
utils/chatFileTokenDrafts.ts:3,components/FollowUpCard.tsx:154composerDrafts.tsutils/fileTokens.ts:883composerFileMentions.tscomponents/ChatPane.tsx:1908/:1955composerDock.tsx/composerChips.tshooks/virtualizer/ScrollAnchorCache.ts:32/:62,test/ScrollAnchorCache.test.ts:98,hooks/virtualizer/useVirtualChat.ts:69/:205,chat-core/transcript/useStableMessageKey.ts:5,store/chat/transcript.ts:23transcriptRows.tsapps/command-bar/CommandBarOverlay.test.tsx:836,utils/errorReport.ts:390launchIntake.ts(useErrorHandoffIntake)components/WidgetFrame.tsx:280launchIntake.ts(useAutoSendIntake)Backwards compatibility
Compatible: the facade keeps every export, prop and default its five importers use (
App.tsx,PopoutFrame.tsx,app-sdk/ChatPanel.tsx,apps/papyrus/CoAuthorPanel.tsx,components/ArtifactChatPanel.tsx); no wire, storage, event or query-key shape changes.Tests
ChatPage.pageOwners.test.tspins the facade exports (PREFILL_STORAGE_KEYis navIntent's binding), that no owner imports the facade or callsswitchSlot, that only ChatPage imports the owners, and the owner call order with the inline signed-token effect's place in it (usePendingInputIntakemust read?prefill=before that effect strips the query). The order and import pins were checked red by mutation.useChatPageEventBridges,useChatPageTranscriptJumps,useChatPageTurnRecovery,useChatPageComposerChips,ChatPage.mobileTopBarActionsandChatPage.paneNoticeDismissalscover owner paths no page suite drove (Web Preview dedupe, prefill-terminal refusals and deadline, cold file-tab reads, search re-click, error-row fixes, pin-write failure, the phone bar's menu actions, every notice's dismiss). Every owner is ≥84% line-covered by owned tests.ChatPageDrafts,dockClearance,reachability,newSessionModel,sessionChipOffline,mcpOAuth,idlePrefetchAuth) read the moved text from its new owner at the same strength.switchSlotCallsiteClassification,chatSlice.ownership, the ChatPage source-text pins and the behavioural renders (116+ files).Manual verification
N/A — unit coverage sufficient: the change is a structural move with no rendered delta, and every user path it touches is driven by the existing ChatPage render suites plus the new owner tests.
Screenshots / video
Why no screenshot: structural move only; every DOM node, class, testid and string renders identically, pinned by the unchanged ChatPage render and source-pin suites.
Related Issues
no linked issue: campaign scope F08 (chat page orchestration refactor).
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement