Repository navigation
refactor(website): split ChatSidebar into composed chat-sidebar owners - #15094
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the five characterization tests were green on the base commit as claimed — behaviour-preservation rests on that, and CI on this branch cannot re-check it. [DESIGN-REVIEWED] 683e1ac Description read[DESCRIPTION-READ] 226038c4e0390f96c92830e5ac1b3f26b1d58a4966bd9a063a733b4b00b2adad 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 |
UX Review (Fable 5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] 683e1ac Description read[DESCRIPTION-READ] 759000632ede284f7186778fc86617f6b3bd7d1b05757b8c6fdb046c4d0c1e18 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 |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the no-behaviour-change claim's one unprovable premise: that the five characterization tests were green on the base commit before the move. What this change shipsInventory (7 items) — 7 justifiedIntent: split the 11,197-line Sessions sidebar into one-job owner modules with zero behaviour change — an ADDITION of structure (a refactor), not a fix; harm is measured (22 open PRs touching one file).
[FIRST-PRINCIPLES-REVIEWED] 683e1ac Description read[DESCRIPTION-READ] 541dc683e49675e4ba398cc367bdb1326a9b4ad9a44041d0f8546c2c238d7551 That sha256 names the PR description this verdict read. 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: |
|
First Principles note: evidence that the characterization tests pass on the base. These five characterization files were run against the base commit's unsplit
They import only from The same 61 tests pass on this head, 7ee9671. The five retargeted source-pin tests (laneFolderHideParity, revealFilterDimensions, dragSensors, chevronGrammar, hiddenFolderBoardTrace) were each red-checked on this branch. A planted violation in an owner file makes each one fail. |
7ee9671 to
617a025
Compare
Opus 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: |
|
self-added: no
|
617a025 to
ab92334
Compare
ChatSidebar.tsx was an 11,196-line module whose one component held the sidebar's storage schema, row sources, filters, lanes, folder and board state, drag and drop, reveal and session creation inline. Those responsibilities now live in 23 owners under pages/chat-sidebar/, and ChatSidebar.tsx composes them. Each owner hook is the block that used to sit in the component, called where the block was, so React runs the effects in the order it always did. Where a block reached into state another owner holds, that owner exposes one action instead of its setter: clearBoardCollapse for the board's per-column fold, widenForBoard and restorePreBoardWidth for the sidebar width. Deps arrays gained only stable setters and refs that exhaustive-deps cannot see through a hook boundary. The facade keeps its public surface (default memo(ChatSidebar), SIDEBAR_MIN/MAX, sidebarCollision, isFolderNestBand, boardSidebarWidth and the rest) and keeps SessionRow, the render closures, the filter-dimension registry, the peer adopt, the cleanup, the bulk model switch and the JSX where source pins and the restyle ratchet read them. Characterization tests pin the storage contract, the haptic taps, the reveal timeline, pinned-target collision and the unread drain; ChatSidebar.ownerComposition pins the owner graph and the call order. The source-pin tests that read moved code now read the owner files at the same strength. The history spec gains the sidebar owner map, and the feature map names the new owner directory.
ab92334 to
683e1ac
Compare
|
Infra reruns under the campaign's SD21 rule: two jobs on 683e1ac failed before producing a verdict, and each run was rerun once with
Both reruns started after waiting more than 20 minutes for the installation rate limit to reset. |
Problem / Motivation
Goal: The Sessions sidebar behaves exactly as it does today, while its code is split into small owners that each hold one job, so a person changing one sidebar behaviour reads and edits one file instead of an 11,000-line module.
website/src/pages/ChatSidebar.tsxwas 11,197 lines, and one component function in it was 7,620 lines. That one function held every sidebar job inline:Twenty-two open PRs touched the file at the last audit, and a change to one behaviour means reading all of them.
Why it matters
Every sidebar fix today starts with reading the whole component and ends in merge conflicts with unrelated sidebar work. With one owner per job, a fix is found in one file, reviewed as one file, and conflicts only with work on the same job.
Not a goal
pages/chat/*,utils/*,hooks/*,components/*), toChatPage.tsx, or to the Redux store.SessionRow, the row and folder render functions, or the JSX: source pins, the restyle ratchet and the paint-order row stamp read them inChatSidebar.tsx.What changed (motivation → approach → change)
ChatSidebar.tsx(on today's main)pages/chat-sidebar/(largest 508 lines)memo(ChatSidebar),SIDEBAR_MIN/MAX,sidebarCollision,isFolderNestBand,boardSidebarWidth, label tables,sessionRowRenderProbeThe sidebar keeps running the same code in the same order. Each owner hook is the block that used to sit in the component, called where that block sat, so React runs every effect in the order it always did. A new test pins that call order, and pins that owners never import the facade, form no import cycle, and are imported by nothing outside the sidebar. That keeps every
vi.mock('../pages/ChatSidebar')in the page tests replacing the whole sidebar.Where a moved block reached into state another owner holds, that owner now offers one named action instead of handing out its setter:
clearBoardCollapsefor the board's per-column fold,widenForBoardandrestorePreBoardWidthfor the sidebar width. Their statements are the ones the call sites ran before.What stays in
ChatSidebar.tsx, and why:SessionRow, the render closures, the filter-dimension registry, the peer adopt, the idle cleanup, the bulk model switch and the JSX.switchSlotcall-site count, list-shell parity, the bulk-switcher pin, the filter registry, the restyle ratchet.The owner map, and the pin behind each block that stays, are in
docs/system-specs/modules/history.md("The Sessions sidebar (frontend)"). The feature map names the new owner directory.Backwards compatibility
Compatible: every exported name, the default export, and every
mc-*storage key keep their spelling, values, defaults and migration; nothing that importspages/ChatSidebarchanges.Tests
ChatSidebar.persistenceContract: every storage key, default, validator, legacy migration and throwing-storage fallback.ChatSidebar.hapticTaps: each drag or reorder that taps, and each refusal or cancel that stays silent.ChatSidebar.revealTimeline: when a reveal is consumed, filters cleared and the scroll lands.ChatSidebar.collisionPinned: pinned-row collision winners.ChatSidebar.unreadDrainFilter: the unread auto-drain under a filter.test/ChatSidebar.ownerComposition.test.tspins the owner graph, the hook call order, the re-exported bindings, that every storage key lives inpersistence.ts(bar the four status-chip keys), and which owners read storage.laneFolderHideParityreads the lane union fromtypes.ts.revealFilterDimensionsreads the reveal effect fromreveal.ts.dragSensors,chevronGrammarandhiddenFolderBoardTracescan the facade plus every owner file.run_scoped_tests.py): 406 files / 10,221 tests passed; sidebar integration 4 files / 69 passed.npm run test:electroncould not run here: this host has nowebsite/electron/node_modules, and the diff touches no Electron file.scripts/local-gate.py --dry-runselects 704 backend and 403 frontend files. The frontend set ran in full; the backend set is over this host's cap and the diff has no Python, so CI runs it.Manual verification
N/A — unit coverage sufficient: the change moves code without changing behaviour. The characterization tests above were written against the unsplit file and pass unchanged after the move.
Screenshots / video
Why no screenshot: internal code move; the rendered sidebar, its DOM and its styling are byte-identical (the JSX and every row/folder render function are unchanged in
ChatSidebar.tsx).Related Issues
no linked issue: part of the frontend component-refactor campaign; builds on #14665 (chat Redux split) and precedes the ChatPage split.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)