Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions packages/core/test/pty/pty-session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () =>
Expand Down Expand Up @@ -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)
}),
Expand Down
Loading