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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(windows): revalidate delayed submission and preserve delivery uncertainty
review0f0a48d0c8c8
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 0f48de70e..ec026fab7 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -71,4 +71,4 @@ jobs:run: npm run host:build- name: Windows-relevant tests- run: npx vitest run src/core/settled-text.test.ts src/core/native-windows-pane.test.ts src/core/phone-approval.test.ts src/main/remote/standing-host.test.ts src/main/remote/approved-devices.test.ts src/renderer/lib/phone-approval.test.ts src/core/fs-atomic.test.ts src/core/fs-atomic.guard.test.ts src/core/exec-path.test.ts src/core/claude-cli.test.ts src/core/codex-identity-caps.test.ts src/core/codex-cli.test.ts src/core/grok-cli.test.ts src/core/commit-message.test.ts src/core/context-link.windows.test.ts src/core/git-service.windows.test.ts src/core/usage/codex-usage.windows.test.ts src/session-host/ src/core/session-host-client.test.ts src/core/session-host-launch-ledger.test.ts src/core/session-host-client-startup-wait.test.ts src/core/agent-launch.test.ts src/core/pty-session-host.test.ts src/main/bootstrap-windows.test.ts src/main/media-protocol.test.ts src/main/remote-atomic-write.test.ts src/main/ssh-fs.test.ts src/main/remote-ssh/ssh-project.test.ts src/renderer/terminal/file-links.test.ts src/renderer/terminal/file-links.windows.test.ts src/renderer/terminal/file-link-dialect.test.ts src/renderer/terminal/host-platform.test.ts src/main/pairing-service.windows.test.ts src/main/windows-ssh-keys.test.ts src/shared/pairing-gate.test.ts src/renderer/components/settings/sections/PhoneSection.windows.test.tsx scripts/windows-update-preflight.test.ts+ run: npx vitest run src/core/windows-delivery-safety.test.ts src/core/settled-text.test.ts src/core/native-windows-pane.test.ts src/core/phone-approval.test.ts src/main/remote/standing-host.test.ts src/main/remote/approved-devices.test.ts src/renderer/lib/phone-approval.test.ts src/core/fs-atomic.test.ts src/core/fs-atomic.guard.test.ts src/core/exec-path.test.ts src/core/claude-cli.test.ts src/core/codex-identity-caps.test.ts src/core/codex-cli.test.ts src/core/grok-cli.test.ts src/core/commit-message.test.ts src/core/context-link.windows.test.ts src/core/git-service.windows.test.ts src/core/usage/codex-usage.windows.test.ts src/session-host/ src/core/session-host-client.test.ts src/core/session-host-launch-ledger.test.ts src/core/session-host-client-startup-wait.test.ts src/core/agent-launch.test.ts src/core/pty-session-host.test.ts src/main/bootstrap-windows.test.ts src/main/media-protocol.test.ts src/main/remote-atomic-write.test.ts src/main/ssh-fs.test.ts src/main/remote-ssh/ssh-project.test.ts src/renderer/terminal/file-links.test.ts src/renderer/terminal/file-links.windows.test.ts src/renderer/terminal/file-link-dialect.test.ts src/renderer/terminal/host-platform.test.ts src/main/pairing-service.windows.test.ts src/main/windows-ssh-keys.test.ts src/shared/pairing-gate.test.ts src/renderer/components/settings/sections/PhoneSection.windows.test.tsx scripts/windows-update-preflight.test.tsdiff --git a/CLAUDE.md b/CLAUDE.mdindex 830ee9b33..1ac101d36 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -5128,3 +5128,13 @@ Pin/revoke mutations use `updateApprovedDevices` to queue the entire read/modifyunique-temp atomic rename alone cannot prevent lost updates. Non-ENOENT reads and malformed JSONreject rather than overwrite unknown trust state. The queue is not a cross-process lock. A clickaccepted before host stop may finish its disk save, but must never open the now-closed session.++Windows messaging final-submit checks cross a second OS identity probe and emulator barrier:+`NativeWindowsPane.sendEnvelope` and `hostMessagePane.send` retain accepted-paste semantics when+the child has changed or paste mode is off, but withhold Enter. The root PTY can outlive the CLI.+`SessionHostClient.sendKeys` tracks whether its V2 frame was handed to the socket separately+from an explicit negative host reply; loss of the reply after transmission returns conservative+partial/unknown delivery, with no resend. The SessionStart idle rescue latch stores its session,+agent and receive time; foreign/missing idle identity never creates proof or changes the+renderer-visible session. These boundaries have behavioral regressions in+`core/windows-delivery-safety.test.ts` and the mirror/client suites.diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex d23d837f2..530e30f88 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -907,3 +907,9 @@ Held approval attention must not replace subagent, recurring or background-taskstate evidence from those lifecycle hooks. A parent may ask several questions while a child ticketis outstanding: track each new picker and preserve child approval cards independently, includingwhen their display titles match. Answering either resolves only that question or ticket.++Delayed Windows message submission must recheck the attested child process/birth AND emulator+paste mode immediately before Enter, not just the surviving PTY root. A missing host reply after+a transmitted text request is uncertain delivery, never a pre-paste refusal; show the no-resend+warning. SessionStart idle rescue is scoped to that same nonempty session and agent identity,+and a foreign idle must not broadcast fresh state proof to the renderer.diff --git a/docs/windows-session-host.md b/docs/windows-session-host.mdindex 649343611..2dfcdb92e 100644--- a/docs/windows-session-host.md+++ b/docs/windows-session-host.md@@ -690,7 +690,8 @@ Windows named-pipe DACL hardening remain outside this profile pass as describedNew callers use additive `sendKeysV2`, returning `result.delivery`: `true` for completedrequested writes, `false` before input, or `pasted-not-submitted` when paste landed but the-settle/mode/generation checks withheld Enter. The last result is terminal for automatic+settle/mode/generation checks withheld Enter, or a transmitted request lost its reply.+The latter case is uncertain: neither paste nor submission is claimed confirmed. The last result is terminal for automaticdelivery: inspect the terminal, do not resend or blindly press Enter. Canvas write, triggerrun history, and one-way UI writers surface it. An older host refuses this command and keepsits sessions; there is no fallback to `sendKeys`, raw input, or automatic restart. Legacydiff --git a/src/core/agent-status-mirror.test.ts b/src/core/agent-status-mirror.test.tsindex 489128011..8aa145b72 100644--- a/src/core/agent-status-mirror.test.ts+++ b/src/core/agent-status-mirror.test.ts@@ -2066,13 +2066,42 @@ describe('reduceEntry records whether the state transition was verified', () =>describe('idle rescue after a verified session start (resumed CLI idling at its prompt)', () => {const started = (verified = true) =>reduceEntry(- reduceEntry(undefined, ev({ state: 'done', verified: true }), 1000),- ev({ kind: 'session', sessionPhase: 'start', verified }),+ reduceEntry(undefined, ev({ sessionId: 'current', state: 'done', verified: true }), 1000),+ ev({ sessionId: 'current', kind: 'session', sessionPhase: 'start', verified }),2000)+ it('does not broadcast stale idle state proof to renderer consumers', () => {+ _resetForTest()+ recordAgentEvent(ev({ nodeId: 'idle-proof', sessionId: 'current', kind: 'session', sessionPhase: 'start', verified: true }))+ const out = recordAgentEvent(ev({ nodeId: 'idle-proof', sessionId: 'old', state: 'done', idle: true, verified: true }))+ expect(out.state).toBeUndefined()+ expect(out.verified).toBeUndefined()+ expect(out.sessionId).toBe('current')+ })+ it.each([+ { sessionId: 'old' }, { sessionId: undefined }, { agentId: 'codex' }+ ])('rejects foreign or missing idle identity %j without overwriting the current session', (identity) => {+ const start = started()+ const result = reduceEntry(start, ev({ sessionId: 'current', state: 'done', idle: true, verified: true, ...identity }), 3000)+ expect(result).toEqual(start)+ const valid = reduceEntry(result, ev({ sessionId: 'current', state: 'done', idle: true, verified: true }), 3100)+ expect(valid.state).toBe('done')+ expect(valid.stateVerified).toBe(true)+ })+ it('does not arm a session start with no session id', () => {+ const start = reduceEntry(undefined, ev({ kind: 'session', sessionPhase: 'start', verified: true }), 1000)+ const idle = reduceEntry(start, ev({ state: 'done', idle: true, verified: true }), 2000)+ expect(start.sessionStarted).toBeUndefined()+ expect(idle.state).toBeUndefined()+ expect(idle.stateVerified).toBe(false)+ })+ it('does not accept an idle observation older than the start', () => {+ const start = started()+ expect(reduceEntry(start, ev({ sessionId: 'current', state: 'done', idle: true, verified: true }), 1999)).toEqual(start)+ })it('a verified idle_prompt commits a verified, NON-inferred done', () => {- const c = reduceEntry(started(), ev({ state: 'done', idle: true, interrupted: true, verified: true }), 3000)+ const c = reduceEntry(started(), ev({ sessionId: 'current', state: 'done', idle: true, interrupted: true, verified: true }), 3000)expect(c.state).toBe('done')expect(c.stateVerified).toBe(true)expect(c.idleInferred).toBeUndefined()@@ -2080,27 +2109,27 @@ describe('reduceEntry records whether the state transition was verified', () =>})it('an unverified idle_prompt is still ignored', () => {- const c = reduceEntry(started(), ev({ state: 'done', idle: true, verified: false }), 3000)+ const c = reduceEntry(started(), ev({ sessionId: 'current', state: 'done', idle: true, verified: false }), 3000)expect(c.state).toBeUndefined()expect(c.stateVerified).toBe(false)})it('an unverified session start does not arm the rescue', () => {- const c = reduceEntry(started(false), ev({ state: 'done', idle: true, verified: true }), 3000)+ const c = reduceEntry(started(false), ev({ sessionId: 'current', state: 'done', idle: true, verified: true }), 3000)expect(c.state).toBeUndefined()})it('a session END never arms the rescue', () => {- const a = reduceEntry(undefined, ev({ state: 'done', verified: true }), 1000)- const b = reduceEntry(a, ev({ kind: 'session', sessionPhase: 'end', verified: true }), 2000)- const c = reduceEntry(b, ev({ state: 'done', idle: true, verified: true }), 3000)+ const a = reduceEntry(undefined, ev({ sessionId: 'current', state: 'done', verified: true }), 1000)+ const b = reduceEntry(a, ev({ sessionId: 'current', kind: 'session', sessionPhase: 'end', verified: true }), 2000)+ const c = reduceEntry(b, ev({ sessionId: 'current', state: 'done', idle: true, verified: true }), 3000)expect(c.state).toBeUndefined()})it('any state commit after the start disarms it (a turn may hold an approval)', () => {- const b = reduceEntry(started(), ev({ state: 'blocked', verified: true }), 2500)+ const b = reduceEntry(started(), ev({ sessionId: 'current', state: 'blocked', verified: true }), 2500)expect(b.sessionStarted).toBeUndefined()- const c = reduceEntry(b, ev({ state: 'done', idle: true, verified: true }), 3000)+ const c = reduceEntry(b, ev({ sessionId: 'current', state: 'done', idle: true, verified: true }), 3000)expect(c.state).toBe('blocked')})})diff --git a/src/core/agent-status-mirror.ts b/src/core/agent-status-mirror.tsindex 222def198..8e02202d5 100644--- a/src/core/agent-status-mirror.ts+++ b/src/core/agent-status-mirror.ts@@ -151,7 +151,7 @@ export interface MirrorEntry {* unmessageable forever: the boundary left it unverified and only a turn could re-verify it.* Runtime-only (not in `buildFile`'s allowlist); cleared by every state commit.*/- sessionStarted?: true+ sessionStarted?: { sessionId: string; agentId: NormalizedAgentEvent['agentId']; at: number }}/** This host's Server-Edition install metadata (spec: server-update). Written by the installer@@ -453,12 +453,23 @@ export function reduceEntry(return reduceEffectiveEntry(prev, resolveGrokStopCancelled(ev), now)}+function uncorrelatedStartIdle(prev: MirrorEntry | undefined, ev: NormalizedAgentEvent, now: number): boolean {+ const started = prev?.sessionStarted+ return !!started && ev.kind === 'state' && !!ev.idle &&+ (ev.sessionId !== started.sessionId || ev.agentId !== started.agentId ||+ prev.sessionId !== started.sessionId || now < started.at)+}+function reduceEffectiveEntry(prev: MirrorEntry | undefined,ev: NormalizedAgentEvent,now: number): MirrorEntry {const next: MirrorEntry = prev ? { ...prev } : { updatedAt: now }+ // Ignore foreign idle proof before generic identity capture can overwrite the session.+ const started = prev?.sessionStarted+ if (uncorrelatedStartIdle(prev, ev, now)) return next+/*** Commit a state onto `next` — and everything that must move WITH it. One function rather than* the same four lines at each branch, because the alternative was measured: of the three branches@@ -550,7 +561,7 @@ function reduceEffectiveEntry(const idleAfterSessionStart =ev.idle === true &&ev.verified === true &&- prev?.sessionStarted === true &&+ !!started &&prev.state === undefinedif (ev.idle && prev?.state !== 'working' && !idleAfterSessionStart) return next// An unanswered Codex `request_user_input`: the ask arrives as waiting+awaitingInput and the@@ -594,7 +605,9 @@ function reduceEffectiveEntry(next.awaitingInput = undefined// The boundary proves nothing about a state (and leaves `verifiedAt` alone), but a VERIFIED// start arms the idle rescue above.- if (ev.sessionPhase === 'start' && ev.verified === true) next.sessionStarted = true+ if (ev.sessionPhase === 'start' && ev.verified === true && ev.sessionId) {+ next.sessionStarted = { sessionId: ev.sessionId, agentId: ev.agentId, at: now }+ }}// subagent-start / subagent-end / recurring: identity captured above, main state untouched.return next@@ -1468,6 +1481,10 @@ export function recordAgentEvent(rawEvent: NormalizedAgentEvent): NormalizedAgenconst now = Date.now()const prev = state.get(nodeId)const prevState = prev?.state+ if (uncorrelatedStartIdle(prev, ev, now)) {+ // Broadcast no state proof either: a renderer must not show this stale done as fresh.+ return { nodeId, kind: 'state', agentId: prev?.sessionStarted?.agentId ?? ev.agentId, sessionId: prev?.sessionId }+ }const next = reduceEffectiveEntry(prev, ev, now)state.set(nodeId, next)const questionAnswered = !!prev?.pendingQuestion && !next.pendingQuestion &&diff --git a/src/core/native-windows-pane.ts b/src/core/native-windows-pane.tsindex 5dee821f2..83fd40db7 100644--- a/src/core/native-windows-pane.ts+++ b/src/core/native-windows-pane.ts@@ -71,8 +71,10 @@ export class NativeWindowsPane {} catch { return false }},submit: async () => {- if (!this.alive) return- try { this.proc.write('\r') } catch { /* paste landed; receipt reports stalled */ }+ try {+ if (!sameNativeProcess(expected, await this.owner()) || !(await this.pasteAware()) || !this.alive) return+ this.proc.write('\r')+ } catch { /* paste landed; receipt reports stalled */ }}}, this.settle)}diff --git a/src/core/session-host-client.ts b/src/core/session-host-client.tsindex cab697139..a9ea49aee 100644--- a/src/core/session-host-client.ts+++ b/src/core/session-host-client.ts@@ -123,6 +123,9 @@ function asError(error: unknown): Error {return error instanceof Error ? error : new Error(String(error))}+/** Explicit host refusal: unlike a lost response, the host answered this request. */+class SessionHostRequestRejectedError extends Error {}+function isTransportUncertainty(value: unknown): boolean {const error = asError(value) as NodeJS.ErrnoExceptionif (@@ -699,7 +702,7 @@ export class SessionHostClient {this.pending.delete(frame.id)if (entry.timer) clearTimeout(entry.timer)if (frame.ok) entry.resolve(frame.result)- else entry.reject(new Error(frame.error))+ else entry.reject(new SessionHostRequestRejectedError(frame.error))}private deliverData(state: ClientSessionState, data: string): void {@@ -780,7 +783,8 @@ export class SessionHostClient {private async request<T>(request: SessionHostRequestBody,- onSuccess?: (result: T, socket: net.Socket) => void+ onSuccess?: (result: T, socket: net.Socket) => void,+ onSent?: () => void): Promise<T> {// A peer-initiated close races the client's own 'close' event: a cached socket can look live// here while the peer already hung up, and a frame written into that gap fails (EPIPE) for@@ -801,7 +805,7 @@ export class SessionHostClient {const socket = this.socketif (!socket) throw new Error('session-host: not connected')try {- return await this.requestOnSocket(socket, request, onSuccess)+ return await this.requestOnSocket(socket, request, onSuccess, onSent)} catch (error) {if (!(error instanceof SessionHostRequestNotDeliveredError)) throw errorif (attempt + 1 >= SESSION_HOST_RESEND_ATTEMPTS) throw error.original@@ -815,7 +819,8 @@ export class SessionHostClient {private requestOnSocket<T>(socket: net.Socket,request: SessionHostRequestBody,- onSuccess?: (result: T, socket: net.Socket) => void+ onSuccess?: (result: T, socket: net.Socket) => void,+ onSent?: () => void): Promise<T> {if (this.socket !== socket || socket.destroyed) {return Promise.reject(@@ -863,6 +868,7 @@ export class SessionHostClient {return}pending.sent = true+ onSent?.()try {socket.write(encodeFrame(full), (error) => {// A response may beat a late write callback. Identity-check this exact pending entry so@@ -1410,12 +1416,15 @@ export class SessionHostClient {}async sendKeys(name: string, text: string, enter: boolean): Promise<TextDeliveryResult> {+ let sent = falsetry {- const result = await this.request<{ delivery?: TextDeliveryResult } | undefined>({ cmd: 'sendKeysV2', name, text, enter })+ const result = await this.request<{ delivery?: TextDeliveryResult } | undefined>({ cmd: 'sendKeysV2', name, text, enter }, undefined, () => { sent = true })// A malformed success cannot prove submission; never retry a possibly accepted paste.return result?.delivery === true || result?.delivery === false ? result.delivery : 'pasted-not-submitted'- } catch {- return false+ } catch (error) {+ // A frame handed to the socket may already have pasted. A lost reply is not a+ // pre-input refusal: surface uncertainty and never invite an automatic resend.+ return sent && !(error instanceof SessionHostRequestRejectedError) ? 'pasted-not-submitted' : false}}diff --git a/src/core/windows-delivery-safety.test.ts b/src/core/windows-delivery-safety.test.tsnew file mode 100644index 000000000..0f340fab4--- /dev/null+++ b/src/core/windows-delivery-safety.test.ts@@ -0,0 +1,85 @@+import { afterEach, describe, expect, it, vi } from 'vitest'+import fs from 'fs'+import os from 'os'+import path from 'path'+import net from 'net'+import { NativeWindowsPane } from './native-windows-pane'+import { hostMessagePane, type MessagePaneSession } from '../session-host/message-pane'+import { reduceEntry } from './agent-status-mirror'+import { SessionHostClient } from './session-host-client'+import { sessionHostPaths } from '../session-host/paths'+import { LineFramer, encodeFrame, type SessionHostRequest } from '../session-host/protocol'+import type { PaneOwner } from '../shared/agents/pane-owner-predicate'+const expected: PaneOwner = { panePid: 10, paneId: 'win32:gen:rootborn', tty: 'win32-console:10', command: 'claude', argv: ['claude'], pids: [20], processBirths: ['agentborn'] }+const shell: PaneOwner = { ...expected, command: 'pwsh', argv: ['pwsh'], pids: [10], processBirths: ['rootborn'] }+afterEach(() => vi.restoreAllMocks())+describe('Windows delivery safety boundaries', () => {+ it.each(['process', 'paste-mode'])('host does not submit after %s changes during settlement', async change => {+ let currentOwner = expected+ let pasteReady = true+ let screen = 'prompt'+ const write = vi.fn((data: string) => {+ if (data.startsWith('\x1b[200~')) {+ screen = 'message footer'+ if (change === 'process') currentOwner = shell+ else pasteReady = false+ }+ })+ const session: MessagePaneSession = { generation: 'gen', exited: false, proc: { pid: 10, write },+ messagePasteReady: async () => pasteReady, serialize: async () => screen }+ const pane = hostMessagePane(() => session, async () => currentOwner, { wait: async () => {} })+ expect(await pane.send('message footer', expected)).toBe(true)+ expect(write.mock.calls).toEqual([['\x1b[200~message footer\x1b[201~']])+ })+ it.each(['process', 'paste-mode'])('direct pane does not submit after %s changes during settlement', async change => {+ let currentOwner = expected+ let pane!: NativeWindowsPane+ const write = vi.fn((data: string) => {+ if (data.startsWith('\x1b[200~')) {+ if (change === 'process') currentOwner = shell+ pane.recordOutput((change === 'paste-mode' ? '\x1b[?2004l' : '') + 'message footer')+ }+ })+ pane = new NativeWindowsPane({ pid: 10, write }, { cols: 80, rows: 24, scrollback: 100 }, async () => currentOwner, { wait: async () => {} })+ pane.recordOutput('\x1b[?2004h')+ try {+ expect(await pane.sendEnvelope('message footer', expected)).toBe(true)+ expect(write.mock.calls).toEqual([['\x1b[200~message footer\x1b[201~']])+ } finally { pane.dispose() }+ })+ it('does not promote an older session idle notification to current verified idle proof', () => {+ const start = reduceEntry(undefined, { nodeId: 'node', agentId: 'claude', sessionId: 'current', kind: 'session', sessionPhase: 'start', verified: true }, 1000)+ const result = reduceEntry(start, { nodeId: 'node', agentId: 'claude', sessionId: 'old', kind: 'state', state: 'done', idle: true, interrupted: true, verified: true }, 1100)+ expect(result.state).toBeUndefined()+ expect(result.stateVerified).toBe(false)+ })+ it('keeps a host-accepted paste ambiguous when its reply connection drops', async () => {+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'review866-'))+ const paths = sessionHostPaths(dir)+ fs.writeFileSync(paths.tokenPath, 'a'.repeat(64))+ fs.writeFileSync(paths.statePath, JSON.stringify({ pid: process.pid, endpoint: paths.endpoint, tokenPath: paths.tokenPath, startedAt: 1, protocolVersion: 2 }))+ const accepted: string[] = []+ const sockets: net.Socket[] = []+ const server = net.createServer(socket => {+ sockets.push(socket)+ const framer = new LineFramer()+ socket.on('data', data => {+ for (const req of framer.push<SessionHostRequest>(data.toString())) {+ if (req.cmd === 'hello') socket.write(encodeFrame({ id: req.id, ok: true, result: { protocolVersion: 2 } }))+ else if (req.cmd === 'sendKeysV2') { accepted.push(req.text); socket.end() }+ }+ })+ })+ await new Promise<void>(resolve => server.listen(paths.endpoint, resolve))+ try {+ const client = new SessionHostClient({ userDataDir: dir, repoRoot: dir })+ const result = await client.sendKeys('nt-test', 'accepted text', true)+ expect(accepted).toEqual(['accepted text'])+ expect(result).toBe('pasted-not-submitted')+ } finally {+ for (const s of sockets) s.destroy()+ await new Promise<void>(resolve => server.close(() => resolve()))+ fs.rmSync(dir, { recursive: true, force: true })+ }+ })+})diff --git a/src/session-host/message-pane.test.ts b/src/session-host/message-pane.test.tsindex cfebde3b4..7b0296968 100644--- a/src/session-host/message-pane.test.ts+++ b/src/session-host/message-pane.test.ts@@ -37,7 +37,7 @@ describe('session-host messaging extension', () => {const owner = await pane.owner()expect(owner?.paneId).toContain('generation-a')expect(await pane.send('line one\nline two\x1b[201~', owner!)).toBe(true)- expect(probe).toHaveBeenCalledTimes(2)+ expect(probe).toHaveBeenCalledTimes(3)// Two writes, in order: the paste, then Enter only once the envelope is on screen.expect(vi.mocked(session.proc.write).mock.calls).toEqual([['\x1b[200~line one\nline two[201~\x1b[201~'],diff --git a/src/session-host/message-pane.ts b/src/session-host/message-pane.tsindex b0ddacb95..2c9094370 100644--- a/src/session-host/message-pane.ts+++ b/src/session-host/message-pane.ts@@ -63,8 +63,11 @@ export function hostMessagePane(},submit: async () => {// A replaced or exited generation gets nothing: a bare Enter into a stranger's pane.- if (!current(s)) return- try { s.proc.write('\r') } catch { /* the paste already landed; receipt reports stalled */ }+ try {+ const owner = await probe(s.proc.pid, s.generation)+ if (!sameNativeProcess(expected, owner) || !(await s.messagePasteReady()) || !current(s)) return+ s.proc.write('\r')+ } catch { /* the paste already landed; receipt reports stalled */ }}}, settle)}diff --git a/src/shared/text-delivery.ts b/src/shared/text-delivery.tsindex 18f7de0ce..5a886dd7d 100644--- a/src/shared/text-delivery.ts+++ b/src/shared/text-delivery.ts@@ -1,3 +1,3 @@-/** A partial paste must never be retried or represented as submitted. */+/** A partial or transport-uncertain paste must never be retried or represented as submitted. */export type TextDeliveryResult = boolean | 'pasted-not-submitted'-export const TEXT_NOT_SUBMITTED = 'Text was pasted but not submitted. Do not resend it. Inspect the terminal and submit manually if appropriate.'+export const TEXT_NOT_SUBMITTED = 'Text may already be pasted, but submission could not be confirmed. Do not resend it. Inspect the terminal before taking further action.'