@brimveyn/aimux 1.7.2 → 1.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brimveyn/aimux",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "A terminal multiplexer for AI CLIs. Run Claude, Codex, OpenCode side-by-side with tabbed navigation, split panes, and persistent sessions.",
5
5
  "keywords": [
6
6
  "ai",
@@ -1,6 +1,7 @@
1
1
  import type { SessionBackend } from '../session-backend/types'
2
2
  import type { AppAction, TabSession } from '../state/types'
3
3
 
4
+ import { logInputDebug } from '../debug/input-log'
4
5
  import { buildPtyPastePayload } from '../input/paste'
5
6
 
6
7
  export interface PtyWriteOptions {
@@ -20,6 +21,12 @@ export function writeToTab(
20
21
  dispatch?: (action: AppAction) => void,
21
22
  options?: PtyWriteOptions
22
23
  ): void {
24
+ logInputDebug('ptyWrite.writeToTab', {
25
+ autoBottom: options?.autoBottom ?? true,
26
+ inputLength: input.length,
27
+ inputPreview: input.slice(0, 64),
28
+ tabId,
29
+ })
23
30
  if ((options?.autoBottom ?? true) && tab && shouldScrollViewportToBottom(tab)) {
24
31
  backend.scrollViewportToBottom(tabId)
25
32
  dispatch?.({ intent: { kind: 'bottom' }, tabId, type: 'set-scroll-intent' })
@@ -286,9 +286,14 @@ export async function runDaemon(): Promise<void> {
286
286
  logDebug('daemon.client.connected')
287
287
  sockets.add(socket)
288
288
  const decoder = new MessageDecoder<ClientRequest>(parseClientRequest)
289
+ // Serialize chunk processing per socket. Each async iteration crosses a
290
+ // microtask boundary, so without chaining, concurrent `data` callbacks
291
+ // interleave their `await manager.write(...)` calls and PTY writes land
292
+ // out of order (visible as scrambled chars during fast typing/Espanso).
293
+ let processing: Promise<void> = Promise.resolve()
289
294
 
290
295
  socket.on('data', (chunk) => {
291
- void (async () => {
296
+ processing = processing.then(async () => {
292
297
  try {
293
298
  for (const message of decoder.push(chunk)) {
294
299
  try {
@@ -527,7 +532,7 @@ export async function runDaemon(): Promise<void> {
527
532
  decoder.reset()
528
533
  send(socket, { id: crypto.randomUUID(), payload: { message }, type: 'error' })
529
534
  }
530
- })()
535
+ })
531
536
  })
532
537
 
533
538
  socket.on('close', () => {