mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-16 21:34:59 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1cf39f9c4a | ||
|
|
e683d6e2d5 | ||
|
|
e29d5f8d5b | ||
|
|
a29f51297b |
@@ -208,6 +208,35 @@ test.describe("Plugin sidebar items", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("a short desktop sidebar keeps workspaces usable while navigation scrolls", async ({
|
||||
page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 1280, height: 480 });
|
||||
await gotoAppShell(page);
|
||||
await expect(botRow(page, "status")).toBeAttached();
|
||||
const workspace = visibleTestId(page, `sidebar-workspace-row-${getServerId()}:${workspaceId}`);
|
||||
await expect(workspace).toBeInViewport({ ratio: 1 });
|
||||
await expect(botRow(page, "status")).not.toBeInViewport();
|
||||
|
||||
await test.step("navigation stays within half the sidebar", async () => {
|
||||
const nav = await boxOf(visibleTestId(page, "sidebar-nav-scroll"));
|
||||
expect(nav.height).toBeLessThanOrEqual(480 / 2 + 1);
|
||||
});
|
||||
|
||||
await test.step("scrolling navigation reaches its last row without moving workspaces", async () => {
|
||||
const before = await boxOf(workspace);
|
||||
await visibleTestId(page, "sidebar-global-new-workspace").hover();
|
||||
await page.mouse.wheel(0, 800);
|
||||
await expect(botRow(page, "status")).toBeInViewport({ ratio: 1 });
|
||||
await expect(workspace).toBeInViewport({ ratio: 1 });
|
||||
expect((await boxOf(workspace)).y).toBe(before.y);
|
||||
await qaScreenshot(page, "desktop-short-sidebar-nav-scrolled");
|
||||
await botRow(page, "status").click();
|
||||
await expect(page.getByText("Bot status details", { exact: true })).toBeVisible();
|
||||
await page.getByRole("button", { name: "Close bot status", exact: true }).click();
|
||||
});
|
||||
});
|
||||
|
||||
test("a restored plugin screen waits for its catalog before rendering", async ({ page }) => {
|
||||
await page.setViewportSize(WIDE);
|
||||
await gotoWorkspace(page, workspaceId);
|
||||
|
||||
@@ -17,6 +17,13 @@ import { isNative } from "@/constants/platform";
|
||||
* On macOS, Electron handles edge resize natively.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Marks a scroll viewport as window content: it and its descendants emit no window
|
||||
* regions, because Electron does not clip app-region rects to scroll viewports.
|
||||
* See the `[data-window-content]` rule in public/index.html.
|
||||
*/
|
||||
export const WINDOW_CONTENT_DATASET = { "window-content": "" };
|
||||
|
||||
export const titlebarDragSurfaceStyle: React.CSSProperties = {
|
||||
cursor: "default",
|
||||
// @ts-expect-error — WebkitAppRegion is not in CSSProperties
|
||||
|
||||
@@ -9,7 +9,16 @@ import {
|
||||
type LucideIcon,
|
||||
} from "lucide-react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState, type RefObject } from "react";
|
||||
import {
|
||||
memo,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
type ReactNode,
|
||||
type RefObject,
|
||||
} from "react";
|
||||
import {
|
||||
Pressable,
|
||||
ScrollView,
|
||||
@@ -19,12 +28,19 @@ import {
|
||||
View,
|
||||
type LayoutChangeEvent,
|
||||
} from "react-native";
|
||||
import { Gesture, ScrollView as GHScrollView } from "react-native-gesture-handler";
|
||||
import {
|
||||
Gesture,
|
||||
type GestureType,
|
||||
ScrollView as GHScrollView,
|
||||
} from "react-native-gesture-handler";
|
||||
import Animated, { runOnJS, useAnimatedStyle, useSharedValue } from "react-native-reanimated";
|
||||
import { scheduleOnRN } from "react-native-worklets";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
||||
import { TitlebarDragRegion } from "@/components/desktop/titlebar-drag-region";
|
||||
import {
|
||||
TitlebarDragRegion,
|
||||
WINDOW_CONTENT_DATASET,
|
||||
} from "@/components/desktop/titlebar-drag-region";
|
||||
import { SidebarCloseButton } from "@/components/headers/sidebar-close-button";
|
||||
import {
|
||||
resolveDesktopSidebarInsetLeft,
|
||||
@@ -622,29 +638,7 @@ function MobileSidebar({
|
||||
>
|
||||
<View style={styles.sidebarContent} pointerEvents="auto">
|
||||
<WindowChromeSafeArea placement="below" />
|
||||
{platformIsNative ? (
|
||||
<GHScrollView
|
||||
// Same contract as the workspace list: vertical drags scroll the nav
|
||||
// block, a clear horizontal intent still activates the close pan.
|
||||
simultaneousHandlers={closeGestureRef}
|
||||
style={styles.mobileNavScroll}
|
||||
showsVerticalScrollIndicator={false}
|
||||
alwaysBounceVertical={false}
|
||||
testID="sidebar-nav-scroll"
|
||||
>
|
||||
{navRows}
|
||||
</GHScrollView>
|
||||
) : (
|
||||
<ScrollView
|
||||
style={styles.mobileNavScroll}
|
||||
showsVerticalScrollIndicator={false}
|
||||
alwaysBounceVertical={false}
|
||||
testID="sidebar-nav-scroll"
|
||||
>
|
||||
{navRows}
|
||||
</ScrollView>
|
||||
)}
|
||||
<SidebarSeparator />
|
||||
<SidebarNavScroll closeGestureRef={closeGestureRef}>{navRows}</SidebarNavScroll>
|
||||
|
||||
<SidebarViewSlot dismiss={handleWorkspacePress}>
|
||||
<SidebarToastRegion active={active}>
|
||||
@@ -689,6 +683,47 @@ function MobileSidebar({
|
||||
);
|
||||
}
|
||||
|
||||
interface SidebarNavScrollProps {
|
||||
closeGestureRef: RefObject<GestureType | undefined>;
|
||||
/** Web only: the viewport emits no window regions (see WINDOW_CONTENT_DATASET). */
|
||||
windowContent?: boolean;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
// The capped, scrolling nav block shared by the mobile and desktop sidebars, with the
|
||||
// divider below it. The divider is a sibling because Unistyles does not patch the
|
||||
// gesture-handler ScrollView.
|
||||
function SidebarNavScroll({ closeGestureRef, windowContent, children }: SidebarNavScrollProps) {
|
||||
return (
|
||||
<>
|
||||
{platformIsNative ? (
|
||||
<GHScrollView
|
||||
// Same contract as the workspace list: vertical drags scroll the nav
|
||||
// block, a clear horizontal intent still activates the close pan.
|
||||
simultaneousHandlers={closeGestureRef}
|
||||
style={styles.navScroll}
|
||||
showsVerticalScrollIndicator={false}
|
||||
alwaysBounceVertical={false}
|
||||
testID="sidebar-nav-scroll"
|
||||
>
|
||||
{children}
|
||||
</GHScrollView>
|
||||
) : (
|
||||
<ScrollView
|
||||
dataSet={windowContent ? WINDOW_CONTENT_DATASET : undefined}
|
||||
style={styles.navScroll}
|
||||
showsVerticalScrollIndicator={false}
|
||||
alwaysBounceVertical={false}
|
||||
testID="sidebar-nav-scroll"
|
||||
>
|
||||
{children}
|
||||
</ScrollView>
|
||||
)}
|
||||
<SidebarSeparator />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function DesktopSidebar({
|
||||
theme,
|
||||
workspaceGroups,
|
||||
@@ -809,12 +844,11 @@ function DesktopSidebar({
|
||||
],
|
||||
[insetsTop, insets.bottom, insets.left, overlay, divisionLayout],
|
||||
);
|
||||
// Below the window controls' row, or in the top band's place, the first row starts flush.
|
||||
const inTopBand = useTopBand() !== null;
|
||||
const sidebarHeaderGroupStyle = useMemo(
|
||||
() => [styles.sidebarHeaderGroup, (ownsTopLeft || inTopBand) && styles.sidebarHeaderGroupFlush],
|
||||
[ownsTopLeft, inTopBand],
|
||||
);
|
||||
// Windows and Linux draw their window controls top-right, so the sidebar has no chrome
|
||||
// row there. The strip above the scrolling rows is then its window drag surface.
|
||||
const showsChromeRow = ownsTopLeft || Boolean(DEV_BUILD_LABEL);
|
||||
const showsDragStrip = !showsChromeRow && !inTopBand;
|
||||
return (
|
||||
<MobilePanelOverlay
|
||||
panel="agent-list"
|
||||
@@ -825,7 +859,7 @@ function DesktopSidebar({
|
||||
<Animated.View style={desktopSidebarStyle}>
|
||||
<View style={desktopSidebarBorderStyle}>
|
||||
<View style={styles.sidebarDragArea}>
|
||||
{ownsTopLeft || DEV_BUILD_LABEL ? (
|
||||
{showsChromeRow ? (
|
||||
<View style={styles.desktopChromeRow}>
|
||||
<TitlebarDragRegion />
|
||||
{DEV_BUILD_LABEL ? (
|
||||
@@ -842,11 +876,19 @@ function DesktopSidebar({
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
) : (
|
||||
<TitlebarDragRegion />
|
||||
)}
|
||||
<SidebarNavRows style={sidebarHeaderGroupStyle} onBeforeNavigate={closeSidebar} />
|
||||
) : null}
|
||||
{showsDragStrip ? (
|
||||
<View style={styles.desktopDragStrip}>
|
||||
<TitlebarDragRegion />
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
{/* The drag overlay stays above this viewport: Electron does not clip
|
||||
app-region rects to scroll viewports, so a scrolled-out row would
|
||||
still claim its no-drag rect. */}
|
||||
<SidebarNavScroll closeGestureRef={closeGestureRef} windowContent>
|
||||
<SidebarNavRows style={styles.sidebarHeaderGroup} onBeforeNavigate={closeSidebar} />
|
||||
</SidebarNavScroll>
|
||||
|
||||
<SidebarViewSlot dismiss={closeSidebar}>
|
||||
<SidebarToastRegion active={active}>
|
||||
@@ -935,19 +977,18 @@ const staticStyles = RNStyleSheet.create({
|
||||
});
|
||||
|
||||
const styles = StyleSheet.create((theme) => ({
|
||||
// The rows start flush: the chrome row, drag strip, or top band above them gives the inset.
|
||||
sidebarHeaderGroup: {
|
||||
paddingTop: theme.spacing[2],
|
||||
gap: 2,
|
||||
paddingBottom: theme.spacing[1.5],
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: theme.colors.border,
|
||||
},
|
||||
sidebarHeaderGroupFlush: {
|
||||
paddingTop: 0,
|
||||
desktopDragStrip: {
|
||||
position: "relative",
|
||||
height: theme.spacing[2],
|
||||
},
|
||||
// The nav block caps at half the sidebar; a long item list scrolls inside the
|
||||
// cap instead of crowding the workspace list off a short screen.
|
||||
mobileNavScroll: {
|
||||
navScroll: {
|
||||
flexGrow: 0,
|
||||
flexShrink: 1,
|
||||
maxHeight: "50%",
|
||||
|
||||
@@ -21,8 +21,7 @@ import {
|
||||
import { useLocalDaemonServerId } from "@/hooks/use-is-local-daemon";
|
||||
import { PairDeviceModal } from "@/desktop/components/pair-device-modal";
|
||||
import { buildSettingsHostSectionRoute } from "@/utils/host-routes";
|
||||
|
||||
const WINDOW_CONTENT_DATASET = { "window-content": "" };
|
||||
import { WINDOW_CONTENT_DATASET } from "@/components/desktop/titlebar-drag-region";
|
||||
|
||||
export function OpenProjectScreen() {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { test, expect } from "../../app/e2e/support/fixtures";
|
||||
import { gotoAppShell } from "../../app/e2e/support/helpers/app";
|
||||
|
||||
// Windows and Linux draw their window controls top-right, so the desktop sidebar has no
|
||||
// chrome row of its own. Its window-drag surface is the strip above the navigation rows.
|
||||
const CUSTOM_CHROME_HOSTS = [
|
||||
{ platform: "linux", windowChromeMode: "custom-linux" },
|
||||
{ platform: "win32", windowChromeMode: "custom-windows" },
|
||||
] as const;
|
||||
|
||||
async function installDesktopHost(
|
||||
page: Page,
|
||||
host: (typeof CUSTOM_CHROME_HOSTS)[number],
|
||||
): Promise<void> {
|
||||
await page.addInitScript((desktopHost) => {
|
||||
window.paseoDesktop = {
|
||||
...desktopHost,
|
||||
events: { on: () => () => {} },
|
||||
invoke: async (command: string) => {
|
||||
if (command === "get_desktop_settings") {
|
||||
return {
|
||||
releaseChannel: "stable",
|
||||
daemon: { manageBuiltInDaemon: true, keepRunningAfterQuit: true },
|
||||
};
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
}, host);
|
||||
}
|
||||
|
||||
async function sidebarDragGeometry(page: Page) {
|
||||
const navScroll = page.locator('[data-testid="sidebar-nav-scroll"]:visible').first();
|
||||
await expect(navScroll).toBeVisible();
|
||||
return navScroll.evaluate((node) => {
|
||||
const nav = node.getBoundingClientRect();
|
||||
const dragRegions = [];
|
||||
for (const element of document.querySelectorAll<HTMLElement>("*")) {
|
||||
if (getComputedStyle(element).getPropertyValue("-webkit-app-region") !== "drag") continue;
|
||||
const rect = element.getBoundingClientRect();
|
||||
const overSidebar = rect.left < nav.right && rect.right > nav.left;
|
||||
if (overSidebar && rect.height > 0) dragRegions.push({ top: rect.top, bottom: rect.bottom });
|
||||
}
|
||||
return { navTop: nav.top, navBottom: nav.bottom, dragRegions };
|
||||
});
|
||||
}
|
||||
|
||||
for (const host of CUSTOM_CHROME_HOSTS) {
|
||||
test.describe(`Desktop sidebar on ${host.platform}`, () => {
|
||||
test.use({ viewport: { width: 1280, height: 480 } });
|
||||
|
||||
test("keeps a window drag strip above the scrolling navigation", async ({ page }) => {
|
||||
await installDesktopHost(page, host);
|
||||
await gotoAppShell(page);
|
||||
|
||||
const geometry = await sidebarDragGeometry(page);
|
||||
expect(geometry.dragRegions).not.toEqual([]);
|
||||
for (const region of geometry.dragRegions) {
|
||||
expect(region.bottom).toBeLessThanOrEqual(geometry.navTop + 1);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user