From 79b9181932859d72db66c394b2ab6335fda53b3c Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Tue, 13 Oct 2026 17:19:02 +0200 Subject: [PATCH] feat(file-preview): open markdown clicked in the terminal in the rendered viewer An in-workspace .md path clicked in the terminal went to the log viewer (tail -f, a "streaming" header over raw text), because md was kept out of FILE_PREVIEW_EXTENSIONS on purpose; every other surface already rendered it. Owner decision 2026-10-13: markdown is a document to read, so md and markdown join FILE_PREVIEW_EXTENSIONS and a click or tap opens the file preview, rendered by default with the MD pill for source. The main pane, every grid tile and the split's Pane B share the link provider, so all of them route the same way. Other in-workspace text (.log, .txt, .json, code) keeps the log viewer and its live follow. FILE_PATH_LINK_PATTERN now also links `.markdown` and `.htm`, which were not clickable at all. Tests: file-preview-markdown.test.ts now asserts md and markdown ARE routed to the preview (and plain text is not); terminal-touch-tap pins a tapped .md, .markdown and .html opening the preview while .log, .txt and .json open the log viewer, and a tile-registered provider routing the same way against the tile's own session. Docs: CLAUDE.md, the architecture invariants and the wiki (Working With Files, Mobile Guide). Co-Authored-By: Claude Opus 5.5 (1M context) --- CLAUDE.md | 2 +- docs/architecture-invariants.md | 4 +-- docs/wiki/Mobile-Guide.md | 5 ++-- docs/wiki/Working-With-Files.md | 7 ++--- src/web/public/constants.js | 9 +++++-- test/file-preview-markdown.test.ts | 13 ++++++--- test/terminal-touch-tap.test.ts | 42 ++++++++++++++++++++++++++++++ 7 files changed, 68 insertions(+), 14 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index f4e720bf..26e44cd2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -305,7 +305,7 @@ Codeman is a Claude Code session manager with web interface and autonomous Ralph **File Viewer edit mode** (issue #212): the file-preview overlay edits workspace text files in place — `GET .../file-content?edit=1` + `PUT /api/sessions/:id/file-content`, policy in `src/config/file-editing.ts`. This is a **third file surface and the only one that WRITES**: read-path confinement (realpath + workspace + ownership) plus sensitive/blocked/`.git` denies and an extension **allowlist**; writes are `wx`-temp + rename (no `O_CREAT` anywhere = edit-in-place is structural); optimistic concurrency via sha256 `baseHash` → 409. ⚠️ `edit=1` never truncates and the client must never save a plain-preview buffer (the 500-line truncation would silently delete the rest). ⚠️ CRLF/UTF-8 guards: EOL re-applied server-side, non-UTF-8 refused via round-trip compare. → [architecture-invariants#file-viewer-edit-mode](docs/architecture-invariants.md#file-viewer-edit-mode), `docs/file-viewer-edit-plan.md` -**File Viewer text view: rendered markdown + Lines/Wrap toggles** (`_renderFilePreviewText()` in panels-ui.js): a `.md`/`.markdown` opens RENDERED by default with an `MD` pill back to source; the plain-text view has `Lines` (CSS-counter gutter) and `Wrap` toggles. ⚠️ ONE markdown pipeline: the viewer calls `_renderMarkdown(text, { breaks: false })` (marked + the DOMPurify allowlist, the Response Viewer's; chat keeps the default `breaks: true`, a file must not turn every hard wrap into a `
`) and binds the Response Viewer's click delegate (`_bindResponseViewerInteractions`) on the preview body for code-copy buttons and path links; never a second parser or handler. ⚠️ The document is built inside a `