fix(web): the Codex in-pane file click is behind the Codex files setting too

Owner decision for 1.52.1: #850 left a click on a file name Codex
underlined in the pane ungated, so it opened the preview for everyone.
_handleDesktopTerminalClick() now asks _codexFilePreviewsEnabled() first;
off, every click in a Codex pane goes on to Codex as before (main
terminal, split pane and tiles share that handler). The setting now
gates four behaviours: the chip's tooltip (and its zh-CN), the wiki,
src/web/CLAUDE.md and the off-state test say so. The new test fails
without the gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-12-03 10:55:34 +01:00
1 parent 3994196341
commit 5f4951884f
8 files changed
+74 -20

No files matched your search

+51 -4
View File
@@ -1,13 +1,14 @@
// test/codex-file-previews-setting.test.ts
// Port: none (static analysis plus vm-loaded modules, runs in CI, no browser/server).
//
// `codexFilePreviewsEnabled` (App Settings > Header buttons > Codex files) gates three
// `codexFilePreviewsEnabled` (App Settings > Header & Panels > Codex files) gates four
// behaviours together, per device, default OFF:
// 1. the Response files header button (never on phones, even when on),
// 2. taking a click on a file tab in Codex's own sidebar (and suppressing the
// ordinary linkifier on those rows),
// 3. the Dock control on file previews.
// With it off none of the three exists. Each surface's off-state behaviour is also
// 3. the Dock control on file previews,
// 4. taking a click on a file name Codex underlined in the pane (owner decision for 1.52.1).
// With it off none of the four exists. Each surface's off-state behaviour is also
// pinned next to its own tests (response-viewer-file-links, terminal-link-provider-target,
// file-preview-window); this file pins the setting's own wiring and the off-state of all
// three through the real reader.
@@ -52,7 +53,7 @@ describe('codexFilePreviewsEnabled stays per-device: display key, stripped from
});
});
describe('with the Codex files setting off (nothing stored), none of the three behaviours exists', () => {
describe('with the Codex files setting off (nothing stored), none of the four behaviours exists', () => {
function loadApp() {
const { window } = new JSDOM(`<!doctype html>
<button id="responseFilesBtn" class="btn-icon-header btn-response-files btn-response-files--hidden" hidden></button>
@@ -159,6 +160,52 @@ describe('with the Codex files setting off (nothing stored), none of the three b
expect(overlay.classList.contains('is-docked')).toBe(true);
});
it('4. passes a click on a file name Codex underlined in the pane on to Codex', () => {
const { app } = loadApp();
const cols = 40;
const text = '• Word brief';
const terminal = {
cols,
modes: { mouseTrackingMode: 'none' },
hasSelection: () => false,
buffer: {
active: {
viewportY: 0,
length: 2,
getLine: (row: number) =>
row > 1
? undefined
: {
isWrapped: false,
getCell: (col: number) => ({
getChars: () => (row === 0 ? (text[col] ?? ' ') : ' '),
getWidth: () => 1,
isUnderline: () => row === 0 && col >= 2 && col < 12,
}),
translateToString: (trim?: boolean, start = 0, end = cols) => {
const line = (row === 0 ? text : '').padEnd(cols).slice(start, end);
return trim ? line.trimEnd() : line;
},
},
},
},
};
app.terminal = terminal;
app._clientPointToCell = () => ({ col: 5, row: 1 });
app._shouldReportMouseToCli = () => true;
app._sendSyntheticSgrTap = vi.fn();
app._openCodexTerminalResponseFile = vi.fn().mockResolvedValue(undefined);
const click = { isTrusted: true, button: 0, detail: 1, clientX: 50, clientY: 10, target: { closest: () => ({}) } };
app._handleDesktopTerminalClick(click);
expect(app._openCodexTerminalResponseFile).not.toHaveBeenCalled();
expect(app._sendSyntheticSgrTap).toHaveBeenCalledTimes(1);
app._codexFilePreviewsEnabled = () => true; // the same click, setting on: looked up first
app._handleDesktopTerminalClick(click);
expect(app._openCodexTerminalResponseFile).toHaveBeenCalledTimes(1);
expect(app._openCodexTerminalResponseFile.mock.calls[0][3]).toMatchObject({ label: 'Word brief' });
expect(app._sendSyntheticSgrTap).toHaveBeenCalledTimes(1);
});
it('flips the Dock button of an open preview when the setting changes, not only at the next open', () => {
const { app, document } = loadApp();
const dockBtn = document.getElementById('filePreviewDockBtn')!;
+1
View File
@@ -510,6 +510,7 @@ describe('terminal touch tap mouse guard', () => {
};
};
app._supportsCodexResponseFiles = () => true;
app._codexFilePreviewsEnabled = () => true;
app._openCodexTerminalResponseFile = vi.fn().mockResolvedValue(undefined);
app._sendSyntheticSgrTap = vi.fn();