Repository navigation
refactor(website): split chatSlice into composed store/chat owners - #14665
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] f9bdba8 Description read[DESCRIPTION-READ] 4df9866aa0205815c02bcf514acbd7610a042ff3cd3c4449d72878fda3ea1edc 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] f9bdba8 Description read[DESCRIPTION-READ] 62cc109bdc8913537b3c36e1c69b33b8221fae440821fc9e099fcd1f976b98d7 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 Behaviour-identity rests wholly on the new pin tests and CI's full suite — a 7,500-line move is unreviewable by eye, so confirm the 442 chat/store test files ran green on this head. What this change shipsInventory (9 items) — 9 justifiedIntent: contributors can edit one part of the dashboard's chat state without merging against the 7,572-line
No undeclared riders found: no consumer files edited, no new persisted keys ( [FIRST-PRINCIPLES-REVIEWED] f9bdba8 Description read[DESCRIPTION-READ] 82d5846b26f40cf0e107c136c1a36d1fbd631d9d6524e00587111a91a7817983 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: |
|
/ai-review override fable f4cc64a: Opus discovery exhausted its 180-turn budget twice at this head on the ~922 KB behaviour-preserving move diff with no verdict and no finding; GPT, Design, First Principles, UX, Security Scope and CodeQL all passed on this head. |
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 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: |
f4cc64a to
a413c27
Compare
|
Rebased: main moved Where each #14699 hunk landed
Proof it is the same change
Re-gated at range-diff excerpt, code files only (
|
a413c27 to
3a47f14
Compare
|
Docs-only amend ( This amend reverts one pointer swap only: the The frozen "Not a goal" bullet still says "Five other docs"; with this revert it is four (learn-cron-dashboard.md, followup-suggestions-trust-model.md and the two RFCs). Verdicts on |
|
One exact-job rerun on
This PR changes only |
|
|
Infra rerun on |
chatSlice.ts had grown to 7,572 lines holding every chat reducer, thunk, selector, wire guard and transcript calculation, with a 1,042-line extraReducers builder. Changes to one responsibility meant reading and merging against all of them. The slice now composes cohesive owners under website/src/store/chat/: the wire trust boundary, pure transcript and paging calculations, the state shape, reducer families (run state, slot cache, messages, queue, composer cards, activity, sub-agents, automations, side chat, workflows, MCP apps), the switch/refresh/lifecycle thunks with their extra reducers, slot teardown, and selector families. chatSlice.ts stays the single createSlice wiring point and the facade every consumer imports: action type strings, action creators, thunk prefixes, selectors, constants, types, initial state and the default reducer export are unchanged. The constructs source-text oracles read from chatSlice.ts stay there. New characterization tests pin the public surface and initial state, prototype-key guards across every reducer family and every depth of the state tree, and the ownership shape (no owner imports the facade, acyclic owner imports, facade-only access from outside src/store, disjoint reducer families, re-export identity). The session, history, mcp-apps, side and subagent specs record the new owners, and four other docs have the file or symbol pointers the move made false re-pointed.
9e13b50 to
f9bdba8
Compare
|
@buluoray Rebased again: new head |
Problem / Motivation
Goal: Contributors can change one part of the dashboard's chat state without reading or merging against the whole 7,572-line
chatSlice.ts, while the dashboard behaves exactly as before.website/src/store/chatSlice.tsheld every chat reducer, thunk, selector, wire guard and transcript calculation in one file. ItsextraReducersbuilder alone was 1,042 lines. It is one of the most-edited frontend files, so an unrelated fix to the side chat, sub-agent cards or older-history paging lands in the same file, conflicts with every other open chat change, and has to be reviewed against thousands of lines it does not touch.Why it matters
Every chat-state fix pays for the file's size: longer reviews, frequent rebase conflicts between unrelated PRs, and a real chance of editing the wrong one of several near-identical slot-detail reducers. The WebSocket router, composer, sidebar and ChatPage refactors that follow also build on this store, and they need clear owners to depend on.
Not a goal
store/chatSlicekeeps working unchanged, and no consumer file is edited.chatslice into several slices, or adding a shared state service.What changed (motivation → approach → change)
website/src/store/chat/wire.tstranscript.ts,paging.ts,thinking.tsstate.tsChatState, initial state, themc-activity-open:<slot>key familyrunState.ts,slotCache.ts,messages.ts,queue.ts,composerCards.ts,activity.tssubagents.ts,automations.ts,side.ts,workflows.ts,mcpApps.tsslotSwitch.ts,slotRefresh.ts,lifecycle.ts,slotResidue.tsswitchSlot,refreshSlot/warmSlotCache, create / fork / resume / history thunks with their extra reducers, and slot teardownselectors.tsThe file was too big to change safely, so each responsibility now has one owner and
chatSlice.ts(849 lines) is the singlecreateSlicecall that composes them. It spreads the reducer families intoreducers, calls each owner'sadd…Cases(builder)inextraReducers, and re-exports every public name. Consumers therefore see the same module, the same action types and the same objects.Three constructs stay in
chatSlice.tsbecause a read-only check reads them from that file. The livechat_messageframe reducer appliesQUESTION_RETIRING_ROLESand the chunk-gap marker, which a backend test and the i18n ledger read.deleteSlotholds the onedispatch(switchSlot(site the call-site oracle counts there.loadOlderMessagescarries the slot capturechatPins.test.tsxreads.requestStopstays too, because it dispatches this slice's own actions. The switch-notice action became acreateActionwith the samechat/setSwitchSlotGonetype soslotSwitch.tsdoes not import the facade. The MCP App key separator became a named constant, so the i18n ledger forstore/chatSlice.tsgoes from 4 to 1 and new files add none.The session, history, mcp-apps, side and subagent specs now name these owners. side.md also fixes one sentence that was already false about the unchanged
sseSideQueuereducer: a redelivered push id is ignored, never rewritten, andfronthead-inserts. history.md adds a chat-store owner table beside the virtualizer table. The #13683availableAgentssection and every backend section are unchanged.Four unowned docs had a pointer the move made false, and each is re-pointed with no other wording change:
learn-cron-dashboard.md(seedContextUsage),followup-suggestions-trust-model.md(follow-up reducers), and two RFCs whose stalechatSlice.ts:NNNline cites become symbol cites.Backwards compatibility
Compatible:
chatSlice.tskeeps its full export surface, action types, thunk prefixes, initial state and default reducer.chatSlice.publicSurface.test.tspins all of them by name, and the 37 existing chatSlice tests, the 12 direct reducer/selector oracles and every other consumer pass unmodified.Tests
website/src/store/chatSlice.publicSurface.test.ts: the exact runtime export list;chat/<name>types for every action creator; every thunk's prefix and lifecycle types; constant values; the initial state in key order; reference identity for an unrelated action; the persistedmc-activity-open:<slot>seed and write; shared empty references; and zero recomputations of the six memoized aggregates across an unrelated change (red when an input is widened tostate.chat).website/src/store/chatSlice.unsafeKeys.test.ts:__proto__,constructorandprototypesent through every keyed reducer family never reachObject.prototype, and never leave an own entry or a swapped prototype anywhere in the state tree. Sub-agent ids are sent on both the active and a background slot. Removing the id guard insseSubagentPendingwas checked to turn it red.website/src/store/chatSlice.ownership.test.ts: no owner imports the facade; the owners' runtime imports have no cycle; nothing insrc,integrationorcaptureoutsidesrc/storeimports an owner (sovi.mock('../store/chatSlice')still replaces everything); reducer families own disjoint action names that add up to the exported action creators; the switch-notice pairslotSwitch.tswires outside that map still sets and clearsswitchSlotGone; every re-export is the owner's own binding. A planted cycle and facade import were checked to turn it red.chatSliceexports was compared betweenmainand this head with the compiler API: identical, except thatsseChatMessage's payload now prints as the structurally identicalChatFramealias.switchSlotCallsiteClassification.test.ts,chatPins.test.tsx,ChatSliceCoverage*.test.tsxandtest/test_slot_needs_input_status.py.Manual verification
N/A — unit coverage sufficient: this is a pure Redux module with no rendered output. The related sets ran locally: 352 frontend test files (10,706 tests), plus the backend files that cite chatSlice or the changed specs (784 tests). Every new module is at least 94% line-covered.
local-gate.py --base e4dd6161b --dry-runselects 864 backend and 346 frontend files; the backend set is CI's to run in full.Screenshots / video
Why no screenshot: the diff moves Redux state code between modules behind an unchanged facade and changes no component, style or string, so nothing renders differently.
Related Issues
no linked issue: structural refactor of the chat store, part of the frontend decomposition campaign.
Code comments outside this claim still say a symbol lives in
chatSlice.ts. The names resolve through the facade, and the owned specs record the true owners. They are left for the owning lanes:src/kiro_crew/dashboard/state.py:1082website/src/store/chat/selectors.tstest/test_dashboard_chat.py:2743,:2867switchSlot.fulfilledreplace,SKIP_ROLESchat/slotSwitch.ts,chat/wire.tswebsite/src/utils/pinnedPrompt.ts:93isTurnBoundaryUser, thelastUserIdxwalkchat/thinking.ts,chat/selectors.tswebsite/src/pages/chat/ChatPageMessageContent.tsx:162,website/src/test/ChatPage.dockSearchClose.test.tsx:362isRedeliveredMessagechat/transcript.tswebsite/src/app-sdk/protocol/options.ts:77,website/src/test/deriveFollowUpOptions.test.ts:277mergePreservedClientTschat/transcript.tswebsite/src/utils/structuralEqual.ts:8sameMessagechat/transcript.tswebsite/src/test/sessionSummaryTab.test.tsx:76,website/capture/chatpane-loader.tsx:26SlotStatechat/state.tswebsite/scripts/capture-autocompact-slider.mjs:69,capture-panel-section-header.mjs:161,capture-pierre-files-tab.mjs:428fetchSlotDetail, activity-open persistencechat/wire.ts,chat/state.tsFollow-up after merge: the
docs/feature-map/README.md"Default memory mode" row still listsstore/chatSlice.ts. That name still resolves through thecreateSlotexport, but the memory-mode default now lives instore/chat/lifecycle.ts. The re-point is left to a docs-sync PR because this diff has to stay under the review lanes' 1 MB diff cap, and that row's long lines cost about 13 KB of diff.Integration follow-up:
.github/docs-lint-baseline.txtline 425 (line-ref … chatSlice.ts:668-671) no longer fires, because that RFC cite is now a symbol cite. docs-lint reports it as an advisory prune; this PR leaves the baseline alone.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)