Skip to content

Open Codex file links in a docked preview (COD-152) - #850

Merged
Ark0N merged 5 commits into
Ark0N:masterfrom
aakhter:pr/COD-152-sidebar-previews
Dec 3, 2026
Merged

Ark0N merged 5 commits into
Ark0N:masterfrom
aakhter:pr/COD-152-sidebar-previews

Conversation

@aakhter

@aakhter aakhter commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Open a Codex transcript file link or a native sidebar filename in Codeman’s existing file preview when the session transcript identifies one matching file. For shortened tabs, match both visible ends of the filename. Preserve the native click when more than one linked file matches.

  • Add a Response files picker and a dock beside the terminal. On narrower screens the preview floats. The existing preview router still handles path authorization and file rendering.

  • Prevent the generic terminal link detector from treating the suffix of a filename with spaces as a separate file.

  • Restore More in the normal response viewer and return keyboard focus to the originating pane when appropriate.

  • Keep the preview floating in split, tiled, web-tab, and narrow layouts. Resolve relative links against the pane's current directory and use the published transcript capability.

Open decisions

The current behavior is unchanged pending maintainer review. This includes the Response files button on phones, whether matching Codex sidebar clicks bypass Codex, and the Dock control on file previews.

Verification

  • 141 targeted tests passed after the review fixes. Coverage includes sidebar labels and link suppression, native fallback and stale clicks, the file picker, and dock lifecycle with Escape and split teardown.
  • Typecheck, lint, formatting, lockfile, public assets, and frontend dead-code checks passed.
  • Chromium with stock Codex 0.171.0 verified an image from a native sidebar tab, a Word PDF from the transcript, and another image from the Response files picker before this follow-up.

A synthetic Word document docked beside the Codex terminal

@Ark0N

Ark0N commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Thanks a lot for this! With this PR a Codex session can open the files it links (from the transcript, a sidebar tab or the new Response files list) in Codeman's own preview, docked beside the terminal. The transcript lookup is well guarded: it refuses ambiguous labels, ignores stale clicks and renders inside a template. A few things need to change before it can go in.

Needs a fix

  1. src/web/public/app.js:3388: moreBtn.style.display = data.hasContext ? '' : 'none' hides the More button in the Last Response viewer for every Claude and Codex session. Only the DeepSeek reader and the pane-segmenter paths send hasContext (src/web/routes/session-routes.ts:3253, :3276). I ran toggleResponseViewer() against a Claude-shaped reply, and More shows on master but is hidden on this branch. Your CSS rule at styles.css:13650 already hides More in files-only mode, so please restore moreBtn.style.display = '' and drop the comment at app.js:3391.
  2. src/web/public/panels-ui.js:3770: while a split pane is open, .terminal-wrap sits inside .terminal-split-container, so terminalWrap.after(overlay) puts the preview in there too. closeSplitPane() (terminal-split.js:261-267) then removes that container and takes #filePreviewOverlay out of the document with it, and every later preview renders into the detached node until a reload. Please move the node only when the wrap is a direct child of .main and the dock will actually apply (1180px or wider, no tiles, no web tab), and open the preview floating otherwise.
  3. Please add tests for the parts that carry the most risk: codexSidebarFileRow() and the link suppression built on it (terminal-ui.js:506-575, :2556-2566), the fallback and stale-click paths of _openCodexTerminalResponseFile, the dock lifecycle (dock, undock on close, Escape, and the split case above) and toggleResponseViewer(true).

Smaller things

  1. app.js:3216: closeResponseViewer() now focuses this.terminal every time. On a phone this raises the keyboard when someone picks a file from Response files or taps close, and when split Pane B has focus it moves focus to Pane A. Please gate it on _shouldFocusTerminalForTabSwitch() and give focus back to the pane that had it.
  2. app.js:3239 and :3273: please resolve relative targets with this._resolveLinkedFilePath(path, sessionId), the way the Response Viewer's click handler does (app.js:2873), so a relative link follows the pane directory here as well.
  3. Please key the new mode === 'codex' checks (app.js:3309, :6575, terminal-ui.js:2556, :6631) on a published capability instead of the CLI id, per the CLI-registry rule in CLAUDE.md. The server already picks the Codex reader by capabilities.transcript === 'codex-rollout'.
  4. app.js:3229: in sidebar mode, please prefilter messages on the file name (or the two visible ends of a shortened tab) before rendering markdown, so not every message in the conversation gets rendered.
  5. Nits: #responseViewerCopy in styles.css:13650 matches nothing (npm run check:frontend-dead reports it). The new strings need zh-CN entries in i18n.js, as their neighbours have. Please revert the unrelated re-wrap at test/mobile-header-buttons-policy.test.ts:223-225, and add a short note to docs/wiki/Working-With-Files.md ("Clicking a path") about Codex links, Response files and Dock.

Open question (not decided yet)

src/web/CLAUDE.md allows one header button on phones, File Viewer, and only as an opt-in setting. This PR adds Response files to that allowlist and shows it for every Codex session on every device, with no setting. The description says the button appears once Codex links a file, but the code only checks the session mode. The other two behaviours raise the same question: a matching click on a Codex sidebar tab no longer reaches Codex, and the Dock button appears on every file preview. Whether these ship as they are or behind a setting is still open, so please hold off on reworking that part until it is settled.

Once 1 to 3 are in and the open question is settled, this can go through another review.

@Ark0N

Ark0N commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks for the thorough follow-up! With this PR a Codex session can open the files it links (from a link in the pane, a sidebar tab or the Response files list) in Codeman's own preview, docked beside the terminal. This round fixes every numbered item from the first review: More is back, the dock no longer ends up inside the split container, focus returns to the right pane, relative paths follow the pane directory, the checks key on transcript === 'codex-rollout', the sidebar lookup prefilters before rendering, and the tests, zh-CN strings and wiki note are in. A few things still need a change.

Needs a fix

  1. test/terminal-touch-tap.test.ts:496 fails at the PR head (_openCodexTerminalResponseFile is called 0 times). The test still expects the old 7-argument call with session third, but the function now takes 6 (terminal-ui.js:6642). Its harness also loads only terminal-ui.js, so _supportsCodexResponseFiles is undefined and the click gets forwarded. Please stub app._supportsCodexResponseFiles = () => true and drop session from the expected arguments.
  2. src/web/server.ts:2097 adds transcript to the served catalog, and test/render-index-html.test.ts:373-379 pins the exact key list, so that test now fails (it passes on master). Please add 'transcript' to the list and assert transcript: 'codex-rollout' on the codex entry. That also gives the server side of the capability a test.
  3. src/web/public/styles.css:11939: the docked overlay becomes position: relative but keeps the base z-index: 5100, and nothing above it creates a stacking context. In Chromium with the real stylesheet, a docked preview sits above every modal backdrop (1000) and over the response viewer sheet (5000). To see it, open a file from Response files, then press Response files again: the sheet's close button is under the preview. Please set z-index: auto (or a small value) in the docked rule and pin it in test/file-preview-window.test.ts.

Smaller things

  1. terminal-ui.js:6614-6643: a double-click on an underlined label opens the preview. The second click returns at ev.detail !== 1 before it can supersede the first, and stillCurrent() does not re-check the selection. Adding !terminal.hasSelection?.() to stillCurrent covers it.
  2. terminal-ui.js:6575: every click on underlined text in a Codex pane fetches last-response?context=full, and the server reads and parses the whole rollout file before the click reaches Codex. Please cache the parsed messages per session until the next turn, or add a comment explaining why the cost is acceptable.
  3. Please add a short paragraph to src/web/CLAUDE.md covering the new mechanisms: the overlay node moving into .main and back (and when it may not), the Codex sidebar link suppression in registerFilePathLinkProvider, transcript in the served catalog, and the docked layer in the Z-index list.
  4. Nits: the Response files rows are <a href="#"> (app.js:3302), so with <base href="/"> a middle-click opens /#; a <button> fits better. The comment above _handleDesktopTerminalClick (terminal-ui.js:6597) still describes only the SGR forwarding.

Still open (not decided yet)

The question from the first review hasn't changed and is still open. It covers three things: whether the Response files button shows on phones and for every Codex session without a setting (test/mobile-header-buttons-policy.test.ts:38 adds it to the phone allowlist, while src/web/CLAUDE.md allows only File Viewer there, as an opt-in), whether a matching click on a Codex sidebar tab may bypass Codex, and whether the Dock control appears on every file preview. Please keep holding off on that part until it is settled.

Once 1 to 3 are in, this can go through another review. 4 to 7 can come along in the same push.

@Ark0N

Ark0N commented Nov 27, 2026

Copy link
Copy Markdown
Owner

The open question is decided: one setting, off by default.

The three behaviours go behind a single opt-in setting, a per-device one like the other header buttons (a display key in settings-ui.js):

  • the Response files button in the header,
  • taking a click on Codex's own sidebar file tab instead of passing it to Codex,
  • the Dock button on file previews.

With the setting off, nothing changes for anyone: no new header button, clicks reach Codex as before, and the preview has no Dock button. On phones the header keeps its rule (one opt-in header button, the File Viewer), so Response files stays out of the phone header even with the setting on.

Please describe the setting in docs/wiki/Settings-Reference.md and add a test that the three behaviours are absent while it is off.

The items from the last review stand as written: the two tests that fail at the PR head (your new desktop-click test and the render-index-html catalog key test), the docked preview's z-index above modals and the response viewer, and the smaller ones. Once those and the setting are in, this can go through its final review. Thanks for the careful follow-ups so far.

The Response files header button, taking a click on a Codex sidebar file
tab (and the link suppression on those rows) and the Dock control on file
previews now sit behind one per-device setting, codexFilePreviewsEnabled
(App Settings > Header buttons > Codex files), default off. With it off
none of the three exists, and Response files stays off phones even with
it on.

Also from the second review: the docked preview is z-index auto so it
sits under modals and the response viewer, a double-click no longer
opens the preview, the parsed conversation is cached per idle session
until its next turn, the Response files rows are buttons, and the two
tests that failed at the previous head pass. Documented in
Settings-Reference, Working-With-Files and src/web/CLAUDE.md.
@aakhter

aakhter commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for settling the open question. This push puts the three behaviours behind one setting and covers every item from the second review. Everything is in e3c156e6e.

The setting

  • codexFilePreviewsEnabled (App Settings > Header buttons > Codex files): per device, default off. It is a display key in settings-ui.js, stripped from the save PUT and absent from the .strict() schema, like Away Digest and Split. One reader, _codexFilePreviewsEnabled() (app.js:3238).
  • While it is off:
    • Response files keeps its btn-response-files--hidden marker (_syncResponseFilesButton(), app.js:3249), and toggleResponseViewer(true) returns before any fetch (app.js:3363).
    • A click on a Codex sidebar file tab is not taken (terminal-ui.js:6558), so it reaches Codex. The sidebar link suppression in registerFilePathLinkProvider is off as well (terminal-ui.js:2558), so those rows keep master's links.
    • The preview has no Dock button (panels-ui.js:3920) and never docks (panels-ui.js:3771). Switching the setting off undocks an open preview.
  • Phones: mobile.css hides .btn-response-files in the 599px block. The policy test's phone allowlist is back to File Viewer alone, and btn-response-files is in KNOWN_PHONE_HIDDEN.
  • test/codex-file-previews-setting.test.ts loads the real constants.js, app.js, settings-ui.js, panels-ui.js and terminal-ui.js with nothing stored and checks that all three behaviours are absent. Each check also runs once with the setting on, so it cannot pass vacuously. The file also pins the display key, the PUT strip, the schema absence, the chip wiring and the phone hide. Off-state tests sit beside each surface's own tests too.
  • Docs: docs/wiki/Settings-Reference.md (chip list plus a paragraph), docs/wiki/Working-With-Files.md, and a new src/web/CLAUDE.md paragraph.

Second review

  1. test/terminal-touch-tap.test.ts: the test stubs _supportsCodexResponseFiles and expects the 6-argument call.
  2. test/render-index-html.test.ts: transcript is in the key list, and the codex entry is asserted as transcript: 'codex-rollout'.
  3. The docked rule sets z-index: auto (styles.css:11949), pinned in test/file-preview-window.test.ts ("sits in page flow when docked"). The Z-index lists in src/web/CLAUDE.md and docs/architecture-invariants.md name the docked layer.
  4. stillCurrent also requires !terminal.hasSelection?.() (terminal-ui.js:6666). The touch-tap test takes the stillCurrent it was handed and checks that it goes stale once a selection exists.
  5. The parsed messages are cached per session by _codexResponseMessages() (terminal-ui.js:6582). The cache holds one entry, used only while the session is idle and its lastSubmitAt is unchanged; a busy session always fetches. Pinned in test/terminal-link-provider-target.test.ts ("caches the parsed conversation per session until its next turn").
  6. src/web/CLAUDE.md has a Codex file previews paragraph. It covers the overlay moving next to .terminal-wrap and back (and when it may not), the sidebar link suppression, transcript in the served catalog, and the docked layer.
  7. The Response files rows are <button type="button"> (app.js:3328), styled as links. test/response-viewer-file-links.test.ts asserts that no <a> is left. The comment above _handleDesktopTerminalClick now describes the Codex lookup before the SGR forwarding.

Left to you

A click on a label Codex underlined in the pane (not the sidebar) still opens the preview with the setting off. Your list named the button, the sidebar tab and Dock, and that click is the main feature of the PR, so I left it ungated. If you want it behind the setting too, it is one more check in _handleDesktopTerminalClick.

Evidence

  • Mutations: I reverted 13 guards one at a time (the setting reader, the dock gate, the Dock button's hidden, the sidebar click gate, the sidebar link suppression gate, the files-only gate, the header marker, the phone hide, the docked z-index, the double-click selection check, the message cache, the button rows, the served transcript). Each one fails at least one test (1 to 5 per mutation).
  • Gates: typecheck, lint, format:check, check:frontend-syntax, check:public-assets, check:browser-excludes and check:frontend-dead pass. npm test: 764 files passed, 1 skipped (17353 tests passed, 13 skipped).

@Ark0N

Ark0N commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Thanks for the careful third round! This PR lets a Codex session open the files it links in Codeman's own file preview. Clicking an underlined file name in the pane does that for everyone. The new per-device Codex files setting (off by default) adds a Response files header button, takes clicks on Codex's sidebar file tabs, and adds a Dock button that puts the preview beside the terminal.

Everything from the last two reviews is in. The two tests that failed now pass, and the docked preview sits under modals and the response viewer. The double-click and caching fixes, the src/web/CLAUDE.md paragraph, the zh-CN strings and the button rows are done, and so is the setting, with its off-state test and Settings-Reference entry. CI is green, and typecheck, lint, format, frontend syntax, public assets, frontend dead-code and the full test suite pass locally as well.

One small thing is left, and I will fix it at merge time:

  • src/web/public/settings-ui.js:4852: changing the setting syncs the Response files button and undocks a docked preview, but the Dock button's hidden attribute is only set when a preview opens (src/web/public/panels-ui.js:3920). With a preview open, turning the setting off leaves a Dock button that does nothing, and turning it on shows no Dock button until the next preview opens. Setting filePreviewDockBtn.hidden next to the _syncResponseFilesButton() call fixes both.

Thanks again for sticking with this through three rounds.

@Ark0N
Ark0N merged commit ab5f197 into Ark0N:master Dec 3, 2026
2 checks passed
Ark0N pushed a commit that referenced this pull request Dec 3, 2026
The Dock button's hidden attribute was set only when a preview opened, so
with a preview open, switching Codex files off left a Dock button that did
nothing and switching it on showed none until the next preview.
applyHeaderVisibilitySettings() now sets it beside the Response files
button, and a test flips the setting with a preview open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ark0N pushed a commit that referenced this pull request Dec 3, 2026
Replaces the four PR changesets (claude-starts-under-root,
installer-headless-sudo, trusted-proxy-sign-in, upload-html-documents)
and names #850, #859, #860 and #866, which brought none. Patch:
#854's changeset asked for minor, which is the owner's call at COM.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ark0N pushed a commit that referenced this pull request Dec 3, 2026
…ing 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>
@Ark0N

Ark0N commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Merged, and shipped in Codeman 1.52.1.

Two things changed at merge time:

  1. The Dock fix from the last review: switching Codex files on or off now shows or hides the Dock button of a preview that is already open (applyHeaderVisibilitySettings()), with a test.
  2. Your open question got an answer before the release: the click on a file name Codex underlined in the pane is behind the setting too. _handleDesktopTerminalClick() asks _codexFilePreviewsEnabled() first, so with the setting off every click in a Codex pane goes to Codex as before. The chip's tooltip, the wiki, src/web/CLAUDE.md and the off-state test now cover four behaviours instead of three.

Thank you for sticking with this through three rounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants