fix(pty): discard pre-write readiness evidence

This commit is contained in:
Tianyi Cui
2026-07-29 05:20:40 +08:00
parent 587fff9fe7
commit f5f40c7403
8 changed files with 44 additions and 12 deletions

View File

@@ -227,10 +227,7 @@ export class LocalPtySession implements PtyBackendSession {
() => { this.interrupt(operation) },
)
this.active = operation
this.lastOutputAt = Date.now()
this.promptSeen = false
this.promptTextSeen = false
this.promptTail = ''
this.resetReadinessEvidence()
if (request.signal !== undefined) {
const onAbort = (): void => { operation.cancel() }
@@ -251,6 +248,7 @@ export class LocalPtySession implements PtyBackendSession {
operation.setInitialForeground(foreground)
const input = `${request.text}${request.submit ? '\r' : ''}`
if (input.length > 0 && !operation.cancelRequested) {
this.resetReadinessEvidence()
this.writing = operation
try {
await this.terminal.write(Buffer.from(input, 'utf8'))
@@ -276,6 +274,13 @@ export class LocalPtySession implements PtyBackendSession {
}
}
private resetReadinessEvidence(): void {
this.lastOutputAt = Date.now()
this.promptSeen = false
this.promptTextSeen = false
this.promptTail = ''
}
read(request: PtyReadRequest): PtyReadResult {
const snapshot = this.scrollback.snapshot()
const lines = snapshot.text.split('\n')