@@ -153,6 +153,8 @@ export interface ChatThread {
153153 interrupted : boolean
154154 tasks : Tasks
155155 id : string
156+ planningMessage ?: string
157+ streamingContents ?: Array < { id : string , text : string } >
156158}
157159
158160interface ChatState {
@@ -735,7 +737,14 @@ export const chatSlice = createSlice({
735737 activeThread . debugChatIndex = action . payload
736738 } ,
737739 setActiveThreadStatus : ( state , action : PayloadAction < ChatThreadStatus > ) => {
738- state . threads [ state . activeThread ] . status = action . payload
740+ const activeThread = state . threads [ state . activeThread ]
741+ const oldStatus = activeThread . status
742+ activeThread . status = action . payload
743+ // Clear planning data when leaving PLANNING status
744+ if ( oldStatus === 'PLANNING' && action . payload !== 'PLANNING' ) {
745+ activeThread . planningMessage = undefined
746+ activeThread . streamingContents = undefined
747+ }
739748 } ,
740749 toggleUserConfirmation : ( state , action : PayloadAction < {
741750 show : boolean
@@ -884,11 +893,43 @@ export const chatSlice = createSlice({
884893 console . error ( 'Error cloning thread from history:' , error )
885894 // Don't change state on error - let existing thread remain active
886895 }
896+ } ,
897+ setPlanningMessage : ( state , action : PayloadAction < string > ) => {
898+ const activeThread = getActiveThread ( state )
899+ activeThread . planningMessage = action . payload
900+ } ,
901+ clearPlanningMessage : ( state ) => {
902+ const activeThread = getActiveThread ( state )
903+ activeThread . planningMessage = undefined
904+ } ,
905+ appendStreamingContent : ( state , action : PayloadAction < { id : string , chunk : string } > ) => {
906+ const activeThread = getActiveThread ( state )
907+ const { id, chunk } = action . payload
908+
909+ // Initialize array if needed
910+ if ( ! activeThread . streamingContents ) {
911+ activeThread . streamingContents = [ ]
912+ }
913+
914+ // Find existing entry by id
915+ const existingEntry = activeThread . streamingContents . find ( entry => entry . id === id )
916+
917+ if ( existingEntry ) {
918+ // Append chunk to existing entry
919+ existingEntry . text += chunk
920+ } else {
921+ // Add new entry
922+ activeThread . streamingContents . push ( { id, text : chunk } )
923+ }
924+ } ,
925+ clearStreamingContent : ( state ) => {
926+ const activeThread = getActiveThread ( state )
927+ activeThread . streamingContents = undefined
887928 }
888929 } ,
889930} )
890931
891932// Action creators are generated for each case reducer function
892- export const { addUserMessage, deleteUserMessage, addActionPlanMessage, addActionPlanMessageV2, startAction, finishAction, interruptPlan, startNewThread, addReaction, removeReaction, updateDebugChatIndex, setActiveThreadStatus, toggleUserConfirmation, setUserConfirmationInput, toggleClarification, setClarificationAnswer, switchToThread, abortPlan, updateThreadID, updateLastWarmedOn, clearTasks, cloneThreadFromHistory, setUserConfirmationFeedback } = chatSlice . actions
933+ export const { addUserMessage, deleteUserMessage, addActionPlanMessage, addActionPlanMessageV2, startAction, finishAction, interruptPlan, startNewThread, addReaction, removeReaction, updateDebugChatIndex, setActiveThreadStatus, toggleUserConfirmation, setUserConfirmationInput, toggleClarification, setClarificationAnswer, switchToThread, abortPlan, updateThreadID, updateLastWarmedOn, clearTasks, cloneThreadFromHistory, setUserConfirmationFeedback, setPlanningMessage , clearPlanningMessage , appendStreamingContent , clearStreamingContent } = chatSlice . actions
893934
894935export default chatSlice . reducer
0 commit comments