@shellui/core 0.5.0-alpha.5 → 0.5.0-beta.2

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 (40) hide show
  1. package/package.json +2 -2
  2. package/src/components/ContentView.tsx +1 -1
  3. package/src/components/ui/alert-dialog.tsx +51 -34
  4. package/src/components/ui/drawer.tsx +57 -40
  5. package/src/components/ui/sidebar.tsx +12 -5
  6. package/src/components/ui/sonner.tsx +20 -2
  7. package/src/features/admin/AdminView.tsx +31 -2
  8. package/src/features/alertDialog/DialogContext.tsx +11 -5
  9. package/src/features/auth/components/AccessPendingView.tsx +1 -1
  10. package/src/features/auth/components/LoginButton.tsx +2 -2
  11. package/src/features/auth/components/LoginView.tsx +77 -30
  12. package/src/features/layouts/LayoutFallback.tsx +1 -1
  13. package/src/features/layouts/OverlayShell.tsx +76 -44
  14. package/src/features/layouts/appbar/AppBarLayout.tsx +501 -293
  15. package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +18 -10
  16. package/src/features/layouts/chrome/ContentDragOverlay.tsx +1 -1
  17. package/src/features/layouts/chrome/DesktopChrome.tsx +1 -1
  18. package/src/features/layouts/chrome/SafeAreaTopbar.tsx +48 -0
  19. package/src/features/layouts/chrome/constants.ts +7 -1
  20. package/src/features/layouts/chrome/index.ts +5 -0
  21. package/src/features/layouts/chrome/runtime.ts +157 -7
  22. package/src/features/layouts/chrome/viewport.ts +66 -0
  23. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +10 -5
  24. package/src/features/layouts/sidebar/SidebarInner.tsx +26 -30
  25. package/src/features/layouts/sidebar/SidebarLayout.tsx +90 -39
  26. package/src/features/layouts/windows/WindowsLayout.tsx +138 -42
  27. package/src/features/overlays/ResponsiveModal.tsx +36 -17
  28. package/src/features/overlays/overlaySize.spec.ts +27 -1
  29. package/src/features/overlays/overlaySize.ts +73 -18
  30. package/src/features/overlays/useOverlayReportedSize.ts +5 -4
  31. package/src/features/settings/SettingsView.tsx +9 -2
  32. package/src/features/storage/uploads/UploadToastCard.tsx +1 -1
  33. package/src/features/storage/uploads/UploadToaster.tsx +6 -3
  34. package/src/features/theme/applyTheme.ts +20 -1
  35. package/src/i18n/translations/en/common.json +2 -1
  36. package/src/i18n/translations/fr/common.json +2 -1
  37. package/src/index.css +177 -18
  38. package/src/index.html +32 -3
  39. package/src/routes/components/RouteErrorBoundary.tsx +1 -1
  40. package/src/routes/components/RouteFallback.tsx +1 -1
@@ -23,13 +23,21 @@ import { useNavigationItems } from '../../../routes/hooks/useNavigationItems';
23
23
  import { useAuth } from '../../auth/hooks/useAuth';
24
24
  import { useSettings } from '../../settings/hooks/useSettings';
25
25
  import { useIsMobile } from '../../../hooks/use-mobile';
26
+ import { useModal } from '../../modal/ModalContext';
27
+ import { useDrawer } from '../../drawer/DrawerContext';
26
28
  import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
27
29
  import { CollapsedDesktopTitlebar } from '../chrome/CollapsedDesktopTitlebar';
30
+ import {
31
+ isShellUiRootWindow,
32
+ SafeAreaTopbarOffset,
33
+ SafeAreaTopbarStrip,
34
+ } from '../chrome/SafeAreaTopbar';
28
35
  import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
29
36
  import {
30
37
  MAC_TRAFFIC_LIGHTS_GAP_PX,
31
38
  MAC_TRAFFIC_LIGHTS_WIDTH_PX,
32
39
  DESKTOP_TITLEBAR_HEIGHT_PX,
40
+ DESKTOP_TITLEBAR_PAD_TOP_PX,
33
41
  } from '../chrome/constants';
34
42
 
35
43
  /** Close the mobile sheet when the route changes. */
@@ -44,6 +52,19 @@ function CloseMobileSidebarOnNavigate() {
44
52
  return null;
45
53
  }
46
54
 
55
+ /** Close the mobile sheet when a modal or drawer opens. */
56
+ function CloseMobileSidebarOnOverlay() {
57
+ const { setOpenMobile } = useSidebar();
58
+ const { isOpen: modalOpen } = useModal();
59
+ const { isOpen: drawerOpen } = useDrawer();
60
+
61
+ useEffect(() => {
62
+ if (modalOpen || drawerOpen) setOpenMobile(false);
63
+ }, [modalOpen, drawerOpen, setOpenMobile]);
64
+
65
+ return null;
66
+ }
67
+
47
68
  /** Sync collapsed-titlebar layout offset onto <html> for CSS. */
48
69
  function CollapsedTitlebarOffset() {
49
70
  const overlay = useMacOverlayChrome();
@@ -71,6 +92,8 @@ const SidebarLayoutContent = ({ title, appIcon, navigation }: SidebarLayoutProps
71
92
  const mobileTrafficInset = trafficLights
72
93
  ? MAC_TRAFFIC_LIGHTS_WIDTH_PX + MAC_TRAFFIC_LIGHTS_GAP_PX
73
94
  : undefined;
95
+ // Nested shell-in-iframe must not repeat the root safe-area top band.
96
+ const showSafeAreaTopbar = isShellUiRootWindow();
74
97
 
75
98
  const currentLanguage = useMemo(() => {
76
99
  return i18n.language || 'en';
@@ -106,47 +129,75 @@ const SidebarLayoutContent = ({ title, appIcon, navigation }: SidebarLayoutProps
106
129
  }, [navigationItem, title, currentLanguage]);
107
130
 
108
131
  return (
109
- <SidebarProvider className="h-svh overflow-hidden">
110
- <CloseMobileSidebarOnNavigate />
111
- <CollapsedTitlebarOffset />
112
- <CollapsedDesktopTitlebar />
113
- <Sidebar
114
- collapsible="icon"
115
- className="border-sidebar-border"
116
- >
117
- <SidebarInner
118
- startNav={startNav}
119
- endItems={endItems}
120
- showAuthButton={!hasCustomLoginNav || isAuthenticated}
121
- title={title}
122
- appIcon={appIcon}
123
- />
124
- <SidebarRail />
125
- </Sidebar>
126
-
127
- <SidebarInset className="relative min-w-0 overflow-hidden">
128
- <header
129
- className="relative z-[46] flex shrink-0 items-center gap-0.5 border-b border-border bg-background px-3 select-none md:hidden"
130
- style={{
131
- height: DESKTOP_TITLEBAR_HEIGHT_PX,
132
- ...(mobileTrafficInset !== undefined ? { paddingLeft: mobileTrafficInset } : {}),
133
- }}
134
- {...(trafficLights
135
- ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
136
- : {})}
132
+ <div
133
+ data-shellui-sidebar-layout=""
134
+ className="flex h-full max-h-full flex-col overflow-hidden"
135
+ >
136
+ <SafeAreaTopbarOffset enabled={showSafeAreaTopbar} />
137
+ {/*
138
+ Root shell only (not when nested in an iframe): tablet / desktop band for
139
+ top safe-area, painted with sidebar background. Height is 0 when the inset
140
+ is 0; overflow clips the border so no stray hairline.
141
+ */}
142
+ <SafeAreaTopbarStrip enabled={showSafeAreaTopbar} />
143
+ <SidebarProvider className="min-h-0 flex-1 overflow-hidden">
144
+ <CloseMobileSidebarOnNavigate />
145
+ <CloseMobileSidebarOnOverlay />
146
+ <CollapsedTitlebarOffset />
147
+ <CollapsedDesktopTitlebar />
148
+ <Sidebar
149
+ collapsible="icon"
150
+ className="border-sidebar-border"
137
151
  >
138
- <SidebarTrigger
139
- data-shellui-no-drag=""
140
- className="relative size-8 touch-manipulation text-foreground"
152
+ <SidebarInner
153
+ startNav={startNav}
154
+ endItems={endItems}
155
+ showAuthButton={!hasCustomLoginNav || isAuthenticated}
156
+ title={title}
157
+ appIcon={appIcon}
141
158
  />
142
- {isTauriEnv ? <DesktopHistoryButtons /> : null}
143
- </header>
144
-
145
- <div className="flex min-h-0 flex-1 flex-col overflow-auto">
146
- <Outlet />
147
- </div>
148
- </SidebarInset>
149
- </SidebarProvider>
159
+ <SidebarRail />
160
+ </Sidebar>
161
+
162
+ <SidebarInset className="relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
163
+ {/*
164
+ Mobile top chrome: extend the header background into the status-bar band
165
+ so there is no empty strip. Interactive controls stay below the inset via
166
+ padding. Overlays are fixed full-screen and still cover this band.
167
+ Nested iframe shells skip top safe-area — the host already cleared it.
168
+ */}
169
+ <header
170
+ className="relative z-[46] flex shrink-0 items-center gap-0.5 border-b border-border bg-background px-3 select-none md:hidden"
171
+ style={{
172
+ paddingTop: showSafeAreaTopbar
173
+ ? `calc(var(--shellui-safe-area-top) + ${DESKTOP_TITLEBAR_PAD_TOP_PX}px)`
174
+ : DESKTOP_TITLEBAR_PAD_TOP_PX,
175
+ height: showSafeAreaTopbar
176
+ ? `calc(${DESKTOP_TITLEBAR_HEIGHT_PX}px + var(--shellui-safe-area-top))`
177
+ : DESKTOP_TITLEBAR_HEIGHT_PX,
178
+ ...(mobileTrafficInset !== undefined ? { paddingLeft: mobileTrafficInset } : {}),
179
+ }}
180
+ {...(trafficLights
181
+ ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
182
+ : {})}
183
+ >
184
+ <SidebarTrigger
185
+ data-shellui-no-drag=""
186
+ className="relative size-8 touch-manipulation text-foreground"
187
+ />
188
+ {isTauriEnv ? <DesktopHistoryButtons /> : null}
189
+ </header>
190
+
191
+ {/*
192
+ Fill to the physical bottom — do not pad safe-area here or the iframe
193
+ looks cut off. In-app content (settings, etc.) owns bottom safe insets.
194
+ */}
195
+ <div className="flex min-h-0 flex-1 flex-col overflow-hidden">
196
+ <Outlet />
197
+ </div>
198
+ </SidebarInset>
199
+ </SidebarProvider>
200
+ </div>
150
201
  );
151
202
  };
152
203
 
@@ -33,6 +33,7 @@ import { useAuth } from '../../auth/hooks/useAuth';
33
33
  import { ExternalLinkIcon, NavIcon } from '../sidebar/SidebarIcons';
34
34
  import { getExternalFaviconUrl, isAppIcon } from '../sidebar/sidebarUtils';
35
35
  import { AppBrandIcon } from '../branding/AppBrandIcon';
36
+ import { useIsMobile } from '../../../hooks/use-mobile';
36
37
 
37
38
  interface WindowsLayoutProps {
38
39
  title?: string;
@@ -88,15 +89,53 @@ const DEFAULT_WIDTH = 720;
88
89
  const DEFAULT_HEIGHT = 480;
89
90
  const TASKBAR_HEIGHT = 48;
90
91
 
91
- function getMaximizedBounds(): WindowState['bounds'] {
92
+ type WindowBounds = WindowState['bounds'];
93
+
94
+ function getDesktopSize(): { width: number; height: number } {
95
+ if (typeof window === 'undefined') return { width: 800, height: 600 };
92
96
  return {
93
- x: 0,
94
- y: 0,
95
- w: typeof window !== 'undefined' ? window.innerWidth : 800,
96
- h: typeof window !== 'undefined' ? window.innerHeight - TASKBAR_HEIGHT : 600,
97
+ width: window.innerWidth,
98
+ height: Math.max(0, window.innerHeight - TASKBAR_HEIGHT),
97
99
  };
98
100
  }
99
101
 
102
+ function getMaximizedBounds(): WindowBounds {
103
+ const { width, height } = getDesktopSize();
104
+ return { x: 0, y: 0, w: width, h: height };
105
+ }
106
+
107
+ /** Keep a window fully inside the desktop (never larger than the viewport). */
108
+ function clampBounds(bounds: WindowBounds): WindowBounds {
109
+ const { width: maxW, height: maxH } = getDesktopSize();
110
+ const minW = Math.min(MIN_WIDTH, maxW);
111
+ const minH = Math.min(MIN_HEIGHT, maxH);
112
+ const w = Math.min(Math.max(bounds.w, minW), maxW);
113
+ const h = Math.min(Math.max(bounds.h, minH), maxH);
114
+ const x = Math.min(Math.max(0, bounds.x), Math.max(0, maxW - w));
115
+ const y = Math.min(Math.max(0, bounds.y), Math.max(0, maxH - h));
116
+ return { x, y, w, h };
117
+ }
118
+
119
+ /** Default open size: cascade on desktop; fill the screen on phones / small viewports. */
120
+ function getDefaultOpenBounds(cascadeIndex: number): WindowBounds {
121
+ const desktop = getDesktopSize();
122
+ if (desktop.width < DEFAULT_WIDTH || desktop.height < DEFAULT_HEIGHT) {
123
+ return getMaximizedBounds();
124
+ }
125
+ const cascade = cascadeIndex * 24;
126
+ return clampBounds({
127
+ x: 60 + cascade,
128
+ y: 60 + cascade,
129
+ w: DEFAULT_WIDTH,
130
+ h: DEFAULT_HEIGHT,
131
+ });
132
+ }
133
+
134
+ function isCompactDesktop(): boolean {
135
+ const { width, height } = getDesktopSize();
136
+ return width < DEFAULT_WIDTH || height < DEFAULT_HEIGHT;
137
+ }
138
+
100
139
  function buildFinalUrl(baseUrl: string, path: string, pathname: string): string {
101
140
  const pathPrefix = getNavPathPrefix({ path } as NavigationItem);
102
141
  const subPath = pathname.length > pathPrefix.length ? pathname.slice(pathPrefix.length + 1) : '';
@@ -128,14 +167,44 @@ function AppWindow({
128
167
  zIndex: number;
129
168
  }) {
130
169
  const windowLabel = resolveNavLabel(navItem.label, currentLanguage);
131
- const [bounds, setBounds] = useState(win.bounds);
132
- const [isMaximized, setIsMaximized] = useState(false);
133
- const boundsBeforeMaximizeRef = useRef<WindowState['bounds']>(bounds);
170
+ const [isMaximized, setIsMaximized] = useState(() => {
171
+ if (isCompactDesktop()) return true;
172
+ const desktop = getDesktopSize();
173
+ return (
174
+ win.bounds.x === 0 &&
175
+ win.bounds.y === 0 &&
176
+ win.bounds.w >= desktop.width &&
177
+ win.bounds.h >= desktop.height
178
+ );
179
+ });
180
+ const [bounds, setBounds] = useState(() => {
181
+ if (isCompactDesktop()) return getMaximizedBounds();
182
+ const desktop = getDesktopSize();
183
+ if (
184
+ win.bounds.x === 0 &&
185
+ win.bounds.y === 0 &&
186
+ win.bounds.w >= desktop.width &&
187
+ win.bounds.h >= desktop.height
188
+ ) {
189
+ return getMaximizedBounds();
190
+ }
191
+ return clampBounds(win.bounds);
192
+ });
193
+ const boundsBeforeMaximizeRef = useRef<WindowBounds>(
194
+ isCompactDesktop()
195
+ ? clampBounds({
196
+ x: 8,
197
+ y: 8,
198
+ w: Math.min(DEFAULT_WIDTH, Math.max(0, getDesktopSize().width - 16)),
199
+ h: Math.min(DEFAULT_HEIGHT, Math.max(0, getDesktopSize().height - 16)),
200
+ })
201
+ : clampBounds(win.bounds),
202
+ );
134
203
  const containerRef = useRef<HTMLDivElement>(null);
135
204
  const dragRef = useRef<{
136
205
  startX: number;
137
206
  startY: number;
138
- startBounds: WindowState['bounds'];
207
+ startBounds: WindowBounds;
139
208
  lastDx: number;
140
209
  lastDy: number;
141
210
  } | null>(null);
@@ -143,10 +212,10 @@ function AppWindow({
143
212
  edge: string;
144
213
  startX: number;
145
214
  startY: number;
146
- startBounds: WindowState['bounds'];
215
+ startBounds: WindowBounds;
147
216
  } | null>(null);
148
217
  const resizeRafRef = useRef<number | null>(null);
149
- const pendingResizeBoundsRef = useRef<WindowState['bounds'] | null>(null);
218
+ const pendingResizeBoundsRef = useRef<WindowBounds | null>(null);
150
219
 
151
220
  // Use a ref for onBoundsChange to avoid it in effect deps (prevents infinite render loop).
152
221
  // The parent creates a new callback reference on every render (inline arrow), so including
@@ -159,10 +228,15 @@ function AppWindow({
159
228
  onBoundsChangeRef.current(bounds);
160
229
  }, [bounds]);
161
230
 
162
- // When maximized, keep filling the viewport on window resize
231
+ // Keep windows inside the viewport on browser / orientation resize
163
232
  useEffect(() => {
164
- if (!isMaximized) return;
165
- const onResize = () => setBounds(getMaximizedBounds());
233
+ const onResize = () => {
234
+ if (isMaximized) {
235
+ setBounds(getMaximizedBounds());
236
+ return;
237
+ }
238
+ setBounds((prev) => clampBounds(prev));
239
+ };
166
240
  window.addEventListener('resize', onResize);
167
241
  return () => window.removeEventListener('resize', onResize);
168
242
  }, [isMaximized]);
@@ -195,11 +269,11 @@ function AppWindow({
195
269
  el.style.transform = '';
196
270
  el.style.willChange = '';
197
271
  }
198
- const finalBounds: WindowState['bounds'] = {
272
+ const finalBounds = clampBounds({
199
273
  ...d.startBounds,
200
- x: Math.max(0, d.startBounds.x + d.lastDx),
201
- y: Math.max(0, d.startBounds.y + d.lastDy),
202
- };
274
+ x: d.startBounds.x + d.lastDx,
275
+ y: d.startBounds.y + d.lastDy,
276
+ });
203
277
  setBounds(finalBounds);
204
278
  dragRef.current = null;
205
279
  }
@@ -233,7 +307,7 @@ function AppWindow({
233
307
 
234
308
  const handleMaximizeToggle = useCallback(() => {
235
309
  if (isMaximized) {
236
- setBounds(boundsBeforeMaximizeRef.current);
310
+ setBounds(clampBounds(boundsBeforeMaximizeRef.current));
237
311
  setIsMaximized(false);
238
312
  } else {
239
313
  boundsBeforeMaximizeRef.current = { ...bounds };
@@ -247,20 +321,31 @@ function AppWindow({
247
321
  const { edge, startX, startY, startBounds } = resizeRef.current;
248
322
  const dx = e.clientX - startX;
249
323
  const dy = e.clientY - startY;
250
- const next: WindowState['bounds'] = { ...startBounds };
251
- if (edge.includes('e')) next.w = Math.max(MIN_WIDTH, startBounds.w + dx);
324
+ const desktop = getDesktopSize();
325
+ const minW = Math.min(MIN_WIDTH, desktop.width);
326
+ const minH = Math.min(MIN_HEIGHT, desktop.height);
327
+ const next: WindowBounds = { ...startBounds };
328
+ if (edge.includes('e')) {
329
+ next.w = Math.min(Math.max(minW, startBounds.w + dx), desktop.width - startBounds.x);
330
+ }
252
331
  if (edge.includes('w')) {
253
- const newW = Math.max(MIN_WIDTH, startBounds.w - dx);
254
- next.x = startBounds.x + startBounds.w - newW;
255
- next.w = newW;
332
+ const newW = Math.max(minW, startBounds.w - dx);
333
+ const maxW = startBounds.x + startBounds.w;
334
+ const w = Math.min(newW, maxW);
335
+ next.x = startBounds.x + startBounds.w - w;
336
+ next.w = w;
337
+ }
338
+ if (edge.includes('s')) {
339
+ next.h = Math.min(Math.max(minH, startBounds.h + dy), desktop.height - startBounds.y);
256
340
  }
257
- if (edge.includes('s')) next.h = Math.max(MIN_HEIGHT, startBounds.h + dy);
258
341
  if (edge.includes('n')) {
259
- const newH = Math.max(MIN_HEIGHT, startBounds.h - dy);
260
- next.y = startBounds.y + startBounds.h - newH;
261
- next.h = newH;
342
+ const newH = Math.max(minH, startBounds.h - dy);
343
+ const maxH = startBounds.y + startBounds.h;
344
+ const h = Math.min(newH, maxH);
345
+ next.y = startBounds.y + startBounds.h - h;
346
+ next.h = h;
262
347
  }
263
- pendingResizeBoundsRef.current = next;
348
+ pendingResizeBoundsRef.current = clampBounds(next);
264
349
  if (resizeRafRef.current === null) {
265
350
  resizeRafRef.current = requestAnimationFrame(() => {
266
351
  const pending = pendingResizeBoundsRef.current;
@@ -533,6 +618,7 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
533
618
  const { i18n } = useTranslation();
534
619
  const { isAuthenticated } = useAuth();
535
620
  const { settings } = useSettings();
621
+ const isMobile = useIsMobile();
536
622
  const currentLanguage = i18n.language || 'en';
537
623
  const hasCustomLoginNav = useMemo(() => hasLoginNavigationItem(navigation), [navigation]);
538
624
  const authAwareNavigation = useMemo(
@@ -549,6 +635,11 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
549
635
  navigationItems: flattenNavigationItems(authAwareNavigation),
550
636
  };
551
637
  }, [authAwareNavigation]);
638
+ /** On mobile, end (taskbar) links live in the start menu — the bar is too narrow. */
639
+ const menuSections = useMemo((): StartSection[] => {
640
+ if (!isMobile || endNavItems.length === 0) return startSections;
641
+ return [...startSections, { type: 'items', items: endNavItems }];
642
+ }, [startSections, endNavItems, isMobile]);
552
643
 
553
644
  const [windows, setWindows] = useState<WindowState[]>([]);
554
645
  /** Id of the window that is on top (first plan). Clicking a window or its taskbar button sets this. */
@@ -579,12 +670,7 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
579
670
  item.openIn === 'external' && !item.icon ? getExternalFaviconUrl(item.url) : null;
580
671
  const icon = item.icon ?? faviconUrl ?? null;
581
672
  const id = genId();
582
- const bounds = {
583
- x: 60 + windows.length * 24,
584
- y: 60 + windows.length * 24,
585
- w: DEFAULT_WIDTH,
586
- h: DEFAULT_HEIGHT,
587
- };
673
+ const bounds = getDefaultOpenBounds(windows.length);
588
674
  setWindows((prev) => [
589
675
  ...prev,
590
676
  {
@@ -733,7 +819,6 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
733
819
  style={{
734
820
  height: TASKBAR_HEIGHT,
735
821
  zIndex: Z_INDEX.WINDOWS_TASKBAR,
736
- paddingBottom: 'env(safe-area-inset-bottom, 0px)',
737
822
  }}
738
823
  >
739
824
  {/* Start button */}
@@ -787,24 +872,35 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
787
872
  </div>
788
873
 
789
874
  <div className="min-h-0 flex-1 space-y-4 overflow-y-auto px-2 py-3">
790
- {startSections.length === 0 ? (
875
+ {menuSections.length === 0 ? (
791
876
  <p className="px-2 py-6 text-center text-sm text-muted-foreground">
792
877
  No applications available
793
878
  </p>
794
879
  ) : (
795
- startSections.map((section, sectionIndex) => {
880
+ menuSections.map((section, sectionIndex) => {
796
881
  const categoryLabel =
797
882
  section.type === 'group'
798
883
  ? resolveNavLabel(section.title, currentLanguage)
799
884
  : null;
885
+ const isEndSection =
886
+ isMobile &&
887
+ endNavItems.length > 0 &&
888
+ sectionIndex === menuSections.length - 1 &&
889
+ section.type === 'items' &&
890
+ section.items === endNavItems;
800
891
  return (
801
892
  <section
802
893
  key={
803
894
  section.type === 'group'
804
895
  ? `group-${categoryLabel}-${sectionIndex}`
805
- : `items-${sectionIndex}`
896
+ : isEndSection
897
+ ? 'end-items'
898
+ : `items-${sectionIndex}`
806
899
  }
807
- className="space-y-1.5"
900
+ className={cn(
901
+ 'space-y-1.5',
902
+ isEndSection && 'border-t border-border/60 pt-3',
903
+ )}
808
904
  >
809
905
  {categoryLabel ? (
810
906
  <h2
@@ -922,8 +1018,8 @@ export function WindowsLayout({ title, appIcon, logo: _logo, navigation }: Windo
922
1018
  })}
923
1019
  </div>
924
1020
 
925
- {/* End navigation items (right side of taskbar) */}
926
- {endNavItems.length > 0 && (
1021
+ {/* End navigation items (right side of taskbar) — desktop only; mobile uses start menu */}
1022
+ {!isMobile && endNavItems.length > 0 && (
927
1023
  <div className="flex items-center gap-0.5 shrink-0 border-l border-sidebar-border pl-2 ml-1">
928
1024
  {endNavItems.map((item) => {
929
1025
  const label =
@@ -303,12 +303,15 @@ export function ResponsiveModal({
303
303
  }
304
304
  }, []);
305
305
 
306
- const resetSheetDrag = useCallback(() => {
307
- dragStartY.current = null;
308
- dragCurrentY.current = 0;
309
- setSheetDragOffset(0);
310
- setIsSheetDragging(false);
311
- }, []);
306
+ // Fresh open always starts at rest (clears any mid-dismiss translate)
307
+ useEffect(() => {
308
+ if (open) {
309
+ dragStartY.current = null;
310
+ dragCurrentY.current = 0;
311
+ setSheetDragOffset(0);
312
+ setIsSheetDragging(false);
313
+ }
314
+ }, [open]);
312
315
 
313
316
  const handleSheetPointerDown = useCallback(
314
317
  (e: ReactPointerEvent<HTMLDivElement>) => {
@@ -339,20 +342,29 @@ export function ResponsiveModal({
339
342
  const delta = dragCurrentY.current;
340
343
  const height = contentRef.current?.offsetHeight ?? window.innerHeight;
341
344
  const shouldDismiss = delta >= SWIPE_DISMISS_PX || delta >= height * SWIPE_DISMISS_RATIO;
342
- resetSheetDrag();
345
+
346
+ dragStartY.current = null;
347
+ dragCurrentY.current = 0;
348
+ setIsSheetDragging(false);
349
+
343
350
  if (shouldDismiss && dismissible) {
351
+ // Keep the dragged translate and continue off-screen — no snap-back before close
352
+ setSheetDragOffset(Math.max(delta, height));
344
353
  onOpenChange(false);
354
+ return;
345
355
  }
356
+
357
+ // Not far enough — ease back to rest from the dragged position
358
+ setSheetDragOffset(0);
346
359
  },
347
- [dismissible, onOpenChange, resetSheetDrag],
360
+ [dismissible, onOpenChange],
348
361
  );
349
362
 
350
363
  const canMove = movable && !isSheet;
351
364
  const canResize = resizable && !isSheet;
352
365
  const hasCustomGeometry = !isSheet && geometry !== null;
353
366
 
354
- const sheetTransform =
355
- isSheet && sheetDragOffset > 0 ? `translateY(${sheetDragOffset}px)` : undefined;
367
+ const sheetExitTransition = 'transform 0.28s cubic-bezier(0.32, 0.72, 0, 1)';
356
368
 
357
369
  const geometryStyle: CSSProperties | undefined = hasCustomGeometry
358
370
  ? {
@@ -384,17 +396,17 @@ export function ResponsiveModal({
384
396
  className={cn(
385
397
  'gap-0 p-0 overflow-hidden flex flex-col',
386
398
  isSheet
387
- ? 'left-0 right-0 top-auto bottom-0 max-w-none w-full translate-x-0 translate-y-0 rounded-t-xl rounded-b-none border-x-0 border-b-0'
399
+ ? 'left-0 right-0 top-auto bottom-0 max-w-none w-full translate-x-0 translate-y-0 rounded-t-xl rounded-b-none border-x-0 border-b-0 pb-[var(--shellui-safe-area-bottom)]'
388
400
  : cn('rounded-lg', hasCustomGeometry && 'translate-x-0 translate-y-0 max-w-none'),
389
401
  className,
390
402
  )}
391
403
  style={{
392
404
  ...style,
393
405
  ...geometryStyle,
394
- ...(sheetTransform
406
+ ...(isSheet
395
407
  ? {
396
- transform: sheetTransform,
397
- transition: isSheetDragging ? 'none' : style?.transition,
408
+ transform: `translateY(${sheetDragOffset}px)`,
409
+ transition: isSheetDragging ? 'none' : sheetExitTransition,
398
410
  }
399
411
  : {}),
400
412
  ...((isSheetDragging || isWindowInteracting) && { transition: 'none' }),
@@ -451,15 +463,22 @@ export function ResponsiveModal({
451
463
  {isSheet && showDragHandle && dismissible && (
452
464
  <div
453
465
  data-responsive-modal-handle
454
- className="pointer-events-none absolute inset-x-0 top-0 z-20 flex touch-none items-center justify-center bg-transparent py-3"
466
+ className="pointer-events-none absolute inset-x-0 top-0 z-20 flex touch-none items-start justify-center bg-transparent"
455
467
  role="presentation"
456
468
  >
469
+ {/* Centered tall hit target only — rest of the strip is click-through */}
457
470
  <div
458
- className="pointer-events-auto h-1.5 w-12 cursor-grab rounded-full bg-muted-foreground/40 active:cursor-grabbing"
471
+ className="pointer-events-auto relative h-11 w-28 shrink-0 cursor-grab touch-none active:cursor-grabbing after:absolute after:left-1/2 after:top-1.5 after:h-[3px] after:w-8 after:-translate-x-1/2 after:rounded-full after:bg-muted-foreground/70 after:content-['']"
459
472
  onPointerDown={handleSheetPointerDown}
460
473
  onPointerMove={handleSheetPointerMove}
461
474
  onPointerUp={handleSheetPointerUp}
462
- onPointerCancel={resetSheetDrag}
475
+ onPointerCancel={() => {
476
+ // Cancel mid-drag — ease back to rest (not a dismiss)
477
+ dragStartY.current = null;
478
+ dragCurrentY.current = 0;
479
+ setIsSheetDragging(false);
480
+ setSheetDragOffset(0);
481
+ }}
463
482
  />
464
483
  </div>
465
484
  )}
@@ -6,6 +6,8 @@ import {
6
6
  resolveDialogSize,
7
7
  resolveDismissOptions,
8
8
  resolveDrawerSize,
9
+ resolveDrawerSizeForViewport,
10
+ resolveEffectiveDrawerPosition,
9
11
  toCssLength,
10
12
  } from './overlaySize';
11
13
 
@@ -50,10 +52,34 @@ describe('overlaySize', () => {
50
52
  });
51
53
 
52
54
  it('resolves drawer presets by direction', () => {
53
- expect(resolveDrawerSize({ size: 'sm' }, 'bottom').drawerSize).toBe('40dvh');
55
+ expect(resolveDrawerSize({ size: 'sm' }, 'bottom').drawerSize).toBe(
56
+ 'calc(var(--shellui-overlay-max-height) * 0.4)',
57
+ );
54
58
  expect(resolveDrawerSize({ size: 'sm' }, 'left').drawerSize).toBe('20rem');
55
59
  });
56
60
 
61
+ it('forces bottom position on mobile', () => {
62
+ expect(resolveEffectiveDrawerPosition('right', true)).toBe('bottom');
63
+ expect(resolveEffectiveDrawerPosition('left', true)).toBe('bottom');
64
+ expect(resolveEffectiveDrawerPosition('top', true)).toBe('bottom');
65
+ expect(resolveEffectiveDrawerPosition('bottom', true)).toBe('bottom');
66
+ expect(resolveEffectiveDrawerPosition('right', false)).toBe('right');
67
+ });
68
+
69
+ it('remaps horizontal freeform size to default height on mobile', () => {
70
+ const desktop = resolveDrawerSizeForViewport({ size: '60vw' }, 'right', false);
71
+ expect(desktop.drawerSize).toBe('60vw');
72
+
73
+ const mobile = resolveDrawerSizeForViewport({ size: '60vw' }, 'right', true);
74
+ expect(mobile.drawerSize).toBe('calc(var(--shellui-overlay-max-height) * 0.8)');
75
+
76
+ const preset = resolveDrawerSizeForViewport({ size: 'md' }, 'right', true);
77
+ expect(preset.drawerSize).toBe('calc(var(--shellui-overlay-max-height) * 0.55)');
78
+
79
+ const fromTop = resolveDrawerSizeForViewport({ size: '60vh' }, 'top', true);
80
+ expect(fromTop.drawerSize).toBe('60vh');
81
+ });
82
+
57
83
  it('defaults dismiss options', () => {
58
84
  expect(resolveDismissOptions(null)).toEqual({
59
85
  showCloseButton: true,