Skip to content

refactor(web): defer tldts load for MCP favicon URL blur - #42486

Merged
crazywoola merged 1 commit into
langgenius:mainfrom
Souravrajvi0:feat/defer-mcp-tldts-774b
Sep 23, 2026
Merged

crazywoola merged 1 commit into
langgenius:mainfrom
Souravrajvi0:feat/defer-mcp-tldts-774b

Conversation

@Souravrajvi0

@Souravrajvi0 Souravrajvi0 commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Fixes #42440.

Summary

The Integrations bundle statically imported tldts through the MCP modal form hook (use-mcp-modal-form.ts), even for users who never open MCP create/edit UI. That hook only needs getDomain when create-mode server URL blur runs, to build the Google favicon URL.

This PR:

  • Removes the top-level import { getDomain } from 'tldts' so tldts is not part of the static dependency graph for the Integrations entry.
  • Loads tldts with await import('tldts') inside handleUrlBlur after URL validation, preserving registrable-domain semantics (getDomain, not raw URL.hostname).
  • Adds a blur-generation guard so slower favicon uploads cannot overwrite state after the user blurs a newer URL.
  • Skips favicon fetch when getDomain returns no domain.

MCP UI modules may still ship in the Integrations chunk via existing static section imports; this change specifically defers the ~300KB tldts parser until favicon lookup runs, matching the issue acceptance criteria.

Screenshots

N/A — bundle-size / network change only; no UI change.

Testing

  • npx vp test --project unit app/components/tools/mcp/hooks/__tests__/use-mcp-modal-form.spec.ts (53 tests)
  • Pre-commit vp check --fix on staged TS files

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

Dynamically import tldts when create-mode MCP server URL blurs so the
Integrations entry no longer statically pulls the domain parser. Guard
async blur handlers against stale completions when the URL changes quickly.
@github-actions github-actions Bot added the web This relates to changes on the web. label Sep 18, 2026
@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.47%. Comparing base (48189fe) to head (4a26cc8).
⚠️ Report is 158 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #42486   +/-   ##
=======================================
  Coverage   87.47%   87.47%           
=======================================
  Files        5468     5468           
  Lines      316809   316817    +8     
  Branches    63506    63511    +5     
=======================================
+ Hits       277127   277134    +7     
- Misses      34300    34301    +1     
  Partials     5382     5382           
Flag Coverage Δ
dify-ui 93.14% <ø> (ø)
web 87.94% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ghfind-review ghfind-review Bot added review: high ghfind author score; see https://ghfind.com and removed review: high ghfind author score; see https://ghfind.com labels Sep 22, 2026
@crazywoola
crazywoola added this pull request to the merge queue Sep 23, 2026
Merged via the queue into langgenius:main with commit 200da31 Sep 23, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor/Chore] Defer MCP favicon parsing dependencies from the Integrations entry

2 participants