Changesets · Branches · Tags · Compare
| Changeset | 74850c9d62af64ccee93dcab106b832ca5cd86f81c35eb3c890756aa521a1278 |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-07-18 18:10 +02:00 |
| Committer | GitHub <noreply@github.com> · 2025-07-18 09:10 -07:00 |
| Parents | 66d2327b97e5 |
1 file changed
modified gui/src/redux/slices/sessionSlice.ts +9 −1
| @@ -289,6 +289,7 @@ | ||
| 289 | 289 | if (state.history.length < 2) { |
| 290 | 290 | return; |
| 291 | 291 | } |
| 292 | + | |
| 292 | 293 | const lastUserOrToolIdx = findLastIndex( |
| 293 | 294 | state.history, |
| 294 | 295 | (item) => item.message.role === "tool" || item.message.role === "user", |
| @@ -315,7 +316,14 @@ | ||
| 315 | 316 | } |
| 316 | 317 | |
| 317 | 318 | 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 | + } | |
| 319 | 327 | } else { |
| 320 | 328 | state.history = state.history.slice(0, validAssistantMessageIdx + 1); |
| 321 | 329 | } |