fix: text compose papercuts #270
Reference in New Issue
Block a user
Delete Branch "fix-text-compose-papercuts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #267
Summary by CodeRabbit
New Features
Bug Fixes
Style
📝 Walkthrough
Walkthrough
Refactors desktop compose: adds URL/markdown helpers, ensures link-preview fallbacks, enables Milkdown ImageBlock (uploads disabled), improves autofocus, replaces forceCardMode with session-latched carded logic, refines paste handling, and updates editor/card styling.
Changes
Compose Editor Improvements
js/desktop/src/lib/link-metadata.ts,js/desktop/src/lib/markdown.ts,js/desktop/package.jsondomainFromUrlextracts normalized hostnames;hasMarkdownFormattingdetects markdown via regex.@milkdown/kitadded (7.21.1).js/desktop/src/features/compose/markdown-editor.css,js/desktop/src/styles/globals.css.scrollbar-cardstyling plus layout CSS variables.js/desktop/src/features/compose/markdown-editor.tsxImageBlock(uploads rejected), constrains image block height, and changes autofocus to dispatch an editor action moving cursor to document end.js/desktop/src/features/compose/text-editor.tsxforceCardModewithcardedstate; auto-switches to card mode when length, attachments, or markdown formatting indicate; updates shortcut and adds entry animations.js/desktop/src/components/link-preview-card.tsx,js/desktop/src/features/compose/attachment-strip.tsx,js/desktop/src/features/particles/text-particle-view.tsxLinkPreviewCardFallbackand uses it where metadata is missing so links remain visible and actionable (open/copy).js/desktop/src/hooks/use-file-input.tsjs/desktop/src/lib/immersive-text.tsgetImmersiveTextStyle(length)to centralize size/weight choices for immersive text display.🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
#267: padding fixes (CSS variables and styles), cursor placement at document end, heading size reduction, width consistency via shared styling variables, improved paste handling via file-only detection, and link metadata fallback rendering.#267. Supporting additions like the Milkdown library dependency and ImageBlock configuration are necessary to implement the required fixes and are not out of scope.✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
fix-text-compose-papercutsComment
@coderabbitai helpto get the list of available commands and usage tips.Actionable comments posted: 1
🧹 Nitpick comments (2)
🤖 Prompt for all review comments with AI agents
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
c025be3d-4a0c-46a6-8ada-baf969e9803b📥 Commits
Reviewing files that changed from the base of the PR and between
66d53497c5and5b199434bf.📒 Files selected for processing (10)
js/desktop/package.jsonjs/desktop/src/components/link-preview-card.tsxjs/desktop/src/features/compose/attachment-strip.tsxjs/desktop/src/features/compose/markdown-editor.cssjs/desktop/src/features/compose/markdown-editor.tsxjs/desktop/src/features/compose/text-editor.tsxjs/desktop/src/features/particles/text-particle-view.tsxjs/desktop/src/hooks/use-file-input.tsjs/desktop/src/lib/link-metadata.tsjs/desktop/src/lib/markdown.ts⚠️ Potential issue | 🔴 Critical | ⚡ Quick win
Fix setState during render — causes React warnings and potential bugs.
The pattern
if (shouldCard && !carded) setCarded(true);calls a state setter directly during the render phase, which violates React's rules and will trigger warnings like "Cannot update a component from inside the function body of a different component."This must be moved into a
useEffectto update state safely after render.🔒 Required fix
🤖 Prompt for AI Agents
♻️ Duplicate comments (1)
🤖 Prompt for all review comments with AI agents
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
705610ec-394f-4e6b-922b-c8eb76b6c858📥 Commits
Reviewing files that changed from the base of the PR and between
5b199434bfande821cd02ef.📒 Files selected for processing (9)
js/desktop/src/components/link-preview-card.tsxjs/desktop/src/features/compose/attachment-strip.tsxjs/desktop/src/features/compose/markdown-editor.cssjs/desktop/src/features/compose/markdown-editor.tsxjs/desktop/src/features/compose/text-editor.tsxjs/desktop/src/features/particles/text-particle-view.tsxjs/desktop/src/hooks/use-file-input.tsjs/desktop/src/lib/immersive-text.tsjs/desktop/src/styles/globals.css🚧 Files skipped from review as they are similar to previous changes (4)