fix(terminal): skip PSReadLine repaint nudge before shell-ready

The form feed was written directly to the subprocess, bypassing Session
write ordering. Routing it through write() would be worse — a queued form
feed flushes after the buffered startup command at an arbitrary later
moment, when the foreground/prompt gates no longer hold. The nudge is
cosmetic, so skip it during the pre-ready window instead.
This commit is contained in:
Jinwoo Hong
2026-07-05 04:10:52 -04:00
parent 58ddcd7d1a
commit d84d9705f3
2 changed files with 21 additions and 0 deletions
+14
View File
@@ -477,6 +477,20 @@ describe('Session', () => {
expect(subprocess.written).toEqual([])
})
it('does not send or queue a form feed before shell-ready', async () => {
createSession({ shellReadySupported: true })
subprocess.foregroundProcess = 'powershell.exe'
subprocess.simulateData('PS C:\\Users\\me> ')
await vi.advanceTimersByTimeAsync(10)
// Why: a queued form feed would flush after the startup command at an
// arbitrary later moment, when the prompt gates no longer hold.
withPlatform('win32', () => session.clearScrollback())
expect(subprocess.written).toEqual([])
subprocess.simulateData('\x1b]777;orca-shell-ready\x07\r\nPS C:\\Users\\me> ')
await vi.advanceTimersByTimeAsync(10)
expect(subprocess.written).toEqual([])
})
it('does not send a form feed at a PowerShell continuation prompt', async () => {
createSession()
subprocess.foregroundProcess = 'powershell.exe'
+7
View File
@@ -305,6 +305,13 @@ export class Session {
if (process.platform !== 'win32') {
return
}
// Why: before shell-ready, write() would queue the form feed behind the
// buffered startup command and deliver it at an arbitrary later moment,
// when the foreground/prompt gates below no longer hold. The nudge is
// cosmetic — skip it rather than defer it.
if (this._shellState === 'pending' || this.postReadyFlushGate.isPending) {
return
}
if (!isPowerShellProcess(this.subprocess.getForegroundProcess())) {
return
}