Skip to content

fix(deps): migrate Tiptap security updates with Markdown compatibility guards - #19376

Merged
OrcaWin merged 8 commits into
mainfrom
OrcaWin/neil-editor-dep-updates
Sep 14, 2026
Merged

OrcaWin merged 8 commits into
mainfrom
OrcaWin/neil-editor-dep-updates

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 7, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​320 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​320
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​476 $\color{#cf222e}{\Huge{\mathbf{−}}}$​356 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​120

ELI5

Update Tiptap for security and correctness fixes while preserving existing Markdown documents. The migration passes every existing editor regression test, plus new literal-source and tokenizer-boundary tests.

What Changed / Why

Align direct Tiptap packages from 3.22.4/3.22.5 to exact 3.31.3, with their coordinated extension graph, ProseMirror View 1.42.3, Model 1.25.11, Inputrules 1.5.1 and Linkify 4.3.3. Other dependency updates are already on main and outside this PR's diff.

Upstream releases include prototype-safe attribute merging (3.30.4), Markdown attribute CPU-exhaustion protection (3.30.5), nested-list serialization and lower React node-view overhead (3.30.6), mobile node-view freeze repair (3.31.1), the ProseMirror paste-XSS fix (3.31.2), and a React declaration repair (3.31.3).

Adapt the existing integration contracts:

  • Use upstream Link priority so formatted and inline-code link labels serialize correctly.
  • Initialize empty Markdown as the schema's editable default document. Detect ordered-list markers directly because upstream start() no longer supplies that signal.
  • Preserve editable literal bracket/transport-looking source through a conservative serializer wrapper. Optional escapes may be omitted from a paragraph or heading only when reopening it through the same codec yields an identical ProseMirror node, including every mark and attribute. Reference-definition documents retain upstream escaping because references cross block boundaries. Parser failures and nested blocks retain upstream output. Cache proofs by immutable document node, so edits invalidate the affected proof.
  • Stop redundant inline look-ahead scans for internal source markers: Marked already stops text at [. Keep block look-ahead and the exact keyed-marker matching/decoding unchanged. This fixes a measured slowdown on long paragraphs during save validation.

The original update introduced 19 existing test failures; all are repaired without weakening their assertions. Literal source stays editable, and typed formatting syntax must remain literal after reopening. The document schema, codec envelope, remote wire, and host-qualified file route are unchanged.

September 14 rebase validation

Rebased cleanly onto main b8554f1c59a68c2b9770f125485aec6c5b97c8dc; current head be68ca8a01e97c7d970a91d2e8fed55f79b28e6f. The dependency/integration scope remains unchanged, with one additional native-chat test adaptation.

  • Inlined a redundant HTML-match wrapper to satisfy the file-size limit after combining with recent main changes; parsing behavior is unchanged. All 16 targeted HTML/tokenizer tests passed after this cleanup.
  • Recent main added a React skill-pill editor: three tests asserted before queued node-view rendering. Awaiting React updates fixes all three while preserving every assertion. Full native-chat suite: 1,487 passed across 147 files. Browser-history timing check failed its 2 ms budget once in shared CI (6.5 ms), then passed locally and in final CI; no budget or implementation change.
  • Frozen dependency install and application typechecks passed.
  • Editor suite: 1,498 passed, 0 failed, 2 existing skips (219 passing files).
  • Changed-code quality: zero new findings across 14 source/test files, including casting, type-aware checks, and React Doctor.
  • Full rebased PR checks passed, including all eight unit-test shards, static analysis, typechecks, Git/wire compatibility, editor E2E, Linux/Windows packaging, and final verification. Focused rendered editor checks: 16 passed, 0 failed on 18038cfc35; final head changes only native-chat test timing (git/folder/paired saves, nested toggles, tables, ordered-list exit, prose reflow, link bubbles and golden save/reopen). All final-head CI checks are green.

The evidence below describes the earlier candidate. The expanded screenshot run was cancelled and did not publish its promised gallery; the four linked table captures remain available.

Testing / evidence

Final candidate: 018e219856ae42e0cdeb589472a216d75a6ca467.

Check Result
Local editor suite 1,444 passed / 0 failed / 2 existing skips, 211 passing files and one skipped file.
Local static/build Frozen install, application pnpm tc, production electron-vite build, changed-file lint: passed.
Root dependency audit Full pnpm audit --json: pre-Tiptap checkout has one moderate advisory (GHSA-cp6q-959q-f8rh); candidate has zero. This covers the root graph, not every subproject.
Security control Installed-package probe: own __proto__ input creates inherited onclick on the old version but no inherited onclick on 3.31.3; ordinary class attributes are preserved.
E2E TypeScript project Existing limitation: old and new checkouts report the same 190 errors at identical file/line locations and diagnostic codes. New specs have no diagnostics; application typechecks pass.
Final PR CI Queued for Linux runners as of September 8, 03:35 UTC. Earlier production candidate passed all PR checks: 75,773 unit tests / 0 failures / 423 skips, types/static checks, Git/wire contracts, Linux/Windows packaging.
Final focused editor E2E 16 passed / 0 failed on the final product commit: git/folder/paired-remote saves, nested toggles, table editing, ordered-list exit, prose reflow, link bubbles and golden save/reopen.
Final three-platform goldens Final macOS and Linux passed. Windows hit the same sibling-workspace PTY-readiness timeout before editor interaction; the workflow is now complete; this remains a Windows validation limitation. Earlier candidate passed 57 tests with 9 skips after one unchanged Windows rerun.

Local performance probes use the complete production extension graph on macOS arm64/Node 26. A 2,000-paragraph malformed-wiki document previously measured about 27 ms for its first save and 6 ms after a one-paragraph edit. A single approximately 100 KB paragraph exposed repeated inline suffix scans: removing them reduced save-after-edit from about 128 ms to 27 ms; cached repeats take about 2 ms. These are stress diagnostics, not a cross-platform latency guarantee. Source equality is asserted in the probes; the new boundary tests cover Unicode, punctuation, emphasis, HTML, wiki links and citations.

Full E2E before the final scan optimization: 612 passed / 4 failed / 102 skipped, plus 46 passing SSH checks. Raw logs are authoritative: shard 6 has a misleading green badge but reports two failures before a post-summary cancellation. Three failures match earlier unchanged-dependency controls: background browser-tab title and two paired-browser assertions. These workflows are not claimed to work on either version.

The fourth failure was the new folder fixture: saved bytes were correct, but closing its only tab intentionally returns to the landing screen (tabs-close-actions.ts). The test now reselects the folder before reopening, using the existing helper. No source/content assertion changed. Git and paired-remote save/reopen passed that full run; the corrected folder case now passes the final focused run.

All local commands use ORCA_BACKGROUND_LAUNCH=1; rendered app checks run only on isolated CI displays. The new E2E spec captures saved Markdown and screenshots. The existing workflow uploads artifacts on failure; successful assertions remain in job logs.

Visual proof

Before/after table screenshots with full-window and editor-detail captures. These are labeled with the earlier candidate and source run; they are not presented as final-head captures.

Final-code screenshot gallery run retains successful captures for 15 scenarios: git/folder/paired-remote save/reopen, nested toggles, table before/after, all three ordered-list exit paths, four prose reflow cases, and link-overlay display/editing. It will publish the captioned gallery and saved Markdown directly to this PR after every scenario passes. This isolated evidence branch changes only test capture/retention/publication, with identical product code to 018e219856ae42e0cdeb589472a216d75a6ca467.

Linked Issue

User-requested careful dependency review, validation, and Tiptap investigation.

Review

  • Existing Markdown regressions repaired without weakening assertions.
  • Literal syntax, cache invalidation, reference links and inline boundaries covered.
  • Source/remote compatibility and serialization performance reviewed.
  • Final PR CI, focused rendered checks, and three-platform goldens reviewed.

@OrcaWin

OrcaWin commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

Still blocked — do not merge at a5dd997ff4aca4a06f7f344f7c90ec53a4da8af7.

The same four existing suites pass 101/101 on original dependencies and fail 17/101 on this candidate after removing the standalone DOMPurify update. That baseline comparison isolates a real Tiptap/ProseMirror migration regression. Full-editor results and exact reproduction commands are in the body; passing types/builds do not override changed saved Markdown/link behavior. DOMPurify is safely isolated in #19377, so its fix need not wait for this migration.

The security/performance benefits justify a future compatible editor migration, but this evaluated version-only candidate is intentionally retained as a draft with failing evidence. No expectations were weakened to accept changed authored content.

@OrcaWin

OrcaWin commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

The complete Node 24 PR CI run independently confirms 19 failing editor tests across four shards: Markdown dirty state, last-row table deletion, toggle insertion, inline-code/bold link labels, raw-source transport and ordered-list tokenizers. This matches the full local editor result and extends the narrower four-suite baseline comparison. The candidate remains draft / do not merge; these are not waived by successful types/builds.

@OrcaWin

OrcaWin commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

Migration investigation: improvements pushed; serialization hold remains

Head b7e7c74cf8ec399cedf8c0c3d74571f46261ff2a incorporates main at 102402e41e and preserves the six already-merged dependency updates. Still draft / do not merge.

The implementation changes repair three independently diagnosed causes:

  • Remove Orca's obsolete link-priority override. Tiptap 3.31 orders Markdown marks by schema rank, so the old priority workaround now places backticks outside links and changes clickable code labels into literal code. The upstream link priority restores [**bold**](href) and [`code`](href). Existing link assertions are unchanged.
  • Initialize empty Markdown using the schema's valid default document after the upstream Markdown hook. Upstream now leaves empty input as a string and invokes its HTML DOM parser, which breaks Orca's DOM-free round-trip path. This production extension is also reused by the existing isolated test factory; tests are not supplied a fake browser. Added regressions cover empty/whitespace documents and editing the resulting paragraph.
  • Keep the fast ordered-list rejection but use the exported upstream marker pattern instead of its start() callback. start() now intentionally returns -1 to prevent mid-paragraph phone numbers becoming lists; treating that as the initial-source predicate rejects every ordered list. Existing tokenizer assertions and nested-list behavior are unchanged; new checks cover alphabetic, Roman and indented markers plus the phone-number guard.

The four remaining original failures concern unnecessary escaping of authored literal source: malformed citations, invalid wiki links, legacy transport-looking text and another codec's envelope. A global escaping bypass would corrupt newly typed literal Markdown; making those text spans inert atoms would degrade editability. Neither workaround was added, and no existing assertion was weakened. New save/reopen checks protect typed **literal** and [literal](./example.md) from becoming formatting.

Initial controlled result: the four original suites improved from 84 passed / 17 failed to 13 fewer failures; ordered-list's two separate failures are also repaired. Full editor run, exact-head types/build and isolated rendered checks are being collected below. Saved Markdown reaches local/folder/SSH files and independently updated peers, so these four source-contract failures still prevent a safe merge; no wire/schema change was introduced.

@OrcaWin OrcaWin changed the title chore(deps): evaluate Tiptap security upgrade — blocked by Markdown regressions fix(deps): migrate Tiptap security updates with Markdown compatibility guards Sep 8, 2026
@OrcaWin

OrcaWin commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

The Markdown migration now passes the complete existing editor suite: 1,431 passed, 0 failed, 2 existing skips. Frozen install, application typechecks, production build, and changed-file lint pass. New tests cover literal syntax, blank initialization, list detection, cross-paragraph references, immutable-node cache invalidation, and parser-error fallback; original assertions were retained.

Full production extension graph benchmark (macOS arm64 / Node 26, 2,000 paragraphs containing malformed wiki syntax): first save 26.7 ms, save after one-paragraph edit 5.9 ms, repeated saves 4.8–5.8 ms. The serializer preserves the exact source in this fixture. This is a local diagnostic, not a platform-wide guarantee.

The optional E2E TypeScript project is not green: both the pre-Tiptap checkout and candidate report 190 errors at identical file/line positions and diagnostic codes; the new spec has no diagnostics. Application pnpm tc passes. These existing diagnostics were not suppressed.

Full E2E and PR CI are running on head cbdc27b375c89ca09007f26c90f861615aa9a9dd. The new E2E spec tests saved bytes and reopened editor behavior in git, non-git folder, and paired remote workspaces, with source/screenshot artifacts.

Three-platform goldens use production-identical commit 5c02d1b60b0d44a5411361705f74ed76216cc547 (the later commit only adds the new E2E spec). macOS passed. Windows initially failed before editing: the sibling-workspace terminal-file-link fixture timed out waiting for a PTY readiness marker and logged an explicitly killed terminal session. One rerun of that unchanged Windows job is requested; its result will be reported. Linux is still running. No green overall result is claimed yet.

@OrcaWin

OrcaWin commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

Current candidate: 018e219. Still draft pending final CI execution.

  • Final local editor suite: 1,444 passed / 0 failed / 2 existing skips. Application types, production build, lint and the changed-file quality gate pass; the latter reports zero new findings across all 14 changed files. All original assertions were retained.
  • Full root audit: one Tiptap advisory on the old checkout, zero on the candidate. A direct installed-package control confirms the prototype-attribute fix.
  • The serialization compatibility guard also exposed repeated inline source-marker scans. Marked already stops text at [, so inline marker look-ahead is unnecessary. Removing it reduces the 100 KB single-paragraph save-after-edit probe from about 128 ms to 27 ms; cached repeats take about 2 ms. The 2,000-paragraph final-code probe takes about 26.5 ms initially and 5.7 ms after editing one paragraph. Tests cover real HTML/wiki/citation boundaries and exact large-paragraph source preservation.
  • Earlier full PR CI passed 75,773 tests, with 423 skips. The broad E2E run reports 612 passed / 4 failed / 102 skipped, plus 46 passing SSH checks. Three failures match exact prior unchanged-dependency browser controls. The fourth was the new folder fixture attempting to reopen after closing its last tab, which intentionally deselects the workspace. The fixture now reselects the folder using the existing helper; no source/content assertion changed. Git and paired-remote save/reopen passed the broad run.
  • Final PR CI and focused editor E2E are queued for Linux runners. Fresh goldens: macOS passed; Linux queued; Windows hit the same sibling-workspace PTY-readiness failure before editor interaction. The earlier unchanged rerun passed, and this final Windows job will be rerun once its workflow permits it. No clean final CI result is claimed.

The body contains the complete rationale, compatibility design, commands and evidence. The other seven dependency PRs are already merged; this PR remains unmerged while its final gates are open.

@OrcaWin

OrcaWin commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator Author

Table editing: visual evidence

Source CI run · Product commit cbdc27b375c89ca09007f26c90f861615aa9a9dd · Original image files

These four captures come from the earlier migration candidate, before the final inline-scan performance fix. The table scenario passed; the broader run had separately documented failures. The final product commit subsequently passed all 16 focused editor tests. A separate final-code screenshot run will add the other scenarios.

1. Table after Backspace: empty row removed; both populated rows remain.

Scenario: electron-table-row-backspace-after-window.png

Table after Backspace: empty row removed; both populated rows remain.

2. Table after Backspace: empty row removed; both populated rows remain.

Scenario: electron-table-row-backspace-after.png

Table after Backspace: empty row removed; both populated rows remain.

3. Table before Backspace: header, two populated rows, and the empty row selected for removal.

Scenario: electron-table-row-backspace-before-window.png

Table before Backspace: header, two populated rows, and the empty row selected for removal.

4. Table before Backspace: header, two populated rows, and the empty row selected for removal.

Scenario: electron-table-row-backspace-before.png

Table before Backspace: header, two populated rows, and the empty row selected for removal.

The product PR still tracks its separate full-CI and Windows golden-test status; this gallery does not override those results.

@OrcaWin
OrcaWin marked this pull request as ready for review September 14, 2026 23:11
@OrcaWin
OrcaWin force-pushed the OrcaWin/neil-editor-dep-updates branch from 018e219 to 60fcbe7 Compare September 14, 2026 23:11
@pullfrog

pullfrog Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

This run was cancelled 🛑

The workflow was cancelled before completion. Please check the link below for details.

Pullfrog  | View workflow run | via Pullfrog | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The change pins Tiptap development dependencies to 3.31.3. It adds a shared rich Markdown extension that handles empty Markdown content and preserves validated literal source during serialization. Inline tokenizers now skip transport start scans, and ordered-list detection uses the ordered-list marker pattern. New unit and end-to-end tests cover DOM-less editing, literal round trips, token boundaries, list markers, and save/reopen behavior.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to be68c

Saving nested literal Markdown can change its source representation to escaped syntax while preserving the rendered document. This is a narrow, low-impact preservation regression.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 15 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the Tiptap dependency migration and the Markdown compatibility work. It is concise and directly related to the main changes.
Description check ✅ Passed The description is detailed and covers the change, rationale, testing, visual evidence, review notes, and known platform limitations. It does not provide a formal linked issue, and several template se…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟡 Minor · Map nested block nodes during literal-source serialization · src/renderer/src/components/editor/rich-markdown-literal-serialization.ts:50-70

50-70: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Map nested block nodes during literal-source serialization

When getMarkdown() enters the escaped-output branch, blocks maps only top-level paragraphs and headings. A nested list paragraph therefore uses upstream escaping. For nested text [literal], @tiptap/[email protected] produces - \[literal\], while validated top-level text can produce [literal]. A save that consumes editor.getMarkdown() can rewrite the nested source representation.

The existing nested-block test uses [literal](./a), where escaping is correct because unescaping creates a link. It only checks reopened JSON, so it does not detect this source rewrite. Include nested block nodes in the mapping and assert the exact nested getMarkdown() output for [literal].


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 438988f6-1a95-4fe0-b73f-8c4f6a67d0e1

📥 Commits

Reviewing files that changed from the base of the PR and between 18038cf and be68ca8.

📒 Files selected for processing (1)
  • src/renderer/src/components/native-chat/NativeChatPromptEditor.test.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@OrcaWin

OrcaWin commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased onto main and validated final head be68ca8a01e97c7d970a91d2e8fed55f79b28e6f.

  • Full final CI: all eight unit-test shards, static analysis, typechecks, Git/wire compatibility, editor E2E, Linux/Windows packaging and final verification passed.
  • Local editor suite: 1,498 passed / 0 failed / 2 existing skips.
  • Local native-chat suite: 1,487 passed / 0 failed across 147 files.
  • Focused rendered editor run: 16 passed / 0 failed, covering git/folder/paired save-reopen, nested toggles, table editing, ordered-list exit, prose reflow, link controls and golden save/reopen. Run used 18038cfc35; final head only changes native-chat test timing, with identical product code.

Rebase follow-ups: removed a redundant HTML-match wrapper to meet the current file-size limit, and awaited React updates in three newly added native-chat skill-pill tests. All original assertions remain. The browser-history performance test failed its budget once on the preceding run, then passed locally and in final CI without changing the implementation or budget.

Merging with the final head pinned; no administrative check bypass.

@OrcaWin
OrcaWin merged commit 6cb5643 into main Sep 14, 2026
36 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…y guards (stablyai#19376)

* chore(deps): evaluate coordinated Tiptap security migration

* fix(editor): adapt link ranking and initialization for Tiptap 3.31

* fix(editor): preserve literal Markdown through Tiptap serialization

* test(editor): cover literal saves in local folder and paired workspaces

* test(editor): reselect folder after closing its final tab

* perf(editor): avoid repeated inline source-marker lookahead scans

* refactor(editor): inline redundant HTML match wrapper

* test(chat): await Tiptap React skill-pill rendering

---------

Co-authored-by: m4air <[email protected]>
Co-authored-by: m4air <[email protected]>
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