fix(tui): exclude reverted assistant reply when copying last message (#5705)

Signed-off-by: assagman <ahmetsercansagman@gmail.com>
This commit is contained in:
Sercan Sagman 2025-12-18 01:03:06 +03:00 committed by GitHub
parent ca65da2d9e
commit a1b68daa9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -597,7 +597,10 @@ export function Session() {
keybind: "messages_copy",
category: "Session",
onSelect: (dialog) => {
const lastAssistantMessage = messages().findLast((msg) => msg.role === "assistant")
const revertID = session()?.revert?.messageID
const lastAssistantMessage = messages().findLast(
(msg) => msg.role === "assistant" && (!revertID || msg.id < revertID),
)
if (!lastAssistantMessage) {
toast.show({ message: "No assistant messages found", variant: "error" })
dialog.clear()