Files
Codeman/test/session-resize-arbitration.test.ts
T
Aamer AkhterandSaqeb Akhter 02fa3f30f5 fix(mobile): terminal and layout fixes for touch devices
Mobile-focused fixes for the web UI: keyboard-accessory layout and
overlap, native input visibility above the keyboard, CJK input handling,
terminal touch scrolling, tab-menu tap targets, mic-recording glow
containment, and mobile resize/keyboard-state handling on tab switch,
plus mobile visual-regression test coverage and snapshots.

Co-Authored-By: Saqeb Akhter <saqeb.akhter@gmail.com>
2026-06-10 03:47:26 +02:00

38 lines
1.2 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest';
import { Session } from '../src/session.js';
type ResizeableSessionInternals = {
ptyProcess: { resize: (cols: number, rows: number) => void };
_ptyCols: number;
_ptyRows: number;
};
function attachFakePty(session: Session, cols = 160, rows = 48) {
const resize = vi.fn();
const internals = session as unknown as ResizeableSessionInternals;
internals.ptyProcess = { resize };
internals._ptyCols = cols;
internals._ptyRows = rows;
return resize;
}
describe('Session resize arbitration', () => {
it('ignores mobile resizes that would shrink a wider desktop PTY', () => {
const session = new Session({ workingDir: '/tmp', mode: 'shell' });
const resize = attachFakePty(session, 160, 48);
session.resize(48, 28, { viewportType: 'mobile' });
expect(resize).not.toHaveBeenCalled();
});
it('allows desktop resizes to change the shared PTY dimensions', () => {
const session = new Session({ workingDir: '/tmp', mode: 'shell' });
const resize = attachFakePty(session, 160, 48);
session.resize(120, 40, { viewportType: 'desktop' });
expect(resize).toHaveBeenCalledWith(120, 40);
});
});