Skip to content

fix(desktop): stop packaged editor crash - #466

Merged
tomymaritano merged 1 commit into
developfrom
fix/codemirror-production-chunk
Aug 16, 2026
Merged

fix(desktop): stop packaged editor crash#466
tomymaritano merged 1 commit into
developfrom
fix/codemirror-production-chunk

Conversation

@tomymaritano

@tomymaritano tomymaritano commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Closes #311

Why

The packaged editor crashed on first note with [CodeMirror] plugin error: TypeError: tags is not iterable. Two things had to be true at once:

  1. The Vite config was never loaded. The file was named electron-vite.config.ts; electron-vite only reads electron.vite.config.ts. optimizeDeps.include and every other renderer option were no-ops.
  2. Two @lezer/common copies (1.5.0 nested under @lezer/highlight, 1.5.2 under language/markdown). Each has its own NodeProp, so HighlightStyle.style received undefined.

Chunk splitting alone did not fix it — the smoke test still went red until common was pinned.

What

  • Rename the config so electron-vite actually loads it
  • manualChunks: @codemirror/* + @lezer/*codemirror
  • resolve.dedupe + alias @lezer/common to the desktop copy
  • pnpm override @lezer/common@1.5.2 and add it as a desktop dependency
  • Smoke: click “Create Your First Note”, wait for .cm-content, fail if [CodeMirror] appears in the console
  • Main/preload stay on electron-vite 5 defaults (externalizeDeps: true) so better-sqlite3 is not inlined

Verify

pnpm --filter @dripnex/desktop build
# one @lezer/common region in out/renderer/assets/codemirror-*.js
pnpm --filter @dripnex/desktop e2e
# smoke 3 passed, notes 2 passed

Local e2e needs better-sqlite3 rebuilt for Electron 41 (electron-rebuild --force --only better-sqlite3).

Deploy order

Desktop only. No contract change for other repos.

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability when opening notes with the CodeMirror editor, including lazy-loaded editor content.
    • Prevented related console and page errors during note editing.
  • Tests

    • Added automated coverage to verify note creation and editor rendering work as expected.

electron-vite never loaded electron-vite.config.ts (it looks
for electron.vite.config.ts). Production also bundled two
@lezer/common copies, so HighlightStyle.style saw undefined
tags. Pin common@1.5.2, emit one CodeMirror chunk, and open
a note in smoke so the lazy editor actually loads.
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file app:desktop size/M labels Aug 16, 2026
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c23b7a77-c6d0-4b61-ad59-23da79f105ac

📥 Commits

Reviewing files that changed from the base of the PR and between efa55d4 and 0621b7d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • apps/desktop/e2e/smoke.spec.ts
  • apps/desktop/electron-vite.config.ts
  • apps/desktop/electron.vite.config.ts
  • apps/desktop/package.json
  • knip.json
  • package.json
💤 Files with no reviewable changes (1)
  • apps/desktop/electron-vite.config.ts

Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The desktop Electron Vite configuration now consolidates CodeMirror and Lezer modules and pins @lezer/common. A smoke test verifies lazy-loaded editor rendering and CodeMirror error handling.

Changes

Desktop CodeMirror integration

Layer / File(s) Summary
Electron Vite and dependency configuration
apps/desktop/electron-vite.config.ts, apps/desktop/electron.vite.config.ts, apps/desktop/package.json, package.json, knip.json
The Electron Vite configuration now defines shared CodeMirror and Lezer chunks, dependency deduplication, and renderer settings. The project pins @lezer/common to 1.5.2 and updates the configuration entry.
Lazy-loaded editor smoke validation
apps/desktop/e2e/smoke.spec.ts
The smoke test creates a note, checks the Untitled editor content, and asserts that no CodeMirror console or page errors occur.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 0621b

The packaged editor build and smoke coverage are updated to address the reported crash, and no actionable merge-blocking risk remains beyond normal checks and review.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the desktop packaged editor crash fix, which matches the primary change.
Linked Issues check ✅ Passed The changes implement the CodeMirror chunking, deduplication, dependency pinning, and smoke-test requirements from issue #311.
Out of Scope Changes check ✅ Passed All changes support the packaged editor crash fix, including configuration loading, dependency resolution, and regression coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/codemirror-production-chunk

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.

@tomymaritano
tomymaritano merged commit f9a1fc6 into develop Aug 16, 2026
16 of 17 checks passed
@tomymaritano
tomymaritano deleted the fix/codemirror-production-chunk branch August 16, 2026 23:21
tomymaritano added a commit that referenced this pull request Aug 16, 2026
Closes #314

## Why

`.cm-table-visual` / `.sortable-table` were `width: 100%` with no
`max-width` and no wrapping on cells. `.cm-table-widget` set
`overflow-x: auto` then overwrote it with `overflow: hidden`, so long
cells painted past the pane.

## What

- `max-width: 100%` on both table classes
- `overflow-wrap` / `word-break` on `th`/`td`
- Keep `overflow-x: auto` on the editor wrapper; add
`.sortable-table-wrap` for preview
- Line decoration `.cm-table-range` over every table (including the one
under the cursor)
- No hard pixel cell widths
- Unit test for `findTableRanges`; e2e inserts a wide table and asserts
the widget is not wider than `.cm-scroller`

**Note:** real per-range no-wrap while editing is deferred to the
plugin-tables extraction. Editor-global `lineWrapping` still wraps raw
pipe rows.

The e2e opens the packaged editor, so it depends on #466 landing (or a
local Electron rebuild of `better-sqlite3`).

## Verify

```
pnpm --filter @dripnex/desktop exec vitest run src/renderer/plugins/__tests__/tables.test.ts
pnpm --filter @dripnex/desktop typecheck:renderer
```
tomymaritano added a commit that referenced this pull request Aug 22, 2026
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## Summary

Playwright e2e now types into the CodeMirror 6 surface instead of
treating `.cm-content` as out of scope. The e2e README matches CI: the
job is required (no `continue-on-error`).

## Type of Change

- [x] Bug fix (test coverage / docs accuracy)
- [ ] New feature
- [ ] Breaking change
- [x] Documentation update

## Related Issues

#311 (packaged `tags is not iterable` — already closed by #466; this PR
does not re-open it)

## What

- `editor.spec.ts`: create first note → type a unique marker into
`.cm-content` → assert it appears. Second case: replace doc with `-
first item`, press Enter, assert continue-markup adds a sibling `- `.
- `openFirstNote()` helper shared with smoke / tables.
- README: typing is in scope for those tests; CI e2e is required;
`tables.spec.ts` still skipped on CI; `pnpm e2e` still runs `out/`, not
a packaged asar.

## Packaged crash (#311)

Not reproduced in this Linux VM (no macOS `.app`). Current tree already
has the #466 work: `manualChunks` for `@codemirror/*` + `@lezer/*`,
`resolve.dedupe`, `@lezer/common` pin/alias, smoke that loads the lazy
editor. Vite 8 deprecates function-form `manualChunks` in favor of
Rolldown `codeSplitting.groups` — I will inspect the built
`out/renderer` chunks in this PR and only change bundling if the split
is still wrong. I will not guess an asar rewrite without a repro.

## Checklist

- [ ] Tests pass locally (`pnpm test` / desktop e2e)
- [ ] Build succeeds (`pnpm --filter @dripnex/desktop build`)
- [x] PR targets `develop` branch (not `main`)

<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-a4c7c79b-af1e-4afa-930f-7dd0ed529d6f?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-a4c7c79b-af1e-4afa-930f-7dd0ed529d6f&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app:desktop dependencies Pull requests that update a dependency file size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(desktop): single-chunk CodeMirror/Lezer in production build (tags is not iterable)

1 participant