11import { processStrReplace } from '../../../process-str-replace'
2+ import {
3+ getProposedContent ,
4+ setProposedContent ,
5+ } from './proposed-content-store'
26
37import type { CodebuffToolHandlerFunction } from '../handler-function-type'
4- import type { FileProcessingState } from './write-file'
58import type {
69 CodebuffToolCall ,
710 CodebuffToolOutput ,
@@ -16,9 +19,9 @@ export const handleProposeStrReplace = (async (
1619 previousToolCallFinished : Promise < void >
1720 toolCall : CodebuffToolCall < 'propose_str_replace' >
1821
19- fileProcessingState : FileProcessingState
2022 logger : Logger
2123 agentState : AgentState
24+ runId : string
2225
2326 requestOptionalFile : RequestOptionalFileFn
2427 } & ParamsExcluding < RequestOptionalFileFn , 'filePath' > ,
@@ -27,16 +30,16 @@ export const handleProposeStrReplace = (async (
2730 previousToolCallFinished,
2831 toolCall,
2932
30- fileProcessingState,
3133 logger,
34+ runId,
3235
3336 requestOptionalFile,
3437 } = params
3538 const { path, replacements } = toolCall . input
3639
37- // Get content from proposed state first, then fall back to disk
40+ // Get content from proposed state first (by runId) , then fall back to disk
3841 const getProposedOrDiskContent = async ( ) : Promise < string | null > => {
39- const proposedContent = fileProcessingState . proposedContentByPath [ path ]
42+ const proposedContent = getProposedContent ( runId , path )
4043 if ( proposedContent !== undefined ) {
4144 return proposedContent
4245 }
@@ -59,9 +62,13 @@ export const handleProposeStrReplace = (async (
5962 }
6063 } )
6164
62- // Store the proposed content for future propose calls on the same file
63- fileProcessingState . proposedContentByPath [ path ] = strReplaceResultPromise . then (
64- ( result ) => ( 'content' in result ? result . content : null ) ,
65+ // Store the proposed content for future propose calls on the same file (by runId)
66+ setProposedContent (
67+ runId ,
68+ path ,
69+ strReplaceResultPromise . then ( ( result ) =>
70+ 'content' in result ? result . content : null ,
71+ ) ,
6572 )
6673
6774 await previousToolCallFinished
0 commit comments