ui/goose2/ui_improvements/state_management/phase-3-session-side-effects.md
Phase 3: Separate Chat Session Side Effects From Generic Store Actions
Status
Goal
chatSessionStore responsibility overload.Scope
ui/goose2/src/features/chat/stores/chatSessionStore.tsui/goose2/src/features/chat/hooks/useChat.tsui/goose2/src/features/chat/hooks/useResolvedAgentModelPicker.tsui/goose2/src/features/chat/hooks/useChatSessionController.tsui/goose2/src/features/chat/stores/chatSessionOperations.tsOut Of Scope
chatSessionStore UI state yet.projectStore.chatSessionStore context-panel or workspace UI ownership here; that belongs in Phase 4.commands naming for the new module, because Tauri backend commands already use that term.Execution Steps
Identify all updateSession call sites.
chatSessionStore ownership, but do not expand this phase beyond mutation semantics.AppShell.tsx should move to updateSessionTitle.AppShell.tsx and useChatSessionController.ts should move to updateSessionProject.acpSessionInfoUpdate.ts should be local-only patchSession.patchSession.useChatSessionController.ts should split projectId into updateSessionProject and keep provider/persona/model fields as patchSession.Add a local-only action.
patchSession in chatSessionStore.Keep compatibility while migrating.
updateSession.updateSession delegate to patchSession only after persisted call sites have moved to operations.updateSession when no production or test call sites remain.Add explicit operation functions.
chatSessionOperations.ts.updateSessionTitle(sessionId, title).
patchSession(sessionId, { title, userSetName: true }).updateSessionProject(sessionId, projectId).
patchSession(sessionId, { projectId }).renameSession as updateSessionTitleApi.Migrate call sites one category at a time.
patchSession.updateSessionTitle.updateSessionProject.patchSession only, even when the patch includes title or userSetName.userSetName alone should never imply a backend call.archiveSession / unarchiveSession until title/project ambiguity is gone.Remove hidden side effects from updateSession.
updateSession.Add focused tests.
patchSession does not call backend APIs.updateSessionTitle calls backend rename before patching local state.updateSessionTitle does not patch local state if backend rename rejects.updateSessionProject calls backend project update before patching local state.updateSessionProject does not patch local state if backend project update rejects.title and/or userSetName are local-only.Record failure-policy follow-up.
phase-5-session-workflow-failure-policy.md.Validation
rg "updateSession\\(" ui/goose2/srccd ui/goose2 && pnpm test -- chatSessionStore useChat useChatSessionControllerSuccess Criteria