Skip to content

fix: improve Monaco editor theming and empty trash UX#24

Merged
typelets merged 2 commits intomainfrom
fix/web-app-performance
Oct 19, 2025
Merged

fix: improve Monaco editor theming and empty trash UX#24
typelets merged 2 commits intomainfrom
fix/web-app-performance

Conversation

@typelets
Copy link
Copy Markdown
Owner

Summary

This PR improves Monaco editor theming, empty trash UX, application performance, and editor stability.

Monaco Editor Improvements

  • Replace CSS overrides with native vs (light) and vs-dark (dark) themes for proper syntax highlighting
  • Add global MonacoThemeContext to synchronize theme across all code execution blocks
  • Fix scroll blocking by setting alwaysConsumeMouseWheel: false in editor options
  • Remove redundant theme icons from individual blocks since theme is now global

Empty Trash UX Improvements

  • Remove confirmation modal for faster workflow - click "Empty Trash" and it happens immediately
  • Add optimistic UI updates to remove trash items from view instantly
  • Add spinner to "Empty Trash" button with "Emptying..." state during operation
  • Fix issue where selected trashed note would persist after emptying trash
  • Improve auto-selection logic to prevent accidentally selecting trashed notes

Performance Optimizations

  • Install and configure React Query (TanStack Query) with optimized cache settings:
    • staleTime: 5 minutes - Data stays fresh for 5 minutes
    • gcTime: 30 minutes - Cache kept for 30 minutes
    • refetchOnWindowFocus: false - Better UX, no unnecessary refetches
  • Implement code splitting with manual chunks for major dependencies:
    • monaco-editor - Large code editor bundle
    • tiptap-core and tiptap-extensions - Rich text editor (split for better caching)
    • clerk, radix-ui, react-query, syntax-highlight - Vendor libraries
  • Convert sequential pagination to parallel requests using Promise.all() for folders and notes
  • Defer WebSocket connection with autoConnect: false until after initial data loads

Editor Stability Fixes

  • Fix "editor view is not available" errors during mount/unmount cycles
  • Add proper null checks for editor.view.dom in all useEffects
  • Wrap editor operations in try-catch blocks for transitional states
  • Remove redundant instanceof Date checks in favor of typeof === 'string'

Bug Fixes

  • Fix type errors: Use note.deleted instead of note.deletedAt (correct property name)
  • Fix React Hook dependency warnings in useNotes.ts and useEditorEffects.ts
  • Remove unused error variables in catch blocks
  • Add eslint-disable for react-refresh/only-export-components in context file

Performance Impact

Before:

  • Sequential pagination with 100ms delays between requests
  • All attachments loaded upfront (100+ sequential requests possible)
  • WebSocket connects immediately on mount
  • No code splitting or caching layer

After:

  • Parallel pagination with Promise.all()
  • Attachments loaded on-demand when note selected
  • WebSocket deferred until after data loads
  • Code splitting reduces initial bundle size
  • React Query caches API responses

Expected improvements:

  • ~50% faster initial page load
  • Reduced bandwidth usage
  • Better perceived performance with optimistic updates

Monaco Editor improvements:
- Replace CSS overrides with native 'vs' and 'vs-dark' themes for proper syntax highlighting
- Add global MonacoThemeContext to sync theme across all code blocks
- Fix scroll blocking by setting alwaysConsumeMouseWheel to false
- Remove theme icon from individual blocks since theme is now global

Empty Trash improvements:
- Remove confirmation modal for faster workflow
- Add optimistic UI updates to clear trash items immediately
- Add spinner to Empty Trash button with "Emptying..." state
- Fix selected note persisting after trash is emptied
- Improve auto-selection logic to prevent selecting trashed notes

 Performance:
- Add React Query with optimized cache configuration
- Implement code splitting with manual chunks for major dependencies
- Defer WebSocket connection until after initial data load
- Convert sequential pagination to parallel requests

Editor stability:
- Fix editor view access errors during mount/unmount cycles
- Add proper null checks for editor.view.dom in all useEffects
- Wrap editor operations in try-catch for transitional states
@typelets typelets self-assigned this Oct 19, 2025
@typelets typelets merged commit e086ee4 into main Oct 19, 2025
3 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.28.8 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants