Skip to content

Commit ae5c06f

Browse files
committed
fix(chatGPTBrowser): render markdown formatting by setting isCreatedByUser, fix(useMessageHandler): avoid double appearance of cursor by setting latest message at initial response creation time
1 parent 9ef1686 commit ae5c06f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

api/server/routes/ask/askChatGPTBrowser.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ const ask = async ({
103103
unfinished: true,
104104
cancelled: false,
105105
error: false,
106+
isCreatedByUser: false,
106107
});
107108
}
108109
},
109110
});
110111

111112
getPartialMessage = getPartialText;
112113
const abortController = new AbortController();
114+
let i = 0;
113115
let response = await browserClient({
114116
text,
115117
parentMessageId: userParentMessageId,
@@ -128,8 +130,12 @@ const ask = async ({
128130

129131
sendMessage(res, {
130132
message: { ...userMessage, conversationId: data.conversation_id },
131-
created: true,
133+
created: i === 0,
132134
});
135+
136+
if (i === 0) {
137+
i++;
138+
}
133139
},
134140
});
135141

@@ -152,6 +158,7 @@ const ask = async ({
152158
unfinished: false,
153159
cancelled: false,
154160
error: false,
161+
isCreatedByUser: false,
155162
};
156163

157164
await saveMessage(responseMessage);
@@ -220,7 +227,8 @@ const ask = async ({
220227
parentMessageId: overrideParentMessageId || userMessageId,
221228
unfinished: false,
222229
cancelled: false,
223-
// error: true,
230+
error: true,
231+
isCreatedByUser: false,
224232
text: `${getPartialMessage() ?? ''}\n\nError message: "${error.message}"`,
225233
};
226234
await saveMessage(errorMessage);

client/src/hooks/useMessageHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { TAskFunction } from '~/common';
66
import store from '~/store';
77

88
const useMessageHandler = () => {
9-
const latestMessage = useRecoilValue(store.latestMessage);
9+
const [latestMessage, setLatestMessage] = useRecoilState(store.latestMessage);
1010
const setSiblingIdx = useSetRecoilState(
1111
store.messagesSiblingIdxFamily(latestMessage?.parentMessageId),
1212
);
@@ -134,6 +134,7 @@ const useMessageHandler = () => {
134134
} else {
135135
setMessages([...submission.messages, currentMsg, initialResponse]);
136136
}
137+
setLatestMessage(initialResponse);
137138
setSubmission(submission);
138139
};
139140

0 commit comments

Comments
 (0)