@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
@@ -1,4 +1,12 @@
1
- import { useMemo, useEffect, useState, Fragment, type ReactNode } from 'react';
1
+ import {
2
+ useMemo,
3
+ useEffect,
4
+ useState,
5
+ useRef,
6
+ useLayoutEffect,
7
+ useCallback,
8
+ type ReactNode,
9
+ } from 'react';
2
10
  import { Link, useLocation, Outlet } from 'react-router';
3
11
  import { useTranslation } from 'react-i18next';
4
12
  import { shellui } from '@shellui/sdk';
@@ -25,6 +33,8 @@ import {
25
33
  DropdownMenu,
26
34
  DropdownMenuContent,
27
35
  DropdownMenuItem,
36
+ DropdownMenuLabel,
37
+ DropdownMenuSeparator,
28
38
  DropdownMenuTrigger,
29
39
  } from '../../../components/ui/dropdown-menu';
30
40
  import { AppBarTooltip, TooltipProvider } from '../../../components/ui/tooltip';
@@ -36,13 +46,22 @@ import { useSettings } from '../../settings/hooks/useSettings';
36
46
  import { NavIcon } from '../sidebar/SidebarIcons';
37
47
  import { getExternalFaviconUrl } from '../sidebar/sidebarUtils';
38
48
  import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
39
- import { useIsTauriClient, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
49
+ import {
50
+ isShellUiRootWindow,
51
+ SafeAreaTopbarOffset,
52
+ SafeAreaTopbarStrip,
53
+ } from '../chrome/SafeAreaTopbar';
54
+ import { useIsTauriRuntime, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
40
55
  import {
41
56
  DESKTOP_TITLEBAR_HEIGHT_PX,
57
+ DESKTOP_TITLEBAR_PAD_TOP_PX,
42
58
  MAC_TRAFFIC_LIGHTS_GAP_PX,
43
59
  MAC_TRAFFIC_LIGHTS_WIDTH_PX,
44
60
  } from '../chrome/constants';
45
61
 
62
+ /** App-bar chrome height — matches the Tauri / sidebar titlebar strip. */
63
+ const APP_BAR_HEIGHT_PX = DESKTOP_TITLEBAR_HEIGHT_PX;
64
+
46
65
  interface AppBarLayoutProps {
47
66
  title?: string;
48
67
  appIcon?: ThemeAsset;
@@ -54,6 +73,14 @@ type NavSection =
54
73
  | { type: 'group'; title: LocalizedString; items: NavigationItem[] }
55
74
  | { type: 'items'; items: NavigationItem[] };
56
75
 
76
+ type NavEntry =
77
+ | { type: 'link'; key: string; item: NavigationItem }
78
+ | { type: 'category'; key: string; title: LocalizedString; items: NavigationItem[] };
79
+
80
+ const NAV_GAP_PX = 4;
81
+ /** Reserved width guess before More is measured; kept close to the real control. */
82
+ const MORE_FALLBACK_PX = 72;
83
+
57
84
  function resolveLocalizedLabel(
58
85
  value: string | { en: string; fr: string; [key: string]: string },
59
86
  lang: string,
@@ -66,151 +93,14 @@ function isNavigationGroup(item: NavigationItem | NavigationGroup): item is Navi
66
93
  return 'title' in item && 'items' in item;
67
94
  }
68
95
 
69
- function AppsGridIcon({ className }: { className?: string }) {
70
- return (
71
- <svg
72
- xmlns="http://www.w3.org/2000/svg"
73
- width="24"
74
- height="24"
75
- viewBox="0 0 24 24"
76
- fill="currentColor"
77
- className={className}
78
- aria-hidden
79
- >
80
- <rect
81
- x="3"
82
- y="3"
83
- width="4.5"
84
- height="4.5"
85
- rx="0.75"
86
- />
87
- <rect
88
- x="9.75"
89
- y="3"
90
- width="4.5"
91
- height="4.5"
92
- rx="0.75"
93
- />
94
- <rect
95
- x="16.5"
96
- y="3"
97
- width="4.5"
98
- height="4.5"
99
- rx="0.75"
100
- />
101
- <rect
102
- x="3"
103
- y="9.75"
104
- width="4.5"
105
- height="4.5"
106
- rx="0.75"
107
- />
108
- <rect
109
- x="9.75"
110
- y="9.75"
111
- width="4.5"
112
- height="4.5"
113
- rx="0.75"
114
- />
115
- <rect
116
- x="16.5"
117
- y="9.75"
118
- width="4.5"
119
- height="4.5"
120
- rx="0.75"
121
- />
122
- <rect
123
- x="3"
124
- y="16.5"
125
- width="4.5"
126
- height="4.5"
127
- rx="0.75"
128
- />
129
- <rect
130
- x="9.75"
131
- y="16.5"
132
- width="4.5"
133
- height="4.5"
134
- rx="0.75"
135
- />
136
- <rect
137
- x="16.5"
138
- y="16.5"
139
- width="4.5"
140
- height="4.5"
141
- rx="0.75"
142
- />
143
- </svg>
144
- );
145
- }
146
-
147
96
  function navItemIsActive(item: NavigationItem, activePathPrefix: string | null): boolean {
148
97
  const isOverlay = item.openIn === 'modal' || item.openIn === 'drawer';
149
98
  const isExternal = item.openIn === 'external';
150
99
  return !isOverlay && !isExternal && getNavPathPrefix(item) === activePathPrefix;
151
100
  }
152
101
 
153
- function itemIconSrc(item: NavigationItem): string | null {
154
- if (item.icon) return item.icon;
155
- if (item.openIn === 'external') return getExternalFaviconUrl(item.url);
156
- return null;
157
- }
158
-
159
- function NavItemGlyph({
160
- item,
161
- label,
162
- className,
163
- /** Rounded muted tile with a compact icon inside (app-bar launcher). */
164
- tiled = false,
165
- }: {
166
- item: NavigationItem;
167
- label: string;
168
- className?: string;
169
- tiled?: boolean;
170
- }) {
171
- const iconSrc = itemIconSrc(item);
172
- const firstLetter = label ? label.charAt(0).toUpperCase() : '?';
173
-
174
- if (tiled) {
175
- return (
176
- <span
177
- className={cn(
178
- 'flex size-10 shrink-0 items-center justify-center rounded-lg bg-background text-muted-foreground shadow-sm ring-1 ring-border/60',
179
- className,
180
- )}
181
- aria-hidden
182
- >
183
- {iconSrc ? (
184
- <NavIcon
185
- src={iconSrc}
186
- className="size-5"
187
- />
188
- ) : (
189
- <span className="text-xs font-semibold">{firstLetter}</span>
190
- )}
191
- </span>
192
- );
193
- }
194
-
195
- if (iconSrc) {
196
- return (
197
- <NavIcon
198
- src={iconSrc}
199
- className={cn('size-4', className)}
200
- />
201
- );
202
- }
203
- return (
204
- <span
205
- className={cn(
206
- 'flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-[10px] font-semibold text-muted-foreground',
207
- className,
208
- )}
209
- aria-hidden
210
- >
211
- {firstLetter}
212
- </span>
213
- );
102
+ function categoryIsActive(items: NavigationItem[], activePathPrefix: string | null): boolean {
103
+ return items.some((item) => navItemIsActive(item, activePathPrefix));
214
104
  }
215
105
 
216
106
  function navigateToItem(item: NavigationItem): void {
@@ -224,9 +114,7 @@ function navigateToItem(item: NavigationItem): void {
224
114
  }
225
115
  if (item.openIn === 'external') {
226
116
  window.open(item.url, '_blank', 'noopener,noreferrer');
227
- return;
228
117
  }
229
- // Link navigation handled by callers that render <Link>
230
118
  }
231
119
 
232
120
  function buildStartSections(start: (NavigationItem | NavigationGroup)[]): NavSection[] {
@@ -269,202 +157,496 @@ function buildStartSections(start: (NavigationItem | NavigationGroup)[]): NavSec
269
157
  return sections;
270
158
  }
271
159
 
272
- /** Resolve selected item + localized category for the current path. */
273
- function resolveSelectedDisplay(
274
- sections: NavSection[],
275
- activePathPrefix: string | null,
276
- lang: string,
277
- ): { item: NavigationItem; label: string; category: string | null } | null {
278
- for (const section of sections) {
279
- const category = section.type === 'group' ? resolveLocalizedLabel(section.title, lang) : null;
280
- for (const item of section.items) {
281
- if (navItemIsActive(item, activePathPrefix)) {
282
- return {
283
- item,
284
- label: resolveNavLabel(item.label, lang) || item.path || 'Home',
285
- category,
286
- };
287
- }
160
+ function sectionsToEntries(sections: NavSection[]): NavEntry[] {
161
+ const entries: NavEntry[] = [];
162
+ sections.forEach((section, sectionIndex) => {
163
+ if (section.type === 'group') {
164
+ entries.push({
165
+ type: 'category',
166
+ key: `category-${sectionIndex}`,
167
+ title: section.title,
168
+ items: section.items,
169
+ });
170
+ return;
288
171
  }
289
- }
290
- for (const section of sections) {
291
- const category = section.type === 'group' ? resolveLocalizedLabel(section.title, lang) : null;
292
- for (const item of section.items) {
293
- if (item.openIn === 'modal' || item.openIn === 'drawer' || item.openIn === 'external') {
294
- continue;
295
- }
296
- return {
172
+ section.items.forEach((item, itemIndex) => {
173
+ entries.push({
174
+ type: 'link',
175
+ key: `link-${sectionIndex}-${item.path}-${itemIndex}`,
297
176
  item,
298
- label: resolveNavLabel(item.label, lang) || item.path || 'Home',
299
- category,
300
- };
301
- }
177
+ });
178
+ });
179
+ });
180
+ return entries;
181
+ }
182
+
183
+ function CaretDownIcon({ className }: { className?: string }) {
184
+ return (
185
+ <svg
186
+ xmlns="http://www.w3.org/2000/svg"
187
+ width="14"
188
+ height="14"
189
+ viewBox="0 0 24 24"
190
+ fill="none"
191
+ stroke="currentColor"
192
+ strokeWidth="2.5"
193
+ strokeLinecap="round"
194
+ strokeLinejoin="round"
195
+ className={className}
196
+ aria-hidden
197
+ >
198
+ <path d="m6 9 6 6 6-6" />
199
+ </svg>
200
+ );
201
+ }
202
+
203
+ function itemIconSrc(item: NavigationItem): string | null {
204
+ if (item.icon) return item.icon;
205
+ if (item.openIn === 'external') return getExternalFaviconUrl(item.url);
206
+ return null;
207
+ }
208
+
209
+ /** Compact icon (or first-letter fallback) for start-nav links. */
210
+ function AppBarItemIcon({ item, label }: { item: NavigationItem; label: string }) {
211
+ const iconSrc = itemIconSrc(item);
212
+ const firstLetter = label ? label.charAt(0).toUpperCase() : '?';
213
+ if (iconSrc) {
214
+ return (
215
+ <span
216
+ className="flex size-5 shrink-0 items-center justify-center rounded-md bg-muted/60 p-0.5"
217
+ aria-hidden
218
+ >
219
+ <NavIcon
220
+ src={iconSrc}
221
+ className="size-3"
222
+ />
223
+ </span>
224
+ );
302
225
  }
303
- const firstSection = sections[0];
304
- const first = firstSection?.items[0];
305
- if (!first) return null;
306
- return {
307
- item: first,
308
- label: resolveNavLabel(first.label, lang) || first.path || 'Home',
309
- category:
310
- firstSection.type === 'group' ? resolveLocalizedLabel(firstSection.title, lang) : null,
311
- };
226
+ return (
227
+ <span
228
+ className="flex size-5 shrink-0 items-center justify-center rounded-md bg-muted p-0.5 text-[9px] font-semibold leading-none text-muted-foreground"
229
+ aria-hidden
230
+ >
231
+ {firstLetter}
232
+ </span>
233
+ );
312
234
  }
313
235
 
314
- function AppBarLauncherTile({
236
+ const navTriggerClass = (active: boolean) =>
237
+ cn(
238
+ // h-7 leaves air in the 42px chrome after the 2px top pad.
239
+ 'inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 text-xs font-medium transition-colors',
240
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
241
+ active
242
+ ? 'bg-sidebar-accent text-sidebar-accent-foreground'
243
+ : 'text-sidebar-foreground/85 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground',
244
+ );
245
+
246
+ /** Text link / action used in the bar (not inside a dropdown). */
247
+ function AppBarNavLink({
315
248
  item,
316
249
  label,
317
250
  activePathPrefix,
318
- onActivate,
319
- onNavigate,
320
251
  }: {
321
252
  item: NavigationItem;
322
253
  label: string;
323
254
  activePathPrefix: string | null;
324
- onActivate: (item: NavigationItem) => void;
325
- onNavigate: () => void;
326
255
  }) {
327
256
  const isActive = navItemIsActive(item, activePathPrefix);
328
257
  const pathPrefix = getNavPathPrefix(item);
329
- const tileClass =
330
- 'group flex w-[7rem] shrink-0 flex-col items-center justify-start rounded-md px-1 pt-4 pb-2 text-center focus:bg-transparent data-[highlighted]:bg-transparent';
331
- const body = (
332
- <span
333
- className={cn(
334
- 'flex aspect-square w-full flex-col items-center justify-center gap-1.5 overflow-hidden rounded-md p-2 transition-colors',
335
- 'hover:bg-accent/80 hover:text-accent-foreground',
336
- 'group-data-[highlighted]:bg-accent/80 group-data-[highlighted]:text-accent-foreground',
337
- isActive && 'bg-accent/80 text-accent-foreground',
338
- )}
258
+ const className = navTriggerClass(isActive);
259
+ const content = (
260
+ <>
261
+ <AppBarItemIcon
262
+ item={item}
263
+ label={label}
264
+ />
265
+ <span className="truncate">{label}</span>
266
+ </>
267
+ );
268
+
269
+ if (item.openIn === 'modal' || item.openIn === 'drawer' || item.openIn === 'external') {
270
+ return (
271
+ <button
272
+ type="button"
273
+ className={className}
274
+ onClick={() => navigateToItem(item)}
275
+ >
276
+ {content}
277
+ </button>
278
+ );
279
+ }
280
+
281
+ return (
282
+ <Link
283
+ to={pathPrefix}
284
+ className={className}
339
285
  >
340
- <NavItemGlyph
286
+ {content}
287
+ </Link>
288
+ );
289
+ }
290
+
291
+ function AppBarNavMenuItem({
292
+ item,
293
+ label,
294
+ activePathPrefix,
295
+ onNavigate,
296
+ }: {
297
+ item: NavigationItem;
298
+ label: string;
299
+ activePathPrefix: string | null;
300
+ onNavigate?: () => void;
301
+ }) {
302
+ const isActive = navItemIsActive(item, activePathPrefix);
303
+ const pathPrefix = getNavPathPrefix(item);
304
+ const itemClass = cn('gap-2 text-sm', isActive && 'bg-accent text-accent-foreground');
305
+ const content = (
306
+ <>
307
+ <AppBarItemIcon
341
308
  item={item}
342
309
  label={label}
343
- tiled
344
310
  />
345
- <span className="line-clamp-2 w-full text-center text-[11px] leading-snug font-medium break-words">
346
- {label}
347
- </span>
348
- </span>
311
+ <span className="truncate">{label}</span>
312
+ </>
349
313
  );
350
314
 
351
315
  if (item.openIn === 'modal' || item.openIn === 'drawer' || item.openIn === 'external') {
352
316
  return (
353
317
  <DropdownMenuItem
354
- className={tileClass}
355
- onSelect={() => onActivate(item)}
318
+ className={itemClass}
319
+ onSelect={() => {
320
+ navigateToItem(item);
321
+ onNavigate?.();
322
+ }}
356
323
  >
357
- {body}
324
+ {content}
358
325
  </DropdownMenuItem>
359
326
  );
360
327
  }
361
328
 
362
329
  return (
363
330
  <DropdownMenuItem
364
- className={tileClass}
331
+ className={itemClass}
365
332
  asChild
366
333
  >
367
334
  <Link
368
335
  to={pathPrefix}
369
336
  onClick={onNavigate}
370
337
  >
371
- {body}
338
+ {content}
372
339
  </Link>
373
340
  </DropdownMenuItem>
374
341
  );
375
342
  }
376
343
 
377
- function AppBarLauncher({
378
- sections,
344
+ function AppBarNavCategory({
345
+ title,
346
+ items,
379
347
  activePathPrefix,
380
348
  currentLanguage,
381
349
  }: {
382
- sections: NavSection[];
350
+ title: LocalizedString;
351
+ items: NavigationItem[];
352
+ activePathPrefix: string | null;
353
+ currentLanguage: string;
354
+ }) {
355
+ const [open, setOpen] = useState(false);
356
+ const label = resolveLocalizedLabel(title, currentLanguage);
357
+ const active = categoryIsActive(items, activePathPrefix);
358
+
359
+ return (
360
+ <DropdownMenu
361
+ open={open}
362
+ onOpenChange={setOpen}
363
+ >
364
+ <DropdownMenuTrigger asChild>
365
+ <Button
366
+ type="button"
367
+ variant="ghost"
368
+ size="sm"
369
+ className={cn(navTriggerClass(active), 'hover:bg-sidebar-accent/50')}
370
+ aria-expanded={open}
371
+ >
372
+ <span className="truncate">{label}</span>
373
+ <CaretDownIcon className="size-3 shrink-0 opacity-70" />
374
+ </Button>
375
+ </DropdownMenuTrigger>
376
+ <DropdownMenuContent
377
+ align="start"
378
+ onCloseAutoFocus={(event) => event.preventDefault()}
379
+ >
380
+ {items.map((item, index) => (
381
+ <AppBarNavMenuItem
382
+ key={`${item.path}-${item.url}-${index}`}
383
+ item={item}
384
+ label={resolveNavLabel(item.label, currentLanguage) || item.path || 'Home'}
385
+ activePathPrefix={activePathPrefix}
386
+ onNavigate={() => setOpen(false)}
387
+ />
388
+ ))}
389
+ </DropdownMenuContent>
390
+ </DropdownMenu>
391
+ );
392
+ }
393
+
394
+ function AppBarNavMore({
395
+ entries,
396
+ activePathPrefix,
397
+ currentLanguage,
398
+ }: {
399
+ entries: NavEntry[];
383
400
  activePathPrefix: string | null;
384
401
  currentLanguage: string;
385
402
  }) {
386
403
  const { t } = useTranslation();
387
404
  const [open, setOpen] = useState(false);
388
- const selected = useMemo(
389
- () => resolveSelectedDisplay(sections, activePathPrefix, currentLanguage),
390
- [sections, activePathPrefix, currentLanguage],
405
+ const moreActive = entries.some((entry) =>
406
+ entry.type === 'link'
407
+ ? navItemIsActive(entry.item, activePathPrefix)
408
+ : categoryIsActive(entry.items, activePathPrefix),
409
+ );
410
+
411
+ return (
412
+ <DropdownMenu
413
+ open={open}
414
+ onOpenChange={setOpen}
415
+ >
416
+ <DropdownMenuTrigger asChild>
417
+ <Button
418
+ type="button"
419
+ variant="ghost"
420
+ size="sm"
421
+ className={cn(navTriggerClass(moreActive), 'hover:bg-sidebar-accent/50')}
422
+ aria-label={t('desktopChrome.more')}
423
+ aria-expanded={open}
424
+ >
425
+ <span>{t('desktopChrome.more')}</span>
426
+ <CaretDownIcon className="size-3 shrink-0 opacity-70" />
427
+ </Button>
428
+ </DropdownMenuTrigger>
429
+ <DropdownMenuContent
430
+ align="start"
431
+ onCloseAutoFocus={(event) => event.preventDefault()}
432
+ className="min-w-[12rem]"
433
+ >
434
+ {entries.map((entry, entryIndex) => {
435
+ if (entry.type === 'link') {
436
+ return (
437
+ <AppBarNavMenuItem
438
+ key={entry.key}
439
+ item={entry.item}
440
+ label={
441
+ resolveNavLabel(entry.item.label, currentLanguage) || entry.item.path || 'Home'
442
+ }
443
+ activePathPrefix={activePathPrefix}
444
+ onNavigate={() => setOpen(false)}
445
+ />
446
+ );
447
+ }
448
+
449
+ const categoryLabel = resolveLocalizedLabel(entry.title, currentLanguage);
450
+ return (
451
+ <div key={entry.key}>
452
+ {entryIndex > 0 ? <DropdownMenuSeparator /> : null}
453
+ <DropdownMenuLabel className="text-xs font-medium text-muted-foreground">
454
+ {categoryLabel}
455
+ </DropdownMenuLabel>
456
+ {entry.items.map((item, index) => (
457
+ <AppBarNavMenuItem
458
+ key={`${item.path}-${item.url}-${index}`}
459
+ item={item}
460
+ label={resolveNavLabel(item.label, currentLanguage) || item.path || 'Home'}
461
+ activePathPrefix={activePathPrefix}
462
+ onNavigate={() => setOpen(false)}
463
+ />
464
+ ))}
465
+ </div>
466
+ );
467
+ })}
468
+ </DropdownMenuContent>
469
+ </DropdownMenu>
391
470
  );
471
+ }
472
+
473
+ /** Lightweight width probe — same padding/type as real triggers, no dropdown portals. */
474
+ function AppBarNavMeasureChip({
475
+ label,
476
+ withCaret,
477
+ withIcon,
478
+ measureRef,
479
+ }: {
480
+ label: string;
481
+ withCaret?: boolean;
482
+ withIcon?: boolean;
483
+ measureRef: (node: HTMLElement | null) => void;
484
+ }) {
485
+ return (
486
+ <span
487
+ ref={measureRef}
488
+ className={cn(navTriggerClass(false), 'whitespace-nowrap')}
489
+ >
490
+ {withIcon ? (
491
+ <span
492
+ className="size-5 shrink-0"
493
+ aria-hidden
494
+ />
495
+ ) : null}
496
+ {label}
497
+ {withCaret ? <CaretDownIcon className="size-3 shrink-0 opacity-70" /> : null}
498
+ </span>
499
+ );
500
+ }
392
501
 
393
- const activateItem = (item: NavigationItem) => {
394
- if (item.openIn === 'modal' || item.openIn === 'drawer' || item.openIn === 'external') {
395
- navigateToItem(item);
396
- setOpen(false);
502
+ /**
503
+ * Horizontal start nav: inline links, category caret dropdowns, and a More overflow menu.
504
+ */
505
+ function AppBarNav({
506
+ sections,
507
+ activePathPrefix,
508
+ currentLanguage,
509
+ }: {
510
+ sections: NavSection[];
511
+ activePathPrefix: string | null;
512
+ currentLanguage: string;
513
+ }) {
514
+ const { t } = useTranslation();
515
+ const entries = useMemo(() => sectionsToEntries(sections), [sections]);
516
+ const containerRef = useRef<HTMLDivElement | null>(null);
517
+ const measureRefs = useRef<(HTMLElement | null)[]>([]);
518
+ const moreMeasureRef = useRef<HTMLElement | null>(null);
519
+ const [visibleCount, setVisibleCount] = useState(entries.length);
520
+
521
+ const setMeasureRef = useCallback((index: number, node: HTMLElement | null) => {
522
+ measureRefs.current[index] = node;
523
+ }, []);
524
+
525
+ const recompute = useCallback(() => {
526
+ const container = containerRef.current;
527
+ if (!container || entries.length === 0) {
528
+ setVisibleCount(entries.length);
529
+ return;
397
530
  }
398
- };
399
531
 
400
- const renderTile = (item: NavigationItem, index: number) => {
401
- const label = resolveNavLabel(item.label, currentLanguage) || item.path || 'Home';
402
- return (
403
- <AppBarLauncherTile
404
- key={`${item.path}-${item.url}-${index}`}
405
- item={item}
406
- label={label}
407
- activePathPrefix={activePathPrefix}
408
- onActivate={activateItem}
409
- onNavigate={() => setOpen(false)}
410
- />
411
- );
412
- };
532
+ const available = container.clientWidth;
533
+ const widths = entries.map((_, i) => measureRefs.current[i]?.offsetWidth ?? 0);
534
+ if (widths.some((w) => w <= 0)) return;
535
+
536
+ const moreWidth = moreMeasureRef.current?.offsetWidth || MORE_FALLBACK_PX;
537
+
538
+ let total = 0;
539
+ for (let i = 0; i < widths.length; i++) {
540
+ total += widths[i] + (i > 0 ? NAV_GAP_PX : 0);
541
+ }
542
+ if (total <= available) {
543
+ setVisibleCount(entries.length);
544
+ return;
545
+ }
546
+
547
+ let used = 0;
548
+ let count = 0;
549
+ for (let i = 0; i < widths.length; i++) {
550
+ const gap = count > 0 ? NAV_GAP_PX : 0;
551
+ const nextUsed = used + gap + widths[i];
552
+ const needed = nextUsed + NAV_GAP_PX + moreWidth;
553
+ if (needed > available) break;
554
+ used = nextUsed;
555
+ count += 1;
556
+ }
557
+ setVisibleCount(count);
558
+ }, [entries]);
559
+
560
+ useLayoutEffect(() => {
561
+ measureRefs.current = measureRefs.current.slice(0, entries.length);
562
+ recompute();
563
+ }, [entries, currentLanguage, t, recompute]);
564
+
565
+ useLayoutEffect(() => {
566
+ const container = containerRef.current;
567
+ if (!container || typeof ResizeObserver === 'undefined') return;
568
+ const observer = new ResizeObserver(() => recompute());
569
+ observer.observe(container);
570
+ return () => observer.disconnect();
571
+ }, [recompute]);
572
+
573
+ const visible = entries.slice(0, visibleCount);
574
+ const overflow = entries.slice(visibleCount);
575
+ const showMore = overflow.length > 0;
576
+ const moreLabel = t('desktopChrome.more');
413
577
 
414
578
  return (
415
579
  <div
416
580
  data-shellui-no-drag=""
417
- className="flex min-w-0 items-center"
581
+ ref={containerRef}
582
+ className="relative flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden"
418
583
  >
419
- <DropdownMenu
420
- open={open}
421
- onOpenChange={setOpen}
584
+ {/* Off-screen width probes (no DropdownMenu — avoids portal noise). */}
585
+ <div
586
+ aria-hidden
587
+ className="pointer-events-none absolute left-0 top-0 -z-10 flex items-center gap-0.5 whitespace-nowrap opacity-0"
422
588
  >
423
- <DropdownMenuTrigger asChild>
424
- <Button
425
- type="button"
426
- variant="ghost"
427
- size="sm"
428
- className="h-7 max-w-[16rem] shrink gap-2 px-2 text-sidebar-foreground hover:bg-sidebar-accent/60 hover:text-sidebar-foreground"
429
- aria-label={t('desktopChrome.openNavigation')}
430
- >
431
- <AppsGridIcon className="size-4 shrink-0 text-muted-foreground" />
432
- <span className="min-w-0 truncate text-xs font-medium">
433
- {selected?.label ?? t('desktopChrome.navigation')}
434
- </span>
435
- </Button>
436
- </DropdownMenuTrigger>
437
- <DropdownMenuContent
438
- align="start"
439
- onCloseAutoFocus={(event) => event.preventDefault()}
440
- className="w-max min-w-0 max-w-[calc(100vw-1.5rem)] max-h-[min(32rem,var(--radix-dropdown-menu-content-available-height,32rem))] overflow-y-auto p-3 pt-4 md:max-w-[50vw]"
441
- >
442
- <div className="flex flex-row flex-wrap items-start gap-x-2 gap-y-4">
443
- {sections.map((section, sectionIndex) => {
444
- if (section.type === 'group') {
445
- const categoryLabel = resolveLocalizedLabel(section.title, currentLanguage);
446
- return (
447
- <div
448
- key={`group-${categoryLabel}-${sectionIndex}`}
449
- className="relative inline-flex max-w-full flex-row flex-wrap gap-1.5 rounded-xl bg-muted/50 px-1.5 py-0 ring-1 ring-border/50"
450
- >
451
- <span className="pointer-events-none absolute left-2.5 top-0 z-10 -translate-y-1/2 rounded-sm bg-popover px-1.5 text-[10px] font-medium leading-none text-muted-foreground">
452
- {categoryLabel}
453
- </span>
454
- {section.items.map((item, index) => renderTile(item, index))}
455
- </div>
456
- );
589
+ {entries.map((entry, index) => {
590
+ if (entry.type === 'link') {
591
+ return (
592
+ <AppBarNavMeasureChip
593
+ key={`measure-${entry.key}`}
594
+ label={
595
+ resolveNavLabel(entry.item.label, currentLanguage) || entry.item.path || 'Home'
596
+ }
597
+ withIcon
598
+ measureRef={(node) => setMeasureRef(index, node)}
599
+ />
600
+ );
601
+ }
602
+ return (
603
+ <AppBarNavMeasureChip
604
+ key={`measure-${entry.key}`}
605
+ label={resolveLocalizedLabel(entry.title, currentLanguage)}
606
+ withCaret
607
+ measureRef={(node) => setMeasureRef(index, node)}
608
+ />
609
+ );
610
+ })}
611
+ <AppBarNavMeasureChip
612
+ label={moreLabel}
613
+ withCaret
614
+ measureRef={(node) => {
615
+ moreMeasureRef.current = node;
616
+ }}
617
+ />
618
+ </div>
619
+
620
+ {visible.map((entry) => {
621
+ if (entry.type === 'link') {
622
+ return (
623
+ <AppBarNavLink
624
+ key={entry.key}
625
+ item={entry.item}
626
+ label={
627
+ resolveNavLabel(entry.item.label, currentLanguage) || entry.item.path || 'Home'
457
628
  }
458
-
459
- return (
460
- <Fragment key={`items-${sectionIndex}`}>
461
- {section.items.map((item, index) => renderTile(item, index))}
462
- </Fragment>
463
- );
464
- })}
465
- </div>
466
- </DropdownMenuContent>
467
- </DropdownMenu>
629
+ activePathPrefix={activePathPrefix}
630
+ />
631
+ );
632
+ }
633
+ return (
634
+ <AppBarNavCategory
635
+ key={entry.key}
636
+ title={entry.title}
637
+ items={entry.items}
638
+ activePathPrefix={activePathPrefix}
639
+ currentLanguage={currentLanguage}
640
+ />
641
+ );
642
+ })}
643
+ {showMore ? (
644
+ <AppBarNavMore
645
+ entries={overflow}
646
+ activePathPrefix={activePathPrefix}
647
+ currentLanguage={currentLanguage}
648
+ />
649
+ ) : null}
468
650
  </div>
469
651
  );
470
652
  }
@@ -491,11 +673,11 @@ function TopBarEndItem({
491
673
  const iconEl = iconSrc ? (
492
674
  <NavIcon
493
675
  src={iconSrc}
494
- className="size-4"
676
+ className="size-3.5"
495
677
  />
496
678
  ) : (
497
679
  <span
498
- className="flex size-5 shrink-0 items-center justify-center rounded-md bg-muted text-[10px] font-semibold text-muted-foreground"
680
+ className="flex size-4 shrink-0 items-center justify-center rounded-md bg-muted text-[9px] font-semibold text-muted-foreground"
499
681
  aria-hidden
500
682
  >
501
683
  {firstLetter}
@@ -565,7 +747,7 @@ export function AppBarLayout({ title, appIcon, navigation }: AppBarLayoutProps)
565
747
  const { settings } = useSettings();
566
748
  const location = useLocation();
567
749
  const isMobile = useIsMobile();
568
- const isTauriEnv = useIsTauriClient();
750
+ const isTauriRuntime = useIsTauriRuntime();
569
751
  const overlay = useMacOverlayChrome();
570
752
  const trafficLights = useMacTrafficLights();
571
753
  const currentLanguage = i18n.language || 'en';
@@ -616,16 +798,33 @@ export function AppBarLayout({ title, appIcon, navigation }: AppBarLayoutProps)
616
798
  : undefined;
617
799
 
618
800
  const hasStartNav = startSections.some((s) => s.items.length > 0);
801
+ // Nested shell-in-iframe must not repeat the root safe-area top band.
802
+ const showSafeAreaTopbar = isShellUiRootWindow();
803
+ // md+: strip owns the inset; mobile pads the header into the status band.
804
+ const headerStyle = {
805
+ paddingLeft: chromeInset ?? 12,
806
+ paddingRight: 8,
807
+ ...(isMobile && showSafeAreaTopbar
808
+ ? {
809
+ paddingTop: `calc(var(--shellui-safe-area-top) + ${DESKTOP_TITLEBAR_PAD_TOP_PX}px)`,
810
+ height: `calc(${APP_BAR_HEIGHT_PX}px + var(--shellui-safe-area-top))`,
811
+ }
812
+ : {
813
+ height: APP_BAR_HEIGHT_PX,
814
+ paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
815
+ }),
816
+ } as const;
619
817
 
620
818
  return (
621
- <div className="flex h-screen flex-col overflow-hidden bg-background">
819
+ <div
820
+ data-shellui-app-bar-layout=""
821
+ className="flex h-full max-h-full flex-col overflow-hidden bg-background"
822
+ >
823
+ <SafeAreaTopbarOffset enabled={showSafeAreaTopbar} />
824
+ <SafeAreaTopbarStrip enabled={showSafeAreaTopbar} />
622
825
  <header
623
826
  className="relative z-[46] flex w-full shrink-0 items-center gap-1.5 border-b border-sidebar-border bg-sidebar text-sidebar-foreground select-none"
624
- style={{
625
- height: DESKTOP_TITLEBAR_HEIGHT_PX,
626
- paddingLeft: chromeInset ?? 12,
627
- paddingRight: 8,
628
- }}
827
+ style={headerStyle}
629
828
  data-layout="app-bar"
630
829
  {...(trafficLights ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' } : {})}
631
830
  >
@@ -634,24 +833,33 @@ export function AppBarLayout({ title, appIcon, navigation }: AppBarLayoutProps)
634
833
  appIcon={appIcon}
635
834
  title={title}
636
835
  data-shellui-no-drag=""
637
- className="mr-1"
836
+ className="mr-1 shrink-0"
638
837
  imgClassName="app-bar-app-icon"
639
838
  />
640
839
  ) : null}
641
840
 
642
841
  {hasStartNav ? (
643
- <AppBarLauncher
842
+ <AppBarNav
644
843
  sections={startSections}
645
844
  activePathPrefix={activePathPrefix}
646
845
  currentLanguage={currentLanguage}
647
846
  />
648
- ) : null}
847
+ ) : (
848
+ <div className="min-w-0 flex-1" />
849
+ )}
649
850
 
650
- {isTauriEnv ? <DesktopHistoryButtons /> : null}
851
+ {isTauriRuntime ? (
852
+ <div
853
+ data-shellui-no-drag=""
854
+ className="shrink-0"
855
+ >
856
+ <DesktopHistoryButtons />
857
+ </div>
858
+ ) : null}
651
859
 
652
860
  <div
653
861
  aria-hidden
654
- className="min-h-full min-w-[8px] flex-1"
862
+ className="min-h-full min-w-[8px] shrink-0 grow-0 basis-2"
655
863
  {...(trafficLights || overlay
656
864
  ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
657
865
  : {})}
@@ -685,7 +893,7 @@ export function AppBarLayout({ title, appIcon, navigation }: AppBarLayoutProps)
685
893
  </div>
686
894
  </header>
687
895
 
688
- <main className="flex min-h-0 flex-1 flex-col overflow-auto">
896
+ <main className="flex min-h-0 flex-1 flex-col overflow-hidden">
689
897
  <Outlet />
690
898
  </main>
691
899
  </div>