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
feat(chat): push-iterable + input queue primitives
enes3c7d846ae1f8
diff --git a/src/main/chat-queue.test.ts b/src/main/chat-queue.test.tsnew file mode 100644index 000000000..c3f9f6f16--- /dev/null+++ b/src/main/chat-queue.test.ts@@ -0,0 +1,26 @@+import { describe, expect, it } from 'vitest'+import { ChatInputQueue, createPushIterable } from './chat-queue'++describe('createPushIterable', () => {+ it('yields pushed items in order and finishes on end()', async () => {+ const { iterable, push, end } = createPushIterable<number>()+ push(1); push(2)+ const seen: number[] = []+ const done = (async () => { for await (const v of iterable) seen.push(v) })()+ // push after consumption started, then close+ push(3); end()+ await done+ expect(seen).toEqual([1, 2, 3])+ })+})++describe('ChatInputQueue', () => {+ it('is FIFO with stable ids and removal', () => {+ const q = new ChatInputQueue()+ const a = q.add('first'); const b = q.add('second')+ expect(q.items().map((i) => i.text)).toEqual(['first', 'second'])+ expect(q.remove(a.id)).toBe(true)+ expect(q.takeNext()).toEqual(b)+ expect(q.takeNext()).toBeUndefined()+ })+})diff --git a/src/main/chat-queue.ts b/src/main/chat-queue.tsnew file mode 100644index 000000000..9144f2e2c--- /dev/null+++ b/src/main/chat-queue.ts@@ -0,0 +1,40 @@+// Pure helpers for the chat driver: a push-based AsyncIterable (the SDK's streaming+// prompt input) and the driver-side FIFO of messages typed while a turn is running.+import type { ChatQueueItem } from '../shared/types'++export function createPushIterable<T>(): { iterable: AsyncIterable<T>; push(item: T): void; end(): void } {+ const buffer: T[] = []+ let notify: (() => void) | null = null+ let ended = false+ const wake = () => { notify?.(); notify = null }+ return {+ push(item: T) { buffer.push(item); wake() },+ end() { ended = true; wake() },+ iterable: {+ async *[Symbol.asyncIterator]() {+ for (;;) {+ while (buffer.length) yield buffer.shift() as T+ if (ended) return+ await new Promise<void>((r) => { notify = r })+ }+ }+ }+ }+}++export class ChatInputQueue {+ private list: ChatQueueItem[] = []+ private seq = 0+ items(): ChatQueueItem[] { return [...this.list] }+ add(text: string): ChatQueueItem {+ const item = { id: `q-${++this.seq}`, text }+ this.list.push(item)+ return item+ }+ remove(id: string): boolean {+ const before = this.list.length+ this.list = this.list.filter((i) => i.id !== id)+ return this.list.length < before+ }+ takeNext(): ChatQueueItem | undefined { return this.list.shift() }+}