From cdbb92f9aeba369d6cbcd657011ce2422158f447 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 16 Apr 2026 03:00:54 +0000 Subject: [PATCH 1/2] fix: clear agent input selection after send --- ServerDeck/src/components/agent/AgentWorkspace.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ServerDeck/src/components/agent/AgentWorkspace.tsx b/ServerDeck/src/components/agent/AgentWorkspace.tsx index b78bb76..1416551 100644 --- a/ServerDeck/src/components/agent/AgentWorkspace.tsx +++ b/ServerDeck/src/components/agent/AgentWorkspace.tsx @@ -12,6 +12,15 @@ export type ModelOption = { model: string; }; +function clearDocumentSelection() { + const selection = window.getSelection(); + if (!selection || selection.rangeCount === 0) { + return; + } + + selection.removeAllRanges(); +} + type AgentWorkspaceProps = { title: string; description: string; @@ -198,6 +207,7 @@ export function AgentWorkspace({ node.focus({ preventScroll: true }); const cursor = node.value.length; node.setSelectionRange(cursor, cursor); + clearDocumentSelection(); }); }, [activeSessionDetail?.session.id, composerValue, createBusy, latestMessageSignature, sendBusy]); @@ -574,6 +584,7 @@ export function AgentWorkspace({ rows={3} value={composerValue} onKeyDown={handleComposerKeyDown} + onBlur={() => clearDocumentSelection()} onChange={(event) => { if (activeSessionDetail) { onFollowUpInputChange(event.target.value); From 689a1821e2a8b89c8261ce7d18467e9043c7f9e3 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 16 Apr 2026 03:02:56 +0000 Subject: [PATCH 2/2] fix: keep terminal focused after enter --- ServerDeck/src/App.tsx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ServerDeck/src/App.tsx b/ServerDeck/src/App.tsx index 887ef16..3c0ed5b 100644 --- a/ServerDeck/src/App.tsx +++ b/ServerDeck/src/App.tsx @@ -297,6 +297,15 @@ function isTerminalViewportNearBottom(terminal: Terminal) { return activeBuffer.baseY - activeBuffer.viewportY <= 1; } +function clearDocumentSelection() { + const selection = window.getSelection(); + if (!selection || selection.rangeCount === 0) { + return; + } + + selection.removeAllRanges(); +} + const MAX_TERMINAL_BUFFER_CHUNKS = 800; const MAX_TERMINAL_BUFFER_CHARS = 400_000; @@ -2070,6 +2079,8 @@ export default function App() { terminal.open(terminalMountNode); const clearSelectionFrame = window.requestAnimationFrame(() => { terminal.clearSelection(); + clearDocumentSelection(); + terminal.focus(); }); terminal.attachCustomKeyEventHandler((event) => { const sequence = getTerminalControlSequence(event); @@ -2095,8 +2106,25 @@ export default function App() { }); } + const terminalTextarea = terminal.textarea; + const handleTerminalBlur = () => { + window.requestAnimationFrame(() => { + terminal.clearSelection(); + clearDocumentSelection(); + }); + }; + terminalTextarea?.addEventListener("blur", handleTerminalBlur); + const disposable = terminal.onData((data) => { sendActiveTerminalInput(data); + + if (data === "\r") { + window.requestAnimationFrame(() => { + terminal.focus(); + terminal.clearSelection(); + clearDocumentSelection(); + }); + } }); let frameId: number | null = null; @@ -2131,6 +2159,7 @@ export default function App() { } window.cancelAnimationFrame(clearSelectionFrame); disposable.dispose(); + terminalTextarea?.removeEventListener("blur", handleTerminalBlur); terminal.dispose(); terminalRef.current = null; fitAddonRef.current = null;