Repository navigation
refactor(website): move ChatPage's views and slot switches to modules - #21054
Conversation
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
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] ece2f4a Description read[DESCRIPTION-READ] 4a0facc9e0a3d641679358bb17c9db6144e355a16d3b62d3bbc9b064bda5e961 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 Make sure the frontend suite is green: about 45 source-scan tests outside this patch read [DESIGN-REVIEWED] ece2f4a Description read[DESCRIPTION-READ] 2fe1350ce89379a9ee7872379d94af4bcb79cb6aded10b90fe1c74a1159d77ff 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) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check that What this change shipsInventory (8 items) — 8 justifiedIntent: bring
[FIRST-PRINCIPLES-REVIEWED] ece2f4a Description read[DESCRIPTION-READ] e07ba5149de3f8470679418b2f8299e66222b6c4a44c9ac80516f1fd6f13a51e 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: |
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: |
|
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved by a maintainer after reading the review lanes: every lane is clean on this head, and the automated triage held it only on a size or category rule.
Problem / Motivation
Goal:
website/src/pages/ChatPage.tsxdrops from 2,775 to 1,089 lines, under the 2,000-line file cap, with unchanged behaviour. Its JSX regions move into eight view components and its own slot switches into one sibling hook module (step 2 of 2).After step 1 (#20388) moved the page's hook logic into owners,
ChatPage.tsxwas still 2,775 lines. About 1,700 of them were one JSX tree, plus the four flows that switch the active session. The campaign rule in #20192 caps a hand-written file at 2,000 lines. The page still had a row in.github/file-line-cap-baseline.txt, so it was the one chat file allowed over the cap.Why it matters
The chat page gets about 38 commits a week, and each of them edits that single tree: the sessions chrome, the title row, the transcript, the composer dock and the side panels all sit in one return statement. With each region in its own view, a change to the composer dock edits only the dock. The page also leaves the baseline, so the line-cap guard now holds it under the cap the same way it holds every other file.
Not a goal
What changed (motivation → approach → change)
The page's return statement was one tree of about 1,700 lines. Its regions are self-contained: each reads page values and renders, and holds no hook. So each region becomes a module-level view component, moved verbatim and handed exactly the identifiers it reads as props. The page keeps the layout skeleton that places the views. A view holds no state, so mounting it in place of its JSX changes nothing React tracks.
ChatPage.focusRetention.test.tsxpins that: the composer keeps its DOM node, focus and caret across a parent re-render and the sidebar pin toggle, and its DOM node across a slot switch and back. The same file pins one ordering the page owns: the composer dock renders after the transcript scroller.pages/chat/page/)ChatPageFrame.tsxSessionsSidebarChrome.tsxChatPaneChrome.tsxChatEmptyState.tsxChatTitleOverlay.tsxChatTranscriptView.tsxComposerDockView.tsxChatSidePanels.tsxThe page's four slot-switching flows move into
pages/useChatPageSlotSwitches.ts(357 lines):useSignedLinkAnchor(a signed chat link),useForkSession,useOpenFollowupSessionanduseOpenSideChatForPane. This module sits beside the page, not underpages/chat/page/, because owners there never switch slots (ChatPage.pageOwners.test.tspins that). Each hook is called where its statements ran, so effect order is unchanged.ChatPage.tsxkeeps its default export,PREFILL_STORAGE_KEYand theshouldAutoFillOlderre-export. It is the only non-test importer of the views (ChatPage.pageOwners.test.tspins it) and of the sibling module.Backwards compatibility
Compatible:
pages/ChatPagekeeps its module id, default export and named exports, so every importer and everyvi.mock('../pages/ChatPage')works unchanged. No view or hook module imports the facade.Removes nothing: every construct moves into a module the page renders or calls; no route, export, key or behaviour is dropped. The two backend files touched (
chat_handlers.py,state.py) change a comment or docstring only.Tests
New tests (deterministic: no sleeps, no timers):
ChatPage.focusRetention.test.tsx: the composer textarea keeps its node, focus and caret across a re-render and the sidebar pin toggle, and its node across a slot switch and back. KeyingComposerDockViewonsidebarPinned,messages.lengthoractiveSlotturns it red. It also passes onmain. Every step runs inside an awaitedact(), so the page's mount queries settle inside the test and the file emits 0 act() warnings underKIROCREW_ACT_STRICT=1. A fourth case, in its own describe, pins that the composer dock root follows the chat-messages scroller in the DOM (that order, not a z-index, paints the dock over the transcript); swapping the two views inChatPage.tsxturns it red.ChatPage.views.test.tsx(10 tests) andChatPage.composerDock.test.tsx(7 tests) render the views directly with their children stubbed and assert the actions each wires. The crew-window case loads a freshChatPaneChrome(vi.resetModules), so its lazy chunk starts unloaded in any test order, and both chunk waits use a namedCREW_WINDOW_CHUNK_TIMEOUT_MS. These cover the branches the page suites rarely reach (a crew window over an embedded pane, the recents flyout, reveal and rename, a popped-out or split-anchored session, the pinned prompt, group approvals, each composer pop-up's close).Source pins. Assertion logic is unchanged: path re-points, row edits and L30 joins, plus the one granted literal split in
scrollShell.recipe. Each pin carries a mutation of its construct in its new home that turns the test red (36 of 36 mutations killed):test/sidePanelMount.test.ts: reads the union ofChatPage.tsx,pages/chat/page/*andpages/useChatPage*, like the 42 files re-pointed in step 1.test/ChatPage.reachability.test.tsx: its negative half (not.toMatch(/trackSession\(\s*activeSlot/)) reads the same union, so the regression shape cannot come back in a view or the sibling (a plant inChatPaneChrome.tsxoruseChatPageSlotSwitches.tsturns it red). Its positive half ("the page must run the bridge") keeps readingChatPage.tsxalone: over the union,useChatEventBridges({would also match the hook's own definition ineventBridges.ts, and the check could never fail (hiding the page's call still turns it red).pages/ChatPage.knowledgeNote.test.ts(step 1's own test): its construct did not move (the call site is still incomposerSend.ts), but "one call site" now counts over the same union as a negative-half guard, so a second site anywhere in the page is seen (a plant inComposerDockView.tsx, or removing the real site, turns it red).test/ChatPage.pageOwners.test.ts: the owner scan includespages/useChatPage*.ts. The pinned order gainsuseSignedLinkAnchor(in place of the inline signed-token effect it anchored before),useForkSession,useOpenFollowupSessionanduseOpenSideChatForPane, each at its call position.INLINEis now empty, and a comment says why the list stays.test/ChatPage.handleFork.test.tsx(its "shared action-error notice" describe, added onmainby fix(chat): refuse an over-capacity whole fork instead of dropping rows #20992):srcreads the same union.handleForknow lives inuseForkSession, so the handler slice is found there (its two markers occur once in the union), and the describe'snot.toContainhalves see every view. Altering the handler'sresult.coderead, or plantingfitsAtorsetForkErrorin a view, turns it red. The describe's comment names the handler's new home.store/switchSlotCallsiteClassification.test.ts: five plain sites move from theChatPage.tsxrow to a newuseChatPageSlotSwitches.tsrow with its reason. The totals (2 announced, 1 keep-target, 6 plain) are unchanged.test/ChatPage.scrollShell.recipe.test.tsx:270(granted by the campaign's integration owner): onetoContainof the combined import becomes two, becauseTranscriptScrollShellis imported byChatTranscriptView.tsxanduseTranscriptWidthby the page.website/scripts/mutation-check-scroll-shell.mjs(granted):FILESgains the three views that now hold scroll-shell regions.--listfinds the same 104 targets and 8 scoped out as before.ComposerDockView.tsxis one of them because it holds the dock root (<div ref={dockRef} … data-testid="composer-dock-root">). That root is the positioned box that floats over the scroller, and everything the view renders lives inside it. Leaving it in the page would split the dock across two files, with the view returning children for a wrapper it does not own.Edits beyond a verbatim move:
useSignedLinkAnchorruns beforeuseComposerDraftLifecyclereturnsnoCarryCreateIdsRef, so it receives a getter,getNoCarryCreateIdsRef: () => noCarryCreateIdsRef. One body token readsgetNoCarryCreateIdsRef().currentinstead ofnoCarryCreateIdsRef.current. The old closure read the binding when its callback ran, and the getter reads it at the same moment.ComposerDockView.tsx's body is not re-indented.ChatPage.statusStackLayering.test.tsxends its status-stack match at a newline plus exactly 14 spaces, so re-indenting the dock would make that read-only pin over-match.CrewWindowGuard's import inChatPaneChrome.tsx. The recipe also collapses the blank-line run the pruned imports leave (the same rule it applies to removed declarations), so the page is 1,089 lines.CrewChatWindowdeclaration moves intoChatPaneChrome.tsx, the only file that renders it, and its import path is re-rooted.COLLAPSED_SESSION_TABS_INSETstays in the page besideCOLLAPSED_PANE_RECLAIM_PX, which it is derived from and which the page's own pane wrapper reads.ChatPaneChromereceives it as a prop.ChatTitleOverlayandComposerDockViewtypeactiveSlotasstring, because both render only in the page's branch whereactiveSlotis set (after!activeSlot ? <ChatEmptyState …/>).Two views under 150 lines.
ChatEmptyState.tsx(53) is the pane with no session open, a region of its own with its own create-or-retry action.ChatPageFrame.tsx(85) is the provider frame every surface reads. Folding either into a neighbour would give that neighbour a second responsibility.Docs that named
ChatPageas the place a region renders now name its view (26 citations acrosslearn-cron-dashboard.md,docs/feature-map/README.md,stt-streaming.md,prompt-optimizer.md,mcp.md,followup-suggestions-trust-model.mdandwebsite/docs/narrow-viewport.md). The owner table inlearn-cron-dashboard.mdgains a row per view and a paragraph on the sibling hook module, and the feature map's Sessions row lists the views andpages/useChatPageSlotSwitches.tswith the other parts of the page. Comments insrc/kiro_crew/dashboard/chat_handlers.py(filteredSlots, defined inchat/page/pageEnvironment.ts) andstate.py(the composer's Resume gate, now inComposerDockView.tsx) cite the new homes.Citations in comments and notes (L29, path or name only; no code, assertion or test-title changes). Comments that located a construct in
ChatPage/ChatPage.tsxthat now lives in a view, the sibling or (for a file-path orComponent.memberlocator) a step-1 owner now name that home. A statement about a hook owner's code that still runs inside theChatPagecomponent stays as it is, and so do citations that were already stale before this series, except one on a line this PR corrects anyway:index.css'sdata-overflowingnote now namesuseChatPageTranscriptController.tsx, where the attribute is set.test/gui_user/features.jsonalso gains twosourcerows besideChatPage.tsx:chat-knowledge-picker-attachaddsComposerDockView.tsx, where KnowledgePicker mounts, andchat-long-history-paginationaddsChatTranscriptView.tsx, where EarlierMessagesBar mounts.test_features_catalog.pyvalidates both.MembersPageThread.tsx(the title-row overlay cite that F07's split moved out ofMembersPage.tsx) now namesChatTitleOverlay.state.py:2052, in G04's live file, is relayed to G04, not edited. Thechat_handlers.pyedit settles S02's relay. TheChatPage.handleFork.test.tsxheader now namesuseForkSession; replacing its hand copy ofhandleForkwith arenderHook(useForkSession)test is a follow-up, not part of this move.101 rewritten lines in 66 files
src/kiro_crew/dashboard/state.py(1)test/gui_user/features.json(3)website/capture/action-row-first-cell-hover.tsx(1)website/capture/loading-indicator-align.tsx(2)website/capture/pinned-prompt-handoff.tsx(4)website/capture/question-card-survives-nudge.tsx(2)website/capture/refused-press.tsx(2)website/capture/steer-bubble-geometry.tsx(1)website/capture/subagent-completion-overflow.tsx(2)website/capture/transcript-row-geometry.tsx(1)website/capture/user-bubble-mobile-overflow.tsx(1)website/capture/workflow-completion-overflow.tsx(2)website/integration/ForkSession.integration.test.tsx(1)website/scripts/capture-filter-input-font.mjs(1)website/scripts/capture-side-panel-dock-flip.mjs(1)website/scripts/capture-sidebar-scrollbar.mjs(1)website/scripts/capture-transcript-row-style.mjs(1)website/src/App.tsx(1)website/src/apps/md-notebook/MdNotebookPage.tsx(4)website/src/components/AgentDropdownList.tsx(1)website/src/components/ChatInput.tsx(1)website/src/components/ChatPane.tsx(2)website/src/components/ProjectPicker.tsx(2)website/src/components/SessionPulseSurveyCard.tsx(1)website/src/components/SessionTabStrip.tsx(1)website/src/components/WelcomeView.tsx(1)website/src/index.css(5)website/src/lib/agentSwitch.ts(1)website/src/pages/PopoutFrame.tsx(1)website/src/pages/chat-sidebar/bulkModelSwitch.tsx(2)website/src/pages/chat-sidebar/scope.ts(2)website/src/pages/chat/PinnedPrompt.tsx(2)website/src/pages/chat/SessionFlyout.tsx(2)website/src/pages/chat/SessionTitleControl.tsx(1)website/src/pages/chat/SubagentCompletionCard.tsx(1)website/src/pages/chat/SubagentRunCard.tsx(1)website/src/pages/chat/WorkflowCompletionCard.tsx(1)website/src/pages/chat/WorkflowRunCard.tsx(1)website/src/pages/chat/crew-window/crewWindowAgentMode.tsx(1)website/src/pages/chat/page/MobileTopBar.tsx(1)website/src/pages/chat/page/composerHost.ts(1)website/src/pages/chat/page/pageEnvironment.ts(1)website/src/pages/chat/page/sessionsDrawer.ts(4)website/src/pages/chat/page/transcriptPaging.ts(1)website/src/pages/chat/page/transcriptRows.ts(1)website/src/pages/members/MembersPageThread.tsx(1)website/src/test/App.topbarCapsule.test.tsx(1)website/src/test/ChatInput.liquidGlass.test.tsx(1)website/src/test/ChatPage.continueGate.test.tsx(1)website/src/test/ChatPage.handleFork.test.tsx(8)website/src/test/ChatPage.pickerAnchorRemeasure.test.tsx(1)website/src/test/ChatPage.responsivePanel.test.tsx(1)website/src/test/ChatPane.headerStacking.test.tsx(1)website/src/test/ProjectPicker.footer.test.tsx(1)website/src/test/SessionControlHostCoverage.test.tsx(1)website/src/test/TranscriptRowGeometry.test.tsx(2)website/src/test/UserMessage.pinnedStandinActions.test.tsx(1)website/src/test/chatSlice.boundedInitialFetch.test.ts(1)website/src/test/mcpAppPanelTab.test.ts(1)website/src/test/mobileSessionsDrawerViewport.test.ts(1)website/src/test/sessionTitleSqueeze.test.ts(1)website/src/test/sidePanelDockMotion.test.tsx(1)website/src/test/usePinnedPrompt.test.tsx(1)website/src/test/useVirtualChat.observerBackfill.test.tsx(1)website/src/uiLocations/areas/chat.ts(2)website/src/utils/pinnedPrompt.ts(1).github/file-line-cap-baseline.txt: theChatPage.tsxrow is deleted (own row only).scripts/check_file_line_cap.pyreports 0 failures.Runs (local,
gate_slot, againstmain333061b; the head was then rebased onto fe87f5b with an unchanged patch,git range-diff=, and docs-lint and the line cap re-ran):tsconfig.app.json) 0; eslint--max-warnings 0on the 72 changed files undersrc/andscripts/0 (and on all ofsrc/0 one rebase earlier);i18n:check: 19 checks PASS;gen-ui-index --check0; jscpd 0 clones; phantom classes 0;check_file_line_cap.py0 failures; focus-cue, brand, comment-history and feature-map gates 0;docs_lint.py0; the take-away check finds no take-away shape;mutation-check-scroll-shell.mjs --list0 (104 targets, 8 scoped out).ChatPage.dirStaging.test.tsx› "the same file picked under two differently-rooted slots keeps both chips" (expected '@src/main.ts ' to contain '@main.ts'), and that test passes 5/5 isolated both here and onmain. Its line-422 barrier waits for slot-b's file search to be issued, not answered, so under load the click can land on slot-a'splaceholderDatarow. That is a pre-existing race in the test, in code this PR does not touch, tracked as the known flake in Flaky: ChatPage.dirStaging 'same file under two differently-rooted slots keeps both chips' clicks a stale placeholder row #20843.src/i18n, the TurnBlock/ToolCallLine filesmainchanged under the move, anduiIndex: 593 files, 11,751 tests passed.KIROCREW_ACT_STRICT=1over the three new files,ChatPage.reachabilityandChatPage.knowledgeNote: 26 tests pass, 0 act() warnings.ChatEmptyState.tsx87.5%,ComposerDockView.tsx92.0%, the other six 100%),useChatPageSlotSwitches.tsis 94.1%, andChatPage.tsxis 91.3%.sessionTitleSqueeze,AgentDropdownList,papyrusNarrow,queueBandReanchor,mobilePanels.compositor,narrowFirstBaseline,composerChromeOcclusion×2,scrollShell.recipe,scrollShell.render,statusStackLayering,chatTableHeightScope×2,filterInputFont×2).chat_handlers.py, or validatetest/gui_user/features.json: 2,163 passed. The 13 that testis_turn_interrupted(whose docstring cites the composer's Resume gate) or readstate.py's source: 891 passed.semgrep/,--baseline-committhe merge-base): 0 findings over 80 files, no parse errors (semgrep skipslearn-cron-dashboard.mdas larger than 1 MB, as CI does).git diffandgit diff --minimaladd the same lines for 94 of the 95 files (ChatPage.tsx: 131 added, 1,817 deleted both ways). The one exception isdocs/system-specs/modules/learn-cron-dashboard.md: +21/−9 by default, +20/−8 with--minimal. The default diff re-shows one blank line (deleted and re-added beside the owner-table rows), and that line carries no gate token; the campaign accepts this as an L41 exception. The diff is 603,544 bytes.scripts/local-gate.py --dry-run: selects 2,843 backend + 1,562 frontend test files (the comment citations instate.py,App.tsx,index.cssand the shared components widen the related set), over the ~600 limit, so the floor above ran instead; CI owns the broad matrix.Manual verification
N/A — unit coverage sufficient: the views are moves of JSX the page suites already render,
ChatPage.focusRetention.test.tsxpins that the composer is not remounted, and effect order is pinned byChatPage.pageOwners.test.ts.Screenshots / video
Why no screenshot: every region renders the same DOM, classes and text from its new module; nothing on screen changes.
Move audit
website/src/pages/ChatPage.tsx: 2775 → 1089 lines; 1799 non-blank removed lines (1,817 with blanks), 1716 found unchanged among the added lines (1715 in the new files, 1 re-placed inChatPage.tsx; 95.39%). The 83 unmatched are glue: 81 import lines (78importstatements plus 3 tail lines of two wrapped imports), the lazyCrewChatWindowdeclaration (moved intoChatPaneChrome.tsxwith its import path re-rooted from./chat/crew-window/to../crew-window/), and the onegetNoCarryCreateIdsRef()token described under Tests. The recipe (regen2.shonmain333061b, views mode) reproducesChatPage.tsx, the eight views anduseChatPageSlotSwitches.tsbyte-for-byte.CI path references
None: no workflow,
AUTOSDE.yamlglob or sensitive-change glob namesChatPage.tsxor the new files.Related Issues
Part of #20192
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)