Merge pull request #12848 from Kilo-Org/fix-pty-non-ascii-flake

fix(pty): stabilize non-ASCII output round-trip test
This commit is contained in:
Marius
2026-08-04 13:11:15 +02:00
committed by GitHub
+10 -6
View File
@@ -80,17 +80,19 @@ const attachCollecting = Effect.fn("PtySessionTest.attachCollecting")(function*
return { attachment, output, ended }
})
const waitForOutput = (output: Queue.Queue<string>, text: string) =>
Effect.gen(function* () {
let received = ""
const waitForOutput = (output: Queue.Queue<string>, text: string) => {
let received = ""
const pull = Effect.gen(function* () {
while (!received.includes(text)) received += yield* Queue.take(output)
return received
}).pipe(
})
return pull.pipe(
Effect.timeoutOrElse({
duration: PTY_TEST_TIMEOUT, // kilocode_change
orElse: () => Effect.fail(new Error(`timeout waiting for output containing ${JSON.stringify(text)}`)),
orElse: () => Effect.fail(new Error(`timeout waiting for output containing ${JSON.stringify(text)}, received ${JSON.stringify(received)}`)),
}),
)
}
describe("pty", () => {
it.live("returns typed not found errors for missing sessions", () =>
@@ -143,11 +145,13 @@ describe("pty", () => {
)
// (script terminals forward raw output to xterm without transcoding).
// The child must outlive its output: an immediate exit can race bun-pty's
// reader thread and drop trailing bytes under load, so print then sleep.
ptyTest("round-trips non-ASCII output byte-identically", () =>
Effect.gen(function* () {
const pty = yield* Pty.Service
const marker = "café-über-北京-🚀"
const info = yield* createPty("sh", ["-c", "printf 'caf\\303\\251-\\303\\274ber-\\345\\214\\227\\344\\272\\254-\\360\\237\\232\\200\\n'"])
const info = yield* createPty("sh", ["-c", "printf 'caf\\303\\251-\\303\\274ber-\\345\\214\\227\\344\\272\\254-\\360\\237\\232\\200\\n'; sleep 5"])
const attached = yield* attachCollecting(info.id)
expect(yield* waitForOutput(attached.output, marker)).toContain(marker)
}),