Files
paseo/packages/app/src/components/desktop-sidebar-layout.ts
T
Mohamed BoudraandGitHub 2b474f7df9 Keep workspaces responsive across app-wide routes (#2791)
* perf(app): retain inactive workspace screens

App-wide routes cleared the active workspace selection, which removed the retained workspace deck from the React tree and made returning rebuild every panel. Keep mounted deck entries inactive across those routes and suspend inactive panel subscriptions so state is preserved without background work.

* perf(app): suspend remaining inactive queries

Retained composers and commit diff panels still subscribed through query hooks that did not receive panel activity. Propagate the existing activity gate so app-wide routes leave those hidden surfaces dormant.

* refactor(app): separate panel activity from connectivity

A hidden retained panel is still connected to its host. Keep connectivity truthful, pause work inside query and stream owners, and preserve terminal emulator identity while its stream is detached.

* test(app): target active retained controls

* fix(app): retain compact and terminal route content

* fix(app): hide inactive workspace overlays
2026-08-02 14:32:17 +02:00

112 lines
3.0 KiB
TypeScript

import { SETTINGS_DESKTOP_SPLIT_MIN_WIDTH } from "@/constants/layout";
import {
MAX_EXPLORER_SIDEBAR_WIDTH,
MAX_SIDEBAR_WIDTH,
MIN_EXPLORER_SIDEBAR_WIDTH,
MIN_SIDEBAR_WIDTH,
} from "@/stores/panel-store";
export const MIN_DESKTOP_CENTER_WIDTH = 400;
export function resolveDesktopSidebarVisibility(input: {
chromeEnabled: boolean;
isCompactLayout: boolean;
isMounted: boolean;
isOpen: boolean;
canShare: boolean;
}): boolean {
return (
input.chromeEnabled &&
!input.isCompactLayout &&
input.isMounted &&
input.isOpen &&
input.canShare
);
}
export function resolveDesktopAppChromeLayout(input: {
desktopSidebarRendered: boolean;
hasTopLeftWindowControls: boolean;
sidebarControlsEnabled: boolean;
}) {
const sidebarOwnsTopLeft = input.desktopSidebarRendered && input.hasTopLeftWindowControls;
let sidebarToggleOwner: "none" | "window" | "content" = "none";
if (input.sidebarControlsEnabled) {
sidebarToggleOwner = input.hasTopLeftWindowControls ? "window" : "content";
}
return {
sidebarCorners: sidebarOwnsTopLeft ? ("top-left" as const) : ("none" as const),
contentCorners: sidebarOwnsTopLeft ? ("top-right" as const) : ("both" as const),
sidebarToggleOwner,
};
}
function resolveDesktopPanelWidth(input: {
requestedWidth: number;
viewportWidth: number;
minimumWidth: number;
maximumWidth: number;
}): number {
"worklet";
const maximumVisibleWidth = Math.max(
input.minimumWidth,
Math.min(input.maximumWidth, input.viewportWidth - MIN_DESKTOP_CENTER_WIDTH),
);
return Math.max(input.minimumWidth, Math.min(maximumVisibleWidth, input.requestedWidth));
}
export function resolveDesktopSidebarWidth(input: {
requestedWidth: number;
viewportWidth: number;
}): number {
"worklet";
return resolveDesktopPanelWidth({
...input,
minimumWidth: MIN_SIDEBAR_WIDTH,
maximumWidth: MAX_SIDEBAR_WIDTH,
});
}
export function resolveDesktopExplorerWidth(input: {
requestedWidth: number;
viewportWidth: number;
}): number {
"worklet";
return resolveDesktopPanelWidth({
...input,
minimumWidth: MIN_EXPLORER_SIDEBAR_WIDTH,
maximumWidth: MAX_EXPLORER_SIDEBAR_WIDTH,
});
}
export function resolveDesktopAppContentMinimum(input: {
isSettingsRoute: boolean;
isWorkspaceExplorerOpen: boolean;
requestedExplorerWidth: number;
viewportWidth: number;
}): number {
const workspaceMinimum = input.isWorkspaceExplorerOpen
? MIN_DESKTOP_CENTER_WIDTH +
resolveDesktopExplorerWidth({
requestedWidth: input.requestedExplorerWidth,
viewportWidth: input.viewportWidth,
})
: 0;
return Math.max(input.isSettingsRoute ? SETTINGS_DESKTOP_SPLIT_MIN_WIDTH : 0, workspaceMinimum);
}
export function canDesktopAppSidebarShare(input: {
contentMinimumWidth: number;
requestedSidebarWidth: number;
viewportWidth: number;
}): boolean {
return (
input.viewportWidth -
resolveDesktopSidebarWidth({
requestedWidth: input.requestedSidebarWidth,
viewportWidth: input.viewportWidth,
}) >=
input.contentMinimumWidth
);
}