fix(terminal): log xterm's mouse encoding with each scroll routing decision

Merge-time fix for #664 (optional item): _logScrollRouting now prints
mouseEncoding (xterm's coreMouseService.activeEncoding, 'unknown' when
the private cannot be read) and counts it in the per-session signature,
since an app switching encodings changes where a touch drag goes. Adds
a unit test for that line and one asserting SGR_PIXELS fails closed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-10-22 19:12:25 +02:00
1 parent d38291b143
commit 76c17e5c4e
2 files changed
+29 -3

No files matched your search

+21
View File
@@ -876,6 +876,20 @@ describe('scroll routing diagnostic (issue #205 round 2)', () => {
app._logScrollRouting('page-keys');
expect(logs[0]).toContain('cliVersion=unknown');
});
it("reports xterm's mouse encoding, the input touch forwarding to native tracking reads", () => {
const { app, logs } = hollowApp({ mode: 'shell' });
app._logScrollRouting('local-scrollback'); // no readable xterm private
expect(logs[0]).toContain('mouseEncoding=unknown');
// An app switching to SGR changes what touch does, so it prints again.
app.terminal.modes.mouseTrackingMode = 'any';
app.terminal._core = { coreMouseService: { activeEncoding: 'SGR' } };
app._logScrollRouting('local-scrollback');
expect(logs).toHaveLength(2);
expect(logs[1]).toContain('mouseTracking=any');
expect(logs[1]).toContain('mouseEncoding=SGR');
});
});
describe('touch scrolling when xterm owns native mouse tracking', () => {
@@ -898,6 +912,13 @@ describe('touch scrolling when xterm owns native mouse tracking', () => {
expect(app._shouldForwardTouchToApp()).toBe(false);
});
it('does not send cell-based SGR reports to an app that asked for SGR pixel coordinates', () => {
const { app } = hollowApp({ mode: 'shell' });
app.terminal.modes.mouseTrackingMode = 'any';
app.terminal._core = { coreMouseService: { activeEncoding: 'SGR_PIXELS' } };
expect(app._shouldForwardTouchToApp()).toBe(false);
});
it('keeps the explicit local-history preference for touch', () => {
const { app } = hollowApp({ mode: 'shell' });
app.terminal.modes.mouseTrackingMode = 'any';