feat(ui): replace MDXEditor with TipTap v3 markdown editor - #2449
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe PR replaces MDXEditor with TipTap v3, adds controlled Markdown editing, toolbar commands, paste conversion, and new styles. Markdown and Matrix chat markup now support headings, lists, italic, and underline formatting. Chat bubbles render derived rich text with expanded test coverage. ChangesRich-text editor and markup migration
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Parent
participant RichTextEditor
participant TipTapEditor
participant PasteMarkdown
Parent->>RichTextEditor: provide Markdown and editor options
RichTextEditor->>TipTapEditor: initialize content and extensions
PasteMarkdown->>TipTapEditor: insert parsed Markdown on paste
TipTapEditor-->>RichTextEditor: emit serialized Markdown changes
Parent->>RichTextEditor: provide external Markdown
RichTextEditor->>TipTapEditor: replace editor content
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 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 `@packages/ui/src/organisms/editor.css`:
- Around line 27-34: Update the editor CSS rules anchored by
.richtext-editor-content-host .tiptap and .richtext-editor-content, including
the referenced ranges, to replace all hardcoded spacing, sizing, and layout
values such as 12px, 120px, 0.5em, 1.5em, and 0.35em with the appropriate design
tokens from ui-utils. Preserve the existing layout behavior while ensuring theme
and density settings control these values consistently.
In `@packages/ui/src/organisms/editor.tsx`:
- Around line 328-329: In packages/ui/src/organisms/editor.tsx#L328-L329, render
EditorToolbar only when editable is true; in
packages/ui/src/organisms/editor.css#L151-L154, remove the pointer-events: none
rule so read-only content remains selectable and editor.setEditable(false)
controls its state.
- Around line 45-57: Define and export named interfaces for the props of both
ToolbarButton and RichTextEditor, replacing ToolbarButton’s anonymous props type
and the existing RichTextEditorProps type alias. Update each component signature
to use its corresponding exported interface while preserving all existing prop
fields and optionality.
- Around line 191-206: Add a link control alongside the list buttons in the
editor toolbar, using an accessible dialog or popover to create and edit links
for the current selection. Wire the control to the editor chain’s setLink,
toggleLink, and unsetLink commands as appropriate, including removal for an
existing link, and preserve the existing ToolbarButton patterns and editor focus
behavior.
- Around line 124-128: Update the toolbar container in the editor component to
implement composite focus management: make only the active ToolbarButton
tabbable, move focus between buttons with Left/Right Arrow keys, and update the
active index as focus changes while preserving normal activation behavior. Use
the existing ToolbarButton elements and toolbar state rather than removing the
role.
- Around line 239-247: The editor currently declares translation as a no-op;
update the toolbar label/title generation to call the provided translation
function for each user-facing value, using the existing English text as the
defaultValue and preserving interpolation arguments where applicable. Apply this
in the toolbar configuration near the translation prop so consumers’
translations replace hardcoded labels while retaining the current fallback when
translation is absent.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 46deb894-7a70-48e6-9a43-34b0ad93021e
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (3)
package.jsonpackages/ui/src/organisms/editor.csspackages/ui/src/organisms/editor.tsx
8d665ac to
e76801a
Compare
|
🔗 Custom preview URL: https://pr-2449.preview-app.hypha.earth |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 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 `@packages/core/src/matrix/chat-markup.ts`:
- Around line 53-59: Use one consistent heading-level maximum across all
affected sites, preferably extending support to levels 5 and 6: update
MarkupNode, chatMarkupLooksFormatted, parseHeadingLine, and HTML rendering in
packages/core/src/matrix/chat-markup.ts (lines 53-59); update heading detection
in packages/ui-utils/src/looks-like-markdown.ts (line 21); and update parsing
plus rendering classes for every supported level in
packages/epics/src/common/human-chat-panel/parse-simple-matrix-html.tsx (lines
69-74).
In `@packages/epics/src/common/human-chat-panel/parse-simple-matrix-html.tsx`:
- Around line 210-215: Update the heading branch in renderSimpleHtmlNodes so it
renders a semantic heading element matching n.level (h1–h4), or applies
role="heading" with aria-level={n.level}, while preserving the existing classes,
key, children, and text transformation.
In `@packages/ui-utils/src/looks-like-markdown.test.ts`:
- Around line 1-35: Move packages/ui-utils/src/looks-like-markdown.test.ts
(lines 1-35) to packages/ui-utils/src/__tests__/looks-like-markdown.test.ts and
update its looksLikeMarkdown relative import; also move
packages/ui-utils/src/markdown-inline.test.ts (lines 1-20) to
packages/ui-utils/src/__tests__/markdown-inline.test.ts and update its relative
import.
In `@packages/ui-utils/src/looks-like-markdown.ts`:
- Around line 47-50: Update looksLikeMarkdown by adding an italic-pair inline
Markdown check alongside the existing bold, underline, link, and code checks, so
inputs such as *italic* are detected before the paste handler bypasses
editor.markdown.parse().
In `@packages/ui/src/organisms/editor.tsx`:
- Around line 269-283: Register a custom underline Markdown handler in the
editor extensions near StarterKit, Placeholder, Markdown, and PasteMarkdown so
__text__ maps to underline rather than bold; update
packages/ui/src/organisms/paste-markdown.ts lines 23-35 to route pasted __text__
through that same handler, ensuring the underline semantics are preserved before
persistence.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a0dbf38a-7c2b-46a5-aa63-8832a1e00703
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (15)
package.jsonpackages/core/src/matrix/__tests__/chat-markup.test.tspackages/core/src/matrix/chat-markup.tspackages/epics/src/common/ai-panel/ai-panel-message-bubble.tsxpackages/epics/src/common/human-chat-panel/__tests__/parse-simple-matrix-html.test.tspackages/epics/src/common/human-chat-panel/human-chat-panel-message-bubble.tsxpackages/epics/src/common/human-chat-panel/parse-simple-matrix-html.tsxpackages/ui-utils/src/index.tspackages/ui-utils/src/looks-like-markdown.test.tspackages/ui-utils/src/looks-like-markdown.tspackages/ui-utils/src/markdown-inline.test.tspackages/ui-utils/src/markdown-inline.tspackages/ui/src/organisms/editor.csspackages/ui/src/organisms/editor.tsxpackages/ui/src/organisms/paste-markdown.ts
580a56f to
e7040b5
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@packages/ui/src/organisms/editor.tsx`:
- Around line 306-320: Add component tests for RichTextEditor covering external
markdown changes and form-reset/resubmit synchronization, verifying the editor
content updates correctly without overwriting local typing. Assert that
controlled synchronization uses the editor update path with emitUpdate: false
and does not invoke onChange.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 23bbeb2c-fe6e-4151-8a5b-aa67386d950a
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (15)
package.jsonpackages/core/src/matrix/__tests__/chat-markup.test.tspackages/core/src/matrix/chat-markup.tspackages/epics/src/common/ai-panel/ai-panel-message-bubble.tsxpackages/epics/src/common/human-chat-panel/__tests__/parse-simple-matrix-html.test.tspackages/epics/src/common/human-chat-panel/human-chat-panel-message-bubble.tsxpackages/epics/src/common/human-chat-panel/parse-simple-matrix-html.tsxpackages/ui-utils/src/index.tspackages/ui-utils/src/looks-like-markdown.test.tspackages/ui-utils/src/looks-like-markdown.tspackages/ui-utils/src/markdown-inline.test.tspackages/ui-utils/src/markdown-inline.tspackages/ui/src/organisms/editor.csspackages/ui/src/organisms/editor.tsxpackages/ui/src/organisms/paste-markdown.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@packages/ui-utils/src/looks-like-markdown.ts`:
- Around line 129-170: Make hasMarkdownLink linear by advancing the outer cursor
to labelEnd after each label scan, including when no closing bracket is found,
while preserving detection of valid links and image-marker skipping. Add a
regression test covering many repeated opening brackets without a closing
bracket and verify it completes without quadratic behavior.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 0b74d568-340f-48ec-b3ce-d391d59eefda
📒 Files selected for processing (6)
packages/epics/src/common/human-chat-panel/parse-simple-matrix-html.tsxpackages/ui-utils/src/__tests__/looks-like-markdown.test.tspackages/ui-utils/src/__tests__/markdown-inline.test.tspackages/ui-utils/src/looks-like-markdown.tspackages/ui/src/organisms/editor.csspackages/ui/src/organisms/editor.tsx
💤 Files with no reviewable changes (1)
- packages/ui/src/organisms/editor.css
Use TipTap for rich-text agreement/signal descriptions with markdown in/out, for better cross-block selection and a simpler editing stack. Co-authored-by: Cursor <cursoragent@cursor.com>
Add TipTap paste heuristics so markdown clipboard content becomes structured editor nodes, and extend Matrix chat markup/HTML rendering for headings, lists, and underline on send and in bubbles. Co-authored-by: Cursor <cursoragent@cursor.com>
Use TipTap for rich-text agreement/signal descriptions with markdown in/out, for better cross-block selection and a simpler editing stack. Co-authored-by: Cursor <cursoragent@cursor.com>
Add TipTap paste heuristics so markdown clipboard content becomes structured editor nodes, and extend Matrix chat markup/HTML rendering for headings, lists, and underline on send and in bubbles. Co-authored-by: Cursor <cursoragent@cursor.com>
Replace polynomial clipboard heuristics with linear scanners for CodeQL, and harden read-only editor toolbar plus semantic chat headings. Co-authored-by: Cursor <cursoragent@cursor.com>
a72ba1b to
0a45db6
Compare
Wire toolbar i18n, link popover, roving tabindex, and design tokens. Co-authored-by: Cursor <cursoragent@cursor.com>
Review-fix commit landedPushed Included
Skipped (already fixed)
|
There was a problem hiding this comment.
Actionable comments posted: 10
♻️ Duplicate comments (2)
packages/ui/src/organisms/editor.tsx (2)
594-608: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftControlled-sync tests are still missing.
No test file covers
RichTextEditor. This effect carries the highest correctness risk in the component: it comparesmarkdownagainstlastEmittedMarkdown.current, then againsteditor.getMarkdown(), and callssetContentwithemitUpdate: false. A serializer normalization difference makescurrent !== markdowneven when the documents match, which resets the cursor mid-edit.Add tests for external markdown updates, form reset, and the assertion that
onChangeis not invoked during controlled sync.This repeats an earlier finding that is not yet resolved.
Do you want me to generate the test file, or open an issue to track it?
🤖 Prompt for 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. In `@packages/ui/src/organisms/editor.tsx` around lines 594 - 608, Add tests covering RichTextEditor controlled synchronization: verify external markdown updates and form resets update the editor content, and verify controlled sync calls setContent with emitUpdate false without invoking onChange. Include a case where editor.getMarkdown() differs only through serializer normalization, ensuring local typing and cursor state are not unnecessarily reset.
557-571: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
__text__still resolves to bold, not underline.The extension list adds
Markdownwith no custom underline tokenizer or serializer.packages/core/src/matrix/chat-markup.tstreats__text__as underline, while Marked-based Markdown treats it as strong emphasis. Round-tripping existing content through this editor converts underline to bold before persistence. The toolbartoggleUnderlinecommand at Line 449 has the same asymmetry on serialization.This repeats an earlier finding that is not yet resolved.
#!/bin/bash # Confirm the underline markup contract is still divergent across the editor and the chat markup layer. set -euo pipefail echo "== underline handling in chat markup ==" rg -nP -C 4 'underline|__|\+\+' packages/core/src/matrix/chat-markup.ts echo "== any custom markdown tokenizer registered for underline ==" rg -nP -C 4 'markdownTokenizer|renderMarkdown|parseMarkdown|Underline' packages/ui/src/organisms echo "== paste path ==" cat -n packages/ui/src/organisms/paste-markdown.ts🤖 Prompt for 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. In `@packages/ui/src/organisms/editor.tsx` around lines 557 - 571, Align the editor’s Markdown extension and the toolbar toggleUnderline serialization with the underline contract in chat-markup.ts, so __text__ parses and serializes as underline rather than bold. Add or reuse the appropriate custom underline tokenizer/serializer in the editor Markdown flow, including pasted Markdown handled by PasteMarkdown, while preserving normal strong-emphasis behavior.
🤖 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 `@packages/ui/src/organisms/editor.css`:
- Around line 147-154: Remove the contrast-reducing color override from the
rich-text underline rule so underlined content inherits the body text color, and
remove opacity from the read-only .richtext-editor container. Preserve the
read-only state using an appropriate background or border change without
reducing text contrast.
- Around line 15-21: Replace the Tailwind utility selector in the rich text
editor styling with the proposed data-attribute hook, and expose that state
through the RichTextEditorProps API in RichTextEditor. Update call sites that
currently depend on the implicit wrapper-class match to pass bordered={false},
preserving border removal only when explicitly requested.
- Around line 163-164: Update the prefers-contrast media query wrapping
.richtext-editor to use the valid more value instead of high, preserving the
existing 2px border styling.
- Around line 42-49: In the rich-text editor placeholder CSS, remove the
unscoped `.tiptap .is-empty::before` selector from the rule and retain only
`.tiptap p.is-editor-empty:first-child::before`, preserving the existing
placeholder declarations.
In `@packages/ui/src/organisms/editor.tsx`:
- Around line 305-329: Update handleToolbarKeyDown and the related itemTabIndex
logic so tabbableIndex is clamped or advanced to an enabled toolbar item
whenever its current button becomes disabled, preserving a reachable Tab stop.
Remove the ineffective ?? tabbableIndex fallback from items.findIndex and
replace the arbitrary items.length * 10 bias with a single items.length offset;
retain existing arrow-key wrapping and focus behavior.
- Around line 572-576: Update RichTextEditorProps and the editorProps.attributes
configuration in the editor setup to accept and apply an accessible name via
aria-label or aria-labelledby, along with role="textbox" and
aria-multiline="true". Because editorProps is captured by useEditor, synchronize
changing ARIA name values with editor.setOptions in an effect, while preserving
the existing class attributes.
- Around line 229-248: Update the applyLink flow in editor.tsx to handle a
collapsed selection with no existing link: insert the URL text and apply the
link mark in the same editor chain, or disable the Apply button for that state.
Preserve the existing behavior for non-empty selections and selections inside
links, and ensure the popover does not close after an ineffective apply.
- Around line 331-340: Inside the component, compute the platform detection once
as an isApple value using the existing navigator guard and regex, then reuse it
for both undoShortcut and redoShortcut ternaries. Remove the duplicated platform
checks while preserving the current shortcut labels and server-safe navigator
handling.
- Around line 566-568: Update the editor synchronization effects near the
existing setEditable effect so changes to the placeholder prop update the
mounted editor’s placeholder extension. Do not rely solely on the one-time
Placeholder.configure call inside useEditor; add the corresponding
editor/placeholder-dependent update using the editor’s existing extension or
command API, while preserving the initial fallback to an empty string.
- Around line 90-136: Update ToolbarButtonProps and ToolbarButton to extend
Button props, forward remaining props to Button, and invoke the optional click
handler with the event while preserving the existing onClick behavior and
onMouseDown guard. Remove the link popover trigger’s no-op click handler so
Radix can receive and compose the forwarded props and event correctly.
---
Duplicate comments:
In `@packages/ui/src/organisms/editor.tsx`:
- Around line 594-608: Add tests covering RichTextEditor controlled
synchronization: verify external markdown updates and form resets update the
editor content, and verify controlled sync calls setContent with emitUpdate
false without invoking onChange. Include a case where editor.getMarkdown()
differs only through serializer normalization, ensuring local typing and cursor
state are not unnecessarily reset.
- Around line 557-571: Align the editor’s Markdown extension and the toolbar
toggleUnderline serialization with the underline contract in chat-markup.ts, so
__text__ parses and serializes as underline rather than bold. Add or reuse the
appropriate custom underline tokenizer/serializer in the editor Markdown flow,
including pasted Markdown handled by PasteMarkdown, while preserving normal
strong-emphasis behavior.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: aec7b5d9-5282-4a65-9481-66977049aeb6
📒 Files selected for processing (2)
packages/ui/src/organisms/editor.csspackages/ui/src/organisms/editor.tsx
Align __underline__/ **bold** with chat markup, harden paste detection and toolbar a11y, and expose an explicit bordered prop instead of Tailwind coupling. Co-authored-by: Cursor <cursoragent@cursor.com>
Autofix Review CompletedFixed 8 file(s) based on 12 unresolved CodeRabbit review comment(s) (1 skipped as already consistent). Files modified:
Commit: Skipped: heading-level max already consistent at 4 across paste detection, Matrix markup, TipTap ( The latest autofix changes are on the |
Summary
Replaces the MDXEditor-based
RichTextEditorwith a TipTap v3 implementation, keeping markdown as the value format in and out so nothing downstream changes. The motivation is better cross-block selection behaviour and a simpler editing stack.@mdxeditor/editorandtiptap-markdownfor the official@tiptap/*v3 packages (starter-kit,react,pm,extensions,markdown), and upgrades the existing TipTap deps from v2 to v3.packages/ui/src/organisms/editor.tsxwith a custom toolbar (paragraph, H1–H4, bold/italic/underline, bullet/numbered list, undo/redo), placeholder support, and external-value syncing that avoids stomping in-progress typing on form reset.packages/ui/src/organisms/editor.cssagainst Hypha design tokens (--accent-*,--neutral-*,--font-family-text) instead of shipping MDXEditor's stylesheet. Net ~1,400 lines of CSS removed.Compatibility
RichTextEditorPropskeeps the shape the two existing call sites already use, so neither was touched:packages/epics/src/agreements/components/create-agreement-base-fields.tsxpackages/epics/src/coherence/components/create-signal-form.tsxeditorRefnow points at a TipTapEditor(both call sites passnull), andtranslationis accepted as a no-op shim — TipTap usesaria-labels on the toolbar instead. Both are migration affordances and can be dropped in a follow-up.Rebase notes
Rebased onto
main(was 136 commits behind). Two things came out of it:mainmoved to--font-family-text/--font-family-codeinrefactor(ui): consolidate app type to IBM Plex Sans. The conflict ineditor.csswasmainediting MDXEditor rules this branch deletes — the deletions win, but the rename is carried forward into the new TipTap rules so the editor picks up IBM Plex Sans.pnpm-lock.yamlrecordedspecifier: ^3for the TipTap packages whilepackage.jsonpinned^3.29.2, which would have failed CI's frozen-lockfile check. Regenerated;pnpm install --frozen-lockfilenow passes.Test plan
Preview: https://hypha-7oosg14il-hypha-dao.vercel.app
The failing
Vercelcheck is theregen-sydneyproject, whose root directoryapps/regen-sydneydoes not exist on this branch. Unrelated to this change.Summary by CodeRabbit
New Features
Bug Fixes