Skip to content

Release v0.8.0#80

Merged
erictli merged 5 commits intomainfrom
release/v0.8.0
Mar 4, 2026
Merged

Release v0.8.0#80
erictli merged 5 commits intomainfrom
release/v0.8.0

Conversation

@erictli
Copy link
Owner

@erictli erictli commented Mar 4, 2026

Summary

  • Bump version to 0.8.0
  • Fix KaTeX block math selection highlight bleed (native DOM selection cleared via ProseMirror plugin)
  • Add Enter/Space to open block math editor when node is selected via keyboard
  • Fix mermaid code blocks collapsing when empty (start in edit mode, show placeholder in preview)
  • Strip ANSI escape codes from Ollama CLI output and improve model-not-found error messages
  • Add ProseMirror-selectednode outline style for block math
  • Align mermaid edit/preview button with language dropdown

Test plan

  • Arrow keys through a note with block math — no highlight bleed on content above
  • Click a block math node — opens editor, no flash
  • Cmd+Enter to submit math edit — no highlight flash
  • Escape to cancel math edit — no highlight flash
  • Enter/Space on a keyboard-selected block math — opens editor
  • Create new code block, switch to mermaid — stays in edit mode
  • Empty mermaid block in preview shows placeholder text
  • Mermaid edit/preview button aligns vertically with language dropdown
  • Ollama AI edit with non-existent model — shows clean "not found" error
  • Version shows 0.8.0 in Settings > About

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved math block interaction plugin for clearer selection and keyboard behavior.
    • Unified Mermaid preview/edit toggle in the editor toolbar.
  • Bug Fixes

    • Strip ANSI sequences from command output for cleaner messages.
    • Cursor now moves after inserted/edited math blocks.
    • Prevent selection bleed when block-math is selected.
    • Better error messaging for missing models.
  • Style

    • Visual highlight for selected block-math and minor toolbar/icon sizing tweaks.
  • Chores

    • Version bumped to 0.8.0.

erictli and others added 2 commits March 4, 2026 10:51
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>
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

Version 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

Cohort / File(s) Summary
Version Manifests
package.json, src-tauri/Cargo.toml, src-tauri/tauri.conf.json
Bumped package/app version from 0.7.1 → 0.8.0 across manifests.
Tauri / Ollama AI Handling
src-tauri/src/lib.rs
Strip ANSI sequences from CLI outputs; use cleaned stdout/stderr in AiExecutionResult; pass model_name.clone() correctly; detect Ollama "model not found" errors and return a clearer, actionable message.
Block-Math Editor Core
src/components/editor/MathExtensions.ts, src/components/editor/Editor.tsx
Added ProseMirror plugin on ScratchBlockMath to clear DOM selection and handle Enter/Space to invoke onClick; move cursor to just after inserted block on submit/cancel to avoid selection bleed.
Editor UI / Code Block & Mermaid
src/components/editor/CodeBlockView.tsx, src/components/editor/MermaidRenderer.tsx
Unified mermaid toggle button, set showSource default based on node emptiness, adjusted icon/text sizing, and display a centered "Empty mermaid diagram" message when no SVG; refined error message styling.
Styling & Copy
src/App.css, src/components/settings/AboutSettingsSection.tsx
Added selected block-math outline styling; minor keyframes formatting; updated About text to credit GitHub contributors.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 A hop, a tweak, a tiny cheer—

I nudge the blocks and clear the smear,
Models whisper, errors mend,
Cursors leap to journey's end,
I nibble bugs and seed a grin. 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Release v0.8.0' directly matches the PR's primary objective: bumping the project version to 0.8.0 and releasing it.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch release/v0.8.0

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 and usage tips.

erictli and others added 2 commits March 4, 2026 10:57
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8b249a2 and 4ad40fe.

⛔ Files ignored due to path filters (1)
  • src-tauri/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • package.json
  • src-tauri/Cargo.toml
  • src-tauri/src/lib.rs
  • src-tauri/tauri.conf.json
  • src/App.css
  • src/components/editor/CodeBlockView.tsx
  • src/components/editor/Editor.tsx
  • src/components/editor/MathExtensions.ts
  • src/components/editor/MermaidRenderer.tsx
  • src/components/settings/AboutSettingsSection.tsx

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ad40fe and 46de471.

📒 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>
@erictli erictli merged commit 7e2158a into main Mar 4, 2026
1 check passed
Shayaan-Azeem pushed a commit to Shayaan-Azeem/scratch that referenced this pull request Mar 10, 2026
* 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>
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