Skip to content

feat(web): add opt-in inline LaTeX rendering setting#1848

Draft
wbxl2000 wants to merge 1 commit into
mainfrom
feat/web-inline-math
Draft

feat(web): add opt-in inline LaTeX rendering setting#1848
wbxl2000 wants to merge 1 commit into
mainfrom
feat/web-inline-math

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

N/A — small opt-in UX addition requested directly; behavior explained below.

Problem

The web UI only renders $$…$$ display math. Users who write inline $…$ LaTeX in prompts/answers see the raw dollar-sign text, but enabling the single-$ inline rule unconditionally would misdetect prices, env vars, and shell paths ($5, $PATH, $HOME/bin) as math and swallow them into broken formulas.

What changed

  • New opt-in setting "Inline math rendering" (Settings → General, desktop dialog and mobile settings sheet), persisted per browser in localStorage, default OFF. When enabled, $…$ spans render as inline KaTeX; $$…$$ display math behavior is unchanged either way.
  • The markdown parse policy moved into a small tested lib (configureMathRules); chat markdown re-parses when the toggle flips so the effect is immediate.
  • The code comments and the settings hint both call out the misdetection risk ($5, $PATH, $HOME/bin).
  • Unit tests for the rule policy; en/zh labels included.

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.

Single-$ inline math stays off by default: the rule can misdetect prices,
env vars, and shell paths ($5, $PATH, $HOME/bin) as math and swallow them
into a broken formula. A new Settings switch (desktop dialog and mobile
sheet) enables it per browser; messages re-parse on toggle. $$…$$ display
math remains always on.
@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8047059

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

@wbxl2000
wbxl2000 marked this pull request as draft July 17, 2026 12:17
@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

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

commit: 8047059

@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: 8047059512

ℹ️ 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".

<span class="srow-label">{{ t('settings.inlineMath') }}</span>
<span class="srow-sub">{{ t('settings.inlineMathHint') }}</span>
</span>
<span class="toggle" :class="{ on: inlineMath }" role="switch" :aria-checked="inlineMath" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use the shared Switch for the mobile toggle

For mobile users—especially those using assistive technology—this creates a role="switch" span nested inside a button, so focus lands on a button while the checked state belongs to a different nested widget. It also violates the mandatory apps/kimi-web/AGENTS.md rule: “Use the primitives in src/components/ui/” and “do not hand-roll a bespoke … switch.” Render the setting with components/ui/Switch.vue, as the desktop dialog does, so the interactive element itself owns the switch role, label, checked state, and focus styling.

Useful? React with 👍 / 👎.

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