mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-12-05 01:29:32 +01:00
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:
1 parent
3994196341
commit
5f4951884f
8 files changed
+74
-20
No files matched your search
@@ -68,13 +68,14 @@ Manager, Attachments, Edit history, File Viewer, Multi-monitor, Split, Tiles, Pl
|
||||
Project Insights, File Browser, Subagents, Approvals Inbox, Read My Mind, Ultracode Agents,
|
||||
Ultracode Windows, Cron.
|
||||
|
||||
**Codex files** (off by default, per device) switches on three extras for Codex sessions, together:
|
||||
a **Response files** header button that lists the previewable files linked in the latest reply
|
||||
**Codex files** (off by default, per device) switches on four extras for Codex sessions, together:
|
||||
a click on a file name Codex underlined in the pane opening that file in the preview when it names a
|
||||
single supported file from the conversation (off, the click goes to Codex), a **Response files** header button that lists the previewable files linked in the latest reply
|
||||
(desktop only: phones keep File Viewer as their one header button, even with this on), a click on a
|
||||
file name in Codex's own sidebar opening that file in the preview when it matches a single linked
|
||||
file (off, the click goes to Codex), and a **Dock** button on file previews that, on a window 1180px
|
||||
or wider with a single terminal, docks the preview beside the terminal. With it off none of the three
|
||||
exists. Clicking a file name Codex underlined in the pane opens the preview either way.
|
||||
or wider with a single terminal, docks the preview beside the terminal. With it off none of the four
|
||||
exists, and every click in a Codex pane goes to Codex as before.
|
||||
|
||||
**Host readings** (opt-in, both off by default and per device): **GPU Stats** adds three items after CPU and MEM: GPU load, graphics memory and the GPU clock,
|
||||
and **CPU MHz** adds the live CPU clock. Both sets of items live inside **System Stats**, so they show only
|
||||
|
||||
@@ -142,10 +142,10 @@ File paths in a session are links. That works in two places:
|
||||
render as underlined monospace links. A Markdown link whose target is a path
|
||||
(`[report](/tmp/run/report.json)`, the way Codex cites files) opens the same way.
|
||||
|
||||
In a Codex session, clicking a file name Codex underlined opens it in Codeman's preview
|
||||
when it names a single supported file from the conversation; anything else goes to Codex as
|
||||
before. The **Codex files** setting (App Settings > Header buttons, per device, off by
|
||||
default) adds three more: a **Response files** header button that lists the files linked in
|
||||
In a Codex session, with the **Codex files** setting on (App Settings > Header & Panels,
|
||||
per device, off by default), clicking a file name Codex underlined opens it in Codeman's
|
||||
preview when it names a single supported file from the conversation; anything else goes to
|
||||
Codex as before. The same setting adds three more: a **Response files** header button that lists the files linked in
|
||||
the latest reply (desktop only), a file name in Codex's own sidebar opening the preview when it
|
||||
matches a single linked file, and a **Dock** button that, on a wide window with a single
|
||||
terminal, switches between a preview beside the terminal and a floating one.
|
||||
|
||||
+1
-1
@@ -100,7 +100,7 @@ Frontend JS modules have `@fileoverview` with `@dependency`/`@loadorder` tags. L
|
||||
|
||||
**SSE staleness watchdog** (`computeSseStale()` in constants.js, `_checkSseStale()` + a 5s interval in app.js): an `EventSource` can stop delivering without erroring, so the client forces a reconnect when nothing arrives. ⚠️ The server keepalive must stay the named `sse:heartbeat` event (`cleanupDeadClients()`, sse-stream-manager.ts), never an SSE comment, which `EventSource` cannot observe; its no-op client listener must stay registered. ⚠️ Judge staleness only while `connected` and online (the loop breaker). ⚠️ The liveness stamp lives inside `addListener`. ⚠️ Clear the interval only at the top of `connectSSE()`, or intervals stack. ⚠️ The watchdog cannot see an attempt that never OPENS (no response headers: no `open`, no `error`, never `connected`), so each attempt is bounded by `SSE_CONNECT_TIMEOUT_MS` (15s, `CodemanSseStale.CONNECT_TIMEOUT_MS`) and then retried through `_handleSseConnectionFailure()`, the same backoff `onerror` uses. Its timer is cleared at the top of `connectSSE()` BEFORE the offline early return, on `open`, and in `_handleSseConnectionFailure()`; the timer and the handler both ignore an `EventSource` that has been replaced. The window `offline` handler leaves it running on purpose (`navigator.onLine` can report offline on a working network). Tests: `test/sse-connect-timeout.test.ts`. → [architecture-invariants#sse-staleness-watchdog](../../docs/architecture-invariants.md#sse-staleness-watchdog)
|
||||
|
||||
**Codex file previews** (`codexFilePreviewsEnabled`, App Settings > Header buttons > Codex files, per-device display key, absent from `SettingsUpdateSchema`, default OFF; `_codexFilePreviewsEnabled()` in app.js is the ONE reader): a session whose CLI publishes `transcript: 'codex-rollout'` opens the files Codex links in the file preview. The served CLI catalog (`window.__codemanCliCatalog`, server.ts) carries `transcript` for that check (`_supportsCodexResponseFiles()`), never a CLI id, and `_syncCliLaunchCatalog()` keeps it across a Settings refresh. A click on an underlined label in the pane is resolved against the conversation (`last-response?context=full`, cached per session while idle until the next `lastSubmitAt`, `_codexResponseMessages()`) and opens only a single, unambiguous, previewable file, else it is forwarded to Codex as before; this part is not behind the setting. Behind it are three things, all absent while it is off: the Response files header button (`toggleResponseViewer(true)`; marker `btn-response-files--hidden` for the setting, `hidden` for the capability, and `mobile.css` hides it on phones regardless, pinned by `test/mobile-header-buttons-policy.test.ts`), the Codex SIDEBAR file tabs (`codexSidebarFileRow()` in terminal-ui.js: with the setting on, `registerFilePathLinkProvider` drops its links on those rows, which are Codex chrome, and a click there is taken by `_codexTerminalLinkLabel()`; off, the row keeps its ordinary links and its click reaches Codex), and the Dock control. ⚠️ Docking MOVES `#filePreviewOverlay` out of its home and after `.terminal-wrap` (`_setFilePreviewDocked()`), only when the wrap is a direct child of `.main` without `.tiles-active`/`.webview-active` and the window is 1180px or wider; otherwise the preview floats. It moves back on close, on Escape inside it, when a split opens (`openSplitPane()` undocks first, or `closeSplitPane()` would remove the overlay with the split container) and when the setting is switched off. Tests: `test/codex-file-previews-setting.test.ts` (off-state of all three), `test/response-viewer-file-links.test.ts`, `test/terminal-link-provider-target.test.ts`, `test/terminal-touch-tap.test.ts`, `test/file-preview-window.test.ts`.
|
||||
**Codex file previews** (`codexFilePreviewsEnabled`, App Settings > Header buttons > Codex files, per-device display key, absent from `SettingsUpdateSchema`, default OFF; `_codexFilePreviewsEnabled()` in app.js is the ONE reader): a session whose CLI publishes `transcript: 'codex-rollout'` opens the files Codex links in the file preview. The served CLI catalog (`window.__codemanCliCatalog`, server.ts) carries `transcript` for that check (`_supportsCodexResponseFiles()`), never a CLI id, and `_syncCliLaunchCatalog()` keeps it across a Settings refresh. A click on an underlined label in the pane is resolved against the conversation (`last-response?context=full`, cached per session while idle until the next `lastSubmitAt`, `_codexResponseMessages()`) and opens only a single, unambiguous, previewable file, else it is forwarded to Codex as before. All of it is behind the setting (owner decision for 1.52.1: the in-pane click too, gated in `_handleDesktopTerminalClick()`), four things absent while it is off: that in-pane click (every click then goes on to Codex), the Response files header button (`toggleResponseViewer(true)`; marker `btn-response-files--hidden` for the setting, `hidden` for the capability, and `mobile.css` hides it on phones regardless, pinned by `test/mobile-header-buttons-policy.test.ts`), the Codex SIDEBAR file tabs (`codexSidebarFileRow()` in terminal-ui.js: with the setting on, `registerFilePathLinkProvider` drops its links on those rows, which are Codex chrome, and a click there is taken by `_codexTerminalLinkLabel()`; off, the row keeps its ordinary links and its click reaches Codex), and the Dock control. ⚠️ Docking MOVES `#filePreviewOverlay` out of its home and after `.terminal-wrap` (`_setFilePreviewDocked()`), only when the wrap is a direct child of `.main` without `.tiles-active`/`.webview-active` and the window is 1180px or wider; otherwise the preview floats. It moves back on close, on Escape inside it, when a split opens (`openSplitPane()` undocks first, or `closeSplitPane()` would remove the overlay with the split container) and when the setting is switched off. Tests: `test/codex-file-previews-setting.test.ts` (off-state of all three), `test/response-viewer-file-links.test.ts`, `test/terminal-link-provider-target.test.ts`, `test/terminal-touch-tap.test.ts`, `test/file-preview-window.test.ts`.
|
||||
|
||||
**Z-index layers** (keep new overlays consistent with this stack): local echo overlay (7; with local echo on it also draws the iOS IME composition preview, as an underlined tail after its pending text via `setComposition`), iOS IME composition preview span when local echo is off (6 inside `.xterm-helpers`, whose own z-index 5 is its EFFECTIVE layer, so it sits UNDER the overlay and must never be used while the overlay shows text), chat view (20, covering the terminal inside `.terminal-wrap`) and its Chat / Terminal switch (21, above it), terminal touch-selection bar (900, below floating agent windows), subagent windows + split picker menu + Tiles count menu (1000), mobile/tablet fixed header (1200), modals on ≤768px (1300, must beat the fixed header), log viewers (2000), connection-loss overlay (2500), image popups (3000), response viewer (5000, backdrop 4999), folder grid (5090, above the response viewer it opens from, below the file preview its tiles open), file-preview overlay (5100, must outrank the response viewer that launches it; DOCKED it is `z-index: auto`, page content beside the terminal, so it sits under every modal and the response viewer, pinned in `test/file-preview-window.test.ts`), toasts/path picker (10000+), custom-model center-status banner (10001; its `[hidden]` must re-assert `display: none` or `dismiss()` leaves an invisible click-blocker), custom-model swap-confirm/context-warning modals (10010). → [architecture-invariants#z-index-layers](../../docs/architecture-invariants.md#z-index-layers)
|
||||
|
||||
|
||||
@@ -503,8 +503,8 @@
|
||||
'Lifecycle Log': '生命周期日志',
|
||||
'Response Viewer': '回复查看器',
|
||||
'Codex files': 'Codex 文件',
|
||||
'Codex sessions: a Response files header button, Codex sidebar file tabs open in the preview, and a Dock control on file previews':
|
||||
'Codex 会话:标题栏的回复中的文件按钮、在预览中打开 Codex 侧边栏文件标签,以及文件预览上的停靠控件',
|
||||
'Codex sessions: underlined file names and Codex sidebar file tabs open in the preview, a Response files header button, and a Dock control on file previews':
|
||||
'Codex 会话:在预览中打开带下划线的文件名和 Codex 侧边栏文件标签、标题栏的回复中的文件按钮,以及文件预览上的停靠控件',
|
||||
'Attachments Button': '附件按钮',
|
||||
'Multi-monitor Button': '多显示器按钮',
|
||||
'Session Manager Button': '会话管理器按钮',
|
||||
|
||||
@@ -2255,7 +2255,7 @@
|
||||
<label class="set-chip" data-preview="header" data-preview-order="2" data-preview-text="3400 MHz"><input type="checkbox" id="appSettingsShowCpuMhz"><svg class="set-chip-ico" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg><span>CPU MHz</span></label>
|
||||
<label class="set-chip" data-preview="header" data-preview-order="3"><input type="checkbox" id="appSettingsShowRedrawButton"><svg class="set-chip-ico" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="1 4 1 10 7 10"/><polyline points="23 20 23 14 17 14"/><path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15"/></svg><span>Redraw Terminal</span></label>
|
||||
<label class="set-chip" data-preview="header" data-preview-order="4"><input type="checkbox" id="appSettingsShowResponseViewer"><svg class="set-chip-ico" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg><span>Response Viewer</span></label>
|
||||
<label class="set-chip" data-search="codex files response files sidebar file tabs dock preview" data-preview="header" data-preview-order="4.5" title="Codex sessions: a Response files header button, Codex sidebar file tabs open in the preview, and a Dock control on file previews"><input type="checkbox" id="appSettingsCodexFilePreviews"><svg class="set-chip-ico" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6M8 13h8m-8 4h6"/></svg><span>Codex files</span></label>
|
||||
<label class="set-chip" data-search="codex files response files sidebar file tabs dock preview" data-preview="header" data-preview-order="4.5" title="Codex sessions: underlined file names and Codex sidebar file tabs open in the preview, a Response files header button, and a Dock control on file previews"><input type="checkbox" id="appSettingsCodexFilePreviews"><svg class="set-chip-ico" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6M8 13h8m-8 4h6"/></svg><span>Codex files</span></label>
|
||||
<label class="set-chip" data-preview="header" data-preview-order="5"><input type="checkbox" id="appSettingsShowAwayDigestButton"><svg class="set-chip-ico" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 6h13"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M3 6h.01"/><path d="M3 12h.01"/><path d="M3 18h.01"/></svg><span>Away Digest</span></label>
|
||||
<label class="set-chip" data-preview="header" data-preview-order="6"><input type="checkbox" id="appSettingsShowSessionButton"><svg class="set-chip-ico" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="12 2 2 7 12 12 22 7 12 2"/><polyline points="2 17 12 22 22 17"/><polyline points="2 12 12 17 22 12"/></svg><span>Session Manager</span></label>
|
||||
<label class="set-chip" data-preview="header" data-preview-order="9"><input type="checkbox" id="appSettingsShowAttachmentsButton"><svg class="set-chip-ico" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg><span>Attachments</span></label>
|
||||
|
||||
@@ -6779,9 +6779,9 @@ Object.assign(CodemanApp.prototype, {
|
||||
|
||||
// Desktop counterpart of the touchend tap branch: hand-encode an SGR report
|
||||
// for a plain left-click when the server strips mouse DECSETs (see
|
||||
// _shouldReportMouseToCli). In a session whose CLI publishes a Codex rollout
|
||||
// transcript, a plain click on an underlined label (or, with the Codex files
|
||||
// setting on, on a sidebar file tab) is first resolved against the
|
||||
// _shouldReportMouseToCli). With the Codex files setting on, in a session whose
|
||||
// CLI publishes a Codex rollout transcript, a plain click on an underlined label
|
||||
// or on a sidebar file tab is first resolved against the
|
||||
// conversation (_openCodexTerminalResponseFile): a single previewable file
|
||||
// opens in the preview, anything else is forwarded as the SGR report below
|
||||
// once the lookup settles. Every skip below is a click that already has
|
||||
@@ -6818,7 +6818,12 @@ Object.assign(CodemanApp.prototype, {
|
||||
this._codexTerminalLinkClicks ??= new WeakMap();
|
||||
const click = Symbol();
|
||||
this._codexTerminalLinkClicks.set(terminal, click);
|
||||
const link = this._supportsCodexResponseFiles?.(sessionId) && this._codexTerminalLinkLabel(terminal, clientX, clientY);
|
||||
// Behind the Codex files setting (owner decision for 1.52.1): off, every click goes on to
|
||||
// Codex as before, an underlined label in the pane included.
|
||||
const link =
|
||||
this._codexFilePreviewsEnabled?.() &&
|
||||
this._supportsCodexResponseFiles?.(sessionId) &&
|
||||
this._codexTerminalLinkLabel(terminal, clientX, clientY);
|
||||
if (!link) {
|
||||
forward();
|
||||
return;
|
||||
|
||||
@@ -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')!;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in new issue
Block a user