Skip to content

The open source coding agent.

TypeScript

Added copy option to message context menu (#4389)

opencode-agent[bot]832be6e7eb2b
diff --git a/packages/opencode/src/cli/cmd/tui/routes/session/dialog-message.tsx b/packages/opencode/src/cli/cmd/tui/routes/session/dialog-message.tsx
index a59fad7b183..07e1a1eb4a0 100644
--- a/packages/opencode/src/cli/cmd/tui/routes/session/dialog-message.tsx
+++ b/packages/opencode/src/cli/cmd/tui/routes/session/dialog-message.tsx
@@ -3,6 +3,7 @@ import { useSync } from "@tui/context/sync"
import { DialogSelect } from "@tui/ui/dialog-select"
import { useSDK } from "@tui/context/sdk"
import { useRoute } from "@tui/context/route"
+import { Clipboard } from "@tui/util/clipboard"
import type { PromptInfo } from "@tui/component/prompt/history"
export function DialogMessage(props: {
@@ -54,6 +55,26 @@ export function DialogMessage(props: {
dialog.clear()
},
},
+ {
+ title: "Copy",
+ value: "message.copy",
+ description: "copy message text to clipboard",
+ onSelect: async (dialog) => {
+ const msg = message()
+ if (!msg) return
+
+ const parts = sync.data.part[msg.id]
+ const text = parts.reduce((agg, part) => {
+ if (part.type === "text" && !part.synthetic) {
+ agg += part.text
+ }
+ return agg
+ }, "")
+
+ await Clipboard.copy(text)
+ dialog.clear()
+ },
+ },
{
title: "Fork",
value: "session.fork",
diff --git a/packages/plugin/package.json b/packages/plugin/package.json
index 43002ca623a..b2a3c93f6a4 100644
--- a/packages/plugin/package.json
+++ b/packages/plugin/package.json
@@ -24,4 +24,4 @@
"typescript": "catalog:",
"@typescript/native-preview": "catalog:"
}
-}
\ No newline at end of file
+}
diff --git a/packages/sdk/js/package.json b/packages/sdk/js/package.json
index 88658a1e663..d2b5e444ebf 100644
--- a/packages/sdk/js/package.json
+++ b/packages/sdk/js/package.json
@@ -26,4 +26,4 @@
"publishConfig": {
"directory": "dist"
}
-}
\ No newline at end of file
+}