Elffuss BraidHub

kikocis/continue public

fix: dangling messages cleanup behavior (#6707)

Changeset74850c9d62af64ccee93dcab106b832ca5cd86f81c35eb3c890756aa521a1278
AuthorDallin Romney <dallinromney@gmail.com> · 2025-07-18 18:10 +02:00
CommitterGitHub <noreply@github.com> · 2025-07-18 09:10 -07:00
Parents66d2327b97e5

Browse the files at this changeset

1 file changed

modified gui/src/redux/slices/sessionSlice.ts +9 −1
@@ -289,6 +289,7 @@
289289 if (state.history.length < 2) {
290290 return;
291291 }
292+
292293 const lastUserOrToolIdx = findLastIndex(
293294 state.history,
294295 (item) => item.message.role === "tool" || item.message.role === "user",
@@ -315,7 +316,14 @@
315316 }
316317
317318 if (validAssistantMessageIdx === -1) {
318- state.history = state.history.slice(0, lastUserOrToolIdx + 1);
319+ const lastMsg = state.history[lastUserOrToolIdx];
320+ const lastRole = lastMsg.message.role as "user" | "tool";
321+ if (lastRole === "user") {
322+ state.mainEditorContentTrigger = lastMsg.editorState;
323+ state.history = state.history.slice(0, lastUserOrToolIdx);
324+ } else {
325+ state.history = state.history.slice(0, lastUserOrToolIdx + 1);
326+ }
319327 } else {
320328 state.history = state.history.slice(0, validAssistantMessageIdx + 1);
321329 }