Skip to content

fix(web): a markdown table column no longer shrinks to one letter per line - #866

Merged
Ark0N merged 3 commits into
Ark0N:masterfrom
irisitymichaelgrundberg:fix/table-cell-wrap
Dec 3, 2026
Merged

Ark0N merged 3 commits into
Ark0N:masterfrom
irisitymichaelgrundberg:fix/table-cell-wrap

Conversation

@irisitymichaelgrundberg

@irisitymichaelgrundberg irisitymichaelgrundberg commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

In the Response Viewer and the File Viewer's markdown view, a table can squeeze one of its columns to a single letter per line. It happens when the header cells fill the width, and the column under an empty header is the one that shrinks.

The screenshots show a sample table rendered with the real stylesheet in Firefox, before and after this change.

Before
image

After
image

Cause

Rendered markdown sets overflow-wrap: anywhere on .rv-text so that a long path in prose wraps, and table cells inherit it. With anywhere, the browser counts every letter as a break point when it computes a cell's minimum width. The header cells are white-space: nowrap, so they claim their full width, and the remaining column gets only its minimum width, which is one letter.

Fix

Table cells now set overflow-wrap: break-word, so a cell wraps between words and its column is never narrower than its longest word. Prose outside tables keeps anywhere. In the sample table, the label column went from 35 px, one letter per line, to 75 px, wrapped between words.

That alone lets one long token set its column's width. Chromium finds no break point inside a URL, an identifier or a hash, because it never breaks a line after /, so a table holding one scrolled sideways on a phone. Inline code and links in a cell therefore keep breaking anywhere, as Codeman's linked paths (a.rv-path) already do through word-break: break-all. Breaking anywhere lets a column shrink again, so a cell that holds inline code or a link gets a minimum width of 6em, about ten characters. Other cells keep their natural width, so a narrow column such as row numbers stays narrow.

In a 360 px column in Chromium and Firefox, tables with URLs, identifiers and hashes fit as they did on master, and a column of linked paths went from 48 px to 80 px.

Two costs remain:

  • A column that holds only short code, such as -v, grows from 52 px to 80 px.
  • CSS can't tell an autolink from a link with a prose label, so a long word in a link label can break mid-word in a narrow column. A path link's label (.rv-path-link) is the exception and keeps breaking between words.

The PR has three commits. The second and third came out of reviews of the first.

Tests

test/response-viewer-table-cells.test.ts pins the declarations: break-word on the cells, anywhere on inline code and links in a cell, the minimum width on a cell that holds one, and anywhere on prose. It reads every rule that names a selector, in styles.css and mobile.css, so a later override fails it. jsdom has no layout, so the test can't measure the columns; the widths above come from headless Firefox and Chromium. Against master's stylesheet, 5 of its 6 cases fail.

I also checked the fix in my own Firefox, on the table where I first saw the problem. Its label column now wraps between words.

The label column is still narrow, because the headers never wrap. Letting headers wrap would change how every table looks, so this PR leaves them alone. Ark0N, say if you'd like that changed too.

🤖 Generated with Claude Code

… line

Rendered markdown sets `overflow-wrap: anywhere` so that a long path in
prose wraps, and table cells inherited it. With `anywhere`, the browser
counts every letter as a break point when it computes a cell's minimum
width. The header cells never wrap, so in a table whose headers fill the
width, the column under an empty header got only its minimum width, and
its labels stood one letter per line.

Table cells now use `overflow-wrap: break-word`. A cell still breaks a
word that is wider than its column, but its minimum width is its longest
word. In Chromium, the label column of a five-column table went from
36 px to 74 px and wraps between words. A table with an unbreakable
cell wider than the view scrolls sideways inside its wrapper, which the
wrapper already allows.

The Response Viewer and the File Viewer's markdown view share these
rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first commit left one case of the same squeeze. Codeman turns the
paths in an answer into links, and a linked path keeps
`word-break: break-all` so that it can wrap anywhere. That lets the
browser count every letter as a break point when it sizes the column,
so in a table whose headers fill the width, a column of paths shrank
to three or four letters per line. A cell that holds a linked path now
has a minimum width of 6em. Other cells keep their natural width, so a
narrow column such as row numbers stays narrow.

On a 390 px view in Firefox and Chromium, a path column went from 48 px
to 83 px, and a `#` column kept its 32 px.

The comment on the cell rule also said wrongly that a cell breaks a word
wider than its column. In automatic table layout a column is never
narrower than its longest word, so that never happens, and the comment
now says that.

The test reads every rule that names a selector, in styles.css and
mobile.css, with comments removed first, so a later override fails it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Ark0N

Ark0N commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Thanks for this fix, and for the careful write-up with measurements. The PR stops a markdown table column in the Response Viewer and the File Viewer from collapsing to one letter per line, by giving table cells overflow-wrap: break-word and a 6em floor to cells that hold a linked path.

One thing needs a change before merge.

URLs, inline code and hashes in a cell no longer wrap in Chromium (src/web/public/styles.css:14126)

The description says a long URL still wraps because browsers break after / and -. Chromium breaks after -, but not after /: in headless Chromium 156, https://github.com/Ark0N/Codeman/pull/866/files has a min-content width of 396 px, and src/web/public/styles.css has 211 px. With break-word, a cell holding such a token sets its column's minimum width, so on a phone the whole table scrolls sideways and the other columns shrink to their longest word. Measured with the real styles.css and mobile.css in a 360 px response-viewer column (first-row column widths in px):

Cell content master this PR
bare URL (autolinked) 180 / 142, fits 389 / 78, scrolls (467 in 322)
`_scheduleDroppedOutputRecovery()` 122 / 201, fits 268 / 120, scrolls (388 in 322)
40-character hash in backticks 143 / 179, fits 325 / 90, scrolls (416 in 322)

The same applies to path links in the File Viewer's markdown view: .file-preview-body .file-preview-md a.rv-path (styles.css:12247) sets word-break: normal, so a path in a table cell there has no break-all to fall back on either.

Your path approach handles this when it is extended to inline code and links. Replacing the td:has(a.rv-path:not(.rv-path-link)) rule (styles.css:14131) with these two:

.rv-table-wrap td :is(code, a:not(.rv-path-link)) { overflow-wrap: anywhere; }
.rv-table-wrap td:has(code, a:not(.rv-path-link)) { min-width: 6em; }

keeps both of your improvements (label column 74 px, path column 116 px with its 80 px floor, # column 36 px) and brings the URL, identifier and hash tables back to master's widths, all fitting. The one cost I measured is a code-only column such as `-v` growing from 57 px to 80 px. Please check it in Firefox as you did for the original change (I measured Chromium only), and update the last case of test/response-viewer-table-cells.test.ts to pin the new rules.

Nit (src/web/public/styles.css:14129): the comment says "the a.rv-path rule below", but .rv-text a.rv-path sits above it, at line 14077.

Checks run here: typecheck, lint, frontend syntax, format, public assets and the browser-exclude check all pass. The new test passes, and 5 of its 6 cases fail against master's stylesheet, as you said. All 70 gate test files that read the stylesheets pass.

Your question about letting headers wrap is still open; keep this PR to the cell rules. With the cell rules updated, this is ready to merge.

Chromium never breaks a line after `/`, so under the cells' `break-word` a
URL, an identifier or a hash in backticks set its column's width, and the
whole table scrolled sideways on a phone. Inline code and links in a cell
now break anywhere, and a cell holding one gets the 6em floor that cells
with a linked path had. In a 360 px column in Chromium and Firefox, URL,
identifier and hash tables fit as they did on master.

Two costs remain. A code-only column such as `-v` grows from 52 px to
80 px. CSS cannot tell an autolink from a link with a prose label, so a
long word in a label can break mid-word in a narrow column.

The test's selector lookup now splits a selector list only on commas
outside parentheses, so it can find the `:is()` and `:has()` rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@irisitymichaelgrundberg

Copy link
Copy Markdown
Contributor Author

Claude:

Thanks, you're right. I measured it again in a 360 px column with the real stylesheets, and Firefox shows part of it as well. Firefox breaks a URL after /, so bare URLs still fit there, but an identifier in backticks and a 40-character hash scroll in both browsers.
691ea6c replaces the path rule with your two rules. URL, identifier and hash tables are back to master's widths in Chromium and Firefox, the path column keeps its 80 px floor, and the original label column still wraps between words. A code-only column such as -v grows from 52 px to 80 px, as you found.
One more cost: a:not(.rv-path-link) also matches a markdown link with a prose label. In a narrow column, a label such as "documentation" now breaks mid-word at the 6em floor (80 px, where it had 112 px). CSS can't tell an autolink from a labelled link, and narrowing the rule would mean tagging autolinks in the renderer, so I left it. Say if you'd like that.
The test now pins both rules, the comment no longer points at a rule "below", and the description's URL sentence is corrected.

@Ark0N

Ark0N commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Thanks for the follow-up commit, and for checking it in Firefox. This PR stops a markdown table column in the Response Viewer and the File Viewer from collapsing to one letter per line. Cells now wrap between words, while inline code and links in a cell still break anywhere and their cell gets a 6em floor.

The third commit is what the last review asked for. I measured it again in headless Chromium 156 at 360 px with the real styles.css and mobile.css. The label column under an empty header goes from 37 px to 78 px. A URL, an identifier and a 40-character hash in backticks fit as they did on master, and a # column keeps its 36 px. The comment now points at the a.rv-path rule above it, and 5 of the 6 test cases fail against master's stylesheet, as you said.

You don't need to change anything. This is ready to merge once CI finishes green. Thanks again for the careful measurements.

@Ark0N
Ark0N merged commit 111fb32 into Ark0N:master Dec 3, 2026
2 checks passed
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

Ark0N commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Merged, and shipped in Codeman 1.52.1.

Nothing was changed on top. Table columns in the response viewer and the file preview now wrap between words, and inline code, links and paths in a cell still break where they need to. Your measurements in two browsers made this an easy one to land.

Thank you!

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