File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import { getErrorMessage } from "../../shared/error-message";
2525import { log } from "../../shared/logger" ;
2626import { createMagicContextCommandHandler } from "./command-handler" ;
2727import { createEventHandler } from "./event-handler" ;
28+ import { clearInjectionCache } from "./inject-compartments" ;
2829import { createNudger } from "./nudger" ;
2930import { createTextCompleteHandler } from "./text-complete" ;
3031import { createNudgePlacementStore , createTransform } from "./transform" ;
@@ -188,7 +189,10 @@ export function createMagicContextHook(deps: MagicContextDeps) {
188189 tagger : deps . tagger ,
189190 db,
190191 nudgePlacements,
191- onSessionCacheInvalidated : deps . onSessionCacheInvalidated ,
192+ onSessionCacheInvalidated : ( sessionId : string ) => {
193+ clearInjectionCache ( sessionId ) ;
194+ deps . onSessionCacheInvalidated ?.( sessionId ) ;
195+ } ,
192196 } ) ;
193197
194198 const runDreamQueueInBackground = ( ) : void => {
Original file line number Diff line number Diff line change @@ -229,7 +229,8 @@ export function runPostTransformPhase(args: RunPostTransformPhaseArgs): void {
229229 } catch ( error ) {
230230 sessionLog ( args . sessionId , "transform failed applying pending operations:" , error ) ;
231231 updateSessionMeta ( args . db , args . sessionId , { lastTransformError : getErrorMessage ( error ) } ) ;
232- args . nudgePlacements . clear ( args . sessionId ) ;
232+ // Only clear on cache-busting passes to avoid re-anchor on next defer.
233+ if ( isCacheBustingPass ) args . nudgePlacements . clear ( args . sessionId ) ;
233234 }
234235 // Only clear nudge placements on cache-busting passes. Clearing on defer would
235236 // cause the next pass to re-anchor the nudge on a cached assistant message (Finding 2).
You can’t perform that action at this time.
0 commit comments