mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-02 13:39:41 +02:00
fix(codex): reassemble chunk-split sequences before the strip; mouse parity on replay
Review fixes: - Hold back a trailing partial CSI (digit-only intro, ≤7 chars) in _handleTerminalOutput and prepend it to the next chunk. PTY chunk boundaries are arbitrary, so '\x1b[?1049h' can arrive as '\x1b[?104' + '9h' — the per-chunk strip misses it, xterm obeys the reassembled toggle, and (with the matching ?1049l stripped) stays stuck in the scrollback-less alt buffer until the next replay. Complete sequences are never held; the carry resets with the other buffers in _resetBuffers. - Replay path now also strips mouse-tracking enables (?1000-?1007), matching the live strip: buffers persisted BEFORE the live strip existed can still carry them, and a replayed ?1006h re-hijacks the scroll wheel. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,34 @@ describe('Codex terminal output filtering', () => {
|
||||
expect(session.terminalBuffer).toBe('\x1b[2Jvisiblescrollback');
|
||||
});
|
||||
|
||||
it('strips sequences split across PTY chunk boundaries (carry reassembly)', () => {
|
||||
const session = new Session({ workingDir: '/tmp', mode: 'codex' });
|
||||
|
||||
const emitted: string[] = [];
|
||||
session.on('terminal', (data) => emitted.push(data));
|
||||
|
||||
// '\x1b[?1049h' split mid-sequence, then '\x1b[3J' split before its final byte.
|
||||
handleOutput(session, 'before\x1b[?104');
|
||||
handleOutput(session, '9h\x1b[2Jafter\x1b[3');
|
||||
handleOutput(session, 'Jtail');
|
||||
|
||||
expect(session.terminalBuffer).toBe('before\x1b[2Jaftertail');
|
||||
expect(emitted).toEqual(['before', '\x1b[2Jafter', 'tail']);
|
||||
});
|
||||
|
||||
it('emits nothing for a chunk that is only a partial CSI, and completes it next chunk', () => {
|
||||
const session = new Session({ workingDir: '/tmp', mode: 'codex' });
|
||||
|
||||
const emitted: string[] = [];
|
||||
session.on('terminal', (data) => emitted.push(data));
|
||||
|
||||
handleOutput(session, '\x1b[?100'); // pure partial — held, nothing emitted
|
||||
handleOutput(session, '6h\x1b[55;1H• Working'); // completes ?1006h (stripped); rest passes
|
||||
|
||||
expect(emitted).toEqual(['\x1b[55;1H• Working']);
|
||||
expect(session.terminalBuffer).toBe('\x1b[55;1H• Working');
|
||||
});
|
||||
|
||||
it('preserves Codex erase-display redraw when the user pressed Ctrl+L', () => {
|
||||
const session = new Session({ workingDir: '/tmp', mode: 'codex' });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user