1+ import { ChatStore } from "@/store/chatStore" ;
2+ import { ProjectStore } from "@/store/projectStore" ;
13import { NavigateFunction } from "react-router-dom" ;
24
35/**
@@ -11,7 +13,7 @@ import { NavigateFunction } from "react-router-dom";
1113 * @param historyId - The history ID for the replay
1214 */
1315export const replayProject = async (
14- projectStore : any ,
16+ projectStore : ProjectStore ,
1517 navigate : NavigateFunction ,
1618 projectId : string ,
1719 question : string ,
@@ -36,8 +38,8 @@ export const replayProject = async (
3638 * @param navigate - The navigate function from useNavigate hook
3739 */
3840export const replayActiveTask = async (
39- chatStore : any ,
40- projectStore : any ,
41+ chatStore : ChatStore ,
42+ projectStore : ProjectStore ,
4143 navigate : NavigateFunction
4244) => {
4345 const taskId = chatStore . activeTaskId as string ;
@@ -57,9 +59,10 @@ export const replayActiveTask = async (
5759 if ( project && project . chatStores ) {
5860 Object . entries ( project . chatStores ) . forEach ( ( [ chatStoreId , chatStoreData ] : [ string , any ] ) => {
5961 const timestamp = project . chatStoreTimestamps [ chatStoreId ] || 0 ;
60-
61- if ( chatStoreData . tasks ) {
62- Object . values ( chatStoreData . tasks ) . forEach ( ( task : any ) => {
62+ const chatState = chatStoreData . getState ( ) ;
63+
64+ if ( chatState . tasks ) {
65+ Object . values ( chatState . tasks ) . forEach ( ( task : any ) => {
6366 // Check messages for user content
6467 if ( task . messages && task . messages . length > 0 ) {
6568 const userMessage = task . messages . find ( ( msg : any ) => msg . role === 'user' ) ;
@@ -68,33 +71,6 @@ export const replayActiveTask = async (
6871 earliestTimestamp = timestamp ;
6972 }
7073 }
71-
72- // Check task info for original questions
73- if ( task . taskInfo && task . taskInfo . length > 0 ) {
74- task . taskInfo . forEach ( ( info : any ) => {
75- if ( info . content && timestamp < earliestTimestamp ) {
76- question = info . content ;
77- earliestTimestamp = timestamp ;
78- }
79- } ) ;
80- }
81-
82- // Check agent logs for original task content
83- if ( task . taskAssigning ) {
84- task . taskAssigning . forEach ( ( agent : any ) => {
85- if ( agent . log ) {
86- agent . log . forEach ( ( logEntry : any ) => {
87- if ( logEntry . data && logEntry . data . message ) {
88- const match = logEntry . data . message . match ( / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n ( .* ?) \n = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = / s) ;
89- if ( match && match [ 1 ] && timestamp < earliestTimestamp ) {
90- question = match [ 1 ] . trim ( ) ;
91- earliestTimestamp = timestamp ;
92- }
93- }
94- } ) ;
95- }
96- } ) ;
97- }
9874 } ) ;
9975 }
10076 } ) ;
@@ -103,6 +79,7 @@ export const replayActiveTask = async (
10379 // Fallback to current task's first message if no question found
10480 if ( ! question && chatStore . tasks [ taskId ] && chatStore . tasks [ taskId ] . messages [ 0 ] ) {
10581 question = chatStore . tasks [ taskId ] . messages [ 0 ] . content ;
82+ console . log ( "[REPLAY] question fall back to " , question ) ;
10683 }
10784
10885 const historyId = projectStore . getHistoryId ( projectId ) ;
0 commit comments