dify/web/app/components
yyh c63a73ef83
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 19:07:32 +08:00
..
app revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
app-sidebar refactor: unified shortcut keys display using component (#31713) 2026-01-29 17:57:46 +08:00
apps feat: try app support review (#31716) 2026-01-29 19:40:47 +08:00
base revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
billing refactor!: migrate commonLayout to SSR prefetch with TanStack Query hydration 2026-02-01 19:07:32 +08:00
custom chore: remove useless __esModule (#30366) 2025-12-30 15:37:16 +08:00
datasets refactor: unified shortcut keys display using component (#31713) 2026-01-29 17:57:46 +08:00
develop test: add comprehensive tests (#31649) 2026-01-29 11:16:26 +08:00
devtools refactor(web): organize devtools components (#30318) 2025-12-30 09:21:41 +08:00
explore chore: hide disable try tab when not support (#31759) 2026-01-30 18:10:25 +08:00
goto-anything refactor: unified shortcut keys display using component (#31713) 2026-01-29 17:57:46 +08:00
header refactor(web): consolidate download helpers (#31664) 2026-01-29 16:02:49 +08:00
plugins revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
provider chore: disable serwist in dev (#31424) 2026-01-23 11:35:14 +08:00
rag-pipeline revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
share revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
signin test: add tests for dataset document detail (#31274) 2026-01-27 15:43:27 +08:00
tools test: add tests for dataset document detail (#31274) 2026-01-27 15:43:27 +08:00
workflow revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
workflow-app revert: revert human input relevant code (#31766) 2026-01-30 19:18:49 +08:00
app-initializer.tsx refactor!: migrate commonLayout to SSR prefetch with TanStack Query hydration 2026-02-01 19:07:32 +08:00
browser-initializer.spec.ts feat: Add polyfill for Array.prototype.toSpliced method (#30031) 2025-12-23 17:48:20 +08:00
browser-initializer.tsx feat: Add polyfill for Array.prototype.toSpliced method (#30031) 2025-12-23 17:48:20 +08:00
sentry-initializer.tsx refactor(web): Migrate to Unified TanStack Devtools (#30279) 2025-12-29 09:43:44 +08:00