@brimveyn/aimux 1.15.2 → 1.16.0

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.15.2",
3
+ "version": "1.16.0",
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",
@@ -126,11 +126,15 @@ export function applyViewportObservation(
126
126
  next: ViewportObservation | null
127
127
  ): ViewportObservation | null {
128
128
  if (!next) {
129
- if (prior !== null) resetSelectionShiftState(renderer)
129
+ if (prior !== null) {
130
+ renderer.clearSelection()
131
+ resetSelectionShiftState(renderer)
132
+ }
130
133
  return null
131
134
  }
132
135
 
133
136
  if (!prior || prior.tabId !== next.tabId) {
137
+ if (prior && prior.tabId !== next.tabId) renderer.clearSelection()
134
138
  resetSelectionShiftState(renderer)
135
139
  return next
136
140
  }
@@ -19,6 +19,7 @@ import {
19
19
  forEachSplitPaneRect,
20
20
  toTerminalContentSize,
21
21
  } from '../state/layout-resize'
22
+ import { getTreeForTab } from '../state/layout-tree'
22
23
 
23
24
  const MAIN_AREA_HORIZONTAL_CHROME = 2
24
25
  const MAIN_AREA_VERTICAL_PADDING = 0
@@ -161,6 +162,19 @@ export function useTerminalResize({
161
162
 
162
163
  const activeTabIdRef = useRef(state.activeTabId)
163
164
  activeTabIdRef.current = state.activeTabId
165
+ // Whether the active tab is part of a split. contentOriginRef must hold the
166
+ // whole terminal-area origin (root.tsx derives splitContentOrigin from it and
167
+ // SplitLayout re-adds each pane's bounds offset). When split, the active
168
+ // pane's measured box is pane-relative, so adopting it as the area origin
169
+ // would double-count the pane offset and push the hardware cursor off along
170
+ // the split axis. Track it so handleMeasure can skip the x/y overwrite.
171
+ const activeIsSplitRef = useRef(false)
172
+ {
173
+ const id = state.activeTabId
174
+ const tree =
175
+ id != null && id !== '' ? getTreeForTab(state.layoutTrees, state.tabGroupMap, id) : null
176
+ activeIsSplitRef.current = tree?.type === 'split'
177
+ }
164
178
  // Last size we pushed to the backend per tab, used to dedupe the measurement
165
179
  // loop so an unchanged box never re-triggers a resize.
166
180
  const measuredRef = useRef(new Map<string, { cols: number; rows: number }>())
@@ -187,7 +201,11 @@ export function useTerminalResize({
187
201
  const cols = Math.max(PTY_MIN_COLS, rect.cols)
188
202
  const rows = Math.max(PTY_MIN_ROWS, rect.rows)
189
203
  const isActive = tabId === activeTabIdRef.current
190
- if (isActive) {
204
+ // Only adopt the measured box as the terminal-area origin when the active
205
+ // pane spans the whole area (no split). In a split the box is pane-local;
206
+ // keep the model-derived area origin from the terminalSize memo below so
207
+ // the hardware cursor isn't offset by the pane's bounds (see ref comment).
208
+ if (isActive && !activeIsSplitRef.current) {
191
209
  contentOriginRef.current = { cols, rows, x: rect.x, y: rect.y }
192
210
  }
193
211
  const prev = measuredRef.current.get(tabId)
@@ -341,6 +341,25 @@ export class PtyManager extends EventEmitter<PtyManagerEvents> {
341
341
  return false
342
342
  })
343
343
 
344
+ // Wire the emulator's reply channel back to the pty. When a program
345
+ // writes a query sequence — CPR (ESC[6n), Device Attributes (ESC[c),
346
+ // Device Status (ESC[5n), DECRQM, OSC color queries — xterm generates
347
+ // the answer and emits it via onData. Without forwarding it the program
348
+ // waits forever for a response it never gets (e.g. AWS CLI / Python
349
+ // prompt_toolkit warns "terminal doesn't support cursor position
350
+ // requests (CPR)"). These replies are produced synchronously inside the
351
+ // emulator.write() below, so write straight to the pty rather than
352
+ // queueing through the render path. The listener is disposed together
353
+ // with the emulator in finalize/dispose, mirroring registerCsiHandler.
354
+ //
355
+ // onBinary (legacy non-UTF-8 mouse reports) is intentionally not wired:
356
+ // bun-pty.write() only accepts a UTF-8 string so byte values >127 can't
357
+ // be transmitted faithfully, and the headless emulator is never fed raw
358
+ // mouse input, so it never generates those reports in the first place.
359
+ emulator.onData((reply) => {
360
+ session.pty.write(reply)
361
+ })
362
+
344
363
  pty.onData((data) => {
345
364
  logDebug('ptyManager.data', {
346
365
  byteLength: Buffer.byteLength(data, 'utf8'),