The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
feat: capture and restore tmux hardware cursor visibility state to prevent stray cursors
0xken1532f266a7a526
diff --git a/cli/src/lib/tmuxStream.spec.ts b/cli/src/lib/tmuxStream.spec.tsindex 6ae79d88f..067262777 100644--- a/cli/src/lib/tmuxStream.spec.ts+++ b/cli/src/lib/tmuxStream.spec.ts@@ -58,6 +58,7 @@ describe('tmux snapshot row normalization', () => {sessionId: '$1', windowId: '@1', windowPanes: 1,windowWidth: 80, windowHeight: 2, paneWidth: 80, paneHeight: 2,alternateOn: false, cursorX: 4, cursorY: 1,+ cursorVisible: true,mouseStandard: false, mouseButton: false, mouseAll: false,mouseUtf8: false, mouseSgr: false,},@@ -69,6 +70,22 @@ describe('tmux snapshot row normalization', () => {expect(snapshot).toContain('\u001b[2;5H\u001b[?7h\u001b[?25h')})+ it('preserves a tmux-hidden hardware cursor while restoring its position', () => {+ const snapshot = Buffer.from(synthesizeTmuxSnapshot(+ Buffer.from('painted input\n'),+ {+ sessionId: '$1', windowId: '@1', windowPanes: 1,+ windowWidth: 80, windowHeight: 2, paneWidth: 80, paneHeight: 2,+ alternateOn: false, cursorX: 0, cursorY: 1,+ cursorVisible: false,+ mouseStandard: false, mouseButton: false, mouseAll: false,+ mouseUtf8: false, mouseSgr: false,+ },+ )).toString()++ expect(snapshot.endsWith('\u001b[2;1H\u001b[?7h\u001b[?25l')).toBe(true)+ })+it('seeds styled cell history before rebuilding the visible grid', () => {const history = Buffer.from('\u001b[31mold-frame-1\u001b[39m\nold-frame-2\n')expect(Buffer.from(normalizeTmuxHistoryLines(history)).toString()).toBe(@@ -80,6 +97,7 @@ describe('tmux snapshot row normalization', () => {sessionId: '$1', windowId: '@1', windowPanes: 1,windowWidth: 80, windowHeight: 2, paneWidth: 80, paneHeight: 2,alternateOn: false, cursorX: 0, cursorY: 0,+ cursorVisible: true,mouseStandard: false, mouseButton: false, mouseAll: false,mouseUtf8: false, mouseSgr: false,},@@ -97,6 +115,7 @@ describe('tmux snapshot row normalization', () => {sessionId: '$1', windowId: '@1', windowPanes: 1,windowWidth: 80, windowHeight: 2, paneWidth: 80, paneHeight: 2,alternateOn: true, cursorX: 0, cursorY: 0,+ cursorVisible: true,mouseStandard: false, mouseButton: false, mouseAll: true,mouseUtf8: false, mouseSgr: true,},diff --git a/cli/src/lib/tmuxStream.ts b/cli/src/lib/tmuxStream.tsindex c97709fb9..06ceff3d9 100644--- a/cli/src/lib/tmuxStream.ts+++ b/cli/src/lib/tmuxStream.ts@@ -26,6 +26,7 @@ const SNAPSHOT_HISTORY_LINES = 500const PANE_META_FORMAT = ['#{session_id}', '#{window_id}', '#{window_panes}', '#{window_width}', '#{window_height}','#{pane_width}', '#{pane_height}', '#{alternate_on}', '#{cursor_x}', '#{cursor_y}',+ '#{cursor_flag}','#{mouse_standard_flag}', '#{mouse_button_flag}', '#{mouse_all_flag}', '#{mouse_utf8_flag}', '#{mouse_sgr_flag}',].join('|')@@ -40,6 +41,7 @@ interface PaneMeta {alternateOn: booleancursorX: numbercursorY: number+ cursorVisible: booleanmouseStandard: booleanmouseButton: booleanmouseAll: boolean@@ -79,7 +81,7 @@ async function paneMeta(paneId: string): Promise<PaneMeta | null> {function parsePaneMeta(bytes: Uint8Array): PaneMeta | null {const fields = Buffer.from(bytes).toString('utf8').trim().split('|')- if (fields.length !== 15 || !/^\$\d+$/.test(fields[0]) || !/^@\d+$/.test(fields[1])) return null+ if (fields.length !== 16 || !/^\$\d+$/.test(fields[0]) || !/^@\d+$/.test(fields[1])) return nullconst nums = fields.slice(2).map(Number)if (nums.some((value) => !Number.isFinite(value))) return nullreturn {@@ -93,11 +95,12 @@ function parsePaneMeta(bytes: Uint8Array): PaneMeta | null {alternateOn: nums[5] === 1,cursorX: nums[6],cursorY: nums[7],- mouseStandard: nums[8] === 1,- mouseButton: nums[9] === 1,- mouseAll: nums[10] === 1,- mouseUtf8: nums[11] === 1,- mouseSgr: nums[12] === 1,+ cursorVisible: nums[8] === 1,+ mouseStandard: nums[9] === 1,+ mouseButton: nums[10] === 1,+ mouseAll: nums[11] === 1,+ mouseUtf8: nums[12] === 1,+ mouseSgr: nums[13] === 1,}}@@ -251,7 +254,12 @@ export function synthesizeTmuxSnapshot(rowIndex++start = index + 1}- const suffix = Buffer.from(`\u001b[${cursorRow};${cursorCol}H\u001b[?7h\u001b[?25h`, 'utf8')+ // tmux keeps visibility separately from the cursor coordinate. Full-screen+ // TUIs such as Command Code park the physical cursor below their own painted+ // input and hide it; restoring the coordinate with an unconditional ?25h+ // creates a stray block cursor in remote renderers.+ const cursorVisibility = meta.cursorVisible ? 'h' : 'l'+ const suffix = Buffer.from(`\u001b[${cursorRow};${cursorCol}H\u001b[?7h\u001b[?25${cursorVisibility}`, 'utf8')return Buffer.concat([prefix, normalizedHistory, historySuffix, ...rows, suffix])}