Stabilize master CI across platforms

This commit is contained in:
Tianyi Cui
2026-07-25 00:10:37 +08:00
parent b97b1b4a3f
commit f9a638b8a6
24 changed files with 173 additions and 86 deletions

View File

@@ -288,11 +288,12 @@ export class LocalPtySession implements PtyBackendSession {
if (sanitized.prompt) {
const foregroundPgid = this.inspector.foregroundPgid(this.pid)
if (this.shellPgid === undefined) this.shellPgid = foregroundPgid
if (foregroundPgid !== undefined && foregroundPgid === this.shellPgid) {
this.promptSeen = true
this.promptTextSeen = sanitized.promptText === true
this.lastOutputAt = Date.now()
}
// Bash can print PROMPT_COMMAND before the kernel publishes its return
// to the foreground process group. Retain the marker; polling below is
// the authority that accepts it only after bash owns the foreground.
this.promptSeen = true
this.promptTextSeen = sanitized.promptText === true
this.lastOutputAt = Date.now()
} else if (this.promptSeen && sanitized.promptText === true) {
this.promptTextSeen = true
}
@@ -312,8 +313,11 @@ export class LocalPtySession implements PtyBackendSession {
return
}
if (this.promptSeen && this.promptTextSeen && Date.now() - this.lastOutputAt >= this.config.pollIntervalMs) {
this.settleActive('stdin_read')
return
const pgid = this.inspector.foregroundPgid(this.pid)
if (this.shellPgid !== undefined && pgid === this.shellPgid) {
this.settleActive('stdin_read')
return
}
}
const elapsed = Date.now() - operation.startedAt
const startupHasOutput = !this.initializing || this.scrollback.snapshot().text.length > 0
@@ -324,7 +328,13 @@ export class LocalPtySession implements PtyBackendSession {
return
}
}
if (startupHasOutput && Date.now() - this.lastOutputAt >= this.config.idleSilenceMs) {
// A complete owned marker is stronger evidence than silence, but can race
// the kernel's foreground-PGID handoff. Once it is pending, wait for bash
// ownership (or the absolute timeout) instead of misclassifying that race
// as inferred idle.
if (!(this.promptSeen && this.promptTextSeen)
&& startupHasOutput
&& Date.now() - this.lastOutputAt >= this.config.idleSilenceMs) {
this.settleActive('inferred_idle')
return
}