@shellui/core 0.5.0-alpha.5 → 0.5.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 (32) 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 +11 -4
  6. package/src/components/ui/sonner.tsx +20 -2
  7. package/src/features/alertDialog/DialogContext.tsx +11 -5
  8. package/src/features/auth/components/AccessPendingView.tsx +1 -1
  9. package/src/features/auth/components/LoginButton.tsx +3 -3
  10. package/src/features/auth/components/LoginView.tsx +5 -4
  11. package/src/features/layouts/LayoutFallback.tsx +1 -1
  12. package/src/features/layouts/OverlayShell.tsx +76 -44
  13. package/src/features/layouts/appbar/AppBarLayout.tsx +473 -291
  14. package/src/features/layouts/chrome/viewport.ts +66 -0
  15. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +1 -1
  16. package/src/features/layouts/sidebar/SidebarInner.tsx +1 -1
  17. package/src/features/layouts/sidebar/SidebarLayout.tsx +110 -38
  18. package/src/features/layouts/windows/WindowsLayout.tsx +138 -42
  19. package/src/features/overlays/ResponsiveModal.tsx +36 -17
  20. package/src/features/overlays/overlaySize.spec.ts +27 -1
  21. package/src/features/overlays/overlaySize.ts +73 -18
  22. package/src/features/overlays/useOverlayReportedSize.ts +5 -4
  23. package/src/features/settings/SettingsView.tsx +9 -2
  24. package/src/features/storage/uploads/UploadToastCard.tsx +1 -1
  25. package/src/features/storage/uploads/UploadToaster.tsx +6 -3
  26. package/src/features/theme/applyTheme.ts +20 -1
  27. package/src/i18n/translations/en/common.json +2 -1
  28. package/src/i18n/translations/fr/common.json +2 -1
  29. package/src/index.css +168 -12
  30. package/src/index.html +32 -3
  31. package/src/routes/components/RouteErrorBoundary.tsx +1 -1
  32. package/src/routes/components/RouteFallback.tsx +1 -1
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Shell / overlay viewport helpers.
3
+ *
4
+ * `--shellui-app-height` is defined in CSS as `100dvh` (see index.html / index.css).
5
+ * Overlay clamps and CSS max-heights should derive from that — never raw
6
+ * `innerHeight` alone.
7
+ */
8
+
9
+ const APP_HEIGHT_VAR = '--shellui-app-height';
10
+
11
+ /** Read a CSS length on :root (px). `env(safe-area-*)` resolves through a probe. */
12
+ function readRootLengthPx(cssLength: string): number {
13
+ if (typeof document === 'undefined') return 0;
14
+ const probe = document.createElement('div');
15
+ probe.style.cssText =
16
+ 'position:fixed;top:0;left:0;width:0;height:0;visibility:hidden;pointer-events:none;' +
17
+ `padding-top:${cssLength}`;
18
+ document.documentElement.appendChild(probe);
19
+ const value = Number.parseFloat(getComputedStyle(probe).paddingTop);
20
+ probe.remove();
21
+ return Number.isFinite(value) ? value : 0;
22
+ }
23
+
24
+ export function readSafeAreaInsetTop(): number {
25
+ return readRootLengthPx('var(--shellui-safe-area-top, env(safe-area-inset-top, 0px))');
26
+ }
27
+
28
+ export function readSafeAreaInsetBottom(): number {
29
+ return readRootLengthPx('var(--shellui-safe-area-bottom, env(safe-area-inset-bottom, 0px))');
30
+ }
31
+
32
+ /** Current shell height in CSS pixels (falls back to innerHeight). */
33
+ export function readAppHeightPx(): number {
34
+ if (typeof window === 'undefined') return 0;
35
+ if (typeof document !== 'undefined') {
36
+ const raw = getComputedStyle(document.documentElement).getPropertyValue(APP_HEIGHT_VAR).trim();
37
+ if (raw.endsWith('px')) {
38
+ const px = Number.parseFloat(raw);
39
+ if (Number.isFinite(px) && px > 0) return px;
40
+ }
41
+ // Resolve dvh/vh/% via a probe so browser-tab fallback still works.
42
+ if (raw) {
43
+ const viaProbe = readRootLengthPx(raw);
44
+ if (viaProbe > 0) return viaProbe;
45
+ }
46
+ }
47
+ return window.innerHeight;
48
+ }
49
+
50
+ /**
51
+ * Max height for modals / sheets / drawers (content-sized clamps).
52
+ * Leaves the top safe area + a small margin so a bottom sheet cannot cover the
53
+ * status bar controls; the sheet itself may still paint into the home-indicator
54
+ * band (footer chrome owns that inset).
55
+ */
56
+ export function overlayMaxHeightPx(ratio = 0.92): number {
57
+ const appH = readAppHeightPx();
58
+ const top = readSafeAreaInsetTop();
59
+ const available = Math.max(0, appH - top - 8);
60
+ return Math.floor(available * ratio);
61
+ }
62
+
63
+ /** CSS expression matching {@link overlayMaxHeightPx} for inline styles. */
64
+ export function overlayMaxHeightCss(): string {
65
+ return 'var(--shellui-overlay-max-height)';
66
+ }
@@ -48,7 +48,7 @@ export function FullscreenLayout({ title, navigation, children }: FullscreenLayo
48
48
  }, [location.pathname, title, navigationItems, currentLanguage]);
49
49
 
50
50
  return (
51
- <main className="relative flex flex-col w-full h-screen overflow-hidden bg-background">
51
+ <main className="relative flex h-full max-h-full w-full flex-col overflow-hidden bg-background">
52
52
  {isTauriEnv ? (
53
53
  <div
54
54
  className="pointer-events-auto absolute top-0 left-0 z-[46] flex items-center"
@@ -155,7 +155,7 @@ export function SidebarInner({
155
155
  <SidebarContent className="gap-1">
156
156
  <NavigationContent navigation={startNav} />
157
157
  </SidebarContent>
158
- <SidebarFooter className="gap-0 border-t border-sidebar-border p-0">
158
+ <SidebarFooter className="gap-0 border-t border-sidebar-border px-0 pt-0 pb-[max(0.5rem,var(--shellui-safe-area-bottom))]">
159
159
  {(endItems.length > 0 || showAuthButton) && (
160
160
  <NavigationContent
161
161
  navigation={endItems}
@@ -23,6 +23,8 @@ 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';
28
30
  import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
@@ -44,6 +46,19 @@ function CloseMobileSidebarOnNavigate() {
44
46
  return null;
45
47
  }
46
48
 
49
+ /** Close the mobile sheet when a modal or drawer opens. */
50
+ function CloseMobileSidebarOnOverlay() {
51
+ const { setOpenMobile } = useSidebar();
52
+ const { isOpen: modalOpen } = useModal();
53
+ const { isOpen: drawerOpen } = useDrawer();
54
+
55
+ useEffect(() => {
56
+ if (modalOpen || drawerOpen) setOpenMobile(false);
57
+ }, [modalOpen, drawerOpen, setOpenMobile]);
58
+
59
+ return null;
60
+ }
61
+
47
62
  /** Sync collapsed-titlebar layout offset onto <html> for CSS. */
48
63
  function CollapsedTitlebarOffset() {
49
64
  const overlay = useMacOverlayChrome();
@@ -60,6 +75,26 @@ function CollapsedTitlebarOffset() {
60
75
  return null;
61
76
  }
62
77
 
78
+ /** True when this window is the outermost shell (not nested in an iframe). */
79
+ function isShellUiRootWindow(): boolean {
80
+ return typeof window !== 'undefined' && window.parent === window;
81
+ }
82
+
83
+ /**
84
+ * Root sidebar only: advertise the safe-area topbar on <html> so fixed chrome
85
+ * (sidebar container, drawers) can clear it. Nested iframe shells skip this.
86
+ */
87
+ function SafeAreaTopbarOffset({ enabled }: { enabled: boolean }) {
88
+ useEffect(() => {
89
+ if (!enabled) return;
90
+ const root = document.documentElement;
91
+ root.setAttribute('data-shellui-safe-area-topbar', '');
92
+ return () => root.removeAttribute('data-shellui-safe-area-topbar');
93
+ }, [enabled]);
94
+
95
+ return null;
96
+ }
97
+
63
98
  const SidebarLayoutContent = ({ title, appIcon, navigation }: SidebarLayoutProps) => {
64
99
  const { i18n } = useTranslation();
65
100
  const { isAuthenticated } = useAuth();
@@ -71,6 +106,8 @@ const SidebarLayoutContent = ({ title, appIcon, navigation }: SidebarLayoutProps
71
106
  const mobileTrafficInset = trafficLights
72
107
  ? MAC_TRAFFIC_LIGHTS_WIDTH_PX + MAC_TRAFFIC_LIGHTS_GAP_PX
73
108
  : undefined;
109
+ // Nested shell-in-iframe must not repeat the root safe-area top band.
110
+ const showSafeAreaTopbar = isShellUiRootWindow();
74
111
 
75
112
  const currentLanguage = useMemo(() => {
76
113
  return i18n.language || 'en';
@@ -106,47 +143,82 @@ const SidebarLayoutContent = ({ title, appIcon, navigation }: SidebarLayoutProps
106
143
  }, [navigationItem, title, currentLanguage]);
107
144
 
108
145
  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
- : {})}
146
+ <div
147
+ data-shellui-sidebar-layout=""
148
+ className="flex h-full max-h-full flex-col overflow-hidden"
149
+ >
150
+ <SafeAreaTopbarOffset enabled={showSafeAreaTopbar} />
151
+ {/*
152
+ Root shell only (not when nested in an iframe): tablet / desktop band for
153
+ top safe-area, painted with sidebar background. Height is 0 when the inset
154
+ is 0; overflow clips the border so no stray hairline.
155
+ */}
156
+ {showSafeAreaTopbar ? (
157
+ <div
158
+ aria-hidden
159
+ data-slot="sidebar-safe-area-top"
160
+ className="relative z-0 hidden shrink-0 overflow-hidden md:block"
161
+ style={{ height: 'var(--shellui-safe-area-top)' }}
137
162
  >
138
- <SidebarTrigger
139
- data-shellui-no-drag=""
140
- className="relative size-8 touch-manipulation text-foreground"
163
+ <div className="box-border h-full border-b border-sidebar-border bg-sidebar" />
164
+ </div>
165
+ ) : null}
166
+ <SidebarProvider className="min-h-0 flex-1 overflow-hidden">
167
+ <CloseMobileSidebarOnNavigate />
168
+ <CloseMobileSidebarOnOverlay />
169
+ <CollapsedTitlebarOffset />
170
+ <CollapsedDesktopTitlebar />
171
+ <Sidebar
172
+ collapsible="icon"
173
+ className="border-sidebar-border"
174
+ >
175
+ <SidebarInner
176
+ startNav={startNav}
177
+ endItems={endItems}
178
+ showAuthButton={!hasCustomLoginNav || isAuthenticated}
179
+ title={title}
180
+ appIcon={appIcon}
141
181
  />
142
- {isTauriEnv ? <DesktopHistoryButtons /> : null}
143
- </header>
182
+ <SidebarRail />
183
+ </Sidebar>
144
184
 
145
- <div className="flex min-h-0 flex-1 flex-col overflow-auto">
146
- <Outlet />
147
- </div>
148
- </SidebarInset>
149
- </SidebarProvider>
185
+ <SidebarInset className="relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
186
+ {/*
187
+ Mobile top chrome: extend the header background into the status-bar band
188
+ so there is no empty strip. Interactive controls stay below the inset via
189
+ padding. Overlays are fixed full-screen and still cover this band.
190
+ Nested iframe shells skip top safe-area — the host already cleared it.
191
+ */}
192
+ <header
193
+ className="relative z-[46] flex shrink-0 items-center gap-0.5 border-b border-border bg-background px-3 select-none md:hidden"
194
+ style={{
195
+ paddingTop: showSafeAreaTopbar ? 'var(--shellui-safe-area-top)' : undefined,
196
+ height: showSafeAreaTopbar
197
+ ? `calc(${DESKTOP_TITLEBAR_HEIGHT_PX}px + var(--shellui-safe-area-top))`
198
+ : DESKTOP_TITLEBAR_HEIGHT_PX,
199
+ ...(mobileTrafficInset !== undefined ? { paddingLeft: mobileTrafficInset } : {}),
200
+ }}
201
+ {...(trafficLights
202
+ ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
203
+ : {})}
204
+ >
205
+ <SidebarTrigger
206
+ data-shellui-no-drag=""
207
+ className="relative size-8 touch-manipulation text-foreground"
208
+ />
209
+ {isTauriEnv ? <DesktopHistoryButtons /> : null}
210
+ </header>
211
+
212
+ {/*
213
+ Fill to the physical bottom — do not pad safe-area here or the iframe
214
+ looks cut off. In-app content (settings, etc.) owns bottom safe insets.
215
+ */}
216
+ <div className="flex min-h-0 flex-1 flex-col overflow-hidden">
217
+ <Outlet />
218
+ </div>
219
+ </SidebarInset>
220
+ </SidebarProvider>
221
+ </div>
150
222
  );
151
223
  };
152
224
 
@@ -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 =