fix(terminal): wait for shell-ready before every SSH startup command

Renderer-delivered SSH launches wrote the startup command after a flat 50ms,
so a remote shell still reaching its prompt could drop it. Only Codex plans
opted into waiting.

Gate on whether a startup command exists rather than on which agent it names:
an unready shell drops whatever is written to it regardless. The relay already
gates its own delivery on the marker it armed; this mirrors that for the
renderer path, bounded by the existing 1.5s fallback.
This commit is contained in:
Brennan Benson
2026-08-07 12:01:14 -07:00
parent 87d1d1a8dc
commit 331d6210fa
@@ -128,8 +128,6 @@ import {
} from '../../../../shared/terminal-mode-reset-profiles'
import { buildFreshShellViewportBlankingSequence } from './terminal-restored-viewport'
import { createShellReadyMarkerScanState, scanForShellReadyMarker } from './shell-ready-marker-scan'
import { shouldUseShellReadyStartupDelivery } from '../../../../shared/codex-startup-delivery'
import { resolveSetupAgentSequenceLaunchCommand } from '../../../../shared/setup-agent-sequencing'
import { getSystemPrefersDark } from '@/lib/terminal-theme'
import {
INITIAL_MODE_2031_REPLY_SCAN_STATE,
@@ -4752,16 +4750,13 @@ export function connectPanePty(
? { command: paneStartup.command }
: null
: null
const startupShellReadyCommandHint = resolveSetupAgentSequenceLaunchCommand(
paneStartup?.env ?? {},
paneStartup?.command
)
// Why every startup command and not a per-agent list: a shell that has not reached its
// prompt drops whatever is written to it, whichever agent the command names. The relay
// already gates its own delivery on the marker it armed; this mirrors that for the
// renderer-delivered path, bounded by the existing fallback timer.
const shouldWaitForSshShellReady =
Boolean(connectionId) &&
shouldUseShellReadyStartupDelivery({
command: startupShellReadyCommandHint,
startupCommandDelivery: paneStartup?.startupCommandDelivery
}) &&
Boolean(pendingStartupCommand) &&
!shouldDeliverStartupViaTerminalPaste
const sshShellReadyMarkerScan = shouldWaitForSshShellReady
? createShellReadyMarkerScanState()