Skip to content

Commit 415dafb

Browse files
committed
Support different kinds of rollback
1 parent 6888166 commit 415dafb

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

eca-chat.el

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -639,11 +639,21 @@ Must be a positive integer."
639639
(defun eca-chat--rollback (session content-id)
640640
"Rollback chat messages for SESSION to before CONTENT-ID."
641641
(unless eca-chat--chat-loading
642-
(when (y-or-n-p "Do you want to really rollback the chat to before this message?")
643-
(eca-api-request-sync session
644-
:method "chat/rollback"
645-
:params (list :chatId eca-chat--id
646-
:contentId content-id)))))
642+
(let ((rollback-messages-str "Rollback only messages")
643+
(rollback-tools-str "Rollback only changes done by tool calls")
644+
(rollback-messages-and-tools-str "Rollback messages and changes done by tool calls"))
645+
(when-let* ((rollback-type (completing-read "Select the rollback type:" (list rollback-messages-and-tools-str
646+
rollback-messages-str
647+
rollback-tools-str) nil t)))
648+
(let ((include (cond
649+
((string= rollback-type rollback-messages-str) ["messages"])
650+
((string= rollback-type rollback-tools-str) ["tools"])
651+
((string= rollback-type rollback-messages-and-tools-str) ["messages" "tools"]))))
652+
(eca-api-request-sync session
653+
:method "chat/rollback"
654+
:params (list :chatId eca-chat--id
655+
:contentId content-id
656+
:include include)))))))
647657

648658
(defun eca-chat--set-chat-loading (session loading)
649659
"Set the SESSION chat to a loading state if LOADING is non nil.

0 commit comments

Comments
 (0)