fix(desktop): prevent shell vars from rendering as math#419
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
🔇 Additional comments (4)
📝 WalkthroughSummary by CodeRabbit
WalkthroughMarkdownContent.vue now preprocesses markdown content to escape shell-variable patterns ( ChangesShell Variable Escaping for Markdown
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
bc0ee04 to
4a953d1
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/desktop/src/components/MarkdownContent.vue`:
- Around line 157-165: shouldEscapeShellVariable currently escapes when the
character after the regex match isn't '$', which misclassifies inline math like
`$x+y$` because the regex matches only `$x` and the following '+' triggers an
escape; update shouldEscapeShellVariable to inspect the character immediately
after the matched token (const end = index + match[0].length) and return true
only if that nextChar is '$' or a character that legally continues a shell
variable (e.g., alphanumeric or '_') — treat operator characters used in math
(like + - * / ^ = and whitespace) as non-shell continuations so the function
returns false for math expressions; apply the same fix to the analogous logic
around the other occurrence referenced (the block mirrored at the second
location).
In `@apps/desktop/tests/components/MarkdownContent-i18n.test.ts`:
- Around line 85-100: Update the test in MarkdownContent-i18n.test.ts so it also
asserts a non-trivial inline math expression is preserved (not escaped) by
adding an example like $x+y$ (or $x_i$) to the props.content string passed to
mount(MarkdownContent) and to the expected string passed to
parseMarkdownToStructureMock; keep shell-variable occurrences escaped (e.g.
\\$HOME, \\${USERPROFILE}) but ensure the math substring remains unescaped (e.g.
... math: $x+y$; ...) so parseMarkdownToStructureMock is expected to receive the
preserved inline math while still escaping shell variables.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 23830e6f-a89a-4fc9-96f9-45b9aa6da2e1
📒 Files selected for processing (2)
apps/desktop/src/components/MarkdownContent.vueapps/desktop/tests/components/MarkdownContent-i18n.test.ts
Summary
Prevents shell-style variables in assistant markdown text from being parsed as KaTeX inline math. This keeps paths and commands such as
$env:USERPROFILE\Desktop,$HOME/project, and${USERPROFILE}\Desktoprendering as normal text while leaving inline code, fenced code, and closed math like$x$unchanged.Related issue or RFC
Link the issue or RFC:
For code changes, link the tracking issue. Only documentation wording, link fixes, or comment-only cleanups may skip the issue-first flow.
AI assistance disclosure
If AI tools materially assisted this contribution, disclose that here or point to the relevant commit trailer.
Testing evidence
List the commands you ran and the results you observed.
pnpm.cmd --filter @touchai/desktop test:unit --run tests/components/MarkdownContent-i18n.test.ts- passed, 8 tests, in the original workspace with dependencies installed.pnpm.cmd --filter @touchai/desktop test:unit --run tests/views/SearchView/components/ConversationPanel/AssistantMessage.test.ts- passed, 8 tests, in the original workspace with dependencies installed.git diff --check- passed in the clean PR worktree.pnpm.cmd --filter @touchai/desktop test:unit --run tests/components/MarkdownContent-i18n.test.tsin the clean PR worktree could not run because that worktree does not havenode_modulesinstalled (vitestwas not recognized).pnpm test:prwas not run locally; relying on CI for full-suite evidence.Did you follow TDD (test-first) for feature and fix work? Strongly recommended. See docs/testing/testing.md.
Risk notes
AgentService, runtime, MCP, or schema impact: None.Screenshots or recordings
N/A. The regression is covered by parser input tests.
Checklist
[WIP]or similar title prefixes.AgentService, runtime, MCP, or schema boundaries, there is an accepted RFC.pnpm test:prfor this code PR, or this is a docs-only change.pnpm test:coverage:rustor relied on CI coverage evidence.pnpm test:e2elocally or documented why CI is the first valid proof.