mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-28 00:02:42 +00:00
fix: enable clipboard support and suppress browser context menu in web terminal
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
696b8de1ed
commit
c4323e40c1
@@ -62,6 +62,7 @@ export async function attach(
|
||||
const cmd = [
|
||||
`tmux new-session -d -s "${gName}" -t "${tmuxSession}"`,
|
||||
`tmux set-option -t "${gName}" mouse on`,
|
||||
`tmux set-option -t "${gName}" set-clipboard on`,
|
||||
`tmux select-window -t "${gName}:${windowTarget}"`,
|
||||
`stty rows ${rows} cols ${cols}`,
|
||||
`exec tmux attach-session -t "${gName}"`,
|
||||
|
||||
@@ -32,6 +32,30 @@
|
||||
term.loadAddon(new WebLinksAddon());
|
||||
term.open(containerEl);
|
||||
|
||||
// Prevent browser context menu so tmux right-click works unobstructed
|
||||
containerEl.addEventListener("contextmenu", (e) => e.preventDefault());
|
||||
|
||||
// Handle OSC 52 sequences from tmux → write to system clipboard
|
||||
term.parser.registerOscHandler(52, (data) => {
|
||||
const idx = data.indexOf(";");
|
||||
if (idx !== -1) {
|
||||
const b64 = data.slice(idx + 1);
|
||||
try {
|
||||
const text = atob(b64);
|
||||
navigator.clipboard.writeText(text);
|
||||
} catch {}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
// Auto-copy on xterm.js selection (e.g. when user Shift+drags to bypass tmux mouse)
|
||||
term.onSelectionChange(() => {
|
||||
const sel = term.getSelection();
|
||||
if (sel) {
|
||||
navigator.clipboard.writeText(sel);
|
||||
}
|
||||
});
|
||||
|
||||
requestAnimationFrame(() => fitAddon.fit());
|
||||
|
||||
const protocol = location.protocol === "https:" ? "wss:" : "ws:";
|
||||
|
||||
Reference in New Issue
Block a user