@shellui/core 0.4.0 → 0.5.0-alpha.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 (145) hide show
  1. package/README.md +2 -2
  2. package/package.json +15 -3
  3. package/schemas/curated-themes.json +4035 -0
  4. package/schemas/shellui.config.schema.json +961 -0
  5. package/schemas/shellui.theme.schema.json +187 -0
  6. package/src/app.tsx +4 -1
  7. package/src/components/ContentView.tsx +144 -9
  8. package/src/components/LoadingOverlay.tsx +1 -1
  9. package/src/components/ui/alert-dialog.tsx +1 -1
  10. package/src/components/ui/dialog.tsx +23 -5
  11. package/src/components/ui/drawer.tsx +282 -42
  12. package/src/components/ui/dropdown-menu.tsx +7 -2
  13. package/src/components/ui/input.tsx +21 -0
  14. package/src/components/ui/separator.tsx +23 -0
  15. package/src/components/ui/sheet.tsx +220 -0
  16. package/src/components/ui/sidebar.tsx +785 -221
  17. package/src/components/ui/skeleton.tsx +13 -0
  18. package/src/constants/urls.ts +1 -0
  19. package/src/features/admin/utils.ts +2 -45
  20. package/src/features/alertDialog/DialogContext.tsx +1 -1
  21. package/src/features/auth/components/LoginButton.tsx +25 -18
  22. package/src/features/auth/components/LoginPreferencesControls.tsx +124 -0
  23. package/src/features/auth/components/LoginView.tsx +131 -49
  24. package/src/features/config/types.ts +64 -82
  25. package/src/features/drawer/DrawerContext.tsx +55 -19
  26. package/src/features/layouts/AppLayout.tsx +3 -3
  27. package/src/features/layouts/OverlayShell.tsx +376 -77
  28. package/src/features/layouts/appbar/AppBarLayout.tsx +501 -88
  29. package/src/features/layouts/branding/AppBrandIcon.tsx +95 -0
  30. package/src/features/layouts/branding/resolveThemeAsset.spec.ts +33 -0
  31. package/src/features/layouts/branding/resolveThemeAsset.ts +33 -0
  32. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +49 -0
  33. package/src/features/layouts/chrome/ContentDragOverlay.tsx +19 -0
  34. package/src/features/layouts/chrome/DesktopBackButton.tsx +71 -0
  35. package/src/features/layouts/chrome/DesktopChrome.tsx +28 -0
  36. package/src/features/layouts/chrome/DesktopForwardButton.tsx +59 -0
  37. package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +16 -0
  38. package/src/features/layouts/chrome/constants.ts +11 -0
  39. package/src/features/layouts/chrome/goDesktopBack.spec.ts +218 -0
  40. package/src/features/layouts/chrome/goDesktopBack.ts +106 -0
  41. package/src/features/layouts/chrome/index.ts +26 -0
  42. package/src/features/layouts/chrome/runtime.ts +45 -0
  43. package/src/features/layouts/findMatchingNavigationItem.spec.ts +55 -0
  44. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +17 -1
  45. package/src/features/layouts/isFrameForAppUrl.spec.ts +33 -0
  46. package/src/features/layouts/sidebar/NavigationContent.tsx +70 -34
  47. package/src/features/layouts/sidebar/SidebarIcons.tsx +41 -42
  48. package/src/features/layouts/sidebar/SidebarInner.tsx +142 -24
  49. package/src/features/layouts/sidebar/SidebarLayout.tsx +100 -37
  50. package/src/features/layouts/sidebar/sidebarUtils.ts +0 -7
  51. package/src/features/layouts/sidebar/types.ts +3 -3
  52. package/src/features/layouts/utils.ts +73 -5
  53. package/src/features/layouts/windows/WindowsLayout.tsx +173 -61
  54. package/src/features/modal/ModalContext.spec.ts +77 -0
  55. package/src/features/modal/ModalContext.tsx +32 -57
  56. package/src/features/modal/validateAndNormalizeUrl.ts +96 -0
  57. package/src/features/overlays/OverlayDrawerPendingBar.tsx +26 -0
  58. package/src/features/overlays/OverlayDynamicDemoView.tsx +108 -0
  59. package/src/features/overlays/OverlayPendingSpinner.tsx +18 -0
  60. package/src/features/overlays/ResponsiveModal.tsx +483 -0
  61. package/src/features/overlays/overlaySize.spec.ts +71 -0
  62. package/src/features/overlays/overlaySize.ts +228 -0
  63. package/src/features/overlays/useOverlayReportedSize.ts +130 -0
  64. package/src/features/settings/SettingsProvider.tsx +66 -46
  65. package/src/features/settings/SettingsView.tsx +42 -47
  66. package/src/features/settings/components/Appearance.tsx +305 -55
  67. package/src/features/settings/components/develop/DrawerTestButtons.tsx +18 -0
  68. package/src/features/settings/components/develop/ModalTestButtons.tsx +23 -0
  69. package/src/features/settings/utils/getResolvedAppearanceForSettings.ts +11 -5
  70. package/src/features/storage/StoragePickerContext.tsx +3 -3
  71. package/src/features/theme/applyTheme.ts +143 -0
  72. package/src/features/theme/color.ts +83 -0
  73. package/src/features/theme/curated/amber-minimal.json +86 -0
  74. package/src/features/theme/curated/amethyst-haze.json +86 -0
  75. package/src/features/theme/curated/astro-vista.json +86 -0
  76. package/src/features/theme/curated/bold-tech.json +86 -0
  77. package/src/features/theme/curated/bubblegum.json +86 -0
  78. package/src/features/theme/curated/caffeine.json +83 -0
  79. package/src/features/theme/curated/candyland.json +86 -0
  80. package/src/features/theme/curated/catppuccin.json +86 -0
  81. package/src/features/theme/curated/claude.json +86 -0
  82. package/src/features/theme/curated/claymorphism.json +86 -0
  83. package/src/features/theme/curated/clean-slate.json +86 -0
  84. package/src/features/theme/curated/cosmic-night.json +86 -0
  85. package/src/features/theme/curated/cyberpunk.json +86 -0
  86. package/src/features/theme/curated/darkmatter.json +86 -0
  87. package/src/features/theme/curated/doom-64.json +86 -0
  88. package/src/features/theme/curated/elegant-luxury.json +86 -0
  89. package/src/features/theme/curated/graphite.json +86 -0
  90. package/src/features/theme/curated/index.ts +260 -0
  91. package/src/features/theme/curated/kodama-grove.json +86 -0
  92. package/src/features/theme/curated/light-green.json +87 -0
  93. package/src/features/theme/curated/midnight-bloom.json +86 -0
  94. package/src/features/theme/curated/mocha-mousse.json +86 -0
  95. package/src/features/theme/curated/modern-minimal.json +86 -0
  96. package/src/features/theme/curated/mono.json +84 -0
  97. package/src/features/theme/curated/nature.json +86 -0
  98. package/src/features/theme/curated/neo-brutalism.json +86 -0
  99. package/src/features/theme/curated/northern-lights.json +86 -0
  100. package/src/features/theme/curated/notebook.json +87 -0
  101. package/src/features/theme/curated/ocean-breeze.json +86 -0
  102. package/src/features/theme/curated/pastel-dreams.json +86 -0
  103. package/src/features/theme/curated/perpetuity.json +86 -0
  104. package/src/features/theme/curated/quantum-rose.json +86 -0
  105. package/src/features/theme/curated/retro-arcade.json +86 -0
  106. package/src/features/theme/curated/sage-garden.json +86 -0
  107. package/src/features/theme/curated/shadcn.json +83 -0
  108. package/src/features/theme/curated/shellui.json +82 -0
  109. package/src/features/theme/curated/soft-pop.json +86 -0
  110. package/src/features/theme/curated/solar-dusk.json +86 -0
  111. package/src/features/theme/curated/starry-night.json +86 -0
  112. package/src/features/theme/curated/sunset-horizon.json +86 -0
  113. package/src/features/theme/curated/supabase.json +85 -0
  114. package/src/features/theme/curated/t3-chat.json +83 -0
  115. package/src/features/theme/curated/tangerine.json +86 -0
  116. package/src/features/theme/curated/twitter.json +86 -0
  117. package/src/features/theme/curated/vercel.json +86 -0
  118. package/src/features/theme/curated/vintage-paper.json +86 -0
  119. package/src/features/theme/curated/violet-bloom.json +87 -0
  120. package/src/features/theme/curated/zen-inspired.json +87 -0
  121. package/src/features/theme/index.ts +76 -0
  122. package/src/features/theme/normalize.ts +159 -0
  123. package/src/features/theme/registry.ts +50 -0
  124. package/src/features/theme/resolveConfig.ts +182 -0
  125. package/src/features/theme/safeApplyTheme.ts +147 -0
  126. package/src/features/theme/themes.spec.ts +276 -0
  127. package/src/features/theme/themes.ts +82 -558
  128. package/src/features/theme/tokenKeys.ts +60 -0
  129. package/src/features/theme/types.ts +170 -0
  130. package/src/features/theme/useTheme.tsx +48 -50
  131. package/src/hooks/use-mobile.tsx +19 -0
  132. package/src/i18n/translations/en/common.json +41 -0
  133. package/src/i18n/translations/en/settings.json +10 -2
  134. package/src/i18n/translations/fr/common.json +41 -0
  135. package/src/i18n/translations/fr/settings.json +10 -2
  136. package/src/index.css +372 -128
  137. package/src/index.ts +71 -0
  138. package/src/lib/z-index.ts +4 -1
  139. package/src/routes/components/IndexRoute.tsx +12 -2
  140. package/src/routes/components/NavigationItemRoute.tsx +1 -10
  141. package/src/routes/hooks/useNavigationItems.ts +29 -44
  142. package/src/routes/routes.tsx +58 -27
  143. package/tailwind.config.js +27 -27
  144. package/src/features/layouts/sidebar/BottomNavItem.tsx +0 -88
  145. package/src/features/layouts/sidebar/MobileBottomNav.tsx +0 -168
@@ -0,0 +1,187 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://shellui.com/schemas/shellui.theme.schema.json",
4
+ "title": "ShelluiTheme",
5
+ "description": "Versioned Shellui theme definition (theme folder JSON or inline theme object). Schema version: 1.",
6
+ "type": "object",
7
+ "required": ["version", "name"],
8
+ "additionalProperties": false,
9
+ "properties": {
10
+ "$schema": {
11
+ "type": "string",
12
+ "description": "JSON Schema URL for editor autocomplete and validation."
13
+ },
14
+ "version": {
15
+ "type": "integer",
16
+ "const": 1,
17
+ "description": "Theme schema version. Must be 1."
18
+ },
19
+ "name": {
20
+ "type": "string",
21
+ "minLength": 1,
22
+ "description": "Unique theme id (e.g. \"acme\")."
23
+ },
24
+ "label": {
25
+ "type": "string",
26
+ "description": "Human-readable name shown in Settings → Appearance."
27
+ },
28
+ "displayName": {
29
+ "type": "string",
30
+ "description": "Deprecated alias for label."
31
+ },
32
+ "description": {
33
+ "type": "string"
34
+ },
35
+ "recommended": {
36
+ "type": "boolean",
37
+ "description": "When true, the theme selector may highlight this theme in large lists."
38
+ },
39
+ "fonts": {
40
+ "$ref": "#/definitions/ThemeFonts"
41
+ },
42
+ "fontFamily": {
43
+ "type": "string"
44
+ },
45
+ "headingFontFamily": {
46
+ "type": "string"
47
+ },
48
+ "bodyFontFamily": {
49
+ "type": "string"
50
+ },
51
+ "fontFiles": {
52
+ "type": "array",
53
+ "items": {
54
+ "type": "string"
55
+ }
56
+ },
57
+ "letterSpacing": {
58
+ "type": "string"
59
+ },
60
+ "textShadow": {
61
+ "type": "string"
62
+ },
63
+ "lineHeight": {
64
+ "type": "string"
65
+ },
66
+ "radius": {
67
+ "type": "string",
68
+ "description": "Shared border radius for light and dark (e.g. \"0.5rem\")."
69
+ },
70
+ "light": {
71
+ "$ref": "#/definitions/ThemeColorTokens"
72
+ },
73
+ "dark": {
74
+ "$ref": "#/definitions/ThemeColorTokens"
75
+ },
76
+ "colors": {
77
+ "type": "object",
78
+ "additionalProperties": false,
79
+ "properties": {
80
+ "light": {
81
+ "$ref": "#/definitions/ThemeColorTokens"
82
+ },
83
+ "dark": {
84
+ "$ref": "#/definitions/ThemeColorTokens"
85
+ }
86
+ }
87
+ }
88
+ },
89
+ "anyOf": [
90
+ {
91
+ "required": ["light", "dark"]
92
+ },
93
+ {
94
+ "required": ["colors"]
95
+ }
96
+ ],
97
+ "definitions": {
98
+ "ThemeFonts": {
99
+ "type": "object",
100
+ "additionalProperties": false,
101
+ "properties": {
102
+ "sans": {
103
+ "type": "string"
104
+ },
105
+ "mono": {
106
+ "type": "string"
107
+ },
108
+ "serif": {
109
+ "type": "string"
110
+ },
111
+ "heading": {
112
+ "type": "string"
113
+ },
114
+ "body": {
115
+ "type": "string"
116
+ },
117
+ "files": {
118
+ "type": "array",
119
+ "items": {
120
+ "type": "string"
121
+ },
122
+ "description": "Paths relative to the theme JSON / themesDir, or absolute URLs."
123
+ }
124
+ }
125
+ },
126
+ "ThemeColorTokens": {
127
+ "type": "object",
128
+ "additionalProperties": false,
129
+ "properties": {
130
+ "background": { "type": "string" },
131
+ "foreground": { "type": "string" },
132
+ "card": { "type": "string" },
133
+ "cardForeground": { "type": "string" },
134
+ "popover": { "type": "string" },
135
+ "popoverForeground": { "type": "string" },
136
+ "primary": { "type": "string" },
137
+ "primaryForeground": { "type": "string" },
138
+ "secondary": { "type": "string" },
139
+ "secondaryForeground": { "type": "string" },
140
+ "muted": { "type": "string" },
141
+ "mutedForeground": { "type": "string" },
142
+ "accent": { "type": "string" },
143
+ "accentForeground": { "type": "string" },
144
+ "destructive": { "type": "string" },
145
+ "destructiveForeground": { "type": "string" },
146
+ "border": { "type": "string" },
147
+ "input": { "type": "string" },
148
+ "ring": { "type": "string" },
149
+ "radius": { "type": "string" },
150
+ "sidebarBackground": { "type": "string" },
151
+ "sidebarForeground": { "type": "string" },
152
+ "sidebarPrimary": { "type": "string" },
153
+ "sidebarPrimaryForeground": { "type": "string" },
154
+ "sidebarAccent": { "type": "string" },
155
+ "sidebarAccentForeground": { "type": "string" },
156
+ "sidebarBorder": { "type": "string" },
157
+ "sidebarRing": { "type": "string" },
158
+ "sidebar": { "type": "string", "description": "CSS-variable alias for sidebarBackground" },
159
+ "card-foreground": { "type": "string" },
160
+ "popover-foreground": { "type": "string" },
161
+ "primary-foreground": { "type": "string" },
162
+ "secondary-foreground": { "type": "string" },
163
+ "muted-foreground": { "type": "string" },
164
+ "accent-foreground": { "type": "string" },
165
+ "destructive-foreground": { "type": "string" },
166
+ "sidebar-background": { "type": "string" },
167
+ "sidebar-foreground": { "type": "string" },
168
+ "sidebar-primary": { "type": "string" },
169
+ "sidebar-primary-foreground": { "type": "string" },
170
+ "sidebar-accent": { "type": "string" },
171
+ "sidebar-accent-foreground": { "type": "string" },
172
+ "sidebar-border": { "type": "string" },
173
+ "sidebar-ring": { "type": "string" },
174
+ "chart-1": { "type": "string" },
175
+ "chart-2": { "type": "string" },
176
+ "chart-3": { "type": "string" },
177
+ "chart-4": { "type": "string" },
178
+ "chart-5": { "type": "string" },
179
+ "chart1": { "type": "string" },
180
+ "chart2": { "type": "string" },
181
+ "chart3": { "type": "string" },
182
+ "chart4": { "type": "string" },
183
+ "chart5": { "type": "string" }
184
+ }
185
+ }
186
+ }
187
+ }
package/src/app.tsx CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  ensureServiceWorkerDisabledWhenOff,
26
26
  } from './service-worker/register';
27
27
  import { useSettings } from './features/settings/hooks/useSettings';
28
+ import { DesktopChrome } from './features/layouts/chrome/DesktopChrome';
28
29
 
29
30
  const AppContent = () => {
30
31
  const { config } = useConfig();
@@ -90,9 +91,10 @@ const AppContent = () => {
90
91
  if (!config.navigation || config.navigation.length === 0) {
91
92
  return (
92
93
  <>
94
+ <DesktopChrome />
93
95
  <CookieConsentModal />
94
96
  <div style={{ fontFamily: 'system-ui, sans-serif', padding: '2rem' }}>
95
- <h1>{config.title || 'ShellUI'}</h1>
97
+ <h1>{config.title || 'Shellui'}</h1>
96
98
  <p>No navigation items configured.</p>
97
99
  </div>
98
100
  </>
@@ -105,6 +107,7 @@ const AppContent = () => {
105
107
 
106
108
  return (
107
109
  <>
110
+ <DesktopChrome />
108
111
  <CookieConsentModal />
109
112
  <RouterProvider router={router} />
110
113
  </>
@@ -9,12 +9,65 @@ import {
9
9
  type ShellUIMessage,
10
10
  } from '@shellui/sdk';
11
11
  import { useEffect, useLayoutEffect, useRef, useState } from 'react';
12
- import { useNavigate } from 'react-router';
12
+ import { useLocation, useNavigate } from 'react-router';
13
13
  import { LOADING_OVERLAY_DURATION_MS } from '../constants/loading';
14
14
  import { LoadingOverlay } from './LoadingOverlay';
15
+ import { IFRAME_FOREIGN_ATTR } from '../features/layouts/chrome/constants';
15
16
 
16
17
  const logger = getLogger('shellcore');
17
18
 
19
+ function normalizeShellPath(pathname: string, search: string): string {
20
+ const pathnamePart = pathname.replace(/\/+$/, '') || '/';
21
+ return pathnamePart + search;
22
+ }
23
+
24
+ /** Reject protocol-relative and scheme-based paths so navigate() stays on-shell. */
25
+ function isSafeShellPath(path: string): boolean {
26
+ if (!path.startsWith('/') || path.startsWith('//')) return false;
27
+ // e.g. "/javascript:..." should never be treated as a router path we trust blindly
28
+ if (/^\/[a-zA-Z][a-zA-Z0-9+.-]*:/.test(path)) return false;
29
+ return true;
30
+ }
31
+
32
+ function isSafeIframeUrl(url: string): boolean {
33
+ try {
34
+ const parsed = new URL(url, typeof window !== 'undefined' ? window.location.href : undefined);
35
+ return parsed.protocol === 'http:' || parsed.protocol === 'https:';
36
+ } catch {
37
+ return false;
38
+ }
39
+ }
40
+
41
+ function isSameOriginAsNavItem(targetUrl: string, navItem: NavigationItem): boolean {
42
+ try {
43
+ const target = new URL(
44
+ targetUrl,
45
+ typeof window !== 'undefined' ? window.location.href : undefined,
46
+ );
47
+ const allowed = new URL(
48
+ navItem.url,
49
+ typeof window !== 'undefined' ? window.location.href : undefined,
50
+ );
51
+ return target.origin === allowed.origin;
52
+ } catch {
53
+ return false;
54
+ }
55
+ }
56
+
57
+ /** Apply a URL inside the iframe without adding a joint session-history entry. */
58
+ function replaceIframeLocation(iframe: HTMLIFrameElement, targetUrl: string): boolean {
59
+ if (!isSafeIframeUrl(targetUrl)) {
60
+ logger.warn('ContentView: refused unsafe iframe URL', targetUrl);
61
+ return false;
62
+ }
63
+ try {
64
+ iframe.contentWindow?.location.replace(targetUrl);
65
+ return true;
66
+ } catch {
67
+ return false;
68
+ }
69
+ }
70
+
18
71
  interface ContentViewProps {
19
72
  url: string;
20
73
  pathPrefix: string;
@@ -29,9 +82,14 @@ export const ContentView = ({
29
82
  navItem,
30
83
  }: ContentViewProps) => {
31
84
  const navigate = useNavigate();
85
+ const location = useLocation();
32
86
  const iframeRef = useRef<HTMLIFrameElement>(null);
33
87
  const cancelRevealRef = useRef<(() => void) | null>(null);
34
88
  const mountTimeRef = useRef(Date.now());
89
+ /** Shell path last reported by the iframe — skip driving iframe when we caused the location change. */
90
+ const lastShellPathFromIframeRef = useRef<string | null>(null);
91
+ const skipInitialShellSyncRef = useRef(true);
92
+ const prevNavPathRef = useRef(navItem?.path ?? '');
35
93
 
36
94
  const [isLoading, setIsLoading] = useState(() => {
37
95
  // Skip overlay when same app URL was just loaded (e.g. switching App ↔ Root with same url)
@@ -40,6 +98,8 @@ export const ContentView = ({
40
98
  });
41
99
 
42
100
  const [iframeUrl, setIframeUrl] = useState(url);
101
+ /** Bumped only when the iframe element must remount (nav item / app change). */
102
+ const [frameGeneration, setFrameGeneration] = useState(0);
43
103
 
44
104
  const MIN_LOADING_MS = 80; // Don't reveal before this, reduces blink from theme/layout paint
45
105
 
@@ -51,16 +111,63 @@ export const ContentView = ({
51
111
  return () => {
52
112
  removeIframe(iframeId);
53
113
  };
54
- }, [iframeUrl, navItem?.path ?? '']);
114
+ }, [iframeUrl, navItem?.path ?? '', frameGeneration]);
55
115
 
116
+ // Drive iframe when the shell location changes from outside the iframe
117
+ // (nav item click, router back/forward). Prefer location.replace so we do not
118
+ // pollute joint session history (same-origin iframe src changes would).
56
119
  useLayoutEffect(() => {
57
120
  if (ignoreMessages) return;
58
- if (isLoading) return;
59
- if (iframeRef.current) {
121
+
122
+ const currentShellPath = normalizeShellPath(location.pathname, location.search);
123
+ const navPath = navItem?.path ?? '';
124
+ const navItemChanged = prevNavPathRef.current !== navPath;
125
+ prevNavPathRef.current = navPath;
126
+
127
+ if (skipInitialShellSyncRef.current) {
128
+ skipInitialShellSyncRef.current = false;
129
+ lastShellPathFromIframeRef.current = currentShellPath;
130
+ if (isSafeIframeUrl(url) && isSameOriginAsNavItem(url, navItem)) {
131
+ setIframeUrl(url);
132
+ }
133
+ return;
134
+ }
135
+
136
+ if (lastShellPathFromIframeRef.current === currentShellPath && !navItemChanged) {
137
+ return;
138
+ }
139
+
140
+ lastShellPathFromIframeRef.current = currentShellPath;
141
+ mountTimeRef.current = Date.now();
142
+ cancelRevealRef.current?.();
143
+
144
+ if (navItemChanged) {
145
+ if (!isSafeIframeUrl(url) || !isSameOriginAsNavItem(url, navItem)) {
146
+ logger.warn('ContentView: refused remount to unsafe or cross-origin URL', url);
147
+ return;
148
+ }
60
149
  setIsLoading(true);
61
150
  setIframeUrl(url);
151
+ setFrameGeneration((generation) => generation + 1);
152
+ return;
153
+ }
154
+
155
+ const iframe = iframeRef.current;
156
+ if (iframe && isSameOriginAsNavItem(url, navItem) && replaceIframeLocation(iframe, url)) {
157
+ // Do not update the src prop — React would re-navigate the iframe and can
158
+ // push a joint session-history entry, wiping intermediate shell routes.
159
+ return;
62
160
  }
63
- }, [navItem]);
161
+
162
+ if (!isSafeIframeUrl(url) || !isSameOriginAsNavItem(url, navItem)) {
163
+ logger.warn('ContentView: refused remount to unsafe or cross-origin URL', url);
164
+ return;
165
+ }
166
+
167
+ setIsLoading(true);
168
+ setIframeUrl(url);
169
+ setFrameGeneration((generation) => generation + 1);
170
+ }, [location.pathname, location.search, url, ignoreMessages, navItem]);
64
171
 
65
172
  // Sync parent URL when iframe notifies us of a change
66
173
  useEffect(() => {
@@ -128,8 +235,17 @@ export const ContentView = ({
128
235
  const normalizedNewPathname = newPathParts?.[1]?.replace(/\/+$/, '') || '/';
129
236
  const normalizedNewPath = normalizedNewPathname + (newPathParts?.[2] || '');
130
237
 
238
+ // Mark before navigate so the shell-sync effect does not reload the iframe
239
+ lastShellPathFromIframeRef.current = normalizedNewPath;
240
+
131
241
  if (currentPath !== normalizedNewPath) {
132
- navigate(newShellPath, { replace: true });
242
+ if (!isSafeShellPath(normalizedNewPath)) {
243
+ logger.warn('ContentView: refused unsafe shell path from iframe', normalizedNewPath);
244
+ return;
245
+ }
246
+ // Push — iframe pushState is replace-only when embedded, so the shell
247
+ // is the sole owner of back/forward entries.
248
+ navigate(newShellPath);
133
249
  }
134
250
  },
135
251
  );
@@ -137,7 +253,7 @@ export const ContentView = ({
137
253
  return () => {
138
254
  cleanup();
139
255
  };
140
- }, [pathPrefix, navigate, navItem]);
256
+ }, [pathPrefix, navigate, navItem, ignoreMessages, isLoading]);
141
257
 
142
258
  const scheduleReveal = (reveal: () => void) => {
143
259
  const doReveal = () => {
@@ -157,7 +273,6 @@ export const ContentView = ({
157
273
 
158
274
  // Hide loading overlay when iframe sends SHELLUI_INITIALIZED.
159
275
  // Defer reveal (double rAF + min time) so the iframe has time to apply theme and paint.
160
- // Remember this URL so we can skip the overlay when navigating to the same app (e.g. App ↔ Root).
161
276
  useEffect(() => {
162
277
  const cleanup = shellui.addMessageListener(
163
278
  'SHELLUI_INITIALIZED',
@@ -183,6 +298,7 @@ export const ContentView = ({
183
298
  }, [ignoreMessages]);
184
299
 
185
300
  // Fallback: hide overlay after LOADING_OVERLAY_DURATION_MS if SHELLUI_INITIALIZED was not received.
301
+ // Also used after location.replace syncs (no full remount / INITIALIZED).
186
302
  useEffect(() => {
187
303
  if (!isLoading) return;
188
304
  const timeoutId = setTimeout(() => {
@@ -201,6 +317,25 @@ export const ContentView = ({
201
317
  return () => clearTimeout(timeoutId);
202
318
  }, [isLoading]);
203
319
 
320
+ // After the first load, a cross-origin document (OAuth/login) cannot be inspected.
321
+ // Flag it so desktop Back can restore the iframe to its assigned app URL.
322
+ useEffect(() => {
323
+ const iframe = iframeRef.current;
324
+ if (!iframe) return;
325
+ let loads = 0;
326
+ const onLoad = () => {
327
+ loads += 1;
328
+ try {
329
+ void iframe.contentWindow?.location.href;
330
+ iframe.removeAttribute(IFRAME_FOREIGN_ATTR);
331
+ } catch {
332
+ if (loads > 1) iframe.setAttribute(IFRAME_FOREIGN_ATTR, 'true');
333
+ }
334
+ };
335
+ iframe.addEventListener('load', onLoad);
336
+ return () => iframe.removeEventListener('load', onLoad);
337
+ }, [iframeUrl, navItem?.path, frameGeneration]);
338
+
204
339
  return (
205
340
  <div
206
341
  style={{ width: '100%', height: '100%', display: 'flex', position: 'relative' }}
@@ -217,7 +352,7 @@ export const ContentView = ({
217
352
  <iframe
218
353
  ref={iframeRef}
219
354
  src={iframeUrl}
220
- key={iframeUrl + (navItem?.path ?? '')}
355
+ key={`${navItem?.path ?? ''}:${frameGeneration}`}
221
356
  loading="eager"
222
357
  style={{
223
358
  width: '100%',
@@ -2,7 +2,7 @@ import { LOADING_OVERLAY_DURATION_MS } from '../constants/loading';
2
2
 
3
3
  export function LoadingOverlay() {
4
4
  return (
5
- <div className="absolute inset-x-0 top-0 z-10">
5
+ <div className="absolute inset-x-0 top-0 z-30">
6
6
  <div className="h-1 w-full overflow-hidden bg-muted/30">
7
7
  <div
8
8
  className="h-full w-0 bg-muted-foreground/50"
@@ -23,7 +23,7 @@ const AlertDialogOverlay = forwardRef<
23
23
  <AlertDialogPrimitive.Overlay
24
24
  ref={ref}
25
25
  data-dialog-overlay
26
- className={cn('fixed inset-0 bg-[hsl(var(--background)/0.8)] backdrop-blur-[1px]', className)}
26
+ className={cn('fixed inset-0 bg-black/50 backdrop-blur-[1px]', className)}
27
27
  style={{ zIndex: Z_INDEX.ALERT_DIALOG_OVERLAY }}
28
28
  {...props}
29
29
  />
@@ -25,8 +25,8 @@ const DialogOverlay = forwardRef<
25
25
  >(({ className, style, ...props }, ref) => (
26
26
  <DialogPrimitive.Overlay
27
27
  ref={ref}
28
- data-dialog-overlay
29
- className={cn('fixed inset-0 bg-[hsl(var(--background)/0.8)] backdrop-blur-[1px]', className)}
28
+ data-dialog-overlay=""
29
+ className={cn('fixed inset-0 bg-black/50 backdrop-blur-[1px]', className)}
30
30
  style={{ zIndex: Z_INDEX.MODAL_OVERLAY, ...style }}
31
31
  {...props}
32
32
  />
@@ -34,8 +34,17 @@ const DialogOverlay = forwardRef<
34
34
  DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
35
35
 
36
36
  interface DialogContentProps extends ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {
37
- /** When true, the default close (X) button is not rendered. Escape and overlay still close. */
37
+ /**
38
+ * When true, the default close (X) button is not rendered.
39
+ * Prefer `showCloseButton={false}` for new code.
40
+ */
38
41
  hideCloseButton?: boolean;
42
+ /**
43
+ * When false, the default close (X) button is not rendered.
44
+ * Escape / overlay click still follow Dialog `onOpenChange` / interact-outside handlers.
45
+ * Default true.
46
+ */
47
+ showCloseButton?: boolean;
39
48
  overlayZIndex?: number;
40
49
  contentZIndex?: number;
41
50
  }
@@ -47,6 +56,7 @@ const DialogContent = forwardRef<ElementRef<typeof DialogPrimitive.Content>, Dia
47
56
  children,
48
57
  onPointerDownOutside,
49
58
  hideCloseButton,
59
+ showCloseButton = true,
50
60
  overlayZIndex,
51
61
  contentZIndex,
52
62
  style,
@@ -55,6 +65,7 @@ const DialogContent = forwardRef<ElementRef<typeof DialogPrimitive.Content>, Dia
55
65
  ref,
56
66
  ) => {
57
67
  const hasContent = Children.count(children) > 2;
68
+ const renderClose = showCloseButton && !hideCloseButton;
58
69
 
59
70
  const handlePointerDownOutside = useCallback(
60
71
  (
@@ -86,15 +97,22 @@ const DialogContent = forwardRef<ElementRef<typeof DialogPrimitive.Content>, Dia
86
97
  className,
87
98
  )}
88
99
  style={{
89
- backgroundColor: 'hsl(var(--background))',
100
+ backgroundColor: 'var(--background)',
90
101
  zIndex: contentZIndex ?? Z_INDEX.MODAL_CONTENT,
102
+ ...(style?.transition === 'none'
103
+ ? { transition: 'none' }
104
+ : {
105
+ transitionProperty: 'height, width, max-height, max-width',
106
+ transitionDuration: '200ms',
107
+ transitionTimingFunction: 'ease',
108
+ }),
91
109
  ...style,
92
110
  }}
93
111
  onPointerDownOutside={handlePointerDownOutside}
94
112
  {...props}
95
113
  >
96
114
  {children}
97
- {!hideCloseButton && (
115
+ {renderClose && (
98
116
  <DialogPrimitive.Close
99
117
  onPointerDown={(e) => e.currentTarget.click()}
100
118
  className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground cursor-pointer"