Browse Source

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

Signed-off-by: assagman <[email protected]>
Sercan Sagman 2 months ago
parent
commit
a1b68daa9a
1 changed files with 4 additions and 1 deletions
  1. 4 1
      packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

+ 4 - 1
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

@@ -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()