File tree Expand file tree Collapse file tree
apps/array/src/renderer/features/sessions/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,14 +104,20 @@ export function SessionView({
104104 const latestPlan = useMemo ( ( ) : Plan | null => {
105105 let planIndex = - 1 ;
106106 let plan : Plan | null = null ;
107- let responseIndex = - 1 ;
107+ let turnEndResponseIndex = - 1 ;
108108
109- // Find the most recent plan and response in one pass
109+ // Find the most recent plan and turn-ending response in one pass
110110 for ( let i = events . length - 1 ; i >= 0 ; i -- ) {
111111 const msg = events [ i ] . message ;
112112
113- if ( responseIndex === - 1 && isJsonRpcResponse ( msg ) ) {
114- responseIndex = i ;
113+ // Only consider responses that end a turn (session/prompt responses have stopReason)
114+ // Other responses (like tool completions) should not invalidate the plan
115+ if (
116+ turnEndResponseIndex === - 1 &&
117+ isJsonRpcResponse ( msg ) &&
118+ ( msg . result as { stopReason ?: string } ) ?. stopReason !== undefined
119+ ) {
120+ turnEndResponseIndex = i ;
115121 }
116122
117123 if (
@@ -127,11 +133,11 @@ export function SessionView({
127133 }
128134 }
129135
130- if ( planIndex !== - 1 && responseIndex !== - 1 ) break ;
136+ if ( planIndex !== - 1 && turnEndResponseIndex !== - 1 ) break ;
131137 }
132138
133- // Plan is stale if the most recent response came after it (turn completed)
134- if ( responseIndex > planIndex ) return null ;
139+ // Plan is stale only if a turn-ending response came after it
140+ if ( turnEndResponseIndex > planIndex ) return null ;
135141
136142 return plan ;
137143 } , [ events ] ) ;
You can’t perform that action at this time.
0 commit comments