From 47ca623e7bb9c34afa1268752c109511c0160d98 Mon Sep 17 00:00:00 2001 From: Omri Katz <9701896+omridevk@users.noreply.github.com> Date: Wed, 4 Nov 2026 22:39:59 +0200 Subject: [PATCH 1/2] fix(hub-ui): keep dock safe-area variables off useScreenSafeArea sets its CSS variables on , which React SSR hosts hydrate themselves, so loading the dock logs a hydration mismatch. Port it as useSafeArea(target): the variables live in the dock stylesheet :host and are read back from the dock anchor. Also parse the insets with parseFloat, since values like "34px" made the unary plus return NaN, so insets were 0. Co-Authored-By: Claude Opus 5.5 --- .../src/client/components/dock/Dock.vue | 10 ++++--- packages/hub-ui/src/client/style.css | 4 +++ .../hub-ui/src/client/utils/useSafeArea.ts | 30 +++++++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 packages/hub-ui/src/client/utils/useSafeArea.ts diff --git a/packages/hub-ui/src/client/components/dock/Dock.vue b/packages/hub-ui/src/client/components/dock/Dock.vue index 4acb1284..83716027 100644 --- a/packages/hub-ui/src/client/components/dock/Dock.vue +++ b/packages/hub-ui/src/client/components/dock/Dock.vue @@ -2,7 +2,7 @@ import type { DocksContext } from '@devframes/hub/client' import type { CSSProperties } from 'vue' import type { DockLayout } from './dock-layout' -import { useEventListener, useScreenSafeArea, whenever } from '@vueuse/core' +import { useEventListener, whenever } from '@vueuse/core' import { computed, onMounted, reactive, ref, useTemplateRef, watch } from 'vue' import { BUILTIN_ENTRY_CLIENT_AUTH_NOTICE } from '../../constants' import { t } from '../../i18n' @@ -10,6 +10,7 @@ import { docksSplitGroupsWithCapacity, getEntryGroup, resolveNextRecentDockIds, import { setDocksOverflowPanel, useDocksGroupPanel } from '../../state/floating-tooltip' import { useSettings } from '../../state/settings-defaults' import { useIsRpcTrusted } from '../../utils/useIsRpcTrusted' +import { useSafeArea } from '../../utils/useSafeArea' import BrandMark from '../icons/BrandMark.vue' import { dockLayoutCssVars, @@ -39,10 +40,12 @@ const layout = computed(() => resolveDockLayout(props.layout)) const isSafari = navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome') -const safeArea = useScreenSafeArea() +const anchorEl = useTemplateRef('anchorEl') + +const safeArea = useSafeArea(anchorEl) function toNumber(value: string) { - const num = +value + const num = Number.parseFloat(value) if (Number.isNaN(num)) return 0 return num @@ -61,7 +64,6 @@ const panelMargins = computed(() => resolveViewportMargins( )) const dockEl = useTemplateRef('dockEl') -const anchorEl = useTemplateRef('anchorEl') const recalculateCounter = ref(0) const isHovering = ref(false) diff --git a/packages/hub-ui/src/client/style.css b/packages/hub-ui/src/client/style.css index 73a81dc4..ff9da9c3 100644 --- a/packages/hub-ui/src/client/style.css +++ b/packages/hub-ui/src/client/style.css @@ -28,6 +28,10 @@ --app-scrollbar-radius: 1px; --app-scrollbar-thumb: #8884; --app-scrollbar-thumb-hover: #8885; + --devframes-safe-area-top: env(safe-area-inset-top, 0px); + --devframes-safe-area-right: env(safe-area-inset-right, 0px); + --devframes-safe-area-bottom: env(safe-area-inset-bottom, 0px); + --devframes-safe-area-left: env(safe-area-inset-left, 0px); } ::-webkit-scrollbar { diff --git a/packages/hub-ui/src/client/utils/useSafeArea.ts b/packages/hub-ui/src/client/utils/useSafeArea.ts new file mode 100644 index 00000000..0195f6e6 --- /dev/null +++ b/packages/hub-ui/src/client/utils/useSafeArea.ts @@ -0,0 +1,30 @@ +import type { MaybeElementRef } from '@vueuse/core' +import { tryOnMounted, unrefElement, useDebounceFn, useEventListener } from '@vueuse/core' +import { shallowRef } from 'vue' + +/** + * Ported from VueUse's `useScreenSafeArea` for now: it always sets its CSS variables on + * `` and has no option for a custom element, which breaks hydration on SSR hosts. + */ +export function useSafeArea(target: MaybeElementRef) { + const top = shallowRef('') + const right = shallowRef('') + const bottom = shallowRef('') + const left = shallowRef('') + + function update() { + const element = unrefElement(target) + if (!element) + return + const style = getComputedStyle(element) + top.value = style.getPropertyValue('--devframes-safe-area-top') + right.value = style.getPropertyValue('--devframes-safe-area-right') + bottom.value = style.getPropertyValue('--devframes-safe-area-bottom') + left.value = style.getPropertyValue('--devframes-safe-area-left') + } + + tryOnMounted(update) + useEventListener('resize', useDebounceFn(update), { passive: true }) + + return { top, right, bottom, left, update } +} From 2447a2f0a6419e4f027992126f1364d8779d4fc3 Mon Sep 17 00:00:00 2001 From: "Anthony Fu (via agent)" Date: Tue, 10 Nov 2026 05:50:07 +0000 Subject: [PATCH 2/2] refactor(hub-ui): return numeric insets from useSafeArea useSafeArea now parses the px values itself and returns one DockMargins ref. The Dock passes it straight to resolveViewportMargins, so the toNumber helper is gone. Co-Authored-By: Claude Opus 5.5 --- .../src/client/components/dock/Dock.vue | 17 +------------ .../hub-ui/src/client/utils/useSafeArea.ts | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/packages/hub-ui/src/client/components/dock/Dock.vue b/packages/hub-ui/src/client/components/dock/Dock.vue index 83716027..6c263535 100644 --- a/packages/hub-ui/src/client/components/dock/Dock.vue +++ b/packages/hub-ui/src/client/components/dock/Dock.vue @@ -44,24 +44,9 @@ const anchorEl = useTemplateRef('anchorEl') const safeArea = useSafeArea(anchorEl) -function toNumber(value: string) { - const num = Number.parseFloat(value) - if (Number.isNaN(num)) - return 0 - return num -} - // Effective spacing from the viewport edge: device safe-area insets plus the // configured viewport margin. Passed down to the panel so both stay in sync. -const panelMargins = computed(() => resolveViewportMargins( - { - left: toNumber(safeArea.left.value), - top: toNumber(safeArea.top.value), - right: toNumber(safeArea.right.value), - bottom: toNumber(safeArea.bottom.value), - }, - layout.value, -)) +const panelMargins = computed(() => resolveViewportMargins(safeArea.value, layout.value)) const dockEl = useTemplateRef('dockEl') diff --git a/packages/hub-ui/src/client/utils/useSafeArea.ts b/packages/hub-ui/src/client/utils/useSafeArea.ts index 0195f6e6..eb94ff80 100644 --- a/packages/hub-ui/src/client/utils/useSafeArea.ts +++ b/packages/hub-ui/src/client/utils/useSafeArea.ts @@ -1,30 +1,36 @@ import type { MaybeElementRef } from '@vueuse/core' +import type { DockMargins } from '../components/dock/dock-layout' import { tryOnMounted, unrefElement, useDebounceFn, useEventListener } from '@vueuse/core' import { shallowRef } from 'vue' /** * Ported from VueUse's `useScreenSafeArea` for now: it always sets its CSS variables on * `` and has no option for a custom element, which breaks hydration on SSR hosts. + * Reads the `--devframes-safe-area-*` variables (see `style.css`) from `target`, in px. */ export function useSafeArea(target: MaybeElementRef) { - const top = shallowRef('') - const right = shallowRef('') - const bottom = shallowRef('') - const left = shallowRef('') + const insets = shallowRef({ top: 0, right: 0, bottom: 0, left: 0 }) + + function read(style: CSSStyleDeclaration, side: keyof DockMargins) { + // The computed value is a length such as `34px`, so parse it as a float. + return Number.parseFloat(style.getPropertyValue(`--devframes-safe-area-${side}`)) || 0 + } function update() { const element = unrefElement(target) if (!element) return const style = getComputedStyle(element) - top.value = style.getPropertyValue('--devframes-safe-area-top') - right.value = style.getPropertyValue('--devframes-safe-area-right') - bottom.value = style.getPropertyValue('--devframes-safe-area-bottom') - left.value = style.getPropertyValue('--devframes-safe-area-left') + insets.value = { + top: read(style, 'top'), + right: read(style, 'right'), + bottom: read(style, 'bottom'), + left: read(style, 'left'), + } } tryOnMounted(update) useEventListener('resize', useDebounceFn(update), { passive: true }) - return { top, right, bottom, left, update } + return insets }