Skip to content

refactor(web): migrate app context consumers#38530

Merged
hyoban merged 2 commits into
mainfrom
0708-app-context-apps
Jul 8, 2026
Merged

refactor(web): migrate app context consumers#38530
hyoban merged 2 commits into
mainfrom
0708-app-context-apps

Conversation

@hyoban

@hyoban hyoban commented Jul 8, 2026

Copy link
Copy Markdown
Member

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>.

Summary

Migrate Apps / app detail AppContext consumers to exact bootstrap atom reads as the next domain migration after Datasets.

This PR replaces broad useAppContext() / useSelector() reads across app detail, app creation/import, app configuration, access control, and apps list/card surfaces with direct reads from app-context-state atoms such as userProfileIdAtom, workspacePermissionKeysAtom, currentWorkspaceAtom, and langGeniusVersionInfoAtom.

It also adds a shared atom mock helper for focused frontend tests and updates affected specs to mock the exact bootstrap atoms consumed by migrated components.

Refs #38514

From Codex

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 -C web test app/components/app/access-config/__tests__/index.spec.tsx 'app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/__tests__/view.spec.tsx' 'app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/__tests__/chart-view.spec.tsx' 'app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/__tests__/panel.spec.tsx' 'app/(commonLayout)/app/(appDetailLayout)/[appId]/__tests__/layout-main.spec.tsx' app/components/app/create-from-dsl-modal/__tests__/index.spec.tsx app/components/app/overview/embedded/__tests__/index.spec.tsx app/components/app/log/__tests__/list.spec.tsx app/components/app/overview/__tests__/trigger-card.spec.tsx app/components/app/create-app-modal/__tests__/index.spec.tsx app/components/app/create-app-dialog/app-list/__tests__/index.spec.tsx app/components/app/app-access-control/__tests__/add-member-or-group-pop.spec.tsx app/components/app/configuration/debug/debug-with-single-model/__tests__/index.spec.tsx app/components/app/configuration/debug/debug-with-multiple-model/__tests__/chat-item.spec.tsx app/components/app/configuration/hooks/__tests__/use-configuration.spec.tsx app/components/app/configuration/dataset-config/__tests__/index.spec.tsx app/components/app/configuration/dataset-config/select-dataset/__tests__/index.spec.tsx app/components/apps/__tests__/app-card.spec.tsx app/components/apps/__tests__/list.spec.tsx app/components/apps/__tests__/index.spec.tsx app/components/apps/__tests__/creators-filter.spec.tsx --run
  • git diff --check HEAD~1..HEAD
  • pnpm --dir web exec eslint __tests__/utils/mock-app-context-state.ts --fix --cache --quiet

Notes:

  • pnpm --dir web exec vp staged is currently blocked because this checkout's vite.config.ts does not define a staged config.
  • pnpm -C web type-check is currently blocked by existing generated .next/types/validator.ts route/layout type errors unrelated to this PR's touched files.
  • Running ESLint directly on all touched source files surfaces existing legacy rule violations in those files, including deprecated base Input imports, existing any usage, and existing a11y issues. This PR intentionally avoids expanding the migration into unrelated cleanup.

@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

❌ Patch coverage is 94.50549% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.34%. Comparing base (ee0068e) to head (74133fa).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
web/__tests__/utils/mock-app-context-state.ts 88.63% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #38530   +/-   ##
=======================================
  Coverage   85.34%   85.34%           
=======================================
  Files        5012     5013    +1     
  Lines      265775   265829   +54     
  Branches    50519    50534   +15     
=======================================
+ Hits       226813   226863   +50     
- Misses      34512    34516    +4     
  Partials     4450     4450           
Flag Coverage Δ
dify-ui 94.72% <ø> (ø)
web 84.90% <94.50%> (+<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 03:50
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. refactor labels Jul 8, 2026
@hyoban hyoban enabled auto-merge July 8, 2026 03:50
@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 76a6cd3 Jul 8, 2026
38 checks passed
@hyoban hyoban deleted the 0708-app-context-apps branch July 8, 2026 03:59
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:L This PR changes 100-499 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