Skip to content

Yippee-ki-yay, maintainer: auto-collapse long code blocks + linkify file paths#3

Open
philipmaymin wants to merge 1 commit into
inceptel:mainfrom
philipmaymin:share-upstream-20260419
Open

Yippee-ki-yay, maintainer: auto-collapse long code blocks + linkify file paths#3
philipmaymin wants to merge 1 commit into
inceptel:mainfrom
philipmaymin:share-upstream-20260419

Conversation

@philipmaymin

Copy link
Copy Markdown

Come out to the coast, we'll get together, have a few laughs.

Two small MessageView.tsx tweaks from a downstream fork, submitted for cherry-pick. No backend changes. CSS uses existing theme vars from the theme refactor.

1. Auto-collapse long code blocks — "Welcome to the party, pal"

You know what's worse than Hans Gruber? Scrolling past a 500-line JSON dump to get back to the conversation.

collapseCodeBlocks(el) runs after markdown rendering. Any <pre> with >=25 lines gets:

  • max-height ~360px with a soft fade at the bottom
  • a "Show N more lines" button that toggles to "Collapse"

Under 25 lines: renders as before. No harm, no foul.

Why it's a good default: tool output dumps are disproportionately common in Claude transcripts. Collapsing by default keeps the transcript scrollable, full content still one click away.

2. Linkify absolute file paths — "Now I have a file path. Ho-ho-ho."

Claude constantly name-drops paths in prose: "I modified /home/user/project/src/foo.ts" or "logs at /var/log/app.log". Today they render as plain text. Hans Gruber would be unimpressed.

fixLinks(el, onImageClick) now walks text nodes and linkifies absolute paths matching /home|/opt|/tmp|/var|/etc|/usr|~/. Routed through the existing /api/file?path=... endpoint (already added in the PDF viewer commit).

Image extensions (png/jpg/jpeg/gif/webp/svg/bmp) get an inline preview below the link, click-to-zoom via the lightbox.

Skips: text inside <pre><code> (fenced code stays as code); existing anchors (no double-linking). Inline <code> stays eligible so `path in backticks` remains clickable.

Why it's a good default: zero-friction terminal-to-file navigation. Image auto-preview is especially nice for generated screenshots/plots. Nakatomi Plaza-tier UX upgrade for near-zero code.

Scope

  • Single file: frontend/src/components/MessageView.tsx
  • Two new helpers + wired into the two existing markdown ref callbacks
  • Small CSS using --bg-secondary, --border-medium, --link, --bg-surface

Built clean against origin/main (c23c762).

Held back (not in this PR)

Downstream has opinionated stuff that's staying put: a single-user server-single.js behind Authelia, full-text session search, a staged-update flow, a cwd/model/token status bar, a Claude-question popup panel, terminal copy/paste toolbar, iOS keyboard fixes. If any of those sound interesting, happy to split further.


Submitted by john maclaine — just a beat cop from NYPD, wrong place, wrong time, wrong fork account. Come out to the Coast, we'll cherry-pick a few commits, have a few laughs.

Yippee-ki-yay, maintainer.

Two small UX tweaks to MessageView that have been helpful in daily use.
Posting them so the project can cherry-pick either or both if they fit.

1. collapseCodeBlocks
   Walks rendered <pre> blocks after markdown rendering. Any block with >=25
   lines collapses to a max-height of ~360px with a soft fade overlay, and
   gets a "Show N more lines" button that toggles to "Collapse". This keeps
   the transcript skimmable when tool output dumps a long file.

   Uses existing theme CSS vars (--bg-secondary, --border-medium, --link,
   --bg-surface) so it inherits whatever palette is active.

2. fixLinks enhancement
   The original fixLinks only retargeted existing <a> to open in a new tab.
   This version also walks text nodes and linkifies absolute paths matching
   /home|/opt|/tmp|/var|/etc|/usr|~/, routing them through /api/file (the
   endpoint already added in the PDF viewer / file-serving commit).

   For image extensions (png/jpg/jpeg/gif/webp/svg/bmp) it also inserts an
   inline <img> preview under the link, clickable to open the lightbox.
   Non-image paths just become normal target=_blank links. Skips text
   inside code blocks and existing anchors so it won't double-link.

No backend changes needed. Both features piggyback on /api/file which
already exists upstream. CSS is scoped and uses existing theme vars.

Author: john maclaine
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.

1 participant