Skip to content

fix(web): prevent fallback code line number overlap - #2347

Open
yicun wants to merge 2 commits into
MoonshotAI:mainfrom
yicun:codex/fix-web-fallback-line-number-overlap
Open

fix(web): prevent fallback code line number overlap#2347
yicun wants to merge 2 commits into
MoonshotAI:mainfrom
yicun:codex/fix-web-fallback-line-number-overlap

Conversation

@yicun

@yicun yicun commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Related Issue

None. The problem is described below.

Problem

When a fenced code block is rendered through markstream-vue's line-numbered fallback, the line numbers can overlap the code text or drift out of vertical alignment.

In markstream-vue@1.0.7, the standalone fallback <pre> is rendered as the component root, while its scoped layout rules are emitted as descendant selectors. Those rules do not match that root element, so the fallback loses its gutter padding, font, and line height. The line-number gutter keeps its own metrics while the code falls back to different metrics.

What changed

  • Restored the complete standalone fallback <pre> layout: gutter space, typography, wrapping, overflow, border, background, and radius.
  • Made the fallback child <code> inherit the container typography and removed child padding, preventing loading fallbacks from reserving the gutter twice.
  • Excluded diff previews and left the Shiki rendering path unchanged.
  • Added a patch changeset for @moonshot-ai/kimi-code.

Verification

  • pnpm --filter @moonshot-ai/kimi-web check:style
  • pnpm --filter @moonshot-ai/kimi-web typecheck
  • pnpm --filter @moonshot-ai/kimi-web test (34 files, 653 tests)
  • pnpm --filter @moonshot-ai/kimi-web build
  • Verified in both Moon Bright and Moon Dark themes.
  • Verified standalone fallback code and gutter heights match (72 px for four lines), with gutter spacing preserved and child padding at 0.
  • Verified loading fallback code and gutter heights match (198 px for eleven lines), without duplicate gutter padding.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update. (No documentation update is needed because commands, configuration, and user workflows are unchanged.)

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5045431

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 29, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@5045431
npx https://pkg.pr.new/@moonshot-ai/kimi-code@5045431

commit: 5045431

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82fdcbce37

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread apps/kimi-web/src/components/chat/Markdown.vue Outdated
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