Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

refactor(windows): deliver direct-PTY sendText through sendKeysWrites

Fabricio Casali5c2f503f7763
diff --git a/src/core/native-windows-pane.test.ts b/src/core/native-windows-pane.test.ts
index 3f0077c35..338729149 100644
--- a/src/core/native-windows-pane.test.ts
+++ b/src/core/native-windows-pane.test.ts
@@ -82,6 +82,11 @@ describe('native Windows sendText (the write verb and the app’s own writers)',
expect(await pane.sendText('ls\x1b', false)).toBe(true)
expect(write.mock.calls).toEqual([['ls']])
})
+ it('keeps an unframed Enter inside the single write, exactly like the session host', async () => {
+ const { pane, write } = fixture()
+ expect(await pane.sendText('ls', true)).toBe(true)
+ expect(write.mock.calls).toEqual([['ls\r']])
+ })
it('sends a bare Enter for an empty payload, and nothing at all when neither is asked', async () => {
const { pane, write } = fixture()
expect(await pane.sendText('', true)).toBe(true)
diff --git a/src/core/native-windows-pane.ts b/src/core/native-windows-pane.ts
index 6f2194570..f80ebdc77 100644
--- a/src/core/native-windows-pane.ts
+++ b/src/core/native-windows-pane.ts
@@ -1,6 +1,7 @@
import { randomUUID } from 'crypto'
import { TerminalEmulator } from '../session-host/terminal-emulator'
import { readWindowsConsoleOwner, sameNativeProcess } from '../session-host/windows-pane-owner'
+import { sendKeysWrites } from '../session-host/send-keys-delivery'
import type { PaneOwner } from '../shared/agents/pane-owner-predicate'
import { sanitizePasteText } from './paste-injection'
import { pasteThenSubmitWhenSettled, type SettleOptions } from './settled-submit'
@@ -85,15 +86,12 @@ export class NativeWindowsPane {
*/
async sendText(text: string, enter: boolean): Promise<boolean> {
if (!this.alive) return false
- // ESC is stripped on BOTH deliveries, as `sanitizePasteText`'s contract requires.
- const clean = sanitizePasteText(text)
+ // The write plan is the session host's `sendKeysWrites` — one rule for both Windows backends,
+ // so the direct PTY cannot drift from the host on where the Enter goes or what gets stripped.
+ const bracketed = sanitizePasteText(text) ? await this.pasteAware() : false
+ if (!this.alive) return false
try {
- if (clean) {
- const framed = await this.pasteAware()
- if (!this.alive) return false
- this.proc.write(framed ? `\x1b[200~${clean}\x1b[201~` : clean)
- }
- if (enter) this.proc.write('\r')
+ for (const chunk of sendKeysWrites(text, enter, bracketed)) this.proc.write(chunk)
return true
} catch {
return false