Skip to content

fix(jcode-ui): stop file-viewer line numbers wrapping vertically - #144

Merged
cnjack merged 1 commit into
mainfrom
fix/file-viewer-lineno-wrap
Jul 17, 2026
Merged

fix(jcode-ui): stop file-viewer line numbers wrapping vertically#144
cnjack merged 1 commit into
mainfrom
fix/file-viewer-lineno-wrap

Conversation

@cnjack

@cnjack cnjack commented Jul 16, 2026

Copy link
Copy Markdown
Owner

问题

文件查看器(read/write 工具渲染)中,两位数及以上的行号被纵向拆开显示(如 22 显示为上下两个 2)。

根因

CSS 特异性冲突:

规则 特异性 属性
.jcode-file-table td 0-1-1 ✅ 胜出 white-space: pre-wrap; word-break: break-all
.jcode-file-lineno 0-1-0 ❌ 落败 white-space: nowrap; width: 1px

行号列依赖 width: 1px + nowrap 做收缩适应,但 nowrap 因特异性低而失效,word-break: break-all 允许任意字符间断行,导致行号逐字符折行。

修复

  • 选择器提升为 .jcode-file-table td.jcode-file-lineno(特异性 0-2-1)
  • 显式 word-break: normal 防御回归
  • 添加注释说明特异性要求的原因

验证

  • pnpm build 通过,dist/styles.css 中确认规则为 white-space:nowrap; word-break:normal
  • web/ 通过 workspace 软链引用,重建后即可看到效果

注:site/ 走 npm registry(^0.4.1),需要后续 bump 0.4.2 + publish 才能拿到此修复。

`.jcode-file-table td` (specificity 0-1-1) overrode `.jcode-file-lineno`
(0-1-0), so `white-space: pre-wrap` + `word-break: break-all` won and
multi-digit line numbers wrapped one digit per line (e.g. 22 rendered as
two stacked 2s).

Raise the selector to `.jcode-file-table td.jcode-file-lineno` (0-2-1),
add explicit `word-break: normal`, and comment why the specificity is
required.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@cnjack, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 33 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e1ed5c11-f9f2-4d6e-a783-bc95a123dd42

📥 Commits

Reviewing files that changed from the base of the PR and between c2a3e49 and c68744a.

📒 Files selected for processing (1)
  • packages/jcode-ui/src/styles/components.css
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/file-viewer-lineno-wrap

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cnjack cnjack left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall Risk

Low

Top Findings

None.

Reviewed as a senior-staff-level pass (correctness, reliability, security, performance, concurrency, data integrity, API compatibility, observability, test coverage). This is a single, self-contained CSS specificity fix:

  • Root cause correctly diagnosed: .jcode-file-table td (specificity 0-1-1, sets white-space: pre-wrap; word-break: break-all) was beating .jcode-file-lineno (0-1-0), causing multi-digit line numbers to wrap character-by-character.
  • Fix raises specificity to .jcode-file-table td.jcode-file-lineno (0-2-1) and adds an explicit word-break: normal as a defensive backstop — both changes are necessary and sufficient.
  • Verified against the actual markup (packages/jcode-ui/src/toolRenderers/fileViewer.tsx:31): <td className="jcode-file-lineno"> is a descendant of table.jcode-file-table, so the new selector matches correctly.
  • No other source defines or duplicates this rule (single CSS source, no committed build artifacts), so there's no missed call site.
  • Sibling .jcode-file-text column intentionally keeps word-break: break-all for wrapping long code lines — correctly unaffected by this change.
  • The PR description already discloses that site/ (npm-pinned to jcode-ui@^0.4.1) won't pick up this fix until a version bump/publish — an accurate, non-hidden caveat.
  • Web CI (type-check/build) passed; Go CI is unrelated to this CSS-only change.

No correctness, security, concurrency, or data-integrity concerns apply to a static CSS rule change.


Generated by Claude Code

@cnjack
cnjack merged commit ec06ef1 into main Jul 17, 2026
3 checks passed
@cnjack
cnjack deleted the fix/file-viewer-lineno-wrap branch July 17, 2026 01:00
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