Skip to content

Make Markdown files readable: wrap toggle, width, links, images, and a Refresh that re-reads files - #120

Merged
michal-wrzosek merged 2 commits into
mainfrom
worktree-markdown-viewer-fixes
Oct 14, 2026
Merged

michal-wrzosek merged 2 commits into
mainfrom
worktree-markdown-viewer-fixes

Conversation

@michal-wrzosek

@michal-wrzosek michal-wrzosek commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Four fixes to reading Markdown files in GitWarren.

What changed

Wrap lines works on Markdown. Prose files were always wrapped no matter what the button said, so the button did nothing on them. Prose still starts wrapped, but a second stored switch (prose-wrap, default on) sits beside the existing diff-wrap, and the button sets both. On Browse files and the repository's Files tab the button shows and flips the open file's state. In Files changed it shows the code switch. Anyone who has already saved diff-wrap sees no difference until they press the button. (lib/line-wrap.ts)

The repository's Files tab is wide. It was capped at max-w-3xl (768px) like the list screens. It now gets the same max-w-[110rem] as a review's Browse files tab, because it shows the same tree and the same file card. (App.tsx)

Links to local files work in the preview.

  • [x](docs/guide.md) opens that file in the app. The move goes into history, so Back returns to the page the link was on.
  • #heading scrolls the document, and other.md#heading opens the other file and lands on that heading. Headings get GitHub-style ids.
  • A link to a folder (docs/) opens the folder's README.
  • In a review's diff preview, a link opens the file in Browse files.
  • URLs still open in the browser. A relative path that climbs out of the repository shows as dotted text instead of a link that does nothing.

Images draw. The main cause: READMEs, including ours, draw every picture with HTML <img> tags, often inside <a href>. Raw HTML is never rendered here, so react-markdown showed those tags as literal text. A remark plugin now reads <img> (only src, alt and a pixel width) and <a href> into ordinary Markdown images and links. No HTML is rendered, and both still go through the existing img/a overrides, so only repository files are drawn and anything remote stays a link. Root-relative /assets/x.png now resolves from the repository root, as it does on GitHub. (remark-document.ts, document-links.ts)

Screenshots

GitWarren's own README in a repository's Files tab: full width, and the logo (at its width="112") and screenshot draw. Before this change they showed as literal <img …> text:

README preview

A Markdown source view with Wrap lines on (the default for prose):

Source wrapped

…and with Wrap lines off, which used to be impossible:

Source unwrapped

After clicking docs/guide.md in a review's diff preview: Browse files opens with the guide, and its ../ and sibling images draw:

Browse from diff link

Phone (390×844, touch emulated). The README preview with an HTML <img> drawn, and nothing scrolls sideways:

…and after tapping the Guide link:

How it was checked

  • npm run typecheck, eslint . and npm test all pass (774 tests, 0 failures). 14 of them are new, in document-links.test.ts.
  • In the built app over CDP, with a scratch database and a scratch repository:
    • All image forms draw: HTML, relative, ./, ../ and /root.
    • Links work: #far-section scrolls, docs/guide.md#costs-and-budget opens and lands on the heading, Back returns, and docs/ opens docs/README.md.
    • Wrap toggles a Markdown source view: scroll width goes 1246 → 2745 and back.
    • The Files tab now uses the full 1600px window.
    • At 390px nothing scrolls sideways, and a tapped link opens.

Refresh re-reads the files too

Found while testing this. On Files changed, Refresh re-read only the diff. Each file's text (behind the expanders and the Markdown preview) and each image stayed cached, so after a new commit the preview compared the new diff against old text. The repository Files tab's Refresh had the same gap: it re-read the file list but not the open file.

Each review and repository now has a read generation that is part of its file and image cache keys. Refresh bumps it once the new diff (or list) has arrived, so a preview never pairs a new file with an old diff. Files on screen are read again and keep showing their previous content until the new read lands, so nothing flashes. Files opened later read fresh. (use-reviews.ts)

Checked in the app:

  • Review preview: after a new commit on the branch and one Refresh, the preview shows the new text. Before this change it didn't.
  • Repository Files tab: after an on-disk edit to the open file and one Refresh, the new text appears.

🤖 Generated with Claude Code

michal-wrzosek and others added 2 commits October 14, 2026 11:00
- The Wrap lines button now works on Markdown and other prose. Prose
  still starts wrapped, but a second stored switch (prose-wrap) lets
  the button unwrap it; the button sets both switches.
- A repository's Files tab gets the same wide layout as a review's
  Browse tab instead of the list screens' 768px.
- Links in the Markdown preview to other files of the repository open
  them in the app (Back returns), #heading links scroll, a folder link
  opens its README, and links in a review's diff preview open the file
  in Browse files.
- HTML <img> and <a href> tags, which READMEs use for every picture,
  are read into ordinary images and links instead of showing up as
  literal tags. Root-relative /paths resolve from the repository root,
  and a numeric width is honoured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After a new commit, Refresh on Files changed brought back a new diff but
left every file's text and image in the cache as it was, so a Markdown
preview compared the new diff against old text. The repository Files
tab's Refresh had the same gap for the open file.

Each review and repository now has a read generation that is part of
its file and image cache keys. Refresh bumps it once the new diff (or
file list) has arrived. Files on screen are read again and keep showing
the previous answer until the new one lands; files opened later read
fresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michal-wrzosek michal-wrzosek changed the title Make Markdown files readable: wrap toggle, width, links and images Make Markdown files readable: wrap toggle, width, links, images, and a Refresh that re-reads files Oct 14, 2026
@michal-wrzosek
michal-wrzosek marked this pull request as ready for review October 14, 2026 09:18
@michal-wrzosek
michal-wrzosek merged commit 99fac3d into main Oct 14, 2026
5 checks passed
@michal-wrzosek
michal-wrzosek deleted the worktree-markdown-viewer-fixes branch October 14, 2026 09:18
@michal-wrzosek michal-wrzosek mentioned this pull request Oct 14, 2026
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