Skip to content

Performance improvements, bundle optimization#734

Merged
feruzm merged 4 commits intodevelopfrom
performance
Apr 2, 2026
Merged

Performance improvements, bundle optimization#734
feruzm merged 4 commits intodevelopfrom
performance

Conversation

@feruzm
Copy link
Copy Markdown
Member

@feruzm feruzm commented Apr 1, 2026

Summary by CodeRabbit

  • New Features

    • Honor users’ “left channel” choices so they aren’t auto-joined back into communities.
  • Improvements

    • Unified markdown-to-HTML pipeline across editor, paste, AI assist, and messaging for consistent rendering.
    • Increased page revalidation windows to 5 minutes and added stronger static asset and font caching.
    • Reduced client tracing and tightened error/reporting configuration.
  • Chores

    • Added bundle analysis tooling, local icon set, stylesheet import moves, and a helper library update.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3201c257-2e73-48d3-ae0c-12b254921e7e

📥 Commits

Reviewing files that changed from the base of the PR and between 8bbcd08 and 20e4c2b.

📒 Files selected for processing (2)
  • packages/render-helper/CHANGELOG.md
  • packages/render-helper/package.json

📝 Walkthrough

Walkthrough

Centralizes markdown-to-HTML via a new utility, adds local Unicons components and webpack aliasing, increases ISR revalidation to 300s for dynamic pages, implements Mattermost per-user left-channel tracking, adds Next.js bundle-analyzer support, relocates some CSS imports, and updates Sentry and cache headers.

Changes

Cohort / File(s) Summary
Next.js config & analyzer
apps/web/next.config.js, apps/web/package.json
Added conditional @next/bundle-analyzer wrapper; webpack alias @tooni/iconscout-unicons-react → local unicons; added headers() cache rules and Sentry bundleSizeOptimizations exclusions.
Local Unicons library
apps/web/src/features/ui/unicons.tsx
New file exporting IconProps and many forwardRef SVG icon components via an icon(...) factory; webpack alias points here.
ISR revalidation
apps/web/src/app/(dynamicPages)/community/[community]/page.tsx, apps/web/src/app/(dynamicPages)/entry/.../page.tsx, apps/web/src/app/(dynamicPages)/profile/[username]/page.tsx
Increased exported revalidate constants from 60/120s → 300s.
Mattermost left-channel tracking
apps/web/src/app/api/mattermost/bootstrap/route.ts, apps/web/src/app/api/mattermost/channels/[channelId]/leave/route.ts, apps/web/src/server/mattermost.ts
Added CHAT_LEFT_CHANNELS_PROP, exported COMMUNITY_CHANNEL_NAME_PATTERN, and functions getUserLeftChannels, addUserLeftChannel, removeUserLeftChannel; bootstrap consults left-channel set to disable auto-join per user; leave route records manual leaves.
Markdown-to-HTML consolidation
packages/render-helper/..., apps/web/src/app/publish/..., apps/web/src/features/..., apps/web/src/specs/..., apps/web/src/features/tiptap-editor/plugins/clipboard/...
Added simpleMarkdownToHTML (Remarkable + sanitize) to render-helper and replaced marked.parse() + DOMPurify.sanitize() usages across editor, publish toolbar, chat rendering, clipboard paste handling, and tests.
Editor alignment handling
apps/web/src/features/tiptap-editor/functions/markdown-to-html.ts, apps/web/src/features/tiptap-editor/functions/parse-all-extensions-to-doc.ts
Turndown rule now considers data-align fallback; parse step migrates data-align into style.textAlign before normalization.
CSS import relocation
apps/web/src/app/market/advanced/_page.tsx, apps/web/src/styles/_components.scss
Moved react-grid-layout and react-resizable CSS imports from global SCSS into MarketAdvanced page.
Sentry client config
apps/web/sentry.client.config.ts
Disabled tracing (tracesSampleRate: 0) and removed BrowserTracing integration from default integrations.
Render-helper package bump & changelog
packages/render-helper/package.json, packages/render-helper/CHANGELOG.md, packages/render-helper/src/...
Bumped version to 2.4.28, added changelog entry, exported and re-exported simpleMarkdownToHTML.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Bootstrap as Bootstrap Handler
    participant MMAPI as Mattermost API
    participant Props as User Props Storage

    Note over User,MMAPI: User triggers join/bootstrap or leave flows
    User->>Bootstrap: Request bootstrap (subscribed communities / specific community)
    Bootstrap->>Props: getUserLeftChannels(user)
    Props-->>Bootstrap: leftChannels Set

    loop per subscribed community
        Bootstrap->>Bootstrap: normalize communityId
        alt not in leftChannels
            Bootstrap->>MMAPI: ensureCommunityChannelMembership(communityId, shouldAutoJoin=true)
        else in leftChannels
            Bootstrap->>MMAPI: ensureCommunityChannelMembership(communityId, shouldAutoJoin=false)
        end
    end

    Note over User,MMAPI: User leaves a channel
    User->>MMAPI: POST /channels/{id}/leave
    MMAPI->>MMAPI: remove user from channel
    alt channel matches COMMUNITY pattern
        MMAPI->>Props: addUserLeftChannel(userId, channelName)
        Props-->>Props: persist ecency_left_channels via PUT /users/{id}/patch
    end
    MMAPI-->>User: { ok: true }
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Improve chats #628: Modifies Mattermost bootstrap/subscribe logic — closely related to left-channel handling and bootstrap flow changes.
  • Image generation #680: Touches publish toolbar and AI assist UI — related to markdown rendering changes in the publish/editor components.

🐰 I hopped through code with nimble paws,
Icons, markdown, and cached applause,
Left-channels tracked, analyzer peeks,
Five-minute pages, cleaner leaks,
A carrot-toast to builds and tweaks!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.26% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Performance improvements, bundle optimization' is overly broad and generic. While the PR includes bundle analyzer setup and performance-related changes, the summary shows diverse modifications across markdown rendering, caching, Mattermost channel management, and icon components that extend beyond typical 'performance improvements.' Consider a more specific title that captures the primary change—such as 'Replace marked+DOMPurify with simpleMarkdownToHTML across editor and chat components' or 'Consolidate markdown processing and add bundle analyzer setup' to better reflect the actual scope of changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch performance

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 and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

feruzm added 2 commits April 2, 2026 07:15
- Add Cache-Control headers for static assets (immutable for hashed
  _next/static, 1-day for public assets) to improve Pingdom cache score
- Disable Sentry BrowserTracing integration (reduces runtime overhead,
  was only sampling 10% of sessions anyway)
- Add Sentry bundleSizeOptimizations to strip replay-related dead code
- Remove enableLogs experiment
- Add data-align to style.textAlign conversion in parse-all-extensions-to-doc
  so editor alignment round-trips correctly through the sanitizer
- Use shared COMMUNITY_CHANNEL_NAME_PATTERN in leave route instead of local duplicate
- Use currentUser.id directly instead of redundant findMattermostUser call
- Add displayName to generated icon components for React DevTools
- Rename misleading variable in test
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
apps/web/next.config.js (1)

169-175: Redundant header rule for /_next/static/media.

The rule at line 164 (/_next/static/:path*) already matches all paths under /_next/static/, including /media/. This second rule is unnecessary.

♻️ Suggested simplification
       {
         // Hashed static assets (JS, CSS, media) - immutable, cache forever
         source: "/_next/static/:path*",
         headers: [
           { key: "Cache-Control", value: "public, max-age=31536000, immutable" }
         ]
-      },
-      {
-        // Fonts served by Next.js
-        source: "/_next/static/media/:path*",
-        headers: [
-          { key: "Cache-Control", value: "public, max-age=31536000, immutable" }
-        ]
       },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/next.config.js` around lines 169 - 175, The route object with source
"/_next/static/media/:path*" is redundant because the existing rule for
"/_next/static/:path*" already covers it; remove the redundant rule (the object
whose source is "/_next/static/media/:path*") or consolidate its headers into
the broader "/_next/static/:path*" rule so you don't duplicate Cache-Control
configuration, and keep only the single route that sets the "Cache-Control"
header for "/_next/static/:path*".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/web/next.config.js`:
- Around line 169-175: The route object with source "/_next/static/media/:path*"
is redundant because the existing rule for "/_next/static/:path*" already covers
it; remove the redundant rule (the object whose source is
"/_next/static/media/:path*") or consolidate its headers into the broader
"/_next/static/:path*" rule so you don't duplicate Cache-Control configuration,
and keep only the single route that sets the "Cache-Control" header for
"/_next/static/:path*".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dd789111-1865-411b-95b1-612bce7334ee

📥 Commits

Reviewing files that changed from the base of the PR and between 170c290 and 8bbcd08.

📒 Files selected for processing (7)
  • apps/web/next.config.js
  • apps/web/sentry.client.config.ts
  • apps/web/src/app/api/mattermost/channels/[channelId]/leave/route.ts
  • apps/web/src/features/tiptap-editor/functions/parse-all-extensions-to-doc.ts
  • apps/web/src/features/ui/unicons.tsx
  • apps/web/src/server/mattermost.ts
  • apps/web/src/specs/features/tiptap-editor/text-color-roundtrip.spec.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/web/src/app/api/mattermost/channels/[channelId]/leave/route.ts
  • apps/web/src/server/mattermost.ts
  • apps/web/src/specs/features/tiptap-editor/text-color-roundtrip.spec.ts

@feruzm feruzm added the patch Bug fixes and patches (1.0.0 → 1.0.1), add this only if any packages/ have patch changes in PR label Apr 2, 2026
@feruzm feruzm merged commit 0b65a63 into develop Apr 2, 2026
1 check was pending
@feruzm feruzm deleted the performance branch April 2, 2026 05:10
@coderabbitai coderabbitai bot mentioned this pull request Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Bug fixes and patches (1.0.0 → 1.0.1), add this only if any packages/ have patch changes in PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant