@@ -12,6 +12,7 @@ import {
1212 updateSessionGoalStatus ,
1313} from "../../config/sessions.js" ;
1414import { rejectUnauthorizedCommand } from "./command-gates.js" ;
15+ import { markCommandSessionMetadataChanged } from "./command-session-metadata.js" ;
1516import type {
1617 CommandHandler ,
1718 CommandHandlerResult ,
@@ -170,6 +171,8 @@ export const handleGoalCommand: CommandHandler = async (params, allowTextCommand
170171 const snapshot = await getSessionGoal ( {
171172 sessionKey : params . sessionKey ,
172173 storePath : params . storePath ,
174+ fallbackEntry : params . sessionEntry ,
175+ persist : false ,
173176 } ) ;
174177 syncGoalSessionEntry ( params ) ;
175178 return goalReply ( formatSessionGoalStatus ( snapshot . goal ) ) ;
@@ -188,6 +191,7 @@ export const handleGoalCommand: CommandHandler = async (params, allowTextCommand
188191 fallbackEntry : params . sessionEntry ,
189192 } ) ;
190193 syncGoalSessionEntry ( params ) ;
194+ markCommandSessionMetadataChanged ( params ) ;
191195 applyGoalContinuationPrompt ( params , formatGoalContinuationPrompt ( goal . objective ) ) ;
192196 return goalContinuation ( ) ;
193197 }
@@ -199,6 +203,7 @@ export const handleGoalCommand: CommandHandler = async (params, allowTextCommand
199203 ...( parsed . text ? { note : parsed . text } : { } ) ,
200204 } ) ;
201205 syncGoalSessionEntry ( params ) ;
206+ markCommandSessionMetadataChanged ( params ) ;
202207 return goalReply ( `Goal paused: ${ goal . objective } ` ) ;
203208 }
204209 case "resume" : {
@@ -209,6 +214,7 @@ export const handleGoalCommand: CommandHandler = async (params, allowTextCommand
209214 ...( parsed . text ? { note : parsed . text } : { } ) ,
210215 } ) ;
211216 syncGoalSessionEntry ( params ) ;
217+ markCommandSessionMetadataChanged ( params ) ;
212218 const message = formatGoalResumeContinuationPrompt ( parsed . text ) ;
213219 applyGoalContinuationPrompt ( params , message ) ;
214220 return goalContinuation ( ) ;
@@ -222,6 +228,7 @@ export const handleGoalCommand: CommandHandler = async (params, allowTextCommand
222228 ...( parsed . text ? { note : parsed . text } : { } ) ,
223229 } ) ;
224230 syncGoalSessionEntry ( params ) ;
231+ markCommandSessionMetadataChanged ( params ) ;
225232 return goalReply ( `Goal complete: ${ goal . objective } \nTokens used: ${ goal . tokensUsed } ` ) ;
226233 }
227234 case "block" :
@@ -233,6 +240,7 @@ export const handleGoalCommand: CommandHandler = async (params, allowTextCommand
233240 ...( parsed . text ? { note : parsed . text } : { } ) ,
234241 } ) ;
235242 syncGoalSessionEntry ( params ) ;
243+ markCommandSessionMetadataChanged ( params ) ;
236244 return goalReply ( `Goal blocked: ${ goal . objective } ` ) ;
237245 }
238246 case "clear" : {
@@ -241,6 +249,9 @@ export const handleGoalCommand: CommandHandler = async (params, allowTextCommand
241249 storePath : params . storePath ,
242250 } ) ;
243251 syncGoalSessionEntry ( params ) ;
252+ if ( removed ) {
253+ markCommandSessionMetadataChanged ( params ) ;
254+ }
244255 return goalReply ( removed ? "Goal cleared." : "No goal to clear." ) ;
245256 }
246257 default :
0 commit comments