Conversation
Version bump: - 0.7.1 → 0.8.0 in package.json, tauri.conf.json, Cargo.toml KaTeX block math fixes: - Fix native DOM selection highlight bleed when navigating to or clicking block math nodes (ProseMirror plugin clears DOM selection) - Add Enter/Space keyboard shortcut to open editor on selected block - Move cursor after node on submit/cancel to avoid re-triggering highlight - Add ProseMirror-selectednode outline style for visual feedback Mermaid fixes: - Start in edit mode when switching empty code block to mermaid - Show "Empty mermaid diagram" placeholder instead of collapsing Ollama error handling: - Strip ANSI escape codes from CLI stdout/stderr - Detect model-not-found errors and show actionable message Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughVersion bumped to 0.8.0; backend AI command output is ANSI-stripped with improved Ollama error messages; editor receives a new block-math ProseMirror plugin (selection/key handling) and cursor placement fixes; UI tweaks to code-block/mermaid rendering and small styling/text updates. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/components/editor/MermaidRenderer.tsx (1)
32-44: Optional: deduplicate repeated feedback block markup.Both error and empty states now render the same structure/classes. Extracting a small helper/component will reduce drift in future UI tweaks.
♻️ Suggested refactor
+function MermaidFeedback({ message }: { message: string }) { + return ( + <div className="text-xs text-text-muted italic px-2 pt-6 pb-3 text-center"> + {message} + </div> + ); +} + export function MermaidRenderer({ code }: MermaidRendererProps) { @@ if (error) { - return ( - <div className="text-xs text-text-muted italic px-2 pt-6 pb-3 text-center"> - Mermaid syntax error - </div> - ); + return <MermaidFeedback message="Mermaid syntax error" />; } if (!svg) { - return ( - <div className="text-xs text-text-muted italic px-2 pt-6 pb-3 text-center"> - Empty mermaid diagram - </div> - ); + return <MermaidFeedback message="Empty mermaid diagram" />; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/editor/MermaidRenderer.tsx` around lines 32 - 44, MermaidRenderer currently returns identical markup for the mermaid error and empty-svg cases; extract that repeated block into a small helper or subcomponent (e.g., renderStatusBlock or MermaidStatus) and replace both return sites to call it, passing a short message like "Mermaid syntax error" or "Empty mermaid diagram"; update references to the local svg variable and any error checks inside MermaidRenderer so both branches simply call the new helper/component to avoid duplication and keep styling centralized.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src-tauri/src/lib.rs`:
- Around line 2576-2589: The current check using err_lower.contains("not found")
is too broad and causes unrelated errors to be remapped; in the error handling
block that builds AiExecutionResult (where err_lower, model_name and
AiExecutionResult are referenced) replace the generic "not found" check with
stricter pattern matching for model-specific messages (e.g., check for phrases
like "model not found", "model does not exist", "ollama: model not found", or a
regex matching "model .* not found") and keep the existing checks for "file does
not exist" and "pull model manifest"; remove the plain "not found" substring
test so only errors that clearly indicate the model is missing produce the
suggested `ollama pull {}` remediation.
- Around line 2350-2365: The code trims stdout before returning results which
can remove meaningful leading/trailing whitespace from successful AI CLI
responses; in the execute_ai_cli logic stop trimming stdout (keep stdout_clean
as the exact replacement result of ansi_re.replace_all(&stdout_str, "")
converted to String) while you may continue trimming stderr if desired; update
the declarations of stdout_clean and/or the branch that constructs
AiExecutionResult (symbols: execute_ai_cli, stdout_clean, stderr_clean,
AiExecutionResult) so success responses return the untrimmed stdout, and ensure
the error branch still returns stderr_clean (trimmed) if you want to normalize
error messages.
In `@src/components/editor/Editor.tsx`:
- Around line 745-756: Both occurrences of
currentEditor.chain().focus().setTextSelection(pos + node.nodeSize).run() are
unsafe because setTextSelection targets a block boundary; replace them with
boundary-aware selection creation using ProseMirror's Selection APIs: resolve
the doc position (pos + node.nodeSize) with editor.view.state.doc.resolve(...),
create a safe cursor with Selection.near(Selection.findFrom(resolvedPos, 1,
true) || resolvedPos) (or use Selection.near(resolvedPos) with a fallback), then
apply that selection via the editor transaction (e.g.,
tr.setSelection(safeSelection) and dispatch or use
currentEditor.chain().focus().command(...) to set the transaction) so both the
submit and onCancel handlers use a normalized, valid cursor position instead of
setTextSelection.
---
Nitpick comments:
In `@src/components/editor/MermaidRenderer.tsx`:
- Around line 32-44: MermaidRenderer currently returns identical markup for the
mermaid error and empty-svg cases; extract that repeated block into a small
helper or subcomponent (e.g., renderStatusBlock or MermaidStatus) and replace
both return sites to call it, passing a short message like "Mermaid syntax
error" or "Empty mermaid diagram"; update references to the local svg variable
and any error checks inside MermaidRenderer so both branches simply call the new
helper/component to avoid duplication and keep styling centralized.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 26aad0d8-fe81-4a97-b478-5e6c955ec6e8
⛔ Files ignored due to path filters (1)
src-tauri/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (10)
package.jsonsrc-tauri/Cargo.tomlsrc-tauri/src/lib.rssrc-tauri/tauri.conf.jsonsrc/App.csssrc/components/editor/CodeBlockView.tsxsrc/components/editor/Editor.tsxsrc/components/editor/MathExtensions.tssrc/components/editor/MermaidRenderer.tsxsrc/components/settings/AboutSettingsSection.tsx
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/editor/CodeBlockView.tsx`:
- Line 14: The initial showSource state in CodeBlockView (const [showSource,
setShowSource] = useState(!node.textContent.trim())) can go out of sync; change
the component to keep showSource in sync by adding a useEffect that watches
node.textContent and the block language (e.g., the language prop or
node.attrs.language) and calls setShowSource(node.textContent.trim() === "" &&
language === "mermaid") so empty mermaid blocks open edit mode, and update any
toggle handler to use a functional update (setShowSource(prev => !prev)) to
avoid stale state.
- Line 58: The Tailwind utility classes used on ChevronDownIcon (w-3.25, h-3.25,
right-1.25) are not in the default spacing scale; add custom spacing tokens to
your theme so those utilities resolve. Open your global theme block (the `@theme`
in src/App.css) and define spacing variables for the 1.25 and 3.25 tokens (e.g.,
--spacing-1.25 and --spacing-3.25) and ensure they are exposed to Tailwind's
spacing scale so the classes w-3.25, h-3.25 and right-1.25 used in
CodeBlockView.tsx will apply correctly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 00faa7b6-df73-491d-ae40-f269013f937e
📒 Files selected for processing (1)
src/components/editor/CodeBlockView.tsx
- Stop trimming stdout in execute_ai_cli (callers trim as needed, and trimming here could strip meaningful whitespace) - Replace broad "not found" check with specific "model not found" and "model does not exist" patterns Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Bump version to v0.8.0 and fix KaTeX/mermaid/Ollama issues Version bump: - 0.7.1 → 0.8.0 in package.json, tauri.conf.json, Cargo.toml KaTeX block math fixes: - Fix native DOM selection highlight bleed when navigating to or clicking block math nodes (ProseMirror plugin clears DOM selection) - Add Enter/Space keyboard shortcut to open editor on selected block - Move cursor after node on submit/cancel to avoid re-triggering highlight - Add ProseMirror-selectednode outline style for visual feedback Mermaid fixes: - Start in edit mode when switching empty code block to mermaid - Show "Empty mermaid diagram" placeholder instead of collapsing Ollama error handling: - Strip ANSI escape codes from CLI stdout/stderr - Detect model-not-found errors and show actionable message Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: align mermaid edit button with language dropdown Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: simplify CodeBlockView toolbar Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Codeblock dropdown styling adjustment. * fix: don't trim stdout in AI CLI, narrow Ollama error matching - Stop trimming stdout in execute_ai_cli (callers trim as needed, and trimming here could strip meaningful whitespace) - Replace broad "not found" check with specific "model not found" and "model does not exist" patterns Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
ProseMirror-selectednodeoutline style for block mathTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Style
Chores