@brimveyn/aimux 1.15.2 → 1.16.1

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.1",
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
  }
@@ -1610,7 +1610,6 @@ async function runDeleteWorktree(
1610
1610
  if (tabsInWorktree.length > 0 && !force && !closeTabs) {
1611
1611
  throw new ActiveWorktreeTabsError(tabsInWorktree.length)
1612
1612
  }
1613
- disposeWorktreeTabs(ctx, worktreeId)
1614
1613
 
1615
1614
  const repoPath = resolveWorktreeGitDir(session, worktree)
1616
1615
  const isAimuxTemp = worktree.source === 'aimux-temp' && worktree.createdByAimux
@@ -1624,15 +1623,14 @@ async function runDeleteWorktree(
1624
1623
  }
1625
1624
  }
1626
1625
 
1626
+ // Run git ops FIRST. If any throws (dirty worktree, etc.) the catch in the
1627
+ // delete-worktree side effect handler re-prompts force or toasts the error —
1628
+ // tabs stay open and the row stays in the sidebar, so the UI matches reality
1629
+ // instead of leaving tabs closed against a worktree that still exists.
1627
1630
  if (isAimuxTemp && isInsideAimuxWorktreeRoot(worktree.path) && !existsSync(worktree.path)) {
1628
1631
  // The dir vanished but git may still pin the branch to a stale worktree entry.
1629
1632
  await pruneGitWorktrees(repoPath)
1630
- await cleanupAimuxBranch()
1631
- removeWorktreeRecordFromSession(ctx, sessionId, session, worktreeId)
1632
- return
1633
- }
1634
-
1635
- if (isAimuxTemp && isInsideAimuxWorktreeRoot(worktree.path)) {
1633
+ } else if (isAimuxTemp && isInsideAimuxWorktreeRoot(worktree.path)) {
1636
1634
  await assertSafeAimuxWorktreePath(worktree.path)
1637
1635
  await removeGitWorktree({ force, repoPath, targetPath: worktree.path })
1638
1636
  } else if (worktree.source === 'aimux-temp' || worktree.createdByAimux) {
@@ -1640,7 +1638,15 @@ async function runDeleteWorktree(
1640
1638
  }
1641
1639
 
1642
1640
  await cleanupAimuxBranch()
1643
- removeWorktreeRecordFromSession(ctx, sessionId, session, worktreeId)
1641
+
1642
+ // Only after git success: close tabs + retire the record. Re-read state so
1643
+ // we don't operate on the snapshot captured before the awaits above.
1644
+ disposeWorktreeTabs({ ...ctx, state: ctx.getState() }, worktreeId)
1645
+ const latest = ctx.getState()
1646
+ const latestSession = latest.sessions.find((entry) => entry.id === sessionId)
1647
+ if (latestSession) {
1648
+ removeWorktreeRecordFromSession({ ...ctx, state: latest }, sessionId, latestSession, worktreeId)
1649
+ }
1644
1650
  }
1645
1651
 
1646
1652
  // A worktree's stored repoRoot can point at a sibling worktree that was since
@@ -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'),