Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
test(chat): exercise push-iterable park/wakeup + push-after-end guard
enes6b652b04bed6
diff --git a/src/main/chat-queue.test.ts b/src/main/chat-queue.test.tsindex c3f9f6f16..27d7dbe9d 100644--- a/src/main/chat-queue.test.ts+++ b/src/main/chat-queue.test.ts@@ -12,6 +12,33 @@ describe('createPushIterable', () => {await doneexpect(seen).toEqual([1, 2, 3])})++ it('parks a consumer on an empty iterable and wakes it when a value is pushed', async () => {+ const { iterable, push, end } = createPushIterable<number>()+ const seen: number[] = []+ // Start consuming an EMPTY iterable — the loop parks on the internal notify promise.+ const done = (async () => { for await (const v of iterable) seen.push(v) })()+ // Let the microtask/timer queue drain so the consumer is actually parked.+ await new Promise((r) => setTimeout(r, 0))+ expect(seen).toEqual([])+ // Now push: this must wake the parked consumer and deliver the value.+ push(42)+ await new Promise((r) => setTimeout(r, 0))+ expect(seen).toEqual([42])+ end()+ await done+ expect(seen).toEqual([42])+ })++ it('drops items pushed after end()', async () => {+ const { iterable, push, end } = createPushIterable<number>()+ push(1); end()+ // push-after-end is ignored — nothing new is delivered.+ push(2)+ const seen: number[] = []+ for await (const v of iterable) seen.push(v)+ expect(seen).toEqual([1])+ })})describe('ChatInputQueue', () => {diff --git a/src/main/chat-queue.ts b/src/main/chat-queue.tsindex 9144f2e2c..3f50c1e8a 100644--- a/src/main/chat-queue.ts+++ b/src/main/chat-queue.ts@@ -2,13 +2,16 @@// prompt input) and the driver-side FIFO of messages typed while a turn is running.import type { ChatQueueItem } from '../shared/types'+// Single-consumer only: one shared buffer + one notify slot. A second concurrent+// consumer would clobber the parked waiter (the last one to await wins the notify),+// so only ever drive one `for await` loop over the returned iterable.export function createPushIterable<T>(): { iterable: AsyncIterable<T>; push(item: T): void; end(): void } {const buffer: T[] = []let notify: (() => void) | null = nulllet ended = falseconst wake = () => { notify?.(); notify = null }return {- push(item: T) { buffer.push(item); wake() },+ push(item: T) { if (ended) return; buffer.push(item); wake() },end() { ended = true; wake() },iterable: {async *[Symbol.asyncIterator]() {