summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrari404 <[email protected]>2025-12-23 19:46:01 -0500
committerGitHub <[email protected]>2025-12-23 18:46:01 -0600
commite8ac0b663b9c88c318a40571c2847f5f3fa0c5c7 (patch)
tree19b7208822e02aaf43a962ce897a44cdf546fb8a
parent2806f240ea0ae56d5f46f6e7e377e9d732ad47d5 (diff)
downloadopencode-e8ac0b663b9c88c318a40571c2847f5f3fa0c5c7.tar.gz
opencode-e8ac0b663b9c88c318a40571c2847f5f3fa0c5c7.zip
feat(tui): console copy-to-clipboard via opentui (#5658)
Co-authored-by: Aiden Cline <[email protected]>
-rw-r--r--packages/opencode/src/cli/cmd/tui/app.tsx16
1 files changed, 15 insertions, 1 deletions
diff --git a/packages/opencode/src/cli/cmd/tui/app.tsx b/packages/opencode/src/cli/cmd/tui/app.tsx
index 5105ee3c6..13c95d9b9 100644
--- a/packages/opencode/src/cli/cmd/tui/app.tsx
+++ b/packages/opencode/src/cli/cmd/tui/app.tsx
@@ -179,6 +179,20 @@ function App() {
const exit = useExit()
const promptRef = usePromptRef()
+ // Wire up console copy-to-clipboard via opentui's onCopySelection callback
+ renderer.console.onCopySelection = async (text: string) => {
+ if (!text || text.length === 0) return
+
+ const base64 = Buffer.from(text).toString("base64")
+ const osc52 = `\x1b]52;c;${base64}\x07`
+ const finalOsc52 = process.env["TMUX"] ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52
+ // @ts-expect-error writeOut is not in type definitions
+ renderer.writeOut(finalOsc52)
+ await Clipboard.copy(text)
+ .then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
+ .catch(toast.error)
+ renderer.clearSelection()
+ }
const [terminalTitleEnabled, setTerminalTitleEnabled] = createSignal(kv.get("terminal_title_enabled", true))
createEffect(() => {
@@ -447,7 +461,7 @@ function App() {
{
title: "Toggle console",
category: "System",
- value: "app.fps",
+ value: "app.console",
onSelect: (dialog) => {
renderer.console.toggle()
dialog.clear()