From 659d26ce68761a0d2963d8a406aecddef8f2f0e7 Mon Sep 17 00:00:00 2001 From: Gloridust Date: Sun, 14 Jun 2026 16:57:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(docker):=20typeInInstance=20=E5=8D=A1=20~2s?= =?UTF-8?q?=20=E6=A0=B9=E5=9B=A0=E2=80=94=E2=80=94xclip=20=E6=9C=AA?= =?UTF-8?q?=E9=87=8D=E5=AE=9A=E5=90=91=20fd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xclip -i 会 daemon 化常驻持有剪贴板选区,并继承 docker exec 的 stdout/stderr, 导致 exec 要等这俩 fd 关闭、每次中文转发卡 ~2.1s。给 xclip 重定向 >/dev/null 2>&1 后整条链路降到 ~0.08s(实测 26× 提速)。中文输入条与无感模式都受益。 Co-Authored-By: Claude Opus 4.8 --- panel/server/src/docker.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/panel/server/src/docker.ts b/panel/server/src/docker.ts index d32af72..af9c56b 100644 --- a/panel/server/src/docker.ts +++ b/panel/server/src/docker.ts @@ -576,7 +576,9 @@ export async function typeInInstance(inst: Instance, text: string): Promise/dev/null 2>&1 || { echo "xclip not installed in instance image" >&2; exit 127; }', 'command -v xdotool >/dev/null 2>&1 || { echo "xdotool not installed in instance image" >&2; exit 127; }', - `echo '${b64}' | base64 -d | xclip -selection clipboard -i`, + // xclip -i 会 daemon 化常驻持有剪贴板选区,并继承 exec 的 stdout/stderr;不重定向的话 docker exec + // 要等这俩 fd 关闭,实测每次卡 ~2s。重定向到 /dev/null 后台后,整条链路从 ~2.1s 降到 ~0.08s。 + `echo '${b64}' | base64 -d | xclip -selection clipboard -i >/dev/null 2>&1`, 'xdotool key --clearmodifiers ctrl+v', ].join('; '); await execCapture(inst, ['bash', '-c', cmd]);