Skip to content

An open-source, self-hosted system for apps built with web technologies.

Synchronization

zohayrslileh537a7a3ea3f2
diff --git a/source/client/view/appearance/appearance.tsx b/source/client/view/appearance/appearance.tsx
index 4ccfa4b..ab352f3 100644
--- a/source/client/view/appearance/appearance.tsx
+++ b/source/client/view/appearance/appearance.tsx
@@ -1,5 +1,5 @@
import DesktopPreferencesProvider, { useDesktopPreferences, useDesktopThemeTransaction } from "./desktop-preferences"
-import { defaultAppearance, parseAppearance, type Appearance } from "@phreshos/core"
+import { applyAppearanceUpdate, defaultAppearance, type Appearance } from "@phreshos/core"
import { UIProvider } from "@phreshos/react-ui"
import ReducedMotion from "@libs/react-motion"
import { createContext, type PropsWithChildren, useCallback, useContext, useLayoutEffect, useState } from "react"
@@ -70,12 +70,12 @@ export function useRememberSystemAppearance(appearance: Appearance) {
useLayoutEffect(() => remember(appearance), [appearance, remember])
}
-/** Restores one complete cached Appearance or falls back to the System default. */
+/** Resolves cached Appearance overrides against the current System default. */
export function resolveStoredAppearance(value: string | null): Appearance {
if (value === null) return defaultAppearance
try {
- return parseAppearance(JSON.parse(value))
+ return applyAppearanceUpdate(defaultAppearance, JSON.parse(value))
}
catch {
return defaultAppearance
diff --git a/source/client/view/components/desktop-host/host.ts b/source/client/view/components/desktop-host/host.ts
index dfa6a27..cc9b89d 100644
--- a/source/client/view/components/desktop-host/host.ts
+++ b/source/client/view/components/desktop-host/host.ts
@@ -928,6 +928,13 @@ export default function host(authManager: AuthManager, pane: string, viewport: (
return []
}
+ if (word === "windowPresentationInteractive") {
+ const target = presentationProcess(args[0])
+ if (typeof args[1] !== "boolean") throw new Error("Window presentation interaction must be true or false")
+ presentation.setInteractive(target.identity, args[1])
+ return []
+ }
+
if (word === "windowPresentationRaise") {
const target = presentationProcess(args[0])
diff --git a/source/client/view/components/desktop-host/window-presentation.ts b/source/client/view/components/desktop-host/window-presentation.ts
index 3ba1153..0fedd97 100644
--- a/source/client/view/components/desktop-host/window-presentation.ts
+++ b/source/client/view/components/desktop-host/window-presentation.ts
@@ -51,6 +51,7 @@ export interface WindowPresentationHost {
resize(identity: string, size: Size, transaction?: PresentationTransactionRequest): Promise<void>
setGeometry(identity: string, geometry: WindowGeometry, transaction?: PresentationTransactionRequest): Promise<void>
setSurface(identity: string, surface: WindowPresentationSurface, transaction?: PresentationTransactionRequest): Promise<void>
+ setInteractive(identity: string, interactive: boolean): void
raise(identity: string): void
complete(identity: string, kind: "geometry" | "surface", revision: number): void
}
diff --git a/source/client/view/components/window-manager/window-presentations.ts b/source/client/view/components/window-manager/window-presentations.ts
index f4ea6cd..43d369a 100644
--- a/source/client/view/components/window-manager/window-presentations.ts
+++ b/source/client/view/components/window-manager/window-presentations.ts
@@ -30,6 +30,7 @@ export interface PresentedWindow {
size: Size
minimized: boolean
maximized: boolean
+ interactive: boolean
layer: WindowLayer
depth: number
surfaceAnimation: PresentationAnimation | null
@@ -195,6 +196,12 @@ export default class WindowPresentations implements WindowPresentationHost {
return this.waitFor(identity, "surface", animation, transaction)
}
+ public setInteractive(process: string, interactive: boolean) {
+ const { identity, state } = this.raw(process)
+ if (state.interactive === interactive) return
+ this.replace(identity, { ...state, interactive })
+ }
+
public raise(process: string) {
const { identity, state } = this.raw(process)
if (frontmost(this.windows, state.layer) === identity) return
@@ -228,6 +235,17 @@ export default class WindowPresentations implements WindowPresentationHost {
const identity = this.live.get(process)
const client = this.client(process)
if (!identity || !client) return
+
+ const state = this.windows.get(identity)
+ if (!state) return
+
+ if (state.layer === "window") {
+ // A document owns only gestures it originated. Standard Window
+ // geometry belongs to the Desktop and must survive iframe load.
+ this.cancelIdentityMoveGestures(identity)
+ return
+ }
+
this.releaseTransient(identity, "The Window presentation was replaced")
this.replace(identity, initialPresentationState(client))
}
@@ -344,6 +362,7 @@ function initialPresentationState(client: ClientState): PresentedWindow {
size: window.size,
minimized: window.minimized,
maximized: window.maximized,
+ interactive: true,
layer,
depth: window.depth,
surfaceAnimation: null,
@@ -358,6 +377,7 @@ function initialPresentationState(client: ClientState): PresentedWindow {
size: { width: "100%", height: "100%" },
minimized: false,
maximized: true,
+ interactive: true,
layer,
depth: 0,
surfaceAnimation: null,
@@ -374,6 +394,7 @@ function initialPresentationState(client: ClientState): PresentedWindow {
size: { width: 0, height: 0 },
minimized: false,
maximized: false,
+ interactive: true,
layer,
depth: window.depth,
surfaceAnimation: null,
diff --git a/source/client/view/structure/desktop/desktop-focus.ts b/source/client/view/structure/desktop/desktop-focus.ts
index 9e2dfb9..4e39028 100644
--- a/source/client/view/structure/desktop/desktop-focus.ts
+++ b/source/client/view/structure/desktop/desktop-focus.ts
@@ -3,7 +3,7 @@ import useWindows from "../../components/window-manager/window-manager"
import { type FocusEvent, type RefObject, useCallback, useRef } from "react"
/** Focus transfer between the workspace, its windows and their taskbar items. */
-export default function useDesktopFocus(desktop: RefObject<HTMLDivElement | null>, windows: ReturnType<typeof useWindows>) {
+export default function useDesktopFocus(desktop: RefObject<HTMLDivElement | null>, windows: ReturnType<typeof useWindows>, taskbarOverlay: boolean) {
const focusedWindow = useRef<string | null>(null)
@@ -23,9 +23,9 @@ export default function useDesktopFocus(desktop: RefObject<HTMLDivElement | null
const focusTaskbar = useCallback(function (record: Process) {
- taskbarItems.current.get(record.identity)?.focus()
+ focusAfterMinimize(desktop.current, taskbarItems.current.get(record.identity), taskbarOverlay)
- }, [])
+ }, [desktop, taskbarOverlay])
const focusAfter = useCallback(function (record: Process) {
@@ -70,9 +70,9 @@ export default function useDesktopFocus(desktop: RefObject<HTMLDivElement | null
windows.minimize(record, minimized)
- if (minimized) focusTaskbar(record)
-
- }, [focusTaskbar, windows.minimize])
+ // If the request came from Window chrome, its later unavailable event
+ // transfers focus. A Taskbar-origin request already owns correct focus.
+ }, [windows.minimize])
const close = useCallback(function (record: Process) {
@@ -84,3 +84,12 @@ export default function useDesktopFocus(desktop: RefObject<HTMLDivElement | null
return { taskbarItem, remember, unavailable, minimize, close }
}
+
+export function focusAfterMinimize(desktop: HTMLDivElement | null, taskbarItem: HTMLButtonElement | undefined, taskbarOverlay: boolean) {
+ if (taskbarOverlay) {
+ desktop?.focus({ preventScroll: true })
+ return
+ }
+
+ taskbarItem?.focus()
+}
diff --git a/source/client/view/structure/desktop/desktop.tsx b/source/client/view/structure/desktop/desktop.tsx
index 9f840db..51cfea5 100644
--- a/source/client/view/structure/desktop/desktop.tsx
+++ b/source/client/view/structure/desktop/desktop.tsx
@@ -87,7 +87,7 @@ export default function Workspace() {
}, [])
- const focus = useDesktopFocus(desktop, windows)
+ const focus = useDesktopFocus(desktop, windows, appearance.taskbar.overlay)
// Resolved once per desktop render. Asking inside every window and
// taskbar item would repeat the same linear scan for each process.
@@ -135,6 +135,8 @@ export default function Workspace() {
size={presentation.size}
+ taskbarPosition={appearance.taskbar.position}
+
surfaceAnimation={presentation.surfaceAnimation}
geometryAnimation={presentation.geometryAnimation}
@@ -161,6 +163,8 @@ export default function Workspace() {
maximized={presentation.maximized}
+ interactive={presentation.interactive}
+
closing={closing}
stopping={stopping}
diff --git a/source/client/view/structure/desktop/layers/desktop-layers.tsx b/source/client/view/structure/desktop/layers/desktop-layers.tsx
index 8f91606..5faf8c2 100644
--- a/source/client/view/structure/desktop/layers/desktop-layers.tsx
+++ b/source/client/view/structure/desktop/layers/desktop-layers.tsx
@@ -76,7 +76,7 @@ interface DesktopLayersProps {
shell: ReactNode
}
-/** Keeps one Appearance gap outside the Taskbar and another before windows. */
+/** Reserves the Taskbar edge unless it overlays the standard Window surface. */
export function windowSurfaceInsets(spacing: number, taskbar: AppearanceTaskbar): CSSProperties {
const inset = {
top: spacing,
@@ -85,7 +85,7 @@ export function windowSurfaceInsets(spacing: number, taskbar: AppearanceTaskbar)
left: spacing
}
- inset[taskbar.position] += taskbar.size + spacing
+ if (!taskbar.overlay) inset[taskbar.position] += taskbar.size + spacing
return inset
}
diff --git a/source/client/view/structure/desktop/layers/shell/default-shell.tsx b/source/client/view/structure/desktop/layers/shell/default-shell.tsx
index a2ec024..4cbd18a 100644
--- a/source/client/view/structure/desktop/layers/shell/default-shell.tsx
+++ b/source/client/view/structure/desktop/layers/shell/default-shell.tsx
@@ -1,7 +1,7 @@
import { type AppearanceTaskbar } from "@phreshos/core"
import { type ReactNode } from "react"
import SystemDialogs from "./dialogs/system-dialogs"
-import StartMenu, { StartMenuButton, StartMenuProvider } from "./start-menu/start-menu"
+import StartMenu, { StartMenuButton, StartMenuProvider, useStartMenuOpen } from "./start-menu/start-menu"
import SignOut from "./taskbar/sign-out"
import Taskbar from "./taskbar/taskbar"
@@ -18,16 +18,9 @@ export default function DefaultShell({ spacing, taskbar, children }: Readonly<{
<StartMenuProvider spacing={spacing} taskbar={taskbar}>
- <Taskbar
- leading={<StartMenuButton showLabel={horizontal} />}
- trailing={<SignOut showLabel={horizontal} />}
- spacing={spacing}
- taskbar={taskbar}
- >
-
+ <DefaultTaskbar spacing={spacing} taskbar={taskbar} horizontal={horizontal}>
{children}
-
- </Taskbar>
+ </DefaultTaskbar>
<StartMenu />
@@ -37,3 +30,22 @@ export default function DefaultShell({ spacing, taskbar, children }: Readonly<{
</>
}
+
+function DefaultTaskbar({ spacing, taskbar, horizontal, children }: Readonly<{
+ spacing: number
+ taskbar: AppearanceTaskbar
+ horizontal: boolean
+ children: ReactNode
+}>) {
+ const startMenuOpen = useStartMenuOpen()
+
+ return <Taskbar
+ leading={<StartMenuButton showLabel={horizontal} />}
+ trailing={<SignOut showLabel={horizontal} />}
+ spacing={spacing}
+ taskbar={taskbar}
+ keepVisible={startMenuOpen}
+ >
+ {children}
+ </Taskbar>
+}
diff --git a/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx b/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx
index c4e58f8..7e6689e 100644
--- a/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx
+++ b/source/client/view/structure/desktop/layers/shell/start-menu/start-menu.tsx
@@ -203,6 +203,11 @@ function useStartMenuControl() {
return value
}
+/** Whether the default Shell's Start Menu currently retains its Taskbar anchor. */
+export function useStartMenuOpen() {
+ return useStartMenuControl().open
+}
+
interface StartMenuControl {
id: string
surface: RefObject<HTMLDivElement | null>
diff --git a/source/client/view/structure/desktop/layers/shell/taskbar/taskbar.tsx b/source/client/view/structure/desktop/layers/shell/taskbar/taskbar.tsx
index 1716ee3..4355de0 100644
--- a/source/client/view/structure/desktop/layers/shell/taskbar/taskbar.tsx
+++ b/source/client/view/structure/desktop/layers/shell/taskbar/taskbar.tsx
@@ -1,47 +1,100 @@
-import { type CSSProperties, type ReactNode } from "react"
-import { Surface, Toolbar, type SurfaceProps } from "@phreshos/react-ui"
-import { type AppearanceTaskbar } from "@phreshos/core"
+import { useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from "react"
+import { Surface, Toolbar, useAppearance, type SurfaceProps } from "@phreshos/react-ui"
+import { type AppearanceTaskbar, type TaskbarPosition } from "@phreshos/core"
+import { useReducedMotion } from "@libs/react-motion"
+import { cssEasing } from "@client/view/appearance/motion"
/**
* The Desktop's Taskbar is a Shell entity; React UI's Toolbar supplies the
* control-group semantics and orientation-aware keyboard navigation.
*/
-export default function Taskbar({ leading, trailing, taskbar, spacing, className, style, children, "aria-label": label = "Taskbar", ...props }: TaskbarProps) {
+export default function Taskbar({ leading, trailing, taskbar, spacing, keepVisible = false, className, style, children, onPointerEnter, "aria-label": label = "Taskbar", ...props }: TaskbarProps) {
const horizontal = taskbar.position === "top" || taskbar.position === "bottom"
const orientation = horizontal ? "horizontal" : "vertical"
+ const transaction = useAppearance().transaction
+ const reducedMotion = useReducedMotion()
+ const [revealed, setRevealed] = useState(false)
+ const configuration = { position: taskbar.position, overlay: taskbar.overlay }
+ const previousConfiguration = useRef(configuration)
+ const configurationChanged = taskbarConfigurationChanged(previousConfiguration.current, configuration)
+ const visible = taskbarVisible(taskbar, revealed, keepVisible, configurationChanged)
+
+ useLayoutEffect(() => {
+ if (!configurationChanged) return
+ // A reveal belongs to the edge that detected the pointer. Carrying it
+ // across an Appearance relocation paints one visible frame at the new edge.
+ previousConfiguration.current = configuration
+ setRevealed(false)
+ }, [configurationChanged, taskbar.overlay, taskbar.position])
+
+ return <div
+ data-taskbar-region=""
+ className="pointer-events-none absolute"
+ style={taskbarRegionStyle(taskbar, spacing)}
+ onPointerLeave={() => setRevealed(false)}
+ >
- return <Surface
+ {taskbar.overlay && visible ? <div
+ data-taskbar-retention-region=""
+ aria-hidden="true"
+ className="pointer-events-auto absolute inset-0"
+ /> : null}
- as={Toolbar}
- aria-label={label}
- orientation={orientation}
- gap="small"
- data-orientation={orientation}
- className={`pointer-events-auto isolate min-h-0 min-w-0 overflow-hidden p-1.5 ${className ?? ""}`}
- style={{ ...taskbarStyle(taskbar, spacing), alignItems: "center", ...style }}
+ {taskbar.overlay ? <div
+ data-taskbar-reveal-region=""
+ aria-hidden="true"
+ className="pointer-events-auto absolute"
+ style={taskbarRevealRegionStyle(taskbar.position, spacing)}
+ onPointerEnter={() => setRevealed(true)}
+ /> : null}
- {...props}
+ <Surface
- material="full"
+ as={Toolbar}
+ aria-label={label}
+ orientation={orientation}
+ gap="small"
+ data-orientation={orientation}
+ className={`pointer-events-auto isolate min-h-0 min-w-0 overflow-hidden p-1.5 ${className ?? ""}`}
+ style={{
+ ...taskbarStyle(taskbar, spacing),
+ alignItems: "center",
+ transform: taskbarOverlayTransform(taskbar.position, visible, spacing),
+ transitionDuration: reducedMotion || configurationChanged ? "0ms" : `${transaction.duration}ms`,
+ transitionTimingFunction: cssEasing(transaction.easing),
+ transitionProperty: "transform",
+ ...style
+ }}
- >
+ {...props}
+
+ material="full"
+
+ onPointerEnter={event => {
+ setRevealed(true)
+ onPointerEnter?.(event)
+ }}
- <Toolbar.Group style={{ flexShrink: 0 }}>{leading}</Toolbar.Group>
+ >
- <Toolbar.Separator className="shadow-taskbar-separator" />
+ <Toolbar.Group style={{ flexShrink: 0 }}>{leading}</Toolbar.Group>
- <Toolbar.Group style={{ flex: "1 1 0", alignSelf: "stretch", minWidth: 0, minHeight: 0, overflow: "hidden" }}>
+ <Toolbar.Separator className="shadow-taskbar-separator" />
- {children}
+ <Toolbar.Group style={{ flex: "1 1 0", alignSelf: "stretch", minWidth: 0, minHeight: 0, overflow: "hidden" }}>
- </Toolbar.Group>
+ {children}
- <Toolbar.Separator className="shadow-taskbar-separator" />
+ </Toolbar.Group>
- <Toolbar.Group style={{ flexShrink: 0 }}>{trailing}</Toolbar.Group>
+ <Toolbar.Separator className="shadow-taskbar-separator" />
- </Surface>
+ <Toolbar.Group style={{ flexShrink: 0 }}>{trailing}</Toolbar.Group>
+
+ </Surface>
+
+ </div>
}
interface TaskbarProps extends Omit<SurfaceProps<typeof Toolbar>, "as" | "children" | "orientation"> {
@@ -55,6 +108,9 @@ interface TaskbarProps extends Omit<SurfaceProps<typeof Toolbar>, "as" | "childr
taskbar: AppearanceTaskbar
spacing: number
+
+ /** Retains an overlay Taskbar while an anchored Shell surface is open. */
+ keepVisible?: boolean
}
/** Taskbar size is its cross-axis extent; spacing remains its outer margin. */
@@ -69,3 +125,52 @@ export function taskbarStyle(taskbar: AppearanceTaskbar, spacing: number): CSSPr
: { top: spacing, bottom: spacing, width: taskbar.size, height: "auto" })
}
}
+
+/** Bounds shared by the edge sensor and the revealed Taskbar. */
+export function taskbarRegionStyle(taskbar: AppearanceTaskbar, spacing: number): CSSProperties {
+ const horizontal = taskbar.position === "top" || taskbar.position === "bottom"
+
+ return {
+ [taskbar.position]: 0,
+ ...(horizontal
+ ? { left: 0, right: 0, height: taskbar.size + spacing + taskbarRetentionDistance }
+ : { top: 0, bottom: 0, width: taskbar.size + spacing + taskbarRetentionDistance })
+ }
+}
+
+/** Fixed inward distance a revealed overlay Taskbar retains pointer ownership. */
+export const taskbarRetentionDistance = 50
+
+interface TaskbarVisibilityConfiguration {
+ position: TaskbarPosition
+ overlay: boolean
+}
+
+export function taskbarConfigurationChanged(previous: TaskbarVisibilityConfiguration, current: TaskbarVisibilityConfiguration) {
+ return previous.position !== current.position || previous.overlay !== current.overlay
+}
+
+export function taskbarVisible(taskbar: AppearanceTaskbar, revealed: boolean, keepVisible: boolean, configurationChanged: boolean) {
+ return !taskbar.overlay || keepVisible || revealed && !configurationChanged
+}
+
+/** The outer Appearance spacing is the non-obstructing reveal target. */
+export function taskbarRevealRegionStyle(position: TaskbarPosition, spacing: number): CSSProperties {
+ const horizontal = position === "top" || position === "bottom"
+
+ return {
+ [position]: 0,
+ ...(horizontal
+ ? { left: 0, right: 0, height: spacing }
+ : { top: 0, bottom: 0, width: spacing })
+ }
+}
+
+/** Moves an overlay Taskbar wholly beyond its configured Desktop edge. */
+export function taskbarOverlayTransform(position: TaskbarPosition, visible: boolean, spacing: number) {
+ if (visible) return "translate(0)"
+ if (position === "top") return `translateY(calc(-100% - ${spacing}px))`
+ if (position === "bottom") return `translateY(calc(100% + ${spacing}px))`
+ if (position === "left") return `translateX(calc(-100% - ${spacing}px))`
+ return `translateX(calc(100% + ${spacing}px))`
+}
diff --git a/source/client/view/structure/desktop/windows/process-window.tsx b/source/client/view/structure/desktop/windows/process-window.tsx
index a78df30..9a5b892 100644
--- a/source/client/view/structure/desktop/windows/process-window.tsx
+++ b/source/client/view/structure/desktop/windows/process-window.tsx
@@ -3,7 +3,7 @@ import ClientState from "@client/core/link-manager/auth-manager/process-manager/
import { type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"
import { type PresentationAnimation, type PresentationMoveGestureController } from "@client/view/components/desktop-host/window-presentation"
import { type PresentationGeometryRepresentation } from "@client/view/components/window-manager/window-presentations"
-import { type Position, type Size, type Theme, type WindowPresentationSurface, type WindowLayer } from "@phreshos/core"
+import { type Position, type Size, type TaskbarPosition, type Theme, type WindowPresentationSurface, type WindowLayer } from "@phreshos/core"
import Spinner from "@client/view/components/spinner"
import Window from "./window"
import ProgramFrame, { programFrameSource } from "@client/view/components/program-frame"
@@ -24,7 +24,7 @@ export function processWindowProgress(layer: WindowLayer, loading: boolean, stop
* props so memoization can see which process actually changed even though
* the peer deliberately keeps each Process instance alive and mutates it.
*/
-export default memo(function ({ identity, record, assetId, client, title, header, surface, layer, icon, position, size, surfaceAnimation, geometryAnimation, minimizeAnimation, onPresentationAnimationComplete, onPresentationRepresentation, onPresentationMoveGesture, paintSurfaceSize, spacing, depth, active, minimized, maximized, closing, stopping, entering, door, programAccess, theme, onFrame, onFrameLoad, onReady, onRaise, onMinimize, onFill, onClose, onClosed, onUnavailable, onMove, onResize, onSnap }: ProcessWindowProps) {
+export default memo(function ({ identity, record, assetId, client, title, header, surface, layer, icon, position, size, taskbarPosition, surfaceAnimation, geometryAnimation, minimizeAnimation, onPresentationAnimationComplete, onPresentationRepresentation, onPresentationMoveGesture, paintSurfaceSize, spacing, depth, active, minimized, maximized, interactive, closing, stopping, entering, door, programAccess, theme, onFrame, onFrameLoad, onReady, onRaise, onMinimize, onFill, onClose, onClosed, onUnavailable, onMove, onResize, onSnap }: ProcessWindowProps) {
const activate = useCallback(() => onRaise(record), [onRaise, record])
@@ -115,6 +115,8 @@ export default memo(function ({ identity, record, assetId, client, title, header
size={size}
+ taskbarPosition={taskbarPosition}
+
surfaceAnimation={surfaceAnimation}
geometryAnimation={geometryAnimation}
@@ -137,6 +139,8 @@ export default memo(function ({ identity, record, assetId, client, title, header
maximized={maximized}
+ interactive={interactive}
+
closing={closing}
stopping={stopping}
@@ -237,6 +241,9 @@ interface ProcessWindowProps {
size: Size
+ /** Desktop-owned presentation destination for minimizing standard Windows. */
+ taskbarPosition: TaskbarPosition
+
surfaceAnimation: PresentationAnimation | null
geometryAnimation: PresentationAnimation | null
@@ -261,6 +268,8 @@ interface ProcessWindowProps {
maximized: boolean
+ interactive: boolean
+
closing: boolean
stopping: boolean
diff --git a/source/client/view/structure/desktop/windows/window.tsx b/source/client/view/structure/desktop/windows/window.tsx
index 22901c0..00a20a8 100644
--- a/source/client/view/structure/desktop/windows/window.tsx
+++ b/source/client/view/structure/desktop/windows/window.tsx
@@ -3,7 +3,7 @@ import { useReducedMotion } from "@libs/react-motion"
import { surfaceLifecyclePose, surfacePresencePose, surfacePresenceTransition } from "@client/view/appearance/surface-presence"
import WindowPanel from "./window-panel"
import { absoluteWindowGeometry, constrainWindowGeometry, minimumWindowSize, resolveWindowGeometry, windowPaintInsets, type WindowRegion, type WindowSurfaceSize } from "@client/view/components/window-manager/window-geometry"
-import { type BeginWindowMoveGesture, type Position, type Size, type WindowPresentationSurface as WindowSurfaceDefinition, type WindowLayer } from "@phreshos/core"
+import { type BeginWindowMoveGesture, type Position, type Size, type TaskbarPosition, type WindowPresentationSurface as WindowSurfaceDefinition, type WindowLayer } from "@phreshos/core"
import WindowHeader from "./window-header"
import WindowSurface, { windowSurfaceRadius } from "./window-surface"
import { type PresentationAnimation, type PresentationMoveGestureController, type PresentationMovePoint } from "@client/view/components/desktop-host/window-presentation"
@@ -48,9 +48,24 @@ const edges: { edge: WindowEdge, className: string }[] = [
{ edge: "se", className: "bottom-0 right-0 size-4 cursor-nwse-resize" }
]
-const minimizedSurfacePose = { scale: 0.86, y: 28, opacity: 0 }
+const windowSurfaceLifecyclePose = Object.freeze({
+ visible: { ...surfaceLifecyclePose.visible, x: 0 },
+ hidden: { ...surfaceLifecyclePose.hidden, x: 0 }
+})
-export default function ({ title, header = true, surface, layer, icon, children, onClose, onClosed, onMinimize, onMaximize, onActivate, onUnavailable, onMove, onResize, onSnap, onPresentationAnimationComplete, onPresentationRepresentation, onPresentationMoveGesture, onFocusCapture, active = false, closing = false, stopping = false, minimized = false, maximized = false, entering = false, position = { x: 0, y: 0 }, size = { width: 520, height: 340 }, surfaceAnimation, geometryAnimation, minimizeAnimation, paintSurfaceSize = { width: 0, height: 0 }, spacing = 0, minWidth = minimumWindowSize.width, minHeight = minimumWindowSize.height, className, style, ...props }: WindowProps) {
+export function windowMinimizePose(position: TaskbarPosition) {
+
+ const distance = 28
+
+ return {
+ scale: 0.86,
+ x: position === "left" ? -distance : position === "right" ? distance : 0,
+ y: position === "top" ? -distance : position === "bottom" ? distance : 0,
+ opacity: 0
+ }
+}
+
+export default function ({ title, header = true, surface, layer, icon, children, onClose, onClosed, onMinimize, onMaximize, onActivate, onUnavailable, onMove, onResize, onSnap, onPresentationAnimationComplete, onPresentationRepresentation, onPresentationMoveGesture, onFocusCapture, active = false, closing = false, stopping = false, minimized = false, maximized = false, interactive = true, entering = false, position = { x: 0, y: 0 }, size = { width: 520, height: 340 }, taskbarPosition = "bottom", surfaceAnimation, geometryAnimation, minimizeAnimation, paintSurfaceSize = { width: 0, height: 0 }, spacing = 0, minWidth = minimumWindowSize.width, minHeight = minimumWindowSize.height, className, style, ...props }: WindowProps) {
const reducedMotion = useReducedMotion()
const appearance = useAppearance()
@@ -231,13 +246,15 @@ export default function ({ title, header = true, surface, layer, icon, children,
const minimizeTransaction = minimizeAnimation
? resolveWindowTransaction(minimizeAnimation.transaction, appearanceTransaction)
: null
- const initialPresence = opening ? surfaceLifecyclePose.hidden : surfaceLifecyclePose.visible
+ const initialPresence = standard
+ ? opening ? windowSurfaceLifecyclePose.hidden : windowSurfaceLifecyclePose.visible
+ : opening ? surfaceLifecyclePose.hidden : surfaceLifecyclePose.visible
const presencePose = closing && standard
- ? surfaceLifecyclePose.hidden
+ ? windowSurfaceLifecyclePose.hidden
: minimized
- ? standard ? minimizedSurfacePose : surfacePresencePose.entering
- : surfaceLifecyclePose.visible
+ ? standard ? windowMinimizePose(taskbarPosition) : surfacePresencePose.entering
+ : standard ? windowSurfaceLifecyclePose.visible : surfaceLifecyclePose.visible
const presenceTransition = reducedMotion
? { duration: 0 }
@@ -568,7 +585,9 @@ export default function ({ title, header = true, surface, layer, icon, children,
onFocusCapture?.(event)
}}
- className={`absolute ${minimized || closing ? "pointer-events-none" : "pointer-events-auto"} ${className ?? ""}`}
+ // Only the Desktop can make the iframe's host box transparent to
+ // lower layers; content inside the iframe cannot cross that boundary.
+ className={`absolute ${minimized || closing || !interactive ? "pointer-events-none" : "pointer-events-auto"} ${className ?? ""}`}
style={{ ...style, left: 0, top: 0, ...geometryMotion.style }}
@@ -577,7 +596,7 @@ export default function ({ title, header = true, surface, layer, icon, children,
// A hidden pane is absent from sequential focus as well as
// pointer hit-testing. Visibility currently provides the same
// effect visually; inert states the interaction rule directly.
- inert={minimized || closing}
+ inert={minimized || closing || !interactive}
>
@@ -714,6 +733,9 @@ interface WindowProps extends Omit<ComponentProps<"div">, "onAnimationStart" | "
maximized?: boolean
+ /** Whether this presentation participates in focus and hit testing. */
+ interactive?: boolean
+
/** Whether mounting this element represents a newly opened Window. */
entering?: boolean
@@ -721,6 +743,9 @@ interface WindowProps extends Omit<ComponentProps<"div">, "onAnimationStart" | "
size?: Size
+ /** Desktop edge toward which this standard Window minimizes. */
+ taskbarPosition?: TaskbarPosition
+
surfaceAnimation?: PresentationAnimation | null
geometryAnimation?: PresentationAnimation | null
diff --git a/source/server/core/appearance-manager.ts b/source/server/core/appearance-manager.ts
index 6abb33b..1958e3b 100644
--- a/source/server/core/appearance-manager.ts
+++ b/source/server/core/appearance-manager.ts
@@ -1,6 +1,6 @@
import Keyv from "keyv"
import { isDeepStrictEqual } from "node:util"
-import { applyAppearanceUpdate, defaultAppearance, parseAppearance, type Appearance } from "@phreshos/core"
+import { applyAppearanceUpdate, defaultAppearance, type Appearance } from "@phreshos/core"
import UploadManager from "./upload-manager"
import { wallpaperKind, wallpaperSizeLimit } from "@shared/wallpaper"
@@ -17,9 +17,15 @@ export default class AppearanceManager {
public static async open(store: Keyv, uploads: UploadManager) {
const stored = await store.get(storageKey)
- const appearance = parseAppearance(stored ?? defaultAppearance)
-
- if (stored === undefined) await store.set(storageKey, appearance)
+ const appearance = stored === undefined
+ ? defaultAppearance
+ : applyAppearanceUpdate(defaultAppearance, stored)
+
+ // Persisted Appearance values may predate newly introduced fields. They
+ // remain overrides of the current defaults, then become canonical here.
+ if (stored === undefined || !isDeepStrictEqual(stored, appearance)) {
+ await store.set(storageKey, appearance)
+ }
return new AppearanceManager(store, uploads, appearance)
}
diff --git a/tests/appearance.test.ts b/tests/appearance.test.ts
index 206c35c..a21ef1a 100644
--- a/tests/appearance.test.ts
+++ b/tests/appearance.test.ts
@@ -40,6 +40,23 @@ test("appearance contract", async () => {
assert(Object.isFrozen(manager.value))
assert.deepEqual(await store.get("appearance"), defaultAppearance)
+ const legacyStore = new Keyv()
+ const { overlay: _overlay, ...legacyTaskbar } = defaultAppearance.taskbar
+ const legacyAppearance = {
+ ...defaultAppearance,
+ spacing: 15,
+ taskbar: { ...legacyTaskbar, position: "top" as const }
+ }
+ await legacyStore.set("appearance", legacyAppearance)
+
+ const migrated = await AppearanceManager.open(legacyStore, uploads)
+
+ assert.deepEqual(migrated.value, {
+ ...legacyAppearance,
+ taskbar: { ...legacyAppearance.taskbar, overlay: false }
+ })
+ assert.deepEqual(await legacyStore.get("appearance"), migrated.value)
+
const initial = manager.value
assert.equal(await manager.update(defaultAppearance), initial)
assert.equal(manager.value, initial)
diff --git a/tests/client-appearance.test.ts b/tests/client-appearance.test.ts
index 9c0e4d7..5c87a06 100644
--- a/tests/client-appearance.test.ts
+++ b/tests/client-appearance.test.ts
@@ -12,6 +12,20 @@ describe("Desktop Appearance bootstrap", () => {
expect(resolveStoredAppearance(JSON.stringify(stored))).toEqual(stored)
})
+ it("fills fields absent from an older cached Appearance without losing its values", () => {
+ const { overlay: _overlay, ...taskbar } = defaultAppearance.taskbar
+ const stored = {
+ ...defaultAppearance,
+ spacing: 15,
+ taskbar: { ...taskbar, position: "top" }
+ }
+
+ expect(resolveStoredAppearance(JSON.stringify(stored))).toEqual({
+ ...stored,
+ taskbar: { ...stored.taskbar, overlay: false }
+ })
+ })
+
it.each([null, "not json", "{}"])("uses the System default when the cached value is %s", value => {
expect(resolveStoredAppearance(value)).toBe(defaultAppearance)
})
diff --git a/tests/desktop-focus.test.ts b/tests/desktop-focus.test.ts
new file mode 100644
index 0000000..20740f7
--- /dev/null
+++ b/tests/desktop-focus.test.ts
@@ -0,0 +1,30 @@
+import { expect, test, vi } from "vitest"
+import { focusAfterMinimize } from "@client/view/structure/desktop/desktop-focus"
+
+test("minimizing from a Window does not focus an overlay Taskbar", () => {
+ const desktopFocus = vi.fn()
+ const taskbarFocus = vi.fn()
+
+ focusAfterMinimize(
+ { focus: desktopFocus } as unknown as HTMLDivElement,
+ { focus: taskbarFocus } as unknown as HTMLButtonElement,
+ true
+ )
+
+ expect(desktopFocus).toHaveBeenCalledWith({ preventScroll: true })
+ expect(taskbarFocus).not.toHaveBeenCalled()
+})
+
+test("minimizing from a Window focuses its visible non-overlay Taskbar item", () => {
+ const desktopFocus = vi.fn()
+ const taskbarFocus = vi.fn()
+
+ focusAfterMinimize(
+ { focus: desktopFocus } as unknown as HTMLDivElement,
+ { focus: taskbarFocus } as unknown as HTMLButtonElement,
+ false
+ )
+
+ expect(desktopFocus).not.toHaveBeenCalled()
+ expect(taskbarFocus).toHaveBeenCalledOnce()
+})
diff --git a/tests/desktop-replacements.test.tsx b/tests/desktop-replacements.test.tsx
index 8848b5e..7d841d8 100644
--- a/tests/desktop-replacements.test.tsx
+++ b/tests/desktop-replacements.test.tsx
@@ -4,9 +4,10 @@ import { UIProvider } from "@phreshos/react-ui"
import type Process from "@client/core/link-manager/auth-manager/process-manager/process"
import Workspace from "@client/view/structure/desktop/desktop"
import { windowSurfaceInsets } from "@client/view/structure/desktop/layers/desktop-layers"
-import { taskbarStyle } from "@client/view/structure/desktop/layers/shell/taskbar/taskbar"
+import Taskbar, { taskbarConfigurationChanged, taskbarOverlayTransform, taskbarRegionStyle, taskbarRetentionDistance, taskbarRevealRegionStyle, taskbarStyle, taskbarVisible } from "@client/view/structure/desktop/layers/shell/taskbar/taskbar"
import { startMenuStyle } from "@client/view/structure/desktop/layers/shell/start-menu/start-menu"
import { taskbarIndicatorClassName } from "@client/view/structure/desktop/layers/shell/taskbar/programs/taskbar-item"
+import { windowMinimizePose } from "@client/view/structure/desktop/windows/window"
import type { ReactNode } from "react"
import { defaultAppearance } from "@phreshos/core"
@@ -69,7 +70,7 @@ test("Desktop composes five full-bound stacked layers without a layout track", (
test.each(["top", "right", "bottom", "left"] as const)("standard window surface reserves the %s Taskbar edge", position => {
const spacing = 12
const size = 44
- const insets = windowSurfaceInsets(spacing, { position, size })
+ const insets = windowSurfaceInsets(spacing, { position, size, overlay: false })
expect(insets).toEqual({
top: position === "top" ? 68 : 12,
@@ -79,10 +80,61 @@ test.each(["top", "right", "bottom", "left"] as const)("standard window surface
})
})
+test.each(["top", "right", "bottom", "left"] as const)("an overlay Taskbar does not reserve the %s standard-window edge", position => {
+ expect(windowSurfaceInsets(12, { position, size: 44, overlay: true })).toEqual({
+ top: 12,
+ right: 12,
+ bottom: 12,
+ left: 12
+ })
+})
+
+test.each(["top", "right", "bottom", "left"] as const)("an overlay Taskbar hides beyond and listens at the %s edge", position => {
+ const taskbar = { position, size: 44, overlay: true }
+ const region = taskbarRegionStyle(taskbar, 12)
+ const reveal = taskbarRevealRegionStyle(position, 12)
+
+ expect(region).toMatchObject({ [position]: 0 })
+ expect(reveal).toMatchObject({ [position]: 0 })
+ expect(position === "top" || position === "bottom" ? region.height : region.width).toBe(56 + taskbarRetentionDistance)
+ expect(position === "top" || position === "bottom" ? reveal.height : reveal.width).toBe(12)
+ expect(taskbarOverlayTransform(position, true, 12)).toBe("translate(0)")
+ expect(taskbarOverlayTransform(position, false, 12)).toContain(position === "top" || position === "bottom" ? "translateY" : "translateX")
+})
+
+test("an open anchored Shell surface retains the overlay Taskbar", () => {
+ const render = (keepVisible: boolean) => renderToStaticMarkup(<UIProvider preferences={{ theme: "light", animations: true }}>
+ <Taskbar
+ leading={null}
+ trailing={null}
+ taskbar={{ position: "bottom", size: 44, overlay: true }}
+ spacing={12}
+ keepVisible={keepVisible}
+ >
+ {null}
+ </Taskbar>
+ </UIProvider>)
+
+ expect(render(true)).toContain("transform:translate(0)")
+ expect(render(true)).toContain("data-taskbar-retention-region")
+ expect(render(false)).toContain("transform:translateY(calc(100% + 12px))")
+ expect(render(false)).not.toContain("data-taskbar-retention-region")
+})
+
+test("moving an overlay Taskbar invalidates the reveal from its previous edge", () => {
+ const previous = { position: "bottom", overlay: true } as const
+ const current = { position: "left", size: 44, overlay: true } as const
+ const changed = taskbarConfigurationChanged(previous, current)
+
+ expect(changed).toBe(true)
+ expect(taskbarVisible(current, true, false, changed)).toBe(false)
+ expect(taskbarVisible(current, true, true, changed)).toBe(true)
+})
+
test.each(["top", "right", "bottom", "left"] as const)("Taskbar occupies its configured %s edge and Start Menu opens inward", position => {
const spacing = 12
const size = 44
- const taskbar = { position, size }
+ const taskbar = { position, size, overlay: false }
const bar = taskbarStyle(taskbar, spacing)
const menu = startMenuStyle(taskbar, spacing)
@@ -106,6 +158,15 @@ test.each(["top", "right", "bottom", "left"] as const)("active Taskbar indicator
expect(taskbarIndicatorClassName(position)).toContain(`${position}-0`)
})
+test.each([
+ ["top", { x: 0, y: -28 }],
+ ["right", { x: 28, y: 0 }],
+ ["bottom", { x: 0, y: 28 }],
+ ["left", { x: -28, y: 0 }]
+] as const)("standard windows minimize toward the %s Taskbar", (position, offset) => {
+ expect(windowMinimizePose(position)).toEqual({ scale: 0.86, ...offset, opacity: 0 })
+})
+
test("Desktop replaces its default wallpaper with the running Client and restores the fallback after stop", () => {
const render = () => renderToStaticMarkup(<UIProvider preferences={{ theme: "light", animations: true }}><Workspace /></UIProvider>)
fixture.processes.clear()
diff --git a/tests/panel.test.tsx b/tests/panel.test.tsx
index eb7512d..4b61233 100644
--- a/tests/panel.test.tsx
+++ b/tests/panel.test.tsx
@@ -55,6 +55,10 @@ test("panel contract", async () => {
assert.doesNotMatch(bare, /data-material/)
assert.doesNotMatch(bare, /grid-template-rows:auto minmax\(0, 1fr\)/)
+ const passThrough = markup(<Window layer="over" icon="/icon.svg" title="Pass-through" interactive={false}><iframe title="Content" /></Window>)
+ assert.match(passThrough, /pointer-events-none/)
+ assert.match(passThrough, /inert=""/)
+
const authentication = markup(<CredentialsForm title="Sign in" description="Welcome" submitLabel="Continue" passwordAutocomplete="current-password" pending={false} onSubmit={() => {}} />)
panel(authentication, 5)
assert.equal(authentication.match(/<form\b/g)?.length, 1)
@@ -101,7 +105,7 @@ test("panel contract", async () => {
const taskbar = markup(<Taskbar
leading={<button>Start</button>}
trailing={<button>Sign out</button>}
- taskbar={{ position: "bottom", size: 44 }}
+ taskbar={{ position: "bottom", size: 44, overlay: false }}
spacing={8}
><button>Window</button></Taskbar>)
assert.match(taskbar, /role="toolbar"/)
diff --git a/tests/window-presentation-layers.test.ts b/tests/window-presentation-layers.test.ts
index 2351fea..4ed807b 100644
--- a/tests/window-presentation-layers.test.ts
+++ b/tests/window-presentation-layers.test.ts
@@ -21,9 +21,10 @@ test("wallpaper is fixed and rejects both raw operations and move gestures", ()
const { presentations } = fixture("wallpaper")
expect(presentations.layer("own")).toBe("wallpaper")
expect(presentations.projection("own")).toMatchObject({
- position: { x: 0, y: 0 }, size: { width: "100%", height: "100%" }, surface: false
+ position: { x: 0, y: 0 }, size: { width: "100%", height: "100%" }, surface: false, interactive: true
})
expect(() => presentations.move("own", { x: 1, y: 2 })).toThrow(/does not support raw/)
+ expect(() => presentations.setInteractive("own", false)).toThrow(/does not support raw/)
expect(() => presentations.raise("own")).toThrow(/does not support raw/)
expect(() => presentations.beginMoveGesture("own", "gesture", { x: 0, y: 0 }, { x: 1, y: 1 })).toThrow(/standard Windows/)
})
@@ -32,12 +33,13 @@ test.each(["under", "over", "shell"] as const)("%s is controlled only through ra
const { client, entries, presentations } = fixture(layer)
expect(presentations.layer("own")).toBe(layer)
expect(presentations.projection("own")).toMatchObject({
- position: { x: 0, y: 0 }, size: { width: 0, height: 0 }, surface: false, header: false
+ position: { x: 0, y: 0 }, size: { width: 0, height: 0 }, surface: false, header: false, interactive: true
})
await presentations.setGeometry("own", { x: 10, y: 20, width: 400, height: 300 })
await presentations.setSurface("own", true)
+ presentations.setInteractive("own", false)
expect(presentations.projection("own")).toMatchObject({
- position: { x: 10, y: 20 }, size: { width: 400, height: 300 }, surface: true
+ position: { x: 10, y: 20 }, size: { width: 400, height: 300 }, surface: true, interactive: false
})
client.window.position = { x: 800, y: 900 }
@@ -45,6 +47,10 @@ test.each(["under", "over", "shell"] as const)("%s is controlled only through ra
entries.get("own")!.client = client as never
presentations.reconcile(entries)
expect(presentations.projection("own").position).toEqual({ x: 10, y: 20 })
+ expect(presentations.projection("own").interactive).toBe(false)
+
+ presentations.begin("own")
+ expect(presentations.projection("own").interactive).toBe(true)
expect(() => presentations.beginMoveGesture("own", "gesture", { x: 0, y: 0 }, { x: 1, y: 1 })).toThrow(/standard Windows/)
})
@@ -53,5 +59,6 @@ test("standard Window presentation is exclusively Desktop-controlled", () => {
expect(presentations.layer("own")).toBe("window")
expect(() => presentations.resize("own", { width: 1, height: 2 })).toThrow(/does not support raw/)
expect(() => presentations.setSurface("own", false)).toThrow(/does not support raw/)
+ expect(() => presentations.setInteractive("own", false)).toThrow(/does not support raw/)
expect(() => presentations.raise("own")).toThrow(/does not support raw/)
})
diff --git a/tests/window-presentation.test.ts b/tests/window-presentation.test.ts
index e22a14c..41c1724 100644
--- a/tests/window-presentation.test.ts
+++ b/tests/window-presentation.test.ts
@@ -24,11 +24,15 @@ test("each Desktop owns an independent raw presentation initialized at zero", as
assert.deepEqual(first.projection("overlay").position, { x: 0, y: 0 })
assert.deepEqual(first.projection("overlay").size, { width: 0, height: 0 })
assert.equal(first.projection("overlay").surface, false)
+ assert.equal(first.projection("overlay").interactive, true)
await first.setGeometry("overlay", { x: 40, y: 50, width: 600, height: 400 })
await first.setSurface("overlay", { color: "primary", radius: "full" })
+ first.setInteractive("overlay", false)
assert.deepEqual(first.projection("overlay").position, { x: 40, y: 50 })
assert.deepEqual(second.projection("overlay").position, { x: 0, y: 0 })
+ assert.equal(first.projection("overlay").interactive, false)
+ assert.equal(second.projection("overlay").interactive, true)
await first.setSurface("overlay", false)
assert.equal(first.projection("overlay").surface, false)
@@ -148,6 +152,23 @@ test("a new Client document preserves its mounted Desktop geometry representatio
assert.equal(presentations.representedGeometry("ordinary"), null)
})
+test("a standard Window presentation survives its iframe document load", () => {
+ const ordinary = client("window")
+ const entries = entry("ordinary", ordinary)
+ const presentations = new WindowPresentations(entries, () => ordinary as never)
+
+ ordinary.window.position = { x: 80, y: 90 }
+ ordinary.window.maximized = true
+ presentations.reconcile(entries)
+
+ const before = presentations.projection("ordinary")
+ assert.ok(before.geometryAnimation)
+
+ presentations.begin("ordinary")
+
+ assert.equal(presentations.projection("ordinary"), before)
+})
+
function entry(process: string, selected: ReturnType<typeof client>) {
return new Map([[process, { identity: `${process}:0`, client: selected }]]) as unknown as ReadonlyMap<string, WindowPresentationEntry>
}