Skip to content

Commit ae0af67

Browse files
authored
fix: clicking on enter button not working after streaming (#8255)
1 parent 9322324 commit ae0af67

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

gui/src/components/mainInput/TipTapEditor/TipTapEditor.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function TipTapEditorInner(props: TipTapEditorProps) {
5757
const historyLength = useAppSelector((store) => store.session.history.length);
5858
const isInEdit = useAppSelector((store) => store.session.isInEdit);
5959

60-
const { editor, onEnterRef } = createEditorConfig({
60+
const { editor, onEnter } = createEditorConfig({
6161
props,
6262
ideMessenger,
6363
dispatch,
@@ -68,9 +68,16 @@ function TipTapEditorInner(props: TipTapEditorProps) {
6868
if (props.isMainInput && editor) {
6969
mainEditorContext.setMainEditor(editor);
7070
mainEditorContext.setInputId(props.inputId);
71-
mainEditorContext.onEnterRef.current = onEnterRef.current;
71+
mainEditorContext.onEnterRef.current = onEnter;
7272
}
73-
}, [editor, props.isMainInput, props.inputId, mainEditorContext, onEnterRef]);
73+
}, [
74+
editor,
75+
props.isMainInput,
76+
props.inputId,
77+
mainEditorContext,
78+
onEnter,
79+
isStreaming,
80+
]);
7481

7582
const [shouldHideToolbar, setShouldHideToolbar] = useState(true);
7683

@@ -272,7 +279,7 @@ function TipTapEditorInner(props: TipTapEditorProps) {
272279
activeKey={activeKey}
273280
hidden={shouldHideToolbar && !props.isMainInput}
274281
onAddContextItem={() => insertCharacterWithWhitespace("@")}
275-
onEnter={onEnterRef.current}
282+
onEnter={onEnter}
276283
onImageFileSelected={(file) => {
277284
void handleImageFile(ideMessenger, file).then((result) => {
278285
if (!editor) {

gui/src/components/mainInput/TipTapEditor/utils/editorConfig.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export function createEditorConfig(options: {
200200
return false;
201201
}
202202

203-
onEnterRef.current({
203+
onEnter({
204204
useCodebase: false,
205205
noContext: !useActiveFile,
206206
});
@@ -210,7 +210,7 @@ export function createEditorConfig(options: {
210210
"Mod-Enter": () => {
211211
posthog.capture("gui_use_active_file_enter");
212212

213-
onEnterRef.current({
213+
onEnter({
214214
useCodebase: false,
215215
noContext: !!useActiveFile,
216216
});
@@ -220,7 +220,7 @@ export function createEditorConfig(options: {
220220
"Alt-Enter": () => {
221221
posthog.capture("gui_use_active_file_enter");
222222

223-
onEnterRef.current({
223+
onEnter({
224224
useCodebase: false,
225225
noContext: !!useActiveFile,
226226
});
@@ -346,30 +346,27 @@ export function createEditorConfig(options: {
346346
editable: !isStreaming || props.isMainInput,
347347
});
348348

349-
const onEnterRef = useUpdatingRef(
350-
(modifiers: InputModifiers) => {
351-
if (!editor) {
352-
return;
353-
}
354-
if (isStreaming || (codeToEdit.length === 0 && isInEdit)) {
355-
return;
356-
}
349+
const onEnter = (modifiers: InputModifiers) => {
350+
if (!editor) {
351+
return;
352+
}
353+
if (isStreaming || (codeToEdit.length === 0 && isInEdit)) {
354+
return;
355+
}
357356

358-
const json = editor.getJSON();
357+
const json = editor.getJSON();
359358

360-
// Don't do anything if input box doesn't have valid content
361-
if (!hasValidEditorContent(json)) {
362-
return;
363-
}
359+
// Don't do anything if input box doesn't have valid content
360+
if (!hasValidEditorContent(json)) {
361+
return;
362+
}
364363

365-
if (props.isMainInput) {
366-
addRef.current(json);
367-
}
364+
if (props.isMainInput) {
365+
addRef.current(json);
366+
}
368367

369-
props.onEnter(json, modifiers, editor);
370-
},
371-
[props.onEnter, editor, props.isMainInput, codeToEdit, isInEdit],
372-
);
368+
props.onEnter(json, modifiers, editor);
369+
};
373370

374-
return { editor, onEnterRef };
371+
return { editor, onEnter };
375372
}

0 commit comments

Comments
 (0)