Skip to content

Commit 40daf7e

Browse files
Added copy option to message context menu
Co-authored-by: rekram1-node <[email protected]>
1 parent 8ba48ed commit 40daf7e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/opencode/src/cli/cmd/tui/routes/session/dialog-message.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useSync } from "@tui/context/sync"
33
import { DialogSelect } from "@tui/ui/dialog-select"
44
import { useSDK } from "@tui/context/sdk"
55
import { useRoute } from "@tui/context/route"
6+
import { Clipboard } from "@tui/util/clipboard"
67
import type { PromptInfo } from "@tui/component/prompt/history"
78

89
export function DialogMessage(props: {
@@ -54,6 +55,26 @@ export function DialogMessage(props: {
5455
dialog.clear()
5556
},
5657
},
58+
{
59+
title: "Copy",
60+
value: "message.copy",
61+
description: "copy message text to clipboard",
62+
onSelect: async (dialog) => {
63+
const msg = message()
64+
if (!msg) return
65+
66+
const parts = sync.data.part[msg.id]
67+
const text = parts.reduce((agg, part) => {
68+
if (part.type === "text" && !part.synthetic) {
69+
agg += part.text
70+
}
71+
return agg
72+
}, "")
73+
74+
await Clipboard.copy(text)
75+
dialog.clear()
76+
},
77+
},
5778
{
5879
title: "Fork",
5980
value: "session.fork",

0 commit comments

Comments
 (0)