Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: /copy disable in headless linux

kdgmpwbac3e13c6618
diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/clipboard.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/clipboard.ts
index a36cab9c4a..febf9dd252 100644
--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/clipboard.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/clipboard.ts
@@ -24,6 +24,30 @@ function tryClipboardUtf8OnWindows(text: string): boolean {
}
}
+function isTmux(): boolean {
+ return !!process.env.TMUX;
+}
+
+function isScreen(): boolean {
+ return !!process.env.STYLE;
+}
+
+function tryOsc52(text: string): boolean {
+ try {
+ const base64 = Buffer.from(text, "utf-8").toString("base64");
+ let osc52 = `\x1b]52;c;${base64}\x07`;
+ if (isTmux()) {
+ osc52 = `\x1bPtmux;${osc52}\x1b\\`;
+ } else if (isScreen()) {
+ osc52 = `\x1bP${osc52}\x1b\\`;
+ }
+ process.stdout.write(osc52);
+ return true;
+ } catch {
+ return false;
+ }
+}
+
export function copyToClipboard(text: string): boolean {
if (!text) return false;
@@ -47,5 +71,9 @@ export function copyToClipboard(text: string): boolean {
return true;
}
+ if (tryOsc52(text)) {
+ return true;
+ }
+
return false;
}