@shellui/core 0.5.4-alpha.1 → 0.6.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +2 -0
  2. package/package.json +6 -4
  3. package/schemas/shellui.config.schema.json +104 -64
  4. package/src/app.tsx +5 -3
  5. package/src/components/ContentView.tsx +26 -5
  6. package/src/components/LoadingOverlay.tsx +1 -1
  7. package/src/components/ui/sonner.spec.tsx +138 -0
  8. package/src/components/ui/sonner.tsx +5 -5
  9. package/src/components/ui/switch.tsx +1 -1
  10. package/src/features/admin/AdminView.tsx +14 -3
  11. package/src/features/ai/AiBridge.tsx +106 -0
  12. package/src/features/ai/AiUnavailableResponder.tsx +39 -0
  13. package/src/features/ai/README.md +52 -0
  14. package/src/features/ai/ShellAiHost.tsx +24 -0
  15. package/src/features/ai/adapters/ollama.ts +170 -0
  16. package/src/features/ai/adapters/promptApi.spec.ts +135 -0
  17. package/src/features/ai/adapters/promptApi.ts +222 -0
  18. package/src/features/ai/adapters/webllm.experimental.spec.ts +69 -0
  19. package/src/features/ai/adapters/webllm.spec.ts +527 -0
  20. package/src/features/ai/adapters/webllm.ts +142 -0
  21. package/src/features/ai/aiDisabledResponses.spec.ts +29 -0
  22. package/src/features/ai/aiDisabledResponses.ts +32 -0
  23. package/src/features/ai/browserInstallStore.spec.ts +58 -0
  24. package/src/features/ai/browserInstallStore.ts +76 -0
  25. package/src/features/ai/catalog.ts +31 -0
  26. package/src/features/ai/createRegistry.ts +83 -0
  27. package/src/features/ai/developHarness.spec.ts +108 -0
  28. package/src/features/ai/developHarness.ts +161 -0
  29. package/src/features/ai/engine/formatAiError.spec.ts +85 -0
  30. package/src/features/ai/engine/formatAiError.ts +132 -0
  31. package/src/features/ai/engine/mapInitProgress.ts +9 -0
  32. package/src/features/ai/engine/normalizeWebLlmModule.spec.ts +47 -0
  33. package/src/features/ai/engine/vite-worker.d.ts +6 -0
  34. package/src/features/ai/engine/webllm.worker.ts +51 -0
  35. package/src/features/ai/engine/webllmEngine.ts +1011 -0
  36. package/src/features/ai/handleRequest.spec.ts +288 -0
  37. package/src/features/ai/handleRequest.ts +325 -0
  38. package/src/features/ai/isAiFeatureEnabled.spec.ts +15 -0
  39. package/src/features/ai/isAiFeatureEnabled.ts +9 -0
  40. package/src/features/ai/promptApiSupport.spec.ts +64 -0
  41. package/src/features/ai/promptApiSupport.ts +117 -0
  42. package/src/features/ai/registry.spec.ts +100 -0
  43. package/src/features/ai/registry.ts +131 -0
  44. package/src/features/ai/status.spec.ts +92 -0
  45. package/src/features/ai/status.ts +85 -0
  46. package/src/features/ai/types.ts +100 -0
  47. package/src/features/ai/webLlmBrowserSupport.spec.ts +86 -0
  48. package/src/features/ai/webLlmBrowserSupport.ts +92 -0
  49. package/src/features/alertDialog/DialogContext.tsx +3 -1
  50. package/src/features/auth/AuthProvider.tsx +254 -39
  51. package/src/features/auth/backends/index.ts +8 -0
  52. package/src/features/auth/backends/shellui.spec.ts +201 -0
  53. package/src/features/auth/backends/shellui.ts +93 -16
  54. package/src/features/auth/backends/supabase.ts +8 -0
  55. package/src/features/auth/backends/types.ts +16 -1
  56. package/src/features/auth/components/LoginButton.tsx +26 -2
  57. package/src/features/auth/components/LoginView.tsx +114 -133
  58. package/src/features/auth/components/SessionLoadingView.tsx +21 -0
  59. package/src/features/auth/hooks/useAuth.tsx +12 -0
  60. package/src/features/auth/shellAccountRequests.ts +76 -0
  61. package/src/features/auth/utils/authRequestError.ts +4 -1
  62. package/src/features/auth/utils/authSessionPersistence.spec.ts +11 -0
  63. package/src/features/auth/utils/authSessionPersistence.ts +12 -0
  64. package/src/features/auth/utils/index.ts +4 -0
  65. package/src/features/auth/utils/resolveLoginSettings.spec.ts +33 -0
  66. package/src/features/auth/utils/resolveLoginSettings.ts +33 -0
  67. package/src/features/auth/utils/shareInFlight.spec.ts +41 -0
  68. package/src/features/auth/utils/shareInFlight.ts +14 -0
  69. package/src/features/config/ConfigProvider.ts +9 -1
  70. package/src/features/config/types.ts +43 -0
  71. package/src/features/layouts/appbar/AppBarLayout.tsx +8 -3
  72. package/src/features/layouts/filterNavigationForAuthState.spec.ts +41 -0
  73. package/src/features/layouts/floating/FloatingLayout.tsx +9 -4
  74. package/src/features/layouts/sidebar/SidebarLayout.tsx +9 -4
  75. package/src/features/layouts/utils.ts +6 -2
  76. package/src/features/layouts/windows/WindowsLayout.tsx +8 -3
  77. package/src/features/messaging/MessagingSecurityBootstrap.tsx +6 -6
  78. package/src/features/security/trustedFrames.spec.ts +65 -0
  79. package/src/features/security/trustedFrames.ts +52 -0
  80. package/src/features/settings/SettingsIcons.tsx +17 -0
  81. package/src/features/settings/SettingsProvider.tsx +28 -3
  82. package/src/features/settings/SettingsRoutes.tsx +8 -0
  83. package/src/features/settings/SettingsView.tsx +21 -4
  84. package/src/features/settings/components/Ai.tsx +830 -0
  85. package/src/features/settings/components/Develop.tsx +4 -0
  86. package/src/features/settings/components/Storage.tsx +197 -32
  87. package/src/features/settings/components/UserSettingsPanel.tsx +160 -12
  88. package/src/features/settings/components/createUserSettingsRoute.tsx +4 -0
  89. package/src/features/settings/components/develop/AiTestTools.tsx +231 -0
  90. package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +54 -1
  91. package/src/features/settings/utils/buildSettingsForPropagation.ts +15 -1
  92. package/src/features/settings/utils/mergePreferencesIntoSettings.spec.ts +6 -0
  93. package/src/features/settings/utils/shouldShowStorageSettings.spec.ts +49 -0
  94. package/src/features/settings/utils/shouldShowStorageSettings.ts +19 -0
  95. package/src/features/storage/uploads/UploadToastCard.tsx +2 -442
  96. package/src/features/storage/uploads/UploadToaster.tsx +2 -44
  97. package/src/features/storage/uploads/uploadQueue.ts +128 -308
  98. package/src/features/storage/uploads/useUploadQueue.ts +7 -3
  99. package/src/features/transfers/TransferToastCard.tsx +467 -0
  100. package/src/features/transfers/TransferToaster.tsx +50 -0
  101. package/src/features/transfers/index.ts +33 -0
  102. package/src/features/transfers/transferQueue.spec.ts +97 -0
  103. package/src/features/transfers/transferQueue.ts +442 -0
  104. package/src/features/transfers/types.ts +38 -0
  105. package/src/features/transfers/useTransferQueue.ts +30 -0
  106. package/src/i18n/translations/en/common.json +46 -2
  107. package/src/i18n/translations/en/settings.json +151 -2
  108. package/src/i18n/translations/fr/common.json +46 -2
  109. package/src/i18n/translations/fr/settings.json +151 -2
  110. package/src/index.css +57 -4
  111. package/src/index.ts +1 -0
  112. package/src/routes/components/NavigationItemRoute.tsx +2 -1
package/README.md CHANGED
@@ -6,6 +6,8 @@ React runtime for the Shellui host. `@shellui/cli` depends on this package. Inst
6
6
  npm install @shellui/core
7
7
  ```
8
8
 
9
+ The 0.6.0 pre-release is on the `beta` tag: `npm install @shellui/core@beta`.
10
+
9
11
  ```typescript
10
12
  import type { ShellUIConfig } from '@shellui/core';
11
13
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shellui/core",
3
- "version": "0.5.4-alpha.1",
3
+ "version": "0.6.0-beta.1",
4
4
  "description": "Shellui Core - Core React application runtime",
5
5
  "main": "src/index.ts",
6
6
  "type": "module",
@@ -44,6 +44,7 @@
44
44
  "author": "Shellui",
45
45
  "license": "MIT",
46
46
  "dependencies": {
47
+ "@mlc-ai/web-llm": "0.2.85",
47
48
  "@radix-ui/react-alert-dialog": "^1.1.15",
48
49
  "@radix-ui/react-collapsible": "^1.1.12",
49
50
  "@radix-ui/react-dialog": "^1.1.15",
@@ -60,7 +61,7 @@
60
61
  "react-i18next": "^16.5.4",
61
62
  "react-icons": "^5.6.0",
62
63
  "react-markdown": "^10.1.0",
63
- "react-router": "^7.13.0",
64
+ "react-router": "^7.18.4",
64
65
  "roarr": "^7.21.4",
65
66
  "sonner": "^2.0.7",
66
67
  "tailwind-merge": "^3.5.0",
@@ -72,7 +73,7 @@
72
73
  "workbox-routing": "^7.4.0",
73
74
  "workbox-strategies": "^7.4.0",
74
75
  "workbox-window": "^7.4.0",
75
- "@shellui/sdk": "0.5.4-alpha.1"
76
+ "@shellui/sdk": "0.6.0-beta.1"
76
77
  },
77
78
  "peerDependencies": {
78
79
  "react": "^18.0.0 || ^19.0.0",
@@ -85,12 +86,13 @@
85
86
  "@tailwindcss/typography": "^0.5.19",
86
87
  "@types/react": "^19.2.14",
87
88
  "@types/react-dom": "^19.2.3",
89
+ "happy-dom": "^20.14.5",
88
90
  "react": "^19.2.4",
89
91
  "react-dom": "^19.2.4",
90
92
  "tailwindcss-animate": "^1.0.7",
91
93
  "ts-json-schema-generator": "^2.9.0",
92
94
  "typescript": "^5.9.3",
93
- "vitest": "^4.0.18"
95
+ "vitest": "^4.1.11"
94
96
  },
95
97
  "scripts": {
96
98
  "test": "node scripts/test.js",
@@ -69,10 +69,18 @@
69
69
  "$ref": "#/definitions/StorageConfig",
70
70
  "description": "Storage-service connection. Propagated to iframes via SDK settings. Enables Admin → Storage when `url` is set. Settings → Storage (quota) is shown when `url` is set unless `storage.showInSettings` is false."
71
71
  },
72
+ "ai": {
73
+ "$ref": "#/definitions/AiConfig",
74
+ "description": "On-device AI (Ollama + browser WebLLM). Disabled by default; set `enabled: true` to show Settings → AI and accept SDK AI calls. `@mlc-ai/web-llm` is never loaded otherwise. See docs/features/ai.md. Distinct from Settings → AI “Allow apps to use AI”."
75
+ },
72
76
  "hosting": {
73
77
  "$ref": "#/definitions/HostingConfig",
74
78
  "description": "Hosting-service connection. Propagated to iframes via SDK settings. Enables `shellui deploy` when `url` is set."
75
79
  },
80
+ "email": {
81
+ "$ref": "#/definitions/EmailConfig",
82
+ "description": "Email-service connection. Propagated to iframes via SDK settings. When `email` is set and `url` is omitted, the shell sends `https://email.shellui.com`. `showInAdmin: false` hides Admin → Email."
83
+ },
76
84
  "theme": {
77
85
  "$ref": "#/definitions/ThemeRef",
78
86
  "description": "Single theme: built-in name, path to a theme JSON/folder, or inline theme object. When set without `themes`, only this theme is available in the selector."
@@ -113,7 +121,7 @@
113
121
  },
114
122
  "security": {
115
123
  "$ref": "#/definitions/SecurityConfig",
116
- "description": "Host security (postMessage allowlist, BFF / HttpOnly refresh, shell CSP)."
124
+ "description": "Host security (postMessage allowlist, BFF auth, CSP — see docs/features/security.md)."
117
125
  },
118
126
  "cookieConsent": {
119
127
  "$ref": "#/definitions/CookieConsentConfig",
@@ -242,7 +250,7 @@
242
250
  },
243
251
  "safeForAuthToken": {
244
252
  "type": "boolean",
245
- "description": "Trust control for auth token sharing to iframe apps.\n- undefined/false: untrusted (default), access token is not shared\n- true: trusted (opt-in), access token can be shared to this companion"
253
+ "description": "Trust control for auth token sharing to iframe apps.\n- undefined/false: untrusted (default), access token is not shared\n- true: trusted, access token can be shared (opt-in)"
246
254
  }
247
255
  },
248
256
  "required": ["label", "path", "url"],
@@ -349,6 +357,17 @@
349
357
  "additionalProperties": false,
350
358
  "description": "Optional storage-service wiring for the shell and admin panel. When set, admin shows the Storage sidebar (files explorer, statistics, Django admin). Settings → Storage (quota) appears when `url` is set, unless `showInSettings` is false. Shellui will also use this for the SDK file API (`shellui.storage`)."
351
359
  },
360
+ "AiConfig": {
361
+ "type": "object",
362
+ "properties": {
363
+ "enabled": {
364
+ "type": "boolean",
365
+ "description": "Deploy-time opt-in for the whole AI feature. Default: false. Only `true` enables it. Otherwise: no AiBridge, no Settings → AI, SDK AI calls answer `unavailable`, and no WebLLM chunk/worker is loaded. Opt in with `\"ai\": { \"enabled\": true }`."
366
+ }
367
+ },
368
+ "additionalProperties": false,
369
+ "description": "On-device AI product feature (Ollama + browser / WebLLM). Distinct from the per-user Settings → AI “Allow apps to use AI” toggle."
370
+ },
352
371
  "HostingConfig": {
353
372
  "type": "object",
354
373
  "properties": {
@@ -377,6 +396,21 @@
377
396
  "additionalProperties": false,
378
397
  "description": "Optional hosting-service wiring for `shellui deploy` preview uploads. Preview sites expire after 7 days unless redeployed to the same slug."
379
398
  },
399
+ "EmailConfig": {
400
+ "type": "object",
401
+ "properties": {
402
+ "url": {
403
+ "type": "string",
404
+ "description": "Base URL of email-service. Default: `https://email.shellui.com` when `email` is set and this is omitted. Local: `http://localhost:8003`."
405
+ },
406
+ "showInAdmin": {
407
+ "type": "boolean",
408
+ "description": "When false, hide Admin → Email. Default: true (shown) when `email` is set."
409
+ }
410
+ },
411
+ "additionalProperties": false,
412
+ "description": "Optional email-service wiring for Admin → Email and iframe apps. When `email` is set and `url` is omitted, the shell uses `https://email.shellui.com`."
413
+ },
380
414
  "ThemeRef": {
381
415
  "anyOf": [
382
416
  {
@@ -858,68 +892,6 @@
858
892
  "additionalProperties": false,
859
893
  "description": "Sentry error reporting configuration. Only used in production; ignored in dev."
860
894
  },
861
- "SecurityConfig": {
862
- "type": "object",
863
- "properties": {
864
- "allowedMessageOrigins": {
865
- "type": "array",
866
- "items": {
867
- "type": "string"
868
- },
869
- "description": "Extra http(s) origins (or absolute URLs) allowed for Shellui postMessage traffic. Unioned with origins derived from navigation, storage, and admin URLs."
870
- },
871
- "bffAuth": {
872
- "$ref": "#/definitions/BffAuthConfig"
873
- },
874
- "csp": {
875
- "$ref": "#/definitions/CspConfig"
876
- }
877
- },
878
- "additionalProperties": false,
879
- "description": "Host security options. Additive namespace for postMessage, CSP, BFF auth, etc."
880
- },
881
- "BffAuthConfig": {
882
- "type": "object",
883
- "properties": {
884
- "enabled": {
885
- "type": "boolean",
886
- "description": "When true, refresh tokens are stored in an HttpOnly cookie via same-origin /api/auth/* routes."
887
- },
888
- "cookieName": {
889
- "type": "string",
890
- "description": "HttpOnly refresh cookie name. Default: shellui_refresh."
891
- }
892
- },
893
- "additionalProperties": false
894
- },
895
- "CspConfig": {
896
- "type": "object",
897
- "properties": {
898
- "enforce": {
899
- "type": "boolean",
900
- "description": "Emit enforcing Content-Security-Policy. Default false (report-only rollout)."
901
- },
902
- "reportOnly": {
903
- "type": "boolean",
904
- "description": "Emit Content-Security-Policy-Report-Only. Default true when security.csp is set."
905
- },
906
- "reportUri": {
907
- "type": "string",
908
- "description": "Optional CSP violation report endpoint."
909
- },
910
- "connectSrc": {
911
- "type": "array",
912
- "items": { "type": "string" },
913
- "description": "Extra connect-src hosts (companions, analytics)."
914
- },
915
- "frameSrc": {
916
- "type": "array",
917
- "items": { "type": "string" },
918
- "description": "Extra frame-src hosts for companion iframes."
919
- }
920
- },
921
- "additionalProperties": false
922
- },
923
895
  "BackendConfig": {
924
896
  "type": "object",
925
897
  "properties": {
@@ -999,6 +971,74 @@
999
971
  "enum": ["password", "oauth", "magic_link", "web3"],
1000
972
  "description": "Supported auth login methods that can be declared in config."
1001
973
  },
974
+ "SecurityConfig": {
975
+ "type": "object",
976
+ "properties": {
977
+ "allowedMessageOrigins": {
978
+ "type": "array",
979
+ "items": {
980
+ "type": "string"
981
+ },
982
+ "description": "Extra http(s) origins (or absolute URLs) allowed for Shellui postMessage traffic. Unioned with origins derived from navigation, storage, and admin URLs."
983
+ },
984
+ "bffAuth": {
985
+ "$ref": "#/definitions/BffAuthConfig"
986
+ },
987
+ "csp": {
988
+ "$ref": "#/definitions/CspConfig"
989
+ }
990
+ },
991
+ "additionalProperties": false,
992
+ "description": "Host security options. Additive namespace for postMessage, CSP, BFF auth, etc."
993
+ },
994
+ "BffAuthConfig": {
995
+ "type": "object",
996
+ "properties": {
997
+ "enabled": {
998
+ "type": "boolean",
999
+ "description": "When true, refresh tokens are stored in an HttpOnly cookie via `/api/auth/*` served by the shell host (CLI dev server or your production reverse proxy). Default: false (refresh stays in sessionStorage until you enable BFF)."
1000
+ },
1001
+ "cookieName": {
1002
+ "type": "string",
1003
+ "description": "HttpOnly cookie name. Default: `shellui_refresh`."
1004
+ }
1005
+ },
1006
+ "additionalProperties": false,
1007
+ "description": "Same-origin BFF auth for HttpOnly refresh cookies (see docs/features/security.md)."
1008
+ },
1009
+ "CspConfig": {
1010
+ "type": "object",
1011
+ "properties": {
1012
+ "enforce": {
1013
+ "type": "boolean",
1014
+ "description": "Emit an enforcing `Content-Security-Policy` header. Default: false (report-only) so playgrounds keep working during rollout."
1015
+ },
1016
+ "reportOnly": {
1017
+ "type": "boolean",
1018
+ "description": "Emit `Content-Security-Policy-Report-Only`. Default: true when `security.csp` is present."
1019
+ },
1020
+ "reportUri": {
1021
+ "type": "string",
1022
+ "description": "Optional CSP violation report endpoint (`report-uri` / `report-to`)."
1023
+ },
1024
+ "connectSrc": {
1025
+ "type": "array",
1026
+ "items": {
1027
+ "type": "string"
1028
+ },
1029
+ "description": "Extra hosts for `connect-src` (companion APIs, analytics, etc.)."
1030
+ },
1031
+ "frameSrc": {
1032
+ "type": "array",
1033
+ "items": {
1034
+ "type": "string"
1035
+ },
1036
+ "description": "Extra hosts for `frame-src` (companion iframes)."
1037
+ }
1038
+ },
1039
+ "additionalProperties": false,
1040
+ "description": "Shell document security headers (CSP, staged rollout)."
1041
+ },
1002
1042
  "CookieConsentConfig": {
1003
1043
  "type": "object",
1004
1044
  "properties": {
package/src/app.tsx CHANGED
@@ -11,10 +11,11 @@ import { DialogProvider } from './features/alertDialog/DialogContext';
11
11
  import { CookieConsentModal } from './features/cookieConsent/CookieConsentModal';
12
12
  import { AuthProvider } from './features/auth/AuthProvider';
13
13
  import { StorageBridge } from './features/storage/StorageBridge';
14
+ import { ShellAiHost } from './features/ai/ShellAiHost';
14
15
  import { SonnerProvider } from './features/sonner/SonnerContext';
15
16
  import { ChromeActionsHost, ChromeActionsProvider } from './features/chromeActions';
16
17
  import { Toaster } from './components/ui/sonner';
17
- import { UploadToaster } from './features/storage/uploads/UploadToaster';
18
+ import { TransferToaster } from './features/transfers/TransferToaster';
18
19
  import './features/sentry/initSentry';
19
20
  import './i18n/config'; // Initialize i18n
20
21
  import './index.css';
@@ -135,14 +136,15 @@ const App = () => {
135
136
  <AuthProvider>
136
137
  <StorageBridge />
137
138
  <SettingsProvider>
139
+ <ShellAiHost />
138
140
  <ThemeProvider>
139
141
  <I18nProvider>
140
142
  <DialogProvider>
141
143
  <SonnerProvider>
142
144
  <ChromeActionsProvider>
143
- {/* Toaster + upload progress live at Shellui root so they survive navigation. */}
145
+ {/* Toaster + transfer progress (uploads / AI downloads) live at Shellui root. */}
144
146
  <Toaster />
145
- <UploadToaster />
147
+ <TransferToaster />
146
148
  <ChromeActionsHost />
147
149
  <AppContent />
148
150
  </ChromeActionsProvider>
@@ -11,6 +11,7 @@ import {
11
11
  import { useEffect, useLayoutEffect, useRef, useState } from 'react';
12
12
  import { useLocation, useNavigate } from 'react-router';
13
13
  import { LoadingOverlay } from './LoadingOverlay';
14
+ import { LOADING_OVERLAY_DURATION_MS } from '../constants/loading';
14
15
  import { IFRAME_FOREIGN_ATTR } from '../features/layouts/chrome/constants';
15
16
  import { resolveContentIframeSandbox } from './contentIframeSandbox';
16
17
 
@@ -107,16 +108,17 @@ export const ContentView = ({
107
108
 
108
109
  const MIN_LOADING_MS = 80; // Don't reveal before this, reduces blink from theme/layout paint
109
110
 
111
+ // Stable object ref + layout effect — do NOT use an inline ref callback.
112
+ // Inline ref identity changes every render → React calls ref(null) and
113
+ // unregisters the frame on each update (breaks SHELLUI_DIALOG, etc.).
110
114
  useLayoutEffect(() => {
111
- if (!iframeRef.current) {
112
- return;
113
- }
114
- const iframeId = addIframe(iframeRef.current);
115
+ const node = iframeRef.current;
116
+ if (!node) return;
117
+ const iframeId = addIframe(node);
115
118
  return () => {
116
119
  removeIframe(iframeId);
117
120
  };
118
121
  }, [iframeUrl, navItem?.path ?? '', frameGeneration]);
119
-
120
122
  // Drive iframe when the shell location changes from outside the iframe
121
123
  // (nav item click, router back/forward). Prefer location.replace so we do not
122
124
  // pollute joint session history (same-origin iframe src changes would).
@@ -303,6 +305,25 @@ export const ContentView = ({
303
305
  };
304
306
  }, [ignoreMessages]);
305
307
 
308
+ // Non-shellui pages never send SHELLUI_INITIALIZED — reveal once the bar finishes
309
+ // (one pass, no loop) so the iframe is not stuck behind a looping overlay.
310
+ useEffect(() => {
311
+ if (!isLoading) return;
312
+ const timer = setTimeout(() => {
313
+ cancelRevealRef.current?.();
314
+ let cancelled = false;
315
+ cancelRevealRef.current = () => {
316
+ cancelled = true;
317
+ cancelRevealRef.current = null;
318
+ };
319
+ scheduleReveal(() => {
320
+ if (!cancelled) setIsLoading(false);
321
+ cancelRevealRef.current = null;
322
+ });
323
+ }, LOADING_OVERLAY_DURATION_MS);
324
+ return () => clearTimeout(timer);
325
+ }, [isLoading, iframeUrl, frameGeneration]);
326
+
306
327
  // After the first load, a cross-origin document (OAuth/login) cannot be inspected.
307
328
  // Flag it so desktop Back can restore the iframe to its assigned app URL.
308
329
  // Handshake is request-driven: the companion posts SETTINGS_REQUESTED when ready;
@@ -7,7 +7,7 @@ export function LoadingOverlay() {
7
7
  <div
8
8
  className="h-full w-0 bg-muted-foreground/50"
9
9
  style={{
10
- animation: `loading-bar-slide ${LOADING_OVERLAY_DURATION_MS}ms linear infinite`,
10
+ animation: `loading-bar-slide ${LOADING_OVERLAY_DURATION_MS}ms linear forwards`,
11
11
  }}
12
12
  />
13
13
  </div>
@@ -0,0 +1,138 @@
1
+ // @vitest-environment happy-dom
2
+ import { readFileSync } from 'node:fs';
3
+ import { dirname, resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ import { act } from 'react';
6
+ import { createRoot, type Root } from 'react-dom/client';
7
+ import { toast } from 'sonner';
8
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
9
+ import { Z_INDEX } from '../../lib/z-index';
10
+ import { Toaster } from './sonner';
11
+
12
+ vi.mock('../../features/settings/hooks/useSettings', () => ({
13
+ useSettings: () => ({
14
+ settings: { appearance: { colorScheme: 'light' } },
15
+ }),
16
+ }));
17
+
18
+ const POSITIONS = [
19
+ 'top-left',
20
+ 'top-center',
21
+ 'top-right',
22
+ 'bottom-left',
23
+ 'bottom-center',
24
+ 'bottom-right',
25
+ ] as const;
26
+
27
+ function specDir(): string {
28
+ const url = import.meta.url;
29
+ if (url.startsWith('file:')) return dirname(fileURLToPath(url));
30
+ return dirname(url);
31
+ }
32
+
33
+ const indexCss = readFileSync(resolve(specDir(), '../../index.css'), 'utf8');
34
+
35
+ function installToasterPointerCss() {
36
+ document.getElementById('toaster-pointer-test')?.remove();
37
+ const toasterRule = indexCss.match(
38
+ /\[data-sonner-toaster\]\s*\{[^}]*pointer-events:\s*none\s*!important;[^}]*\}/,
39
+ );
40
+ const toastRule = indexCss.match(
41
+ /\[data-sonner-toast\],[\s\S]*?\[data-upload-toast\] button\s*\{[^}]*pointer-events:\s*auto\s*!important;[^}]*\}/,
42
+ );
43
+ expect(toasterRule, 'toaster list must be pointer-events: none').toBeTruthy();
44
+ expect(toastRule, 'toast cards and buttons must be pointer-events: auto').toBeTruthy();
45
+ const style = document.createElement('style');
46
+ style.id = 'toaster-pointer-test';
47
+ style.textContent = `${toasterRule?.[0] ?? ''}\n${toastRule?.[0] ?? ''}`;
48
+ document.head.appendChild(style);
49
+ }
50
+
51
+ async function flush() {
52
+ await act(async () => {
53
+ await new Promise((done) => setTimeout(done, 0));
54
+ });
55
+ }
56
+
57
+ describe('Toaster hit testing', () => {
58
+ let root: Root;
59
+ let host: HTMLDivElement;
60
+
61
+ beforeEach(() => {
62
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
63
+ installToasterPointerCss();
64
+ host = document.createElement('div');
65
+ document.body.appendChild(host);
66
+ root = createRoot(host);
67
+ });
68
+
69
+ afterEach(async () => {
70
+ toast.dismiss();
71
+ await flush();
72
+ await act(async () => {
73
+ root.unmount();
74
+ });
75
+ host.remove();
76
+ document.body.style.pointerEvents = '';
77
+ });
78
+
79
+ it('does not stretch bottom lists and keeps pointer events on the cards', async () => {
80
+ await act(async () => {
81
+ root.render(<Toaster closeButton />);
82
+ });
83
+
84
+ for (const position of POSITIONS) {
85
+ toast(position, {
86
+ id: position,
87
+ duration: Infinity,
88
+ position,
89
+ description: 'Offset check',
90
+ action: { label: 'Go', onClick: () => {} },
91
+ cancel: { label: 'Stop', onClick: () => {} },
92
+ });
93
+ }
94
+ await flush();
95
+ await flush();
96
+
97
+ const lists = [...document.querySelectorAll<HTMLElement>('[data-sonner-toaster]')];
98
+ expect(
99
+ lists.map((list) => `${list.dataset.yPosition}-${list.dataset.xPosition}`).sort(),
100
+ ).toEqual([...POSITIONS].sort());
101
+
102
+ for (const list of lists) {
103
+ expect(list.style.top, `${list.dataset.yPosition} list inline top`).toBe('');
104
+ expect(list.style.pointerEvents, `${list.dataset.yPosition} list inline pointer-events`).toBe(
105
+ '',
106
+ );
107
+ expect(list.style.zIndex).toBe(String(Z_INDEX.TOAST));
108
+ expect(list.style.getPropertyValue('--offset-top')).toContain('--shellui-safe-area-top');
109
+ expect(list.style.getPropertyValue('--mobile-offset-top')).toContain(
110
+ '--shellui-safe-area-top',
111
+ );
112
+ expect(getComputedStyle(list).pointerEvents).toBe('none');
113
+
114
+ const card = list.querySelector<HTMLElement>('[data-sonner-toast]');
115
+ if (!card) throw new Error('missing toast card');
116
+ expect(getComputedStyle(card).pointerEvents).toBe('auto');
117
+ for (const selector of ['[data-action]', '[data-cancel]', '[data-close-button]']) {
118
+ const button = card.querySelector<HTMLElement>(selector);
119
+ if (!button) throw new Error(`missing ${selector}`);
120
+ expect(getComputedStyle(button).pointerEvents).toBe('auto');
121
+ }
122
+ }
123
+
124
+ document.body.style.pointerEvents = 'none';
125
+ const bottom = document.querySelector<HTMLElement>(
126
+ '[data-sonner-toaster][data-y-position="bottom"][data-x-position="center"]',
127
+ );
128
+ if (!bottom) throw new Error('missing bottom-center list');
129
+ expect(getComputedStyle(bottom).pointerEvents).toBe('none');
130
+ const bottomCard = bottom.querySelector<HTMLElement>('[data-sonner-toast]');
131
+ const action = bottomCard?.querySelector<HTMLElement>('[data-action]');
132
+ const close = bottomCard?.querySelector<HTMLElement>('[data-close-button]');
133
+ if (!bottomCard || !action || !close) throw new Error('missing bottom-center controls');
134
+ expect(getComputedStyle(bottomCard).pointerEvents).toBe('auto');
135
+ expect(getComputedStyle(action).pointerEvents).toBe('auto');
136
+ expect(getComputedStyle(close).pointerEvents).toBe('auto');
137
+ });
138
+ });
@@ -66,12 +66,12 @@ const Toaster = ({ ...props }: ToasterProps) => {
66
66
  theme={settings.appearance.colorScheme as 'light' | 'dark' | 'system'}
67
67
  className="toaster group"
68
68
  style={{
69
+ // Stacking only. Sonner copies `style` onto every position list. An inline
70
+ // `top` plus a bottom list's own `bottom` stretches that list over the
71
+ // viewport, and pointer-events on the list then block clicks outside the
72
+ // cards. Safe-area offset is `offset` / `mobileOffset`. Pointer events live
73
+ // on the toast cards (see index.css) so they stay clickable over a modal.
69
74
  zIndex: Z_INDEX.TOAST,
70
- // Re-enable pointer events so toasts stay clickable when a Radix modal is open
71
- // (Radix sets body.style.pointerEvents = 'none' and only the dialog content gets 'auto')
72
- pointerEvents: 'auto',
73
- // Clear the safe-area topbar / notch, then keep a 1rem gap below it
74
- top: 'calc(var(--shellui-safe-area-top, env(safe-area-inset-top, 0px)) + 1rem)',
75
75
  }}
76
76
  offset={{
77
77
  top: 'calc(var(--shellui-safe-area-top, env(safe-area-inset-top, 0px)) + 1rem)',
@@ -13,7 +13,7 @@ const Switch = forwardRef<HTMLInputElement, SwitchProps>(
13
13
  };
14
14
 
15
15
  return (
16
- <label className="inline-flex items-center cursor-pointer">
16
+ <label className="inline-flex items-center cursor-pointer relative">
17
17
  <input
18
18
  type="checkbox"
19
19
  ref={ref}
@@ -4,6 +4,7 @@ import { Button } from '../../components/ui/button';
4
4
  import { ContentView } from '../../components/ContentView';
5
5
  import { useIsMobile } from '../../hooks/use-mobile';
6
6
  import { LoginButton } from '../auth/components/LoginButton';
7
+ import { SessionLoadingView } from '../auth/components/SessionLoadingView';
7
8
  import { useAuth } from '../auth/hooks/useAuth';
8
9
  import { useConfig } from '../config/useConfig';
9
10
  import type { NavigationItem } from '../config/types';
@@ -19,7 +20,10 @@ import { buildAdminIframeSrc } from './utils';
19
20
 
20
21
  const ADMIN_HEADER_HEIGHT_PX = 48;
21
22
 
22
- const AdminAccessGuard = ({ allow }: { allow: boolean }) => {
23
+ const AdminAccessGuard = ({ allow, isLoading }: { allow: boolean; isLoading: boolean }) => {
24
+ if (isLoading) {
25
+ return <SessionLoadingView />;
26
+ }
23
27
  if (!allow) {
24
28
  return <AdminForbiddenAccess />;
25
29
  }
@@ -30,7 +34,7 @@ export const AdminView = () => {
30
34
  const navigate = useNavigate();
31
35
  const location = useLocation();
32
36
  const { config } = useConfig();
33
- const { user } = useAuth();
37
+ const { user, isLoading: isAuthLoading } = useAuth();
34
38
  const isMobile = useIsMobile();
35
39
  const canOpenAdminPanel = Boolean(user?.isStaff || user?.isCompanyOwner);
36
40
  const adminPath = getAdminPath(config);
@@ -119,7 +123,14 @@ export const AdminView = () => {
119
123
  </header>
120
124
  <main className="flex min-h-0 flex-1">
121
125
  <Routes>
122
- <Route element={<AdminAccessGuard allow={canOpenAdminPanel} />}>
126
+ <Route
127
+ element={
128
+ <AdminAccessGuard
129
+ allow={canOpenAdminPanel}
130
+ isLoading={isAuthLoading}
131
+ />
132
+ }
133
+ >
123
134
  <Route
124
135
  path="*"
125
136
  element={