ide-page.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { lazy, Suspense } from 'react'
  2. import { Alerts } from '@/features/ide-react/components/alerts/alerts'
  3. import { MainLayout } from '@/features/ide-react/components/layout/main-layout'
  4. import EditorLeftMenu from '@/features/editor-left-menu/components/editor-left-menu'
  5. import { useLayoutEventTracking } from '@/features/ide-react/hooks/use-layout-event-tracking'
  6. import useSocketListeners from '@/features/ide-react/hooks/use-socket-listeners'
  7. import { useEditingSessionHeartbeat } from '@/features/ide-react/hooks/use-editing-session-heartbeat'
  8. import { useRegisterUserActivity } from '@/features/ide-react/hooks/use-register-user-activity'
  9. import { useHasLintingError } from '@/features/ide-react/hooks/use-has-linting-error'
  10. import { Modals } from '@/features/ide-react/components/modals/modals'
  11. import { GlobalAlertsProvider } from '@/features/ide-react/context/global-alerts-context'
  12. import { GlobalToasts } from '../global-toasts'
  13. import {
  14. canUseNewEditor,
  15. useIsNewEditorEnabled,
  16. } from '@/features/ide-redesign/utils/new-editor-utils'
  17. import EditorSurvey from '../editor-survey'
  18. import { useFeatureFlag } from '@/shared/context/split-test-context'
  19. import { useStatusFavicon } from '@/features/ide-react/hooks/use-status-favicon'
  20. const MainLayoutNew = lazy(
  21. () => import('@/features/ide-redesign/components/main-layout')
  22. )
  23. const SettingsModalNew = lazy(
  24. () => import('@/features/ide-redesign/components/settings/settings-modal')
  25. )
  26. export default function IdePage() {
  27. useLayoutEventTracking() // sent event when the layout changes
  28. useSocketListeners() // listen for project-related websocket messages
  29. useEditingSessionHeartbeat() // send a batched event when user is active
  30. useRegisterUserActivity() // record activity and ensure connection when user is active
  31. useHasLintingError() // pass editor:lint hasLintingError to the compiler
  32. useStatusFavicon() // update the favicon based on the compile status
  33. const newEditor = useIsNewEditorEnabled()
  34. const canAccessNewEditor = canUseNewEditor()
  35. const editorSurveyFlag = useFeatureFlag('editor-popup-ux-survey')
  36. const showEditorSurvey = editorSurveyFlag && !canAccessNewEditor
  37. return (
  38. <GlobalAlertsProvider>
  39. <Alerts />
  40. <Modals />
  41. {newEditor ? (
  42. <Suspense fallback={null}>
  43. <SettingsModalNew />
  44. <MainLayoutNew />
  45. </Suspense>
  46. ) : (
  47. <>
  48. <EditorLeftMenu />
  49. <MainLayout />
  50. </>
  51. )}
  52. <GlobalToasts />
  53. {showEditorSurvey && <EditorSurvey />}
  54. </GlobalAlertsProvider>
  55. )
  56. }