@@ -3,7 +3,6 @@ import { inferResolvedUriFromRelativePath } from "core/util/ideUtils";
3
3
import { debounce } from "lodash" ;
4
4
import { useContext , useEffect , useRef , useState } from "react" ;
5
5
import styled from "styled-components" ;
6
- import { v4 as uuidv4 } from "uuid" ;
7
6
import {
8
7
defaultBorderRadius ,
9
8
vscCommandCenterInactiveBorder ,
@@ -52,17 +51,18 @@ export interface StepContainerPreToolbarProps {
52
51
relativeFilepath : string ;
53
52
isGeneratingCodeBlock : boolean ;
54
53
codeBlockIndex : number ; // To track which codeblock we are applying
54
+ codeBlockStreamId : string ;
55
55
range ?: string ;
56
56
children : any ;
57
57
expanded ?: boolean ;
58
58
hideApply ?: boolean ;
59
+ autoApply ?: boolean ;
59
60
}
60
61
61
62
export default function StepContainerPreToolbar (
62
63
props : StepContainerPreToolbarProps ,
63
64
) {
64
65
const ideMessenger = useContext ( IdeMessengerContext ) ;
65
- const streamIdRef = useRef < string > ( uuidv4 ( ) ) ;
66
66
const wasGeneratingRef = useRef ( props . isGeneratingCodeBlock ) ;
67
67
const isInEditMode = useAppSelector ( selectIsInEditMode ) ;
68
68
const [ isExpanded , setIsExpanded ] = useState (
@@ -76,7 +76,7 @@ export default function StepContainerPreToolbar(
76
76
) ;
77
77
78
78
const applyState = useAppSelector ( ( state ) =>
79
- selectApplyStateByStreamId ( state , streamIdRef . current ) ,
79
+ selectApplyStateByStreamId ( state , props . codeBlockStreamId ) ,
80
80
) ;
81
81
82
82
// This handles an edge case when the last node in the markdown syntax tree is a codeblock.
@@ -104,7 +104,7 @@ export default function StepContainerPreToolbar(
104
104
) ;
105
105
106
106
ideMessenger . post ( "applyToFile" , {
107
- streamId : streamIdRef . current ,
107
+ streamId : props . codeBlockStreamId ,
108
108
filepath : fileUri ,
109
109
text : codeBlockContent ,
110
110
curSelectedModelTitle : defaultModel . title ,
@@ -135,19 +135,25 @@ export default function StepContainerPreToolbar(
135
135
}
136
136
} , [ props . children , codeBlockContent ] ) ;
137
137
138
- // Temporarily disabling auto apply for Edit mode
139
138
// useEffect(() => {
140
139
// const hasCompletedGenerating =
141
140
// wasGeneratingRef.current && !isGeneratingCodeBlock;
142
-
143
- // const shouldAutoApply = hasCompletedGenerating && isInEditMode;
144
-
145
- // if (shouldAutoApply) {
146
- // onClickApply();
147
- // }
148
-
141
+ // console.log(
142
+ // wasGeneratingRef.current,
143
+ // isGeneratingCodeBlock,
144
+ // props.autoApply,
145
+ // );
149
146
// wasGeneratingRef.current = isGeneratingCodeBlock;
150
- // }, [isGeneratingCodeBlock]);
147
+ // if (hasCompletedGenerating) {
148
+ // console.log("Completed generating", props.autoApply);
149
+ // if (props.autoApply) {
150
+ // onClickApply();
151
+ // }
152
+ // // else if(isInEditMode) {
153
+ // // onClickApply();
154
+ // // }
155
+ // }
156
+ // }, [wasGeneratingRef, isGeneratingCodeBlock, props.autoApply]);
151
157
152
158
async function onClickAcceptApply ( ) {
153
159
const fileUri = await inferResolvedUriFromRelativePath (
@@ -156,7 +162,7 @@ export default function StepContainerPreToolbar(
156
162
) ;
157
163
ideMessenger . post ( "acceptDiff" , {
158
164
filepath : fileUri ,
159
- streamId : streamIdRef . current ,
165
+ streamId : props . codeBlockStreamId ,
160
166
} ) ;
161
167
}
162
168
@@ -167,7 +173,7 @@ export default function StepContainerPreToolbar(
167
173
) ;
168
174
ideMessenger . post ( "rejectDiff" , {
169
175
filepath : fileUri ,
170
- streamId : streamIdRef . current ,
176
+ streamId : props . codeBlockStreamId ,
171
177
} ) ;
172
178
}
173
179
0 commit comments