@shellui/core 0.6.0 → 0.6.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 (42) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/schemas/shellui.config.schema.json +15 -0
  4. package/src/features/admin/AdminView.tsx +18 -4
  5. package/src/features/auth/AuthProvider.tsx +184 -69
  6. package/src/features/auth/backends/shellui.spec.ts +115 -0
  7. package/src/features/auth/backends/shellui.ts +8 -2
  8. package/src/features/auth/backends/types.ts +9 -1
  9. package/src/features/auth/hooks/useAuth.tsx +1 -0
  10. package/src/features/auth/utils/accessTokenRefreshDue.spec.ts +15 -0
  11. package/src/features/auth/utils/accessTokenRefreshDue.ts +8 -0
  12. package/src/features/auth/utils/desktopAuthCallback.spec.ts +68 -0
  13. package/src/features/auth/utils/desktopAuthCallback.ts +126 -0
  14. package/src/features/auth/utils/desktopSignIn.spec.ts +203 -0
  15. package/src/features/auth/utils/desktopSignIn.ts +483 -0
  16. package/src/features/auth/utils/frameSessionRefresher.spec.ts +23 -0
  17. package/src/features/auth/utils/frameSessionRefresher.ts +21 -0
  18. package/src/features/auth/utils/pkce.spec.ts +36 -0
  19. package/src/features/auth/utils/pkce.ts +38 -0
  20. package/src/features/chromeActions/ChromeActionsHost.tsx +7 -1
  21. package/src/features/chromeActions/computeActionInsets.ts +6 -0
  22. package/src/features/config/types.ts +17 -0
  23. package/src/features/layouts/appbar/AppBarLayout.tsx +39 -9
  24. package/src/features/layouts/chrome/ContentDragOverlay.tsx +14 -7
  25. package/src/features/layouts/chrome/DesktopChrome.tsx +3 -1
  26. package/src/features/layouts/floating/FloatingLayout.tsx +4 -1
  27. package/src/features/layouts/floating/FloatingSidebar.tsx +84 -28
  28. package/src/features/layouts/floating/computeFloatingInsets.spec.ts +19 -0
  29. package/src/features/layouts/floating/computeFloatingInsets.ts +40 -8
  30. package/src/features/layouts/floating/layoutChromeStore.ts +13 -0
  31. package/src/features/layouts/floating/useFloatingChrome.ts +11 -5
  32. package/src/features/layouts/fullscreen/FullscreenLayout.tsx +3 -0
  33. package/src/features/layouts/sidebar/SidebarInner.tsx +5 -0
  34. package/src/features/layouts/sidebar/SidebarLayout.tsx +1 -0
  35. package/src/features/layouts/windows/WindowsLayout.tsx +106 -46
  36. package/src/features/security/trustedFrames.spec.ts +17 -1
  37. package/src/features/security/trustedFrames.ts +31 -9
  38. package/src/features/settings/SettingsProvider.tsx +86 -31
  39. package/src/features/settings/utils/buildSettingsForPropagation.ts +9 -2
  40. package/src/index.css +16 -1
  41. package/src/index.ts +6 -0
  42. package/src/lib/z-index.ts +5 -0
@@ -53,8 +53,13 @@ import {
53
53
  } from '../chrome/SafeAreaTopbar';
54
54
  import { useScrollHideChrome } from '../chrome/useScrollHideChrome';
55
55
  import { InsetMobileRadiusOverlay } from '../chrome/InsetMobileRadiusOverlay';
56
+ import {
57
+ DESKTOP_TITLEBAR_HEIGHT_PX,
58
+ DESKTOP_TITLEBAR_PAD_TOP_PX,
59
+ MAC_TRAFFIC_LIGHTS_GAP_PX,
60
+ MAC_TRAFFIC_LIGHTS_WIDTH_PX,
61
+ } from '../chrome/constants';
56
62
  import { useIsTauriRuntime, useMacOverlayChrome, useMacTrafficLights } from '../chrome/runtime';
57
- import { MAC_TRAFFIC_LIGHTS_GAP_PX, MAC_TRAFFIC_LIGHTS_WIDTH_PX } from '../chrome/constants';
58
63
 
59
64
  /** App-bar chrome height — taller than the 42px Tauri/sidebar title strip. */
60
65
  const APP_BAR_HEIGHT_PX = 56;
@@ -509,10 +514,13 @@ function AppBarNav({
509
514
  sections,
510
515
  activePathPrefix,
511
516
  currentLanguage,
517
+ windowDrag = false,
512
518
  }: {
513
519
  sections: NavSection[];
514
520
  activePathPrefix: string | null;
515
521
  currentLanguage: string;
522
+ /** Leftover space after the links drags the Tauri window. */
523
+ windowDrag?: boolean;
516
524
  }) {
517
525
  const { t } = useTranslation();
518
526
  const entries = useMemo(() => sectionsToEntries(sections), [sections]);
@@ -580,7 +588,6 @@ function AppBarNav({
580
588
 
581
589
  return (
582
590
  <div
583
- data-shellui-no-drag=""
584
591
  ref={containerRef}
585
592
  className="relative flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden"
586
593
  >
@@ -650,6 +657,14 @@ function AppBarNav({
650
657
  currentLanguage={currentLanguage}
651
658
  />
652
659
  ) : null}
660
+ {windowDrag ? (
661
+ <div
662
+ aria-hidden
663
+ data-shellui-drag-region=""
664
+ data-tauri-drag-region=""
665
+ className="h-full min-h-8 min-w-2 flex-1 self-stretch"
666
+ />
667
+ ) : null}
653
668
  </div>
654
669
  );
655
670
  }
@@ -764,10 +779,13 @@ export function AppBarLayout({
764
779
  // Nested shell-in-iframe must not repeat the root safe-area top band.
765
780
  const showSafeAreaTopbar = isShellUiRootWindow();
766
781
  const scrollHideLayout = isInset ? 'app-bar-inset' : 'app-bar';
782
+ const titlebarAligned = isTauriRuntime && !isMobile;
783
+ const barHeightPx = titlebarAligned ? DESKTOP_TITLEBAR_HEIGHT_PX : APP_BAR_HEIGHT_PX;
784
+ const barPadTopPx = titlebarAligned ? DESKTOP_TITLEBAR_PAD_TOP_PX : APP_BAR_PAD_TOP_PX;
767
785
  const { chromeVisible } = useScrollHideChrome({
768
786
  enabled: isMobile,
769
787
  layout: scrollHideLayout,
770
- barHeightPx: APP_BAR_HEIGHT_PX,
788
+ barHeightPx,
771
789
  includeSafeArea: showSafeAreaTopbar,
772
790
  });
773
791
  const authAwareNavigation = useMemo(
@@ -838,12 +856,12 @@ export function AppBarLayout({
838
856
  paddingRight: isInset ? (isMobile ? 8 : insetFramePadPx + insetBarContentOffsetRightPx) : 8,
839
857
  ...(isMobile && showSafeAreaTopbar
840
858
  ? {
841
- paddingTop: `calc(var(--shellui-safe-area-top) + ${APP_BAR_PAD_TOP_PX}px)`,
842
- height: `calc(${APP_BAR_HEIGHT_PX}px + var(--shellui-safe-area-top))`,
859
+ paddingTop: `calc(var(--shellui-safe-area-top) + ${barPadTopPx}px)`,
860
+ height: `calc(${barHeightPx}px + var(--shellui-safe-area-top))`,
843
861
  }
844
862
  : {
845
- height: APP_BAR_HEIGHT_PX,
846
- paddingTop: APP_BAR_PAD_TOP_PX,
863
+ height: barHeightPx,
864
+ paddingTop: barPadTopPx,
847
865
  }),
848
866
  } as const;
849
867
 
@@ -902,9 +920,15 @@ export function AppBarLayout({
902
920
  sections={startSections}
903
921
  activePathPrefix={activePathPrefix}
904
922
  currentLanguage={currentLanguage}
923
+ windowDrag={isTauriRuntime}
905
924
  />
906
925
  ) : (
907
- <div className="min-w-0 flex-1" />
926
+ <div
927
+ className="min-w-0 flex-1 self-stretch"
928
+ {...(isTauriRuntime
929
+ ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
930
+ : {})}
931
+ />
908
932
  )}
909
933
 
910
934
  {isTauriRuntime ? (
@@ -982,9 +1006,15 @@ export function AppBarLayout({
982
1006
  sections={startSections}
983
1007
  activePathPrefix={activePathPrefix}
984
1008
  currentLanguage={currentLanguage}
1009
+ windowDrag={isTauriRuntime}
985
1010
  />
986
1011
  ) : (
987
- <div className="min-w-0 flex-1" />
1012
+ <div
1013
+ className="min-w-0 flex-1 self-stretch"
1014
+ {...(isTauriRuntime
1015
+ ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
1016
+ : {})}
1017
+ />
988
1018
  )}
989
1019
 
990
1020
  {isTauriRuntime ? (
@@ -1,19 +1,26 @@
1
- import { DESKTOP_TITLEBAR_HEIGHT_PX } from './constants';
1
+ import { DESKTOP_TITLEBAR_HEIGHT_PX, MAC_TRAFFIC_LIGHTS_WIDTH_PX } from './constants';
2
2
 
3
3
  /**
4
- * Full-width invisible 42px strip at the top of the Tauri window.
4
+ * Narrow left strip over the traffic-light band only.
5
5
  *
6
- * Uses Tauri's official `data-tauri-drag-region` (requires
7
- * `core:window:allow-start-dragging` in capabilities). Shell controls must sit
8
- * above this strip (higher z-index) so they stay clickable.
6
+ * A full-width overlay used to sit on top of iframes and steal clicks from
7
+ * embedded content. Dragging the window still works from layout chrome
8
+ * (app bar, sidebar header, admin header, windows titlebar) and from this
9
+ * empty traffic-light spacer. Interactive iframe content to the right stays
10
+ * clickable.
11
+ *
12
+ * Requires `core:window:allow-start-dragging` in Tauri capabilities.
9
13
  */
10
14
  export function ContentDragOverlay() {
11
15
  return (
12
16
  <div
13
17
  aria-hidden
14
18
  data-tauri-drag-region
15
- className="fixed inset-x-0 top-0 z-[45] w-full"
16
- style={{ height: DESKTOP_TITLEBAR_HEIGHT_PX }}
19
+ className="fixed top-0 left-0 z-[45]"
20
+ style={{
21
+ height: DESKTOP_TITLEBAR_HEIGHT_PX,
22
+ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX,
23
+ }}
17
24
  />
18
25
  );
19
26
  }
@@ -9,9 +9,11 @@ import {
9
9
  } from './runtime';
10
10
 
11
11
  /**
12
- * Global shell host chrome: document flags + the 42px Tauri drag strip.
12
+ * Global shell host chrome: document flags + a narrow traffic-light drag strip.
13
13
  * Mounted at the app root so it stays available on every page (layouts, login,
14
14
  * settings, route error boundary, empty config) — including narrow/mobile widths.
15
+ * Full-width drag lives on layout chrome so iframe content under the titlebar
16
+ * band stays clickable.
15
17
  *
16
18
  * Sets `data-shellui-host` to `browser` | `pwa` | `tauri` so CSS / layout can
17
19
  * distinguish Safari Home Screen PWAs (iOS 27 system status gradient) from
@@ -114,7 +114,7 @@ export function FloatingLayout({ title, appIcon, navigation = [] }: FloatingLayo
114
114
  <SafeAreaTopbarOffset enabled={showSafeAreaTopbar} />
115
115
  <FloatingStatusScrim enabled={showStatusScrim} />
116
116
 
117
- {isTauriEnv ? (
117
+ {isTauriEnv && !(showSidebar && !sidebarCollapsed) ? (
118
118
  <div
119
119
  className="pointer-events-auto absolute top-0 left-0 z-[46] flex items-center"
120
120
  style={{
@@ -122,6 +122,9 @@ export function FloatingLayout({ title, appIcon, navigation = [] }: FloatingLayo
122
122
  paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
123
123
  paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 8,
124
124
  }}
125
+ {...(trafficLights
126
+ ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
127
+ : {})}
125
128
  >
126
129
  <DesktopHistoryButtons />
127
130
  </div>
@@ -15,10 +15,17 @@ import { NavIcon, ExternalLinkIcon } from '../sidebar/SidebarIcons';
15
15
  import { AppBrandIcon } from '../branding/AppBrandIcon';
16
16
  import { LoginButton } from '../../auth/components/LoginButton';
17
17
  import { cn } from '../../../lib/utils';
18
- import { useIsTauriClient, useMacTrafficLights } from '../chrome/runtime';
19
- import { MAC_TRAFFIC_LIGHTS_WIDTH_PX } from '../chrome/constants';
18
+ import { DesktopHistoryButtons } from '../chrome/DesktopHistoryButtons';
19
+ import { useIsTauriClient, useIsTauriRuntime, useMacTrafficLights } from '../chrome/runtime';
20
+ import {
21
+ DESKTOP_TITLEBAR_HEIGHT_PX,
22
+ DESKTOP_TITLEBAR_PAD_TOP_PX,
23
+ MAC_TRAFFIC_LIGHTS_GAP_PX,
24
+ MAC_TRAFFIC_LIGHTS_WIDTH_PX,
25
+ } from '../chrome/constants';
20
26
  import {
21
27
  FLOATING_CHROME_MARGIN,
28
+ FLOATING_HISTORY_CLUSTER_PX,
22
29
  FLOATING_SIDEBAR_TOGGLE_SIZE,
23
30
  FLOATING_SIDEBAR_WIDTH,
24
31
  } from './computeFloatingInsets';
@@ -100,9 +107,13 @@ export function FloatingSidebar({
100
107
  const lang = i18n.language || 'en';
101
108
  const trafficLights = useMacTrafficLights();
102
109
  const isTauriEnv = useIsTauriClient();
103
- const trafficPadPx = trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 0;
104
- /** History cluster only for the collapsed chip (shares the top-left corner on Tauri). */
105
- const chipLeadingPx = trafficPadPx + (isTauriEnv ? 72 : 0);
110
+ const tauriRuntime = useIsTauriRuntime();
111
+ /** Tauri drops the floating edge gap so this row shares the traffic-light band. */
112
+ const edgeMargin = tauriRuntime ? 0 : FLOATING_CHROME_MARGIN;
113
+ /** Collapsed chip clears the corner lights and the history cluster. */
114
+ const chipLeadingPx =
115
+ (trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 0) +
116
+ (isTauriEnv ? FLOATING_HISTORY_CLUSTER_PX : 0);
106
117
 
107
118
  const sidebarNav = useMemo(() => filterNavigationForSidebar(navigation), [navigation]);
108
119
  const sections = useMemo(() => buildSections(sidebarNav), [sidebarNav]);
@@ -113,15 +124,23 @@ export function FloatingSidebar({
113
124
  );
114
125
 
115
126
  const sidebarEdgePad = {
116
- paddingTop: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-top, 0px))`,
117
- paddingLeft: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-left, 0px) + ${trafficPadPx}px)`,
118
- paddingBottom: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-bottom, 0px))`,
127
+ paddingTop: `calc(${edgeMargin}px + var(--shellui-safe-area-top, 0px))`,
128
+ paddingLeft: `calc(${edgeMargin}px + var(--shellui-safe-area-left, 0px))`,
129
+ paddingBottom: `calc(${edgeMargin}px + var(--shellui-safe-area-bottom, 0px))`,
119
130
  };
120
131
 
121
- const chipEdgePad = {
122
- paddingTop: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-top, 0px))`,
123
- paddingLeft: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-left, 0px) + ${chipLeadingPx}px)`,
124
- };
132
+ const chipEdgePad = tauriRuntime
133
+ ? {
134
+ height: DESKTOP_TITLEBAR_HEIGHT_PX,
135
+ paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
136
+ paddingLeft: `calc(var(--shellui-safe-area-left, 0px) + ${chipLeadingPx}px)`,
137
+ boxSizing: 'border-box' as const,
138
+ alignItems: 'center',
139
+ }
140
+ : {
141
+ paddingTop: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-top, 0px))`,
142
+ paddingLeft: `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-left, 0px) + ${chipLeadingPx}px)`,
143
+ };
125
144
 
126
145
  const toggleLabel = collapsed
127
146
  ? t('develop.layout.showSidebar', { defaultValue: 'Show sidebar' })
@@ -247,6 +266,7 @@ export function FloatingSidebar({
247
266
  aria-hidden={collapsed}
248
267
  >
249
268
  <nav
269
+ data-shellui-tauri-flush={tauriRuntime ? '' : undefined}
250
270
  className={cn(
251
271
  'shellui-floating-glass pointer-events-auto flex h-full flex-col overflow-hidden',
252
272
  'origin-left will-change-transform',
@@ -258,25 +278,61 @@ export function FloatingSidebar({
258
278
  style={{ width: FLOATING_SIDEBAR_WIDTH }}
259
279
  aria-label={title || 'Navigation'}
260
280
  >
261
- <div className="flex shrink-0 items-center gap-2 border-b border-sidebar-border/80 px-2.5 py-2.5">
262
- {appIcon ? (
263
- <AppBrandIcon
264
- appIcon={appIcon}
265
- title={title}
266
- className="size-7 shrink-0"
281
+ <div
282
+ className={cn(
283
+ 'flex shrink-0 items-center border-b border-sidebar-border/80',
284
+ tauriRuntime ? 'pr-2.5' : 'gap-2 px-2.5 py-2.5',
285
+ )}
286
+ style={
287
+ tauriRuntime
288
+ ? {
289
+ height: DESKTOP_TITLEBAR_HEIGHT_PX,
290
+ paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
291
+ }
292
+ : undefined
293
+ }
294
+ {...(tauriRuntime
295
+ ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
296
+ : {})}
297
+ >
298
+ {trafficLights ? (
299
+ <div
300
+ className="h-full shrink-0"
301
+ style={{ width: MAC_TRAFFIC_LIGHTS_WIDTH_PX }}
302
+ aria-hidden
267
303
  />
268
304
  ) : null}
269
- <span className="min-w-0 flex-1" />
270
- <button
271
- type="button"
272
- tabIndex={collapsed ? -1 : 0}
273
- className="shellui-floating-nav-control flex size-8 shrink-0 items-center justify-center text-sidebar-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
274
- aria-label={toggleLabel}
275
- aria-expanded={!collapsed}
276
- onClick={onToggleCollapsed}
305
+ <div
306
+ className="flex h-full min-w-0 flex-1 items-center gap-1"
307
+ style={{
308
+ paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_GAP_PX : undefined,
309
+ }}
277
310
  >
278
- <SidebarPanelIcon className="size-4" />
279
- </button>
311
+ {isTauriEnv && !collapsed ? <DesktopHistoryButtons className="self-center" /> : null}
312
+ {appIcon ? (
313
+ <AppBrandIcon
314
+ appIcon={appIcon}
315
+ title={title}
316
+ className="size-7 shrink-0"
317
+ />
318
+ ) : null}
319
+ <span
320
+ className="min-h-full min-w-0 flex-1 self-stretch"
321
+ {...(tauriRuntime
322
+ ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
323
+ : {})}
324
+ />
325
+ <button
326
+ type="button"
327
+ tabIndex={collapsed ? -1 : 0}
328
+ className="shellui-floating-nav-control flex size-8 shrink-0 items-center justify-center text-sidebar-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
329
+ aria-label={toggleLabel}
330
+ aria-expanded={!collapsed}
331
+ onClick={onToggleCollapsed}
332
+ >
333
+ <SidebarPanelIcon className="size-4" />
334
+ </button>
335
+ </div>
280
336
  </div>
281
337
 
282
338
  <div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-2">
@@ -65,6 +65,25 @@ describe('computeFloatingInsets', () => {
65
65
  });
66
66
  });
67
67
 
68
+ it('drops the floating edge gap when edgeMargin is 0', () => {
69
+ expect(
70
+ computeFloatingInsets({
71
+ viewport: 'desktop',
72
+ chromeVisible: true,
73
+ safeArea: safe,
74
+ edgeMargin: 0,
75
+ }).left,
76
+ ).toBe(3 + FLOATING_SIDEBAR_WIDTH + FLOATING_CONTENT_CLEARANCE);
77
+ expect(
78
+ computeFloatingInsets({
79
+ viewport: 'mobile',
80
+ chromeVisible: true,
81
+ safeArea: safe,
82
+ edgeMargin: 0,
83
+ }).bottom,
84
+ ).toBe(20 / 2 + FLOATING_TAB_BAR_HEIGHT + FLOATING_CONTENT_CLEARANCE);
85
+ });
86
+
68
87
  it('keeps content full-bleed when desktop sidebar is collapsed', () => {
69
88
  expect(
70
89
  computeFloatingInsets({
@@ -1,4 +1,7 @@
1
1
  import type { LayoutChromeInsets, LayoutChromeViewport } from '@shellui/sdk';
2
+ import { MAC_TRAFFIC_LIGHTS_WIDTH_PX } from '../chrome/constants';
3
+ import { isMacOSDesktop, isTauriRuntime } from '../chrome/runtime';
4
+ import { isTauri } from '../../../service-worker/register';
2
5
 
3
6
  /** Floating tab bar content height (icon + short label) — phone. */
4
7
  export const FLOATING_TAB_BAR_HEIGHT = 56;
@@ -13,6 +16,12 @@ export const FLOATING_CHROME_MARGIN = 12;
13
16
  export const FLOATING_DOCK_SIDE_INSET = 8;
14
17
  /** Extra clearance so the last content row clears the floating chrome comfortably. */
15
18
  export const FLOATING_CONTENT_CLEARANCE = 12;
19
+ /**
20
+ * Tauri desktop: keep the action scrim off the sidebar’s right edge so the
21
+ * glass border and its glow stay visible. The content inset only clears 12px,
22
+ * which the opaque action background still covers.
23
+ */
24
+ export const TAURI_FLOATING_ACTION_SIDEBAR_GAP_PX = 16;
16
25
  /** Desktop floating sidebar width. */
17
26
  export const FLOATING_SIDEBAR_WIDTH = 240;
18
27
  /**
@@ -48,8 +57,9 @@ export function floatingMinTabSlotWidth(viewport: LayoutChromeViewport): number
48
57
  export function floatingTabBarBottomPadPx(
49
58
  safeBottom: number,
50
59
  viewport: LayoutChromeViewport,
60
+ edgeMargin: number = FLOATING_CHROME_MARGIN,
51
61
  ): number {
52
- const full = FLOATING_CHROME_MARGIN + safeBottom;
62
+ const full = edgeMargin + safeBottom;
53
63
  return viewport === 'mobile' ? full / 2 : full;
54
64
  }
55
65
 
@@ -57,11 +67,14 @@ export function floatingTabBarBottomPadPx(
57
67
  * Same bottom pad as the floating dock, as a CSS value so
58
68
  * `--shellui-safe-area-bottom` / env() apply on iPhone (not a snapped 0px number).
59
69
  */
60
- export function floatingTabBarBottomPadCss(viewport: LayoutChromeViewport): string {
70
+ export function floatingTabBarBottomPadCss(
71
+ viewport: LayoutChromeViewport,
72
+ edgeMargin: number = FLOATING_CHROME_MARGIN,
73
+ ): string {
61
74
  if (viewport === 'mobile') {
62
- return `calc((${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-bottom, 0px)) / 2)`;
75
+ return `calc((${edgeMargin}px + var(--shellui-safe-area-bottom, 0px)) / 2)`;
63
76
  }
64
- return `calc(${FLOATING_CHROME_MARGIN}px + var(--shellui-safe-area-bottom, 0px))`;
77
+ return `calc(${edgeMargin}px + var(--shellui-safe-area-bottom, 0px))`;
65
78
  }
66
79
  /** Collapsed desktop toggle control size (glass chip). */
67
80
  export const FLOATING_SIDEBAR_TOGGLE_SIZE = 36;
@@ -72,6 +85,20 @@ export const FLOATING_SIDEBAR_TOGGLE_SIZE = 36;
72
85
  */
73
86
  export const FLOATING_COLLAPSED_ACTIONS_LEADING_EXTRA =
74
87
  FLOATING_SIDEBAR_TOGGLE_SIZE + FLOATING_CONTENT_CLEARANCE;
88
+ /** Back + forward pair ahead of the collapsed expand chip in Tauri. */
89
+ export const FLOATING_HISTORY_CLUSTER_PX = 72;
90
+
91
+ /**
92
+ * Left offset for the top action row when the desktop sidebar is collapsed.
93
+ * Tauri also clears the traffic lights and the history buttons before the chip.
94
+ */
95
+ export function floatingCollapsedActionsLeadingPx(): number {
96
+ let leading = FLOATING_COLLAPSED_ACTIONS_LEADING_EXTRA;
97
+ if (typeof window === 'undefined' || !isTauri()) return leading;
98
+ leading += FLOATING_HISTORY_CLUSTER_PX;
99
+ if (isTauriRuntime() && isMacOSDesktop()) leading += MAC_TRAFFIC_LIGHTS_WIDTH_PX;
100
+ return leading;
101
+ }
75
102
  /**
76
103
  * Floating sidebar brand header: `py-2.5` (10+10) + `size-8` toggle (32).
77
104
  * Keep in sync with FloatingSidebar brand row.
@@ -94,6 +121,11 @@ export function computeFloatingInsets(options: {
94
121
  /** Desktop only: sidebar hidden — no left content inset (chip cleared by actions pad). */
95
122
  sidebarCollapsed?: boolean;
96
123
  safeArea?: Partial<FloatingSafeArea>;
124
+ /**
125
+ * Gap between floating chrome and the window edge.
126
+ * Tauri passes `0` so the title row meets the traffic lights.
127
+ */
128
+ edgeMargin?: number;
97
129
  }): LayoutChromeInsets {
98
130
  const safe: FloatingSafeArea = {
99
131
  top: options.safeArea?.top ?? 0,
@@ -107,14 +139,15 @@ export function computeFloatingInsets(options: {
107
139
  }
108
140
 
109
141
  const { viewport } = options;
142
+ const edge = options.edgeMargin ?? FLOATING_CHROME_MARGIN;
110
143
  if (viewport === 'mobile' || viewport === 'tablet') {
111
144
  return {
112
145
  top: safe.top,
113
146
  right: safe.right,
114
147
  bottom:
115
- floatingTabBarBottomPadPx(safe.bottom, viewport) +
148
+ floatingTabBarBottomPadPx(safe.bottom, viewport, edge) +
116
149
  floatingTabBarHeight(viewport) +
117
- FLOATING_CHROME_MARGIN +
150
+ edge +
118
151
  FLOATING_CONTENT_CLEARANCE,
119
152
  left: safe.left,
120
153
  };
@@ -133,8 +166,7 @@ export function computeFloatingInsets(options: {
133
166
  top: safe.top,
134
167
  right: safe.right,
135
168
  bottom: safe.bottom,
136
- left:
137
- safe.left + FLOATING_SIDEBAR_WIDTH + FLOATING_CHROME_MARGIN * 2 + FLOATING_CONTENT_CLEARANCE,
169
+ left: safe.left + FLOATING_SIDEBAR_WIDTH + edge * 2 + FLOATING_CONTENT_CLEARANCE,
138
170
  };
139
171
  }
140
172
 
@@ -29,6 +29,19 @@ export function getPublishedLayoutChrome(): LayoutChrome | null {
29
29
  return currentChrome;
30
30
  }
31
31
 
32
+ /**
33
+ * Layout chrome for one iframe, including that frame's action-bar insets.
34
+ * Settings must carry this — the base snapshot has no action padding, so the
35
+ * first paint misses the top gap until a later resize republishes it.
36
+ */
37
+ export function getLayoutChromeForFrame(frameUuid: string): LayoutChrome | null {
38
+ if (!currentChrome) return null;
39
+ const actions = getChromeActionsForFrame(frameUuid);
40
+ return buildFrameLayoutChrome(currentChrome, actionChromeFlags(actions), {
41
+ topInTitleBar: isTopActionsInTitleBar(currentChrome),
42
+ });
43
+ }
44
+
32
45
  /** Subscribe to published layout-chrome changes (e.g. floating hide-on-scroll). */
33
46
  export function subscribeLayoutChrome(listener: LayoutChromeListener): () => void {
34
47
  layoutChromeListeners.add(listener);
@@ -9,9 +9,10 @@ import {
9
9
  type LayoutChromeViewport,
10
10
  type ScrollChromeState,
11
11
  } from '@shellui/sdk';
12
+ import { useIsTauriRuntime } from '../chrome/runtime';
12
13
  import {
13
14
  computeFloatingInsets,
14
- FLOATING_COLLAPSED_ACTIONS_LEADING_EXTRA,
15
+ floatingCollapsedActionsLeadingPx,
15
16
  readShellSafeAreaPx,
16
17
  } from './computeFloatingInsets';
17
18
  import { publishLayoutChrome } from './layoutChromeStore';
@@ -43,7 +44,7 @@ function syncChromeActionsLeadingExtra(desktopCollapsed: boolean): void {
43
44
  if (typeof document === 'undefined') return;
44
45
  document.documentElement.style.setProperty(
45
46
  ACTIONS_LEADING_EXTRA_VAR,
46
- `${desktopCollapsed ? FLOATING_COLLAPSED_ACTIONS_LEADING_EXTRA : 0}px`,
47
+ `${desktopCollapsed ? floatingCollapsedActionsLeadingPx() : 0}px`,
47
48
  );
48
49
  }
49
50
 
@@ -52,6 +53,7 @@ function buildChrome(
52
53
  chromeVisible: boolean,
53
54
  sidebarCollapsed: boolean,
54
55
  autoPadding = true,
56
+ edgeMargin?: number,
55
57
  ): LayoutChrome {
56
58
  const safeArea =
57
59
  typeof document !== 'undefined'
@@ -70,6 +72,7 @@ function buildChrome(
70
72
  chromeVisible: true,
71
73
  sidebarCollapsed: desktopCollapsed,
72
74
  safeArea,
75
+ edgeMargin,
73
76
  }),
74
77
  };
75
78
  }
@@ -80,6 +83,8 @@ function buildChrome(
80
83
  */
81
84
  export function useFloatingChrome(viewport: LayoutChromeViewport) {
82
85
  const location = useLocation();
86
+ const tauriRuntime = useIsTauriRuntime();
87
+ const edgeMargin = tauriRuntime && viewport === 'desktop' ? 0 : undefined;
83
88
  const [chromeVisible, setChromeVisible] = useState(true);
84
89
  const [sidebarCollapsed, setSidebarCollapsedState] = useState(readSidebarCollapsed);
85
90
  const scrollStateRef = useRef<ScrollChromeState>({ visible: true, lastY: 0 });
@@ -93,9 +98,9 @@ export function useFloatingChrome(viewport: LayoutChromeViewport) {
93
98
  (visible: boolean, vp: LayoutChromeViewport, collapsed: boolean) => {
94
99
  const desktopCollapsed = vp === 'desktop' && collapsed;
95
100
  syncChromeActionsLeadingExtra(desktopCollapsed);
96
- publishLayoutChrome(buildChrome(vp, visible, collapsed));
101
+ publishLayoutChrome(buildChrome(vp, visible, collapsed, true, edgeMargin));
97
102
  },
98
- [],
103
+ [edgeMargin],
99
104
  );
100
105
 
101
106
  const setSidebarCollapsed = useCallback((collapsed: boolean) => {
@@ -192,8 +197,9 @@ export function useFloatingChrome(viewport: LayoutChromeViewport) {
192
197
  chromeVisible: true,
193
198
  sidebarCollapsed: viewport === 'desktop' && sidebarCollapsed,
194
199
  safeArea,
200
+ edgeMargin,
195
201
  });
196
- }, [viewport, sidebarCollapsed]);
202
+ }, [viewport, sidebarCollapsed, edgeMargin]);
197
203
 
198
204
  return {
199
205
  chromeVisible: effectiveVisible,
@@ -61,6 +61,9 @@ export function FullscreenLayout({ title, navigation, children }: FullscreenLayo
61
61
  paddingTop: DESKTOP_TITLEBAR_PAD_TOP_PX,
62
62
  paddingLeft: trafficLights ? MAC_TRAFFIC_LIGHTS_WIDTH_PX : 8,
63
63
  }}
64
+ {...(trafficLights
65
+ ? { 'data-shellui-drag-region': '', 'data-tauri-drag-region': '' }
66
+ : {})}
64
67
  >
65
68
  <DesktopHistoryButtons />
66
69
  </div>
@@ -26,12 +26,15 @@ export function SidebarInner({
26
26
  showAuthButton,
27
27
  title,
28
28
  appIcon,
29
+ inset = false,
29
30
  }: {
30
31
  startNav: (NavigationItem | NavigationGroup)[];
31
32
  endItems: (NavigationItem | NavigationGroup)[];
32
33
  showAuthButton: boolean;
33
34
  title?: string;
34
35
  appIcon?: ThemeAsset;
36
+ /** Sidebar-inset: the column is padded, so the title row must break out to meet the lights. */
37
+ inset?: boolean;
35
38
  }) {
36
39
  const isTauriEnv = useIsTauriClient();
37
40
  const overlay = useMacOverlayChrome();
@@ -81,6 +84,8 @@ export function SidebarInner({
81
84
  'gap-0 border-b border-sidebar-border select-none',
82
85
  showOverlayHeader || mobileSheetHeader ? 'p-0' : 'px-2 py-0',
83
86
  showCollapsedTopBar && 'hidden',
87
+ // Inset `p-3` sits this row 12px under the lights. Pull it to the window edge.
88
+ inset && showOverlayHeader && '-mt-3 -ml-3 w-[calc(100%+1.5rem)]',
84
89
  )}
85
90
  style={{
86
91
  height: DESKTOP_TITLEBAR_HEIGHT_PX,
@@ -211,6 +211,7 @@ const SidebarLayoutContent = ({
211
211
  showAuthButton={!hasCustomLoginNav || isAuthenticated || isAuthLoading}
212
212
  title={title}
213
213
  appIcon={appIcon}
214
+ inset={variant === 'inset'}
214
215
  />
215
216
  {variant !== 'inset' ? <SidebarRail /> : null}
216
217
  </Sidebar>