Skip to content

refactor(web): migrate plugins and tools app context consumers#38533

Merged
hyoban merged 4 commits into
mainfrom
0708-app-context-bootstrap
Jul 8, 2026
Merged

refactor(web): migrate plugins and tools app context consumers#38533
hyoban merged 4 commits into
mainfrom
0708-app-context-bootstrap

Conversation

@hyoban

@hyoban hyoban commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

Refs #38514

  • Migrate plugins and tools AppContext consumers away from direct @/context/app-context compatibility reads.
  • Read exact bootstrap atoms from @/context/app-context-state at each use site, including permission keys, workspace id, user id, role flags, loading state, and version info.
  • Keep existing plugin/tool permission and ACL calculations local to their owning components and hooks without adding pass-through domain hooks.
  • Update focused tests to mock the exact bootstrap atoms consumed by the migrated code.

No UI changes.

Screenshots

Before After
N/A N/A

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 added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Validation

  • pnpm --dir web test hooks/use-credential-permissions.spec.ts app/components/plugins/install-plugin/base/__tests__/use-get-icon.spec.ts app/components/plugins/install-plugin/hooks/__tests__/use-workspace-plugin-install-permission.spec.ts app/components/plugins/card/__tests__/index.spec.tsx app/components/plugins/plugin-item/__tests__/index.spec.tsx app/components/plugins/plugin-auth/authorized/__tests__/item.spec.tsx app/components/tools/mcp/hooks/__tests__/use-mcp-service-card.spec.ts service/__tests__/use-plugins.spec.tsx app/components/plugins/plugin-page/__tests__/use-reference-setting.spec.ts app/components/plugins/install-plugin/install-from-marketplace/steps/__tests__/install.spec.tsx app/components/plugins/install-plugin/install-from-local-package/steps/__tests__/install.spec.tsx app/components/tools/mcp/__tests__/index.spec.tsx app/components/tools/mcp/__tests__/provider-card.spec.tsx app/components/tools/mcp/__tests__/create-card.spec.tsx app/components/tools/mcp/detail/__tests__/content.spec.tsx app/components/tools/provider/__tests__/custom-create-card.spec.tsx app/components/tools/provider/__tests__/detail.spec.tsx
  • pnpm --dir web exec eslint hooks/use-credential-permissions.ts hooks/use-credential-permissions.spec.ts app/components/tools/hooks/use-tool-permissions.ts app/components/tools/mcp/hooks/use-mcp-service-card.ts app/components/tools/mcp/hooks/__tests__/use-mcp-service-card.spec.ts app/components/plugins/card/index.tsx app/components/plugins/card/__tests__/index.spec.tsx app/components/plugins/install-plugin/base/use-get-icon.ts app/components/plugins/install-plugin/base/__tests__/use-get-icon.spec.ts app/components/plugins/marketplace/marketplace-install-permission-provider.tsx app/components/plugins/install-plugin/hooks/use-workspace-plugin-install-permission.ts app/components/plugins/install-plugin/hooks/__tests__/use-workspace-plugin-install-permission.spec.ts app/components/plugins/install-plugin/install-from-marketplace/steps/install.tsx app/components/plugins/install-plugin/install-from-marketplace/steps/__tests__/install.spec.tsx app/components/plugins/install-plugin/install-from-local-package/steps/install.tsx app/components/plugins/install-plugin/install-from-local-package/steps/__tests__/install.spec.tsx app/components/plugins/plugin-page/use-reference-setting.ts app/components/plugins/plugin-page/__tests__/use-reference-setting.spec.ts service/use-plugins.ts service/__tests__/use-plugins.spec.tsx __tests__/utils/mock-app-context-state.ts --cache --quiet
  • git diff --check
  • Pre-commit hook ran eslint --fix --pass-on-unpruned-suppressions on staged files successfully.

Notes:

  • pnpm --dir web type-check still fails locally in generated .next/types/validator.ts route types before reaching this change.
  • pnpm --dir web exec vp staged cannot run locally because no staged config is defined in vite.config.ts.
  • Full touched-file eslint still reports pre-existing issues in legacy plugin components (deprecated base Input, existing a11y warnings, and existing any usage) outside this migration's scope.

From Codex

@github-actions github-actions Bot added the web This relates to changes on the web. label Jul 8, 2026
@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.34%. Comparing base (76a6cd3) to head (43fbd02).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #38533   +/-   ##
=======================================
  Coverage   85.34%   85.34%           
=======================================
  Files        5013     5013           
  Lines      265787   265799   +12     
  Branches    50528    50533    +5     
=======================================
+ Hits       226829   226843   +14     
+ Misses      34510    34508    -2     
  Partials     4448     4448           
Flag Coverage Δ
dify-ui 94.61% <ø> (ø)
web 84.90% <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.

@hyoban hyoban marked this pull request as ready for review July 8, 2026 06:25
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. refactor labels Jul 8, 2026
@hyoban hyoban enabled auto-merge July 8, 2026 06:25
@hyoban hyoban added this pull request to the merge queue Jul 8, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 8, 2026
Merged via the queue into main with commit 503d80b Jul 8, 2026
38 checks passed
@hyoban hyoban deleted the 0708-app-context-bootstrap branch July 8, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:M This PR changes 30-99 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants