Skip to content

Commit cfbe9d3

Browse files
committed
Revert "Use opentui OSC52 clipboard (anomalyco#11718)"
This reverts commit 8e985e0.
1 parent f02499f commit cfbe9d3

5 files changed

Lines changed: 31 additions & 28 deletions

File tree

bun.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/hashes.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"nodeModules": {
3-
"x86_64-linux": "sha256-aRFzPzgu32XgNSk8S2z4glTlgHqEmOLZHlBQSIYIMvY=",
4-
"aarch64-linux": "sha256-aCZLkmRrCa0bli0jgsaLcC5GlZdjQPbb6xD6Fc03eX8=",
5-
"aarch64-darwin": "sha256-oZOOR6k8MmabNVDQNY5ywR06rRycdnXZL+gUucKSQ+g=",
6-
"x86_64-darwin": "sha256-LXIcLnjn+1eTFWIsQ9W0U2orGm59P/L470O0KFFkRHg="
3+
"x86_64-linux": "sha256-06Otz3loT4vn0578VDxUqVudtzQvV7oM3EIzjZnsejo=",
4+
"aarch64-linux": "sha256-88Qai5RkSenCZkakOg52b6xU2ok+h/Ns4/5L3+55sFY=",
5+
"aarch64-darwin": "sha256-x8dgCF0CJBWi2dZLDHMGdlTqys1X755ok0PM6x0HAGo=",
6+
"x86_64-darwin": "sha256-FkLDqorfIfOw+tB7SW5vgyhOIoI0IV9lqPW1iEmvUiI="
77
}
88
}

packages/opencode/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@
8282
"@opencode-ai/sdk": "workspace:*",
8383
"@opencode-ai/util": "workspace:*",
8484
"@openrouter/ai-sdk-provider": "1.5.4",
85-
"@opentui/core": "0.1.76",
86-
"@opentui/solid": "0.1.76",
85+
"@opentui/core": "0.1.75",
86+
"@opentui/solid": "0.1.75",
8787
"@parcel/watcher": "2.5.1",
8888
"@pierre/diffs": "catalog:",
8989
"@solid-primitives/event-bus": "1.1.2",

packages/opencode/src/cli/cmd/tui/app.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ function App() {
186186
const route = useRoute()
187187
const dimensions = useTerminalDimensions()
188188
const renderer = useRenderer()
189-
Clipboard.setRenderer(renderer)
190189
renderer.disableStdoutInterception()
191190
const dialog = useDialog()
192191
const local = useLocal()

packages/opencode/src/cli/cmd/tui/util/clipboard.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
import { $ } from "bun"
2-
import type { CliRenderer } from "@opentui/core"
32
import { platform, release } from "os"
43
import clipboardy from "clipboardy"
54
import { lazy } from "../../../../util/lazy.js"
65
import { tmpdir } from "os"
76
import path from "path"
87

9-
const rendererRef = { current: undefined as CliRenderer | undefined }
8+
/**
9+
* Writes text to clipboard via OSC 52 escape sequence.
10+
* This allows clipboard operations to work over SSH by having
11+
* the terminal emulator handle the clipboard locally.
12+
*/
13+
function writeOsc52(text: string): void {
14+
if (!process.stdout.isTTY) return
15+
const base64 = Buffer.from(text).toString("base64")
16+
const osc52 = `\x1b]52;c;${base64}\x07`
17+
// tmux and screen require DCS passthrough wrapping
18+
const passthrough = process.env["TMUX"] || process.env["STY"]
19+
const sequence = passthrough ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52
20+
process.stdout.write(sequence)
21+
}
1022

1123
export namespace Clipboard {
1224
export interface Content {
1325
data: string
1426
mime: string
1527
}
1628

17-
export function setRenderer(renderer: CliRenderer | undefined): void {
18-
rendererRef.current = renderer
19-
}
20-
2129
export async function read(): Promise<Content | undefined> {
2230
const os = platform()
2331

@@ -146,11 +154,7 @@ export namespace Clipboard {
146154
})
147155

148156
export async function copy(text: string): Promise<void> {
149-
const renderer = rendererRef.current
150-
if (renderer) {
151-
const copied = renderer.copyToClipboardOSC52(text)
152-
if (copied) return
153-
}
157+
writeOsc52(text)
154158
await getCopyMethod()(text)
155159
}
156160
}

0 commit comments

Comments
 (0)