dify/web/service
yyh 2833965815
refactor!: migrate commonLayout to SSR prefetch with TanStack Query hydration
BREAKING CHANGE: commonLayout is now an async Server Component that
prefetches user-profile and current-workspace on the server via
TanStack Query's prefetchQuery + HydrationBoundary pattern. This
replaces the previous purely client-side data fetching approach.

Key changes:

- **SSR data prefetch (root layout)**: prefetch systemFeatures and
  setupStatus in the root layout server component, wrap children with
  HydrationBoundary to hydrate TanStack Query cache on the client.

- **SSR data prefetch (commonLayout)**: convert commonLayout from a
  client component to an async server component that prefetches
  user-profile (with x-version/x-env response headers) and
  current-workspace. Client-side providers/UI extracted to a new
  layout-client.tsx component.

- **Add loading.tsx (Next.js convention)**: add a Next.js loading.tsx
  file in commonLayout that shows a centered spinner. This replaces the
  deleted Splash component but works via Next.js built-in Suspense
  boundary for route segments, not a client-side overlay.

- **Extract shared SSR fetch utilities (utils/ssr-fetch.ts)**: create
  serverFetch (unauthenticated) and serverFetchWithAuth (with cookie
  forwarding + CSRF token). getAuthHeaders is wrapped with React.cache()
  for per-request deduplication across multiple SSR fetches.

- **Refactor AppInitializer**: split single monolithic async IIFE effect
  into three independent useEffects (oauth tracking, education verify,
  setup status check). Use useReducer for init flag, useRef to prevent
  duplicate tracking in StrictMode. Now reads setupStatus from TanStack
  Query cache (useSetupStatusQuery) instead of fetching independently.

- **Refactor global-public-context**: move Zustand store sync from
  queryFn side-effect to a dedicated useEffect, keeping queryFn pure.
  fetchSystemFeatures now simply returns the API response.

- **Fix usePSInfo SSR crash**: defer globalThis.location access from
  hook top-level to callback execution time via getDomain() helper,
  preventing "Cannot read properties of undefined" during server render.

- **Remove Splash component**: delete the client-side loading overlay
  that relied on useIsLogin polling, replaced by Next.js loading.tsx.

- **Remove staleTime/gcTime overrides in useUserProfile**: allow the
  SSR-prefetched data to be reused via default cache policy instead of
  forcing refetch on every mount.

- **Revert middleware auth guard**: remove the cookie-based session
  check in proxy.ts that caused false redirects to /signin for
  authenticated users (Dify's auth uses token refresh, not simple
  cookie presence).
2026-02-01 18:29:41 +08:00
..
knowledge feat: summary index (#31523) 2026-01-28 11:09:34 +08:00
_tools_util.spec.ts chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
_tools_util.ts fix: properly escape collectionName in query string parameters (#14476) 2025-02-27 18:59:07 +08:00
access-control.ts chore: integrate @tanstack/eslint-plugin-query and fix service layer lint errors (#30444) 2026-01-04 11:20:06 +08:00
annotation.ts refactor(web): drop swr and migrate share/chat hooks to tanstack query (#30232) 2025-12-29 14:04:01 +08:00
apps.ts feat(bundle): manifest-driven import with sandbox upload 2026-01-29 22:33:31 +08:00
base.spec.ts fix(web): add null check for SSE stream bufferObj to prevent TypeError (#30131) 2026-01-13 15:40:43 +08:00
base.ts Merge branch 'feat/llm-support-tools' into feat/support-agent-sandbox 2026-01-20 10:27:42 +08:00
billing.ts refactor: init orpc contract (#30885) 2026-01-13 23:38:28 +09:00
client.ts refactor: init orpc contract (#30885) 2026-01-13 23:38:28 +09:00
common.ts use contract for api request 2026-01-21 18:20:38 +08:00
datasets.ts feat: Download the uploaded files (#31068) 2026-01-19 16:48:13 +08:00
debug.ts refactor: Improve type safety in context generate modal hooks 2026-01-30 21:41:04 +08:00
explore.ts feat: frontend part of support try apps (#31287) 2026-01-22 18:16:37 +08:00
fetch.ts fix(web): replace Response.json with legacy Response constructor for pre-Chrome 105 compatibility(#31091) (#31095) 2026-01-16 14:26:23 +08:00
log.ts refactor(web): migrate log service to TanStack Query (#30065) 2025-12-24 15:25:28 +08:00
plugins.ts refactor(web): drop swr and migrate share/chat hooks to tanstack query (#30232) 2025-12-29 14:04:01 +08:00
refresh-token.ts fix: fix refresh token deadlock (#30828) 2026-01-12 09:35:31 +08:00
share.ts feat: frontend part of support try apps (#31287) 2026-01-22 18:16:37 +08:00
sso.ts chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
strategy.ts Introduce Plugins (#13836) 2025-02-17 17:05:13 +08:00
tag.ts chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
tools.ts refactor(tool-selector): remove unused components and consolidate import (#31018) 2026-01-26 14:24:00 +08:00
try-app.ts feat: frontend part of support try apps (#31287) 2026-01-22 18:16:37 +08:00
upload-to-presigned-url.ts refactor(app-asset): migrate file upload to presigned URL and batch upload 2026-01-23 15:11:04 +08:00
use-app-asset.ts feat(skill): add create blank skill modal with name validation 2026-01-30 16:10:19 +08:00
use-apps.ts fix: fix enhance app mode check (#30758) 2026-01-09 14:07:40 +08:00
use-base.ts chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
use-billing.ts refactor(contract): restructure console contracts with nested billing module (#30999) 2026-01-15 10:41:18 +08:00
use-common.ts refactor!: migrate commonLayout to SSR prefetch with TanStack Query hydration 2026-02-01 18:29:41 +08:00
use-dataset-card.ts refactor: restructure DatasetCard component for improved readability and maintainability (#30617) 2026-01-06 21:57:21 +08:00
use-datasource.ts chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
use-education.ts fix: correct useEducationStatus query cache configuration (#30416) 2025-12-31 13:51:05 +08:00
use-endpoints.ts chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
use-explore.ts feat: frontend part of support try apps (#31287) 2026-01-22 18:16:37 +08:00
use-flow.ts chore(web): migrate lodash-es to es-toolkit compat (#30126) 2025-12-25 09:44:57 +08:00
use-log.ts refactor(web): migrate log service to TanStack Query (#30065) 2025-12-24 15:25:28 +08:00
use-models.ts chore: integrate @tanstack/eslint-plugin-query and fix service layer lint errors (#30444) 2026-01-04 11:20:06 +08:00
use-oauth.ts chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
use-pipeline.ts chore: integrate @tanstack/eslint-plugin-query and fix service layer lint errors (#30444) 2026-01-04 11:20:06 +08:00
use-plugins-auth.ts chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
use-plugins.ts refactor: init orpc contract (#30885) 2026-01-13 23:38:28 +09:00
use-sandbox-file.ts feat(sandbox): refactor sandbox file handling to include app_id 2026-01-30 22:45:28 +08:00
use-sandbox-provider.ts feat(sandbox): preserve user config when switching to system default 2026-01-19 22:27:06 +08:00
use-share.spec.tsx feat: frontend part of support try apps (#31287) 2026-01-22 18:16:37 +08:00
use-share.ts feat: frontend part of support try apps (#31287) 2026-01-22 18:16:37 +08:00
use-strategy.ts chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
use-tools.ts perf(workflow): skip unnecessary query subscriptions for non-plugin nodes 2026-01-30 01:46:50 +08:00
use-triggers.ts fix(web): disable cache for trigger dynamic select options (#30161) 2025-12-25 16:35:26 +08:00
use-try-app.ts feat: frontend part of support try apps (#31287) 2026-01-22 18:16:37 +08:00
use-workflow.ts refactor(web): migrate workflow run history from useSWR to TanStack Query (#30077) 2025-12-24 18:21:01 +08:00
use-workspace.ts feat: ee workspace permission control (#30841) 2026-01-19 11:06:04 +08:00
utils.spec.ts chore(web): new lint setup (#30020) 2025-12-23 16:58:55 +08:00
utils.ts feat: knowledge pipeline (#25360) 2025-09-18 12:49:10 +08:00
webapp-auth.ts fix(api): add session_id validation for webapp JWT authentication (#28297) 2025-11-21 11:23:52 +08:00
workflow-comment.ts use contract for api request 2026-01-21 18:20:38 +08:00
workflow-payload.ts feat: enhance start node object value check (#30732) 2026-01-09 16:13:17 +08:00
workflow.ts Merge branch 'feat/collaboration2' into feat/support-agent-sandbox 2026-01-25 00:00:03 +08:00