diff --git a/docs/wiki/Settings-Reference.md b/docs/wiki/Settings-Reference.md index 1fa1fea3..6d9076fc 100644 --- a/docs/wiki/Settings-Reference.md +++ b/docs/wiki/Settings-Reference.md @@ -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 diff --git a/docs/wiki/Working-With-Files.md b/docs/wiki/Working-With-Files.md index 0029cef1..7dc00e11 100644 --- a/docs/wiki/Working-With-Files.md +++ b/docs/wiki/Working-With-Files.md @@ -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. diff --git a/src/web/CLAUDE.md b/src/web/CLAUDE.md index 4b96928a..13772d87 100644 --- a/src/web/CLAUDE.md +++ b/src/web/CLAUDE.md @@ -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) diff --git a/src/web/public/i18n.js b/src/web/public/i18n.js index 8280555a..e9b4a34a 100644 --- a/src/web/public/i18n.js +++ b/src/web/public/i18n.js @@ -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': '会话管理器按钮', diff --git a/src/web/public/index.html b/src/web/public/index.html index 8cd7d94b..d2e39a62 100644 --- a/src/web/public/index.html +++ b/src/web/public/index.html @@ -2255,7 +2255,7 @@ - + diff --git a/src/web/public/terminal-ui.js b/src/web/public/terminal-ui.js index 9d3969dd..9f626492 100644 --- a/src/web/public/terminal-ui.js +++ b/src/web/public/terminal-ui.js @@ -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; diff --git a/test/codex-file-previews-setting.test.ts b/test/codex-file-previews-setting.test.ts index f1881392..bb64b6f2 100644 --- a/test/codex-file-previews-setting.test.ts +++ b/test/codex-file-previews-setting.test.ts @@ -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(` @@ -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')!; diff --git a/test/terminal-touch-tap.test.ts b/test/terminal-touch-tap.test.ts index dea7c773..a00f55e5 100644 --- a/test/terminal-touch-tap.test.ts +++ b/test/terminal-touch-tap.test.ts @@ -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();