mirror of
https://github.com/getpaseo/paseo.git
synced 2026-12-05 14:45:25 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
765aec33e5 |
@@ -175,7 +175,7 @@ The app runs on iOS, Android, web (browser), and web (Electron desktop). Code is
|
||||
| Use a native-only API (Haptics, push tokens, camera) | `if (isNative)` |
|
||||
| Use an Electron bridge (file dialog, titlebar, updates) | `if (getIsElectron())` |
|
||||
| Switch layout between phone and tablet/desktop | `useIsCompactFormFactor()` |
|
||||
| Show something on hover, always-visible on touch screens | `isHovered \|\| revealsWithoutHover` (see [docs/hover.md](docs/hover.md)) |
|
||||
| Show something on hover, always-visible on native | `isHovered \|\| isNative \|\| isCompact` (hover only works on web) |
|
||||
| Gate to iOS or Android specifically | `Platform.OS === "ios"` / `Platform.OS === "android"` (rare, keep inline) |
|
||||
|
||||
### Rules
|
||||
@@ -198,7 +198,7 @@ The app runs on iOS, Android, web (browser), and web (Electron desktop). Code is
|
||||
Import as `@/desktop/browser/pane` — Electron desktop gets the `.electron.tsx` file, browser web gets `.web.tsx`, and native gets the native/base implementation.
|
||||
- **NEVER use raw DOM APIs without `isWeb` guard.** DOM APIs crash native. Casting a RN ref to `HTMLElement` is a red flag — ensure the block is web-only.
|
||||
- **NEVER use `onPointerEnter`/`onPointerLeave`.** They don't fire on native iOS.
|
||||
- **Hover needs a mouse-like pointer.** React Native's `onHoverIn`/`onHoverOut` on `Pressable` does NOT fire on native iOS/iPad — the underlying W3C pointer events are behind disabled experimental flags. For hover-to-show UI (kebab menus, action buttons), call `useRevealsWithoutHover()` unconditionally, then use `isHovered || revealsWithoutHover` so the controls are always visible on touch screens and hover-to-show elsewhere. Don't use `isNative` for this: a native build is not the only touch-first surface, since a touch-first browser such as iPad Safari is `isWeb` but cannot hover.
|
||||
- **Hover only works on web.** React Native's `onHoverIn`/`onHoverOut` on `Pressable` does NOT fire on native iOS/iPad — the underlying W3C pointer events are behind disabled experimental flags. For hover-to-show UI (kebab menus, action buttons), use `isHovered || isNative || isCompact` so the controls are always visible on native and hover-to-show on web.
|
||||
- **Don't use Platform.OS as a proxy for layout capabilities.** Use breakpoints for layout decisions, not platform checks.
|
||||
- **Import `isWeb`/`isNative` from `@/constants/platform`.** Never write `const isWeb = Platform.OS === "web"` locally.
|
||||
|
||||
|
||||
+6
-7
@@ -111,18 +111,17 @@ rendered while the menu is up. `useOpenKebabMenuVisibility`
|
||||
sidebar rows: it owns `open`, hands the menu its controlled props, and ORs `open` into the
|
||||
row's own `showKebab`.
|
||||
|
||||
## Touch fallback
|
||||
## Native fallback
|
||||
|
||||
Hover doesn't exist on touch screens. Anything you hide behind hover must have a non-hover path on touch screens and compact layouts:
|
||||
Hover doesn't exist on touch devices. Anything you hide behind hover must have a non-hover path on native and compact layouts:
|
||||
|
||||
```tsx
|
||||
const revealsWithoutHover = useRevealsWithoutHover();
|
||||
const showControls = isHovered || revealsWithoutHover;
|
||||
const showControls = isHovered || isNative || isCompact;
|
||||
```
|
||||
|
||||
`useRevealsWithoutHover()` (`@/hooks/hover-reveal`) asks the pointer, not the platform: it is true when no mouse-like pointer drives the UI or the layout is compact. Don't use `isNative` for this. A touch-first browser such as iPad Safari is `isWeb` yet cannot hover, so `isNative` would leave its hover controls unreachable.
|
||||
`isNative` and `isCompact` come from `@/constants/platform` and `@/constants/layout`. Don't use `Platform.OS === "ios"` as a proxy.
|
||||
|
||||
`onPointerEnter` / `onPointerLeave` are DOM events. They fire on the web and do not fire on iOS or Android. You do not need to gate them: on a touch screen, hover is unreachable and visibility comes from `useRevealsWithoutHover()`. This is why the workspace row's pointer events are not wrapped in `if (isWeb)`.
|
||||
`onPointerEnter` / `onPointerLeave` are DOM events. They do not fire on native. You do not need to gate them — on native, hover is unreachable anyway and visibility is driven by `isNative` / `isCompact` in your show-the-controls expression above. This is why the workspace row's pointer events are not wrapped in `if (isWeb)`.
|
||||
|
||||
## What about `Pressable.onHoverIn` / `onHoverOut`?
|
||||
|
||||
@@ -149,7 +148,7 @@ Before opening a PR that touches hover:
|
||||
- [ ] The hover trigger's bounding box contains every element the user might mouse into while interacting with the feature.
|
||||
- [ ] Hovered state does **not** change the trigger's outer geometry (`width`, `height`, `padding`, `borderWidth`, mount/unmount of siblings that shift it). Internal swaps fit inside a fixed `minHeight` / `minWidth`.
|
||||
- [ ] Revealed content inside the trigger uses `opacity` + `pointerEvents`, not conditional rendering, if mounting it would reflow the trigger.
|
||||
- [ ] Visibility on touch screens and compact layouts works without hover (`isHovered || revealsWithoutHover`, with `useRevealsWithoutHover()` called unconditionally).
|
||||
- [ ] Visibility on native and compact layouts works without hover (`isHovered || isNative || isCompact`).
|
||||
- [ ] A menu opened from the revealed trigger keeps the trigger rendered while it is open, so losing hover can't strand it.
|
||||
- [ ] If the revealed content sits in a separate layer (portal, floating panel) and the user can point at it, it is a `HoverCard`.
|
||||
- [ ] You opened the dev server, hovered the trigger, and slowly moved the mouse along **every** revealed element — including any visible gaps — without losing hover state.
|
||||
|
||||
@@ -410,41 +410,3 @@ async function connectToTestHost(page: import("@playwright/test").Page) {
|
||||
await page.getByRole("button", { name: "Connect", exact: true }).click();
|
||||
await expect(page.getByTestId("add-host-modal")).toBeHidden({ timeout: 30_000 });
|
||||
}
|
||||
|
||||
test.describe("Settings host page on a wide touch screen", () => {
|
||||
test.use({ viewport: { width: 1400, height: 480 }, hasTouch: true, isMobile: true });
|
||||
|
||||
test("an info tip opened by a tap closes when the pane scrolls or another spot is tapped", async ({
|
||||
page,
|
||||
}) => {
|
||||
await gotoAppShell(page);
|
||||
await openSettings(page);
|
||||
await openSettingsHost(page, getServerId());
|
||||
|
||||
const infoTip = page
|
||||
.getByTestId("host-page-idle-runtime-cleanup-card")
|
||||
.getByRole("button", { name: /^About / });
|
||||
await infoTip.scrollIntoViewIfNeeded();
|
||||
await infoTip.tap();
|
||||
await expect(page.getByRole("tooltip")).toBeVisible();
|
||||
|
||||
await infoTip.evaluate((element) => {
|
||||
for (let node = element.parentElement; node; node = node.parentElement) {
|
||||
if (
|
||||
node.scrollHeight > node.clientHeight &&
|
||||
getComputedStyle(node).overflowY !== "visible"
|
||||
) {
|
||||
node.scrollTop += 40;
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new Error("The settings pane has nothing to scroll");
|
||||
});
|
||||
await expect(page.getByRole("tooltip")).toHaveCount(0);
|
||||
|
||||
await infoTip.tap();
|
||||
await expect(page.getByRole("tooltip")).toBeVisible();
|
||||
await page.getByTestId("host-page-identity").tap();
|
||||
await expect(page.getByRole("tooltip")).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -805,36 +805,3 @@ test.describe("Half-screen desktop layout", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Wide touch layout", () => {
|
||||
test.use({ viewport: { width: 1400, height: 900 }, hasTouch: true, isMobile: true });
|
||||
|
||||
test("tapping a sidebar row opens its workspace without a hover card and shows the row menu", async ({
|
||||
page,
|
||||
}) => {
|
||||
const workspace = await seedWorkspace({ repoPrefix: "sidebar-touch-tap-" });
|
||||
|
||||
try {
|
||||
const created = await workspace.client.createWorkspace({
|
||||
source: { kind: "directory", path: workspace.repoPath, projectId: workspace.projectId },
|
||||
title: "Tapped workspace",
|
||||
});
|
||||
if (!created.workspace) throw new Error(created.error ?? "Failed to create a second row");
|
||||
const tappedId = created.workspace.id;
|
||||
|
||||
await gotoAppShell(page);
|
||||
const row = await waitForSidebarWorkspace(page, tappedId);
|
||||
await expect(
|
||||
page.getByTestId(`sidebar-workspace-kebab-${getServerId()}:${tappedId}`),
|
||||
).toBeVisible();
|
||||
|
||||
await row.tap();
|
||||
await expect(page).toHaveURL(new RegExp(`/workspace/${escapeRegex(tappedId)}`), {
|
||||
timeout: 30_000,
|
||||
});
|
||||
await expectWorkspaceHoverCardClosed(page);
|
||||
} finally {
|
||||
await workspace.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,8 @@ import { type ReactNode, useCallback, useMemo, useState } from "react";
|
||||
import { Image, Pressable, Text, View } from "react-native";
|
||||
import { StyleSheet, withUnistyles } from "react-native-unistyles";
|
||||
import { X } from "lucide-react-native";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import { isNative } from "@/constants/platform";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import type { AttachmentMetadata } from "@/attachments/types";
|
||||
import { useAttachmentPreviewUrl } from "@/attachments/use-attachment-preview-url";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
@@ -30,9 +31,10 @@ export function AttachmentPill({
|
||||
testID,
|
||||
children,
|
||||
}: AttachmentPillProps) {
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const [isBodyHovered, setIsBodyHovered] = useState(false);
|
||||
const [isCloseHovered, setIsCloseHovered] = useState(false);
|
||||
const alwaysShow = useRevealsWithoutHover();
|
||||
const alwaysShow = isNative || isCompact;
|
||||
const showRemove = alwaysShow || isBodyHovered || isCloseHovered;
|
||||
const closeButtonStyle = useMemo(
|
||||
() => [styles.closeButton, !showRemove && styles.closeButtonHidden],
|
||||
|
||||
@@ -12,8 +12,7 @@ import { useTranslation } from "react-i18next";
|
||||
import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/ui/hover-card";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { isNative, isWeb } from "@/constants/platform";
|
||||
import { usePointerCapabilities } from "@/hooks/pointer-capabilities";
|
||||
import { isNative } from "@/constants/platform";
|
||||
import type { AgentMetric } from "@getpaseo/protocol/agent-types";
|
||||
import { useHostReportsUsage } from "@/usage";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
@@ -172,11 +171,8 @@ export function ContextWindowMeter({
|
||||
const showsUsage = useHostReportsUsage(serverId);
|
||||
const isWide = showsUsage || sessionMetrics.length > 0;
|
||||
const popoverWidth = Math.min(USAGE_POPOVER_WIDTH, width - 24);
|
||||
// Compact screens and touch-first browsers open the details in a sheet, which can hold a
|
||||
// pressable Refresh.
|
||||
// Compact screens open the details in a sheet, which can hold a pressable Refresh.
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const { finePointer } = usePointerCapabilities();
|
||||
const opensSheet = isCompact || (isWeb && !finePointer);
|
||||
const [isSheetOpen, setIsSheetOpen] = useState(false);
|
||||
const openSheet = useCallback(() => setIsSheetOpen(true), []);
|
||||
const closeSheet = useCallback(() => setIsSheetOpen(false), []);
|
||||
@@ -224,7 +220,7 @@ export function ContextWindowMeter({
|
||||
? t("contextWindow.accessibility", { percentage: context.percentage })
|
||||
: t("contextWindow.accessibilityNoData");
|
||||
|
||||
if (opensSheet) {
|
||||
if (isCompact) {
|
||||
return (
|
||||
<>
|
||||
<Pressable
|
||||
@@ -256,7 +252,7 @@ export function ContextWindowMeter({
|
||||
? [styles.usagePopover, { width: popoverWidth }]
|
||||
: styles.plainPopover;
|
||||
|
||||
// Wide native screens have no hover, so the details open in a tooltip on press. The tooltip
|
||||
// Native wide screens have no hover, so the details open in a tooltip on press. The tooltip
|
||||
// takes no presses, so its usage cards have no Refresh.
|
||||
if (isNative) {
|
||||
return (
|
||||
|
||||
@@ -4,8 +4,8 @@ import * as Clipboard from "expo-clipboard";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { HighlightToken } from "@getpaseo/highlight";
|
||||
import { BlockCopyButton } from "@/components/markdown/block-copy-button";
|
||||
import { isWeb } from "@/constants/platform";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import { isNative, isWeb } from "@/constants/platform";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { syntaxTokenStyleFor } from "@/styles/syntax-token-styles";
|
||||
import { CODE_SURFACE_DATASET } from "@/styles/code-surface";
|
||||
import { highlightToKeyedLines, type KeyedLine } from "@/utils/highlight-cache";
|
||||
@@ -87,11 +87,11 @@ export const HighlightedCodeBlock = React.memo(function HighlightedCodeBlock({
|
||||
);
|
||||
|
||||
const { t } = useTranslation();
|
||||
const revealsWithoutHover = useRevealsWithoutHover();
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const handlePointerEnter = useCallback(() => setIsHovered(true), []);
|
||||
const handlePointerLeave = useCallback(() => setIsHovered(false), []);
|
||||
const controlsVisible = isHovered || revealsWithoutHover;
|
||||
const controlsVisible = isHovered || isNative || isCompact;
|
||||
// Copy the code without its trailing blank lines. A fence body ends in a newline,
|
||||
// and ends in more than one when the author left a blank line before the closing
|
||||
// fence; pasting any of them into a terminal runs the last line.
|
||||
|
||||
@@ -26,8 +26,6 @@ import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { isNative, isWeb } from "@/constants/platform";
|
||||
import { useProvidersSnapshot } from "@/hooks/use-providers-snapshot";
|
||||
import { usePointerCapabilities } from "@/hooks/pointer-capabilities";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import { useRevealedText, type MarkdownPhase } from "@/hooks/use-revealed-text";
|
||||
import { ICON_SIZE, type Theme } from "@/styles/theme";
|
||||
import { inlineUnistylesStyle } from "@/styles/unistyles-inline-style";
|
||||
@@ -465,7 +463,7 @@ export const UserMessage = memo(function UserMessage({
|
||||
isPending = false,
|
||||
disableOuterSpacing,
|
||||
}: UserMessageProps) {
|
||||
const revealsWithoutHover = useRevealsWithoutHover();
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const { t } = useTranslation();
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const [lightboxMetadata, setLightboxMetadata] = useState<AttachmentMetadata | null>(null);
|
||||
@@ -478,7 +476,7 @@ export const UserMessage = memo(function UserMessage({
|
||||
const hasText = message.trim().length > 0;
|
||||
const hasImages = images.length > 0;
|
||||
const hasAttachments = attachments.length > 0;
|
||||
const showTrailingRow = !isPending && hasText && (revealsWithoutHover || isHovered);
|
||||
const showTrailingRow = !isPending && hasText && (isCompact || isNative || isHovered);
|
||||
const formattedTimestamp = useMemo(
|
||||
() => formatMessageTimestamp(new Date(timestamp)),
|
||||
[timestamp],
|
||||
@@ -682,7 +680,6 @@ export const AssistantTurnFooter = memo(function AssistantTurnFooter({
|
||||
metrics,
|
||||
}: AssistantTurnFooterProps) {
|
||||
const { t } = useTranslation();
|
||||
const { finePointer } = usePointerCapabilities();
|
||||
const [hovered, setHovered] = useState(false);
|
||||
const [pressedReveal, setPressedReveal] = useState(false);
|
||||
const revealTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
@@ -708,12 +705,12 @@ export const AssistantTurnFooter = memo(function AssistantTurnFooter({
|
||||
|
||||
const primaryLabel = durationLabel || timestampLabel;
|
||||
const canSwap = Boolean(durationLabel && timestampLabel);
|
||||
const showTimestamp = canSwap && (finePointer ? hovered : pressedReveal);
|
||||
const showTimestamp = canSwap && (isWeb ? hovered : pressedReveal);
|
||||
|
||||
const handleHoverIn = useCallback(() => setHovered(true), []);
|
||||
const handleHoverOut = useCallback(() => setHovered(false), []);
|
||||
const handlePress = useCallback(() => {
|
||||
if (finePointer || !canSwap) return;
|
||||
if (isWeb || !canSwap) return;
|
||||
if (revealTimerRef.current) {
|
||||
clearTimeout(revealTimerRef.current);
|
||||
}
|
||||
@@ -722,7 +719,7 @@ export const AssistantTurnFooter = memo(function AssistantTurnFooter({
|
||||
setPressedReveal(false);
|
||||
revealTimerRef.current = null;
|
||||
}, TIMESTAMP_REVEAL_MS);
|
||||
}, [canSwap, finePointer]);
|
||||
}, [canSwap]);
|
||||
const handleFork = useCallback(
|
||||
(target: AssistantForkTarget) => {
|
||||
return onFork?.(target);
|
||||
|
||||
@@ -60,10 +60,9 @@ import { useRevealActiveFlatListRow, useRevealActiveItem } from "@/components/ui
|
||||
import type { EditingTextInputHandle } from "@/components/ui/text-input";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { useProviderIcon } from "@/components/provider-icons";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { isNative } from "@/constants/platform";
|
||||
import { usesDesktopPopoverSpacing } from "@/constants/presentation";
|
||||
import { usePointerCapabilities } from "@/hooks/pointer-capabilities";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import {
|
||||
hasSoftwareKeyboard,
|
||||
useHardwareKeyboardPresent,
|
||||
@@ -150,7 +149,7 @@ function ProviderSettingsAction({
|
||||
|
||||
/**
|
||||
* An icon button that explains itself in a tooltip on desktop hover. Tooltips
|
||||
* need a hovering pointer, so a touch screen renders the shared gesture-aware pressable
|
||||
* never open on mobile, so native renders the shared gesture-aware pressable
|
||||
* instead of a plain Pressable: inside the model list's independent scroll
|
||||
* viewport (Android, wide windows) the native scroll gesture cancels a plain
|
||||
* Pressable's touches and the button would never fire.
|
||||
@@ -170,8 +169,7 @@ function IconActionButton({
|
||||
| ((state: PressableStateCallbackType & { hovered?: boolean }) => StyleProp<ViewStyle>);
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const { finePointer } = usePointerCapabilities();
|
||||
if (!finePointer) {
|
||||
if (isNative) {
|
||||
return (
|
||||
<ModelBrowserPressable
|
||||
onPress={onPress}
|
||||
@@ -828,8 +826,8 @@ function ModelRowProfileAction({
|
||||
testID: string;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const revealsWithoutHover = useRevealsWithoutHover();
|
||||
const visible = hovered || revealsWithoutHover;
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const visible = hovered || isNative || isCompact;
|
||||
const pressableStyle = useCallback(
|
||||
({ hovered: buttonHovered, pressed }: PressableStateCallbackType & { hovered?: boolean }) => [
|
||||
styles.rowIconButton,
|
||||
|
||||
@@ -56,7 +56,6 @@ import {
|
||||
import { useSidebarCollapsedSectionsStore } from "@/stores/sidebar-collapsed-sections-store";
|
||||
import { useHostFeatureMap } from "@/runtime/host-features";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import { useProjectIcons } from "@/projects/icons";
|
||||
import {
|
||||
buildNewWorkspaceRoute,
|
||||
@@ -423,6 +422,7 @@ function ProjectRowTrailingActions({
|
||||
settingsTarget,
|
||||
projectPath,
|
||||
isHovered,
|
||||
isMobileBreakpoint,
|
||||
isProjectActive,
|
||||
onBeginWorkspaceSetup,
|
||||
onRemoveProject,
|
||||
@@ -434,13 +434,13 @@ function ProjectRowTrailingActions({
|
||||
settingsTarget: { serverId: string; projectId: string } | null;
|
||||
projectPath: string;
|
||||
isHovered: boolean;
|
||||
isMobileBreakpoint: boolean;
|
||||
isProjectActive: boolean;
|
||||
onBeginWorkspaceSetup: () => void;
|
||||
onRemoveProject?: () => void;
|
||||
removeProjectStatus: "idle" | "pending" | "success";
|
||||
}) {
|
||||
const revealsWithoutHover = useRevealsWithoutHover();
|
||||
const actionsVisible = isHovered || revealsWithoutHover;
|
||||
const actionsVisible = isHovered || platformIsNative || isMobileBreakpoint;
|
||||
return (
|
||||
<View style={styles.projectTrailingActions}>
|
||||
{worktreeTarget ? (
|
||||
@@ -907,6 +907,7 @@ function ProjectHeaderRow({
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const [isHighlighted, setIsHighlighted] = useState(false);
|
||||
const [contextMenuOpen, setContextMenuOpen] = useState(false);
|
||||
const isMobileBreakpoint = useIsCompactFormFactor();
|
||||
const localDaemonServerId = useLocalDaemonServerId();
|
||||
const projectPath = resolveSidebarProjectLocalPath(project, localDaemonServerId);
|
||||
const settingsTarget = project.hosts[0] ?? null;
|
||||
@@ -989,6 +990,7 @@ function ProjectHeaderRow({
|
||||
settingsTarget={settingsTarget}
|
||||
projectPath={projectPath}
|
||||
isHovered={isHovered}
|
||||
isMobileBreakpoint={isMobileBreakpoint}
|
||||
isProjectActive={isProjectActive}
|
||||
onBeginWorkspaceSetup={handleBeginWorkspaceSetup}
|
||||
onRemoveProject={onRemoveProject}
|
||||
@@ -1102,13 +1104,11 @@ function WorkspaceRowInner({
|
||||
onTogglePin,
|
||||
reserveIdleStatusIndicatorSpace = true,
|
||||
}: WorkspaceRowInnerProps) {
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const [isHighlighted, setIsHighlighted] = useState(false);
|
||||
const isSelectionMode = useIsSidebarSelectionMode();
|
||||
const isBulkSelected = useIsWorkspaceBulkSelected(workspace.workspaceKey);
|
||||
const isTouchPlatform = useRevealsWithoutHover();
|
||||
// Service status is row metadata, not a hover control: it follows the layout, not the pointer.
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const showsServiceStatus = !(platformIsNative || isCompact);
|
||||
const isTouchPlatform = platformIsNative || isCompact;
|
||||
const interaction = useLongPressDragInteraction({
|
||||
drag,
|
||||
menuController,
|
||||
@@ -1149,9 +1149,8 @@ function WorkspaceRowInner({
|
||||
showArchiveIndicator={showArchiveIndicator}
|
||||
>
|
||||
{({ isHovered, contextMenuOpen, onContextMenuOpenChange, hoverHandlers }) => {
|
||||
const serviceSummary = showsServiceStatus
|
||||
? selectWorkspaceServiceSummary(workspace.scripts)
|
||||
: null;
|
||||
const isDesktop = !isTouchPlatform;
|
||||
const serviceSummary = isDesktop ? selectWorkspaceServiceSummary(workspace.scripts) : null;
|
||||
const workspaceRowStyle = getProjectWorkspaceRowStyle({
|
||||
isDragging,
|
||||
selected: rowSelected,
|
||||
|
||||
@@ -4,7 +4,8 @@ import { ChevronDown, ChevronRight } from "lucide-react-native";
|
||||
import { Text, View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { DensityIcon } from "@/components/ui/density-icon";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { isNative } from "@/constants/platform";
|
||||
import { density } from "@/styles/density";
|
||||
|
||||
/** A sidebar section label such as "Pinned" or "Workspaces". A section with `onToggle`
|
||||
@@ -52,7 +53,7 @@ function CollapsibleTitle({
|
||||
onToggle: () => void;
|
||||
testID?: string;
|
||||
}) {
|
||||
const revealsWithoutHover = useRevealsWithoutHover();
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const accessibilityState = useMemo(() => ({ expanded: !collapsed }), [collapsed]);
|
||||
|
||||
return (
|
||||
@@ -66,7 +67,7 @@ function CollapsibleTitle({
|
||||
{({ hovered }) => (
|
||||
<>
|
||||
<Text style={styles.title}>{title}</Text>
|
||||
{hovered || revealsWithoutHover ? (
|
||||
{hovered || isNative || isCompact ? (
|
||||
<DensityIcon
|
||||
icon={collapsed ? ChevronRight : ChevronDown}
|
||||
size="xs"
|
||||
|
||||
@@ -24,7 +24,6 @@ import { SidebarFilterEmptyState } from "@/components/sidebar/empty-states";
|
||||
import type { HostBadgeModel } from "@/hosts/appearance";
|
||||
import { isWeb as platformIsWeb, isNative as platformIsNative } from "@/constants/platform";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { density, densityIconBox, densityIconProps } from "@/styles/density";
|
||||
import type { SidebarSurfaceBackdrop } from "@/styles/surface-backdrop";
|
||||
@@ -910,10 +909,8 @@ function StatusWorkspaceRowInnerContent({
|
||||
}: StatusWorkspaceRowInnerProps & {
|
||||
dragInteraction?: ReturnType<typeof useLongPressDragInteraction>;
|
||||
}) {
|
||||
const isTouchPlatform = useRevealsWithoutHover();
|
||||
// Service status is row metadata, not a hover control: it follows the layout, not the pointer.
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const showsServiceStatus = !(platformIsNative || isCompact);
|
||||
const isTouchPlatform = platformIsNative || isCompact;
|
||||
const [isHighlighted, setIsHighlighted] = useState(false);
|
||||
const isSelectionMode = useIsSidebarSelectionMode();
|
||||
const isBulkSelected = useIsWorkspaceBulkSelected(workspace.workspaceKey);
|
||||
@@ -925,9 +922,8 @@ function StatusWorkspaceRowInnerContent({
|
||||
...dragAttributes
|
||||
} = dragHandleProps?.attributes ?? {};
|
||||
|
||||
const serviceSummary = showsServiceStatus
|
||||
? selectWorkspaceServiceSummary(workspace.scripts)
|
||||
: null;
|
||||
const isDesktop = !isTouchPlatform;
|
||||
const serviceSummary = isDesktop ? selectWorkspaceServiceSummary(workspace.scripts) : null;
|
||||
|
||||
const rowSelected = isSelectionMode ? isBulkSelected : selected;
|
||||
const accessibilityState = useMemo(
|
||||
|
||||
@@ -13,8 +13,7 @@ import {
|
||||
import { PressHighlight } from "@/components/ui/press-highlight";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { isNative, isWeb } from "@/constants/platform";
|
||||
import { usePointerCapabilities } from "@/hooks/pointer-capabilities";
|
||||
import { isNative } from "@/constants/platform";
|
||||
import { ICON_SIZE, type Theme } from "@/styles/theme";
|
||||
import { DetailsSheet } from "./details-sheet";
|
||||
import { MetricsList } from "./metrics-list";
|
||||
@@ -25,8 +24,7 @@ const foregroundMutedColorMapping = (theme: Theme) => ({ color: theme.colors.for
|
||||
|
||||
/**
|
||||
* The turn footer's stats button: what the provider reported about this turn, in a hover card on
|
||||
* desktop, a tooltip opened by press on wide native screens, and a sheet on compact screens and
|
||||
* touch-first browsers.
|
||||
* web, a tooltip opened by press on native wide screens, and a sheet on compact screens.
|
||||
*/
|
||||
export const TurnMetricsButton = memo(function TurnMetricsButton({
|
||||
metrics,
|
||||
@@ -34,8 +32,7 @@ export const TurnMetricsButton = memo(function TurnMetricsButton({
|
||||
metrics: AgentMetric[];
|
||||
}) {
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const { finePointer } = usePointerCapabilities();
|
||||
if (isCompact || (isWeb && !finePointer)) return <TurnMetricsSheetButton metrics={metrics} />;
|
||||
if (isCompact) return <TurnMetricsSheetButton metrics={metrics} />;
|
||||
if (isNative) return <TurnMetricsTooltipButton metrics={metrics} />;
|
||||
return <TurnMetricsHoverCardButton metrics={metrics} />;
|
||||
});
|
||||
|
||||
@@ -20,7 +20,6 @@ import { OverlayLayerProvider, useOverlayLayer } from "@/lib/overlay-root";
|
||||
import { FloatingSurface } from "@/components/ui/floating";
|
||||
import { useFloatingPanelPortalHostName } from "@/components/ui/floating-panel-portal";
|
||||
import { isWeb } from "@/constants/platform";
|
||||
import { usePointerCapabilities } from "@/hooks/pointer-capabilities";
|
||||
import { useHoverSafeZone } from "@/hooks/use-hover-safe-zone";
|
||||
import { computePosition, type Alignment, type Placement, type Rect } from "./anchor";
|
||||
|
||||
@@ -44,8 +43,8 @@ const HoverCardContext = createContext<HoverCardContextValue | null>(null);
|
||||
|
||||
/**
|
||||
* A card that opens while the pointer is on its trigger and stays open while the pointer crosses
|
||||
* onto it, so its content can be pressed. Only a mouse-like pointer hovers; on a touch screen the
|
||||
* trigger renders alone and the content never mounts. See docs/hover.md.
|
||||
* onto it, so its content can be pressed. Hover only exists on web; elsewhere the trigger renders
|
||||
* alone and the content never mounts. See docs/hover.md.
|
||||
*
|
||||
* ```tsx
|
||||
* <HoverCard>
|
||||
@@ -62,8 +61,7 @@ export function HoverCard({
|
||||
disabled?: boolean;
|
||||
children: ReactNode;
|
||||
}): ReactNode {
|
||||
const { finePointer } = usePointerCapabilities();
|
||||
if (!finePointer) return children;
|
||||
if (!isWeb) return children;
|
||||
return <WebHoverCard disabled={disabled}>{children}</WebHoverCard>;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,10 @@ import {
|
||||
} from "react-native";
|
||||
import { FadeIn, FadeOut } from "react-native-reanimated";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { FloatingSurface } from "@/components/ui/floating";
|
||||
import { useRetainedPanelActive } from "@/components/retained-panel";
|
||||
import { isWeb } from "@/constants/platform";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import { usePointerCapabilities } from "@/hooks/pointer-capabilities";
|
||||
import { isNative, isWeb } from "@/constants/platform";
|
||||
import { getOverlayRoot, OVERLAY_Z } from "@/lib/overlay-root";
|
||||
import { holdSurfaceEdge, surfaceFrameStyles, type SurfacePosition } from "./anchor";
|
||||
|
||||
@@ -51,8 +50,6 @@ interface TooltipContextValue {
|
||||
triggerRef: React.RefObject<TooltipTriggerElement | null>;
|
||||
enabled: boolean;
|
||||
openOnPress: boolean;
|
||||
/** A mouse-like pointer drives the UI, so entering and leaving the trigger opens and closes it. */
|
||||
opensOnHover: boolean;
|
||||
delayDuration: number;
|
||||
}
|
||||
|
||||
@@ -260,12 +257,9 @@ export function Tooltip({
|
||||
onOpenChange,
|
||||
});
|
||||
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const active = useRetainedPanelActive();
|
||||
// Where nothing hovers, a press opens the tooltip instead.
|
||||
const opensOnPress = useRevealsWithoutHover();
|
||||
// A touch fires compatibility mouse events around its tap, which would close the tooltip the tap
|
||||
// just opened.
|
||||
const { finePointer: opensOnHover } = usePointerCapabilities();
|
||||
const opensOnPress = isNative || isCompact;
|
||||
const enabled = active && (opensOnPress ? enabledOnMobile : enabledOnDesktop);
|
||||
|
||||
// Remove the portal in the inactive commit, before the retained chat freezes.
|
||||
@@ -281,10 +275,9 @@ export function Tooltip({
|
||||
triggerRef,
|
||||
enabled,
|
||||
openOnPress: opensOnPress,
|
||||
opensOnHover,
|
||||
delayDuration,
|
||||
}),
|
||||
[isOpen, setIsOpen, enabled, opensOnPress, opensOnHover, delayDuration],
|
||||
[isOpen, setIsOpen, enabled, opensOnPress, delayDuration],
|
||||
);
|
||||
|
||||
return <TooltipContext.Provider value={value}>{children}</TooltipContext.Provider>;
|
||||
@@ -352,17 +345,17 @@ export function TooltipTrigger({
|
||||
const handleHoverIn = useCallback(
|
||||
(e?: unknown) => {
|
||||
if (isCallable(onHoverIn)) onHoverIn(e);
|
||||
if (ctx.opensOnHover) scheduleOpen();
|
||||
scheduleOpen();
|
||||
},
|
||||
[ctx.opensOnHover, onHoverIn, scheduleOpen],
|
||||
[onHoverIn, scheduleOpen],
|
||||
);
|
||||
|
||||
const handleHoverOut = useCallback(
|
||||
(e?: unknown) => {
|
||||
if (isCallable(onHoverOut)) onHoverOut(e);
|
||||
if (ctx.opensOnHover) close();
|
||||
close();
|
||||
},
|
||||
[ctx.opensOnHover, onHoverOut, close],
|
||||
[onHoverOut, close],
|
||||
);
|
||||
|
||||
const handleFocus = useCallback(
|
||||
@@ -539,26 +532,6 @@ export function TooltipContent({
|
||||
|
||||
const handleDismiss = useCallback(() => ctx.setOpen(false), [ctx]);
|
||||
|
||||
// A tooltip opened by a tap has no pointer leaving to close it, and the web measures its anchor
|
||||
// once. It closes on a tap elsewhere, and when the page scrolls it would sit over other content.
|
||||
const closesOnTouchDismiss = isWeb && ctx.openOnPress && ctx.open;
|
||||
useEffect(() => {
|
||||
if (!closesOnTouchDismiss) return;
|
||||
const dismissOutsideTrigger = (event: Event) => {
|
||||
const trigger = ctx.triggerRef.current;
|
||||
if (trigger instanceof HTMLElement && event.target instanceof Node) {
|
||||
if (trigger.contains(event.target)) return;
|
||||
}
|
||||
handleDismiss();
|
||||
};
|
||||
window.addEventListener("scroll", handleDismiss, { capture: true, passive: true });
|
||||
window.addEventListener("pointerdown", dismissOutsideTrigger, { capture: true });
|
||||
return () => {
|
||||
window.removeEventListener("scroll", handleDismiss, { capture: true });
|
||||
window.removeEventListener("pointerdown", dismissOutsideTrigger, { capture: true });
|
||||
};
|
||||
}, [closesOnTouchDismiss, ctx.triggerRef, handleDismiss]);
|
||||
|
||||
if (!ctx.open || !ctx.enabled) return null;
|
||||
|
||||
// On web, avoid React Native's <Modal/> implementation (it uses <dialog> and can
|
||||
|
||||
@@ -35,7 +35,7 @@ import { useSessionStore } from "@/stores/session-store";
|
||||
import { useWorkspaceAttachmentsStore } from "@/attachments/workspace-attachments-store";
|
||||
import { useToast } from "@/contexts/toast-context";
|
||||
import { useCheckoutGitActionsStore } from "@/git/actions-store";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import { isNative } from "@/constants/platform";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import {
|
||||
PaneContentToolbar,
|
||||
@@ -659,12 +659,12 @@ function TimelineEntryCard({
|
||||
}
|
||||
|
||||
function useRevealOnHover() {
|
||||
const revealsWithoutHover = useRevealsWithoutHover();
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
const handlePointerEnter = useCallback(() => setIsHovered(true), []);
|
||||
const handlePointerLeave = useCallback(() => setIsHovered(false), []);
|
||||
const actionsVisible = isHovered || menuOpen || revealsWithoutHover;
|
||||
const actionsVisible = isHovered || menuOpen || isNative || isCompact;
|
||||
return { actionsVisible, handlePointerEnter, handlePointerLeave, setMenuOpen };
|
||||
}
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveRevealsWithoutHover } from "./hover-reveal";
|
||||
import { createPointerCapabilitiesSource, type PointerCapabilities } from "./pointer-capabilities";
|
||||
|
||||
function browserPointer(queries: Record<string, boolean>): PointerCapabilities {
|
||||
const matchMedia = (query: string) =>
|
||||
({
|
||||
matches: queries[query],
|
||||
addEventListener() {},
|
||||
removeEventListener() {},
|
||||
}) as unknown as MediaQueryList;
|
||||
return createPointerCapabilitiesSource(matchMedia).getSnapshot();
|
||||
}
|
||||
|
||||
const desktopBrowser = browserPointer({
|
||||
"(hover: hover) and (pointer: fine)": true,
|
||||
"(any-pointer: coarse)": false,
|
||||
"(pointer: coarse)": false,
|
||||
});
|
||||
// iPad Safari: a wide web layout that no mouse drives.
|
||||
const touchBrowser = browserPointer({
|
||||
"(hover: hover) and (pointer: fine)": false,
|
||||
"(any-pointer: coarse)": true,
|
||||
"(pointer: coarse)": true,
|
||||
});
|
||||
const nativeTouch: PointerCapabilities = { finePointer: false, touchScreen: true };
|
||||
|
||||
describe("hover-revealed controls per target", () => {
|
||||
it("hides them until hover on a desktop browser", () => {
|
||||
expect(resolveRevealsWithoutHover(desktopBrowser, false)).toBe(false);
|
||||
});
|
||||
|
||||
it("pins them on a touch screen, native or in a wide browser", () => {
|
||||
expect(resolveRevealsWithoutHover(nativeTouch, false)).toBe(true);
|
||||
expect(resolveRevealsWithoutHover(touchBrowser, false)).toBe(true);
|
||||
});
|
||||
|
||||
it("pins them in the compact layout whatever the pointer", () => {
|
||||
expect(resolveRevealsWithoutHover(desktopBrowser, true)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,19 +0,0 @@
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { usePointerCapabilities, type PointerCapabilities } from "@/hooks/pointer-capabilities";
|
||||
|
||||
/**
|
||||
* Whether controls a hover would reveal stay visible instead: the pointer
|
||||
* cannot hover (a touch screen), or the compact layout shows them anyway.
|
||||
* Ask this rather than `isNative`: a touch-first browser such as iPad Safari
|
||||
* is web yet cannot hover.
|
||||
*/
|
||||
export function resolveRevealsWithoutHover(
|
||||
pointer: PointerCapabilities,
|
||||
isCompact: boolean,
|
||||
): boolean {
|
||||
return !pointer.finePointer || isCompact;
|
||||
}
|
||||
|
||||
export function useRevealsWithoutHover(): boolean {
|
||||
return resolveRevealsWithoutHover(usePointerCapabilities(), useIsCompactFormFactor());
|
||||
}
|
||||
@@ -39,7 +39,6 @@ import type {
|
||||
DraggableRenderItemInfo,
|
||||
} from "@/components/draggable-list.types";
|
||||
import { isNative, isWeb } from "@/constants/platform";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import {
|
||||
ContextMenu,
|
||||
ContextMenuContent,
|
||||
@@ -796,7 +795,7 @@ function TabChip({
|
||||
const middleClickRef = useMiddleClickClose(
|
||||
useCallback(() => void onCloseTab(tab.tabId), [onCloseTab, tab.tabId]),
|
||||
);
|
||||
const revealsWithoutHover = useRevealsWithoutHover();
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const [hovered, setHovered] = useState(false);
|
||||
// An active tab in a pane that does not have focus stays legible but quiet: it keeps the fill of
|
||||
// a hovered chip and the muted label, so only one chip in the window reads as the live one.
|
||||
@@ -809,7 +808,7 @@ function TabChip({
|
||||
isActiveFocused,
|
||||
isFilled,
|
||||
});
|
||||
const showCloseControl = showCloseButton && (isHovered || revealsWithoutHover || isClosingTab);
|
||||
const showCloseControl = showCloseButton && (isHovered || isNative || isCompact || isClosingTab);
|
||||
const closeButtonDragBlockers = isWeb
|
||||
? ({
|
||||
onPointerDown: (event: { stopPropagation?: () => void }) => {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { ComposerTrackActions, ComposerTrackPill, ComposerTrackRow } from "@/com
|
||||
import { mutedIconColorMapping } from "@/components/ui/icon-button-chrome";
|
||||
import { ToolbarButton, paneContentToolbarIconSize } from "@/components/ui/pane-content-toolbar";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import { isNative } from "@/constants/platform";
|
||||
import {
|
||||
WorkspaceTabIcon,
|
||||
type WorkspaceTabPresentation,
|
||||
@@ -207,7 +207,6 @@ function SubagentsTrackRow({
|
||||
}: SubagentsTrackRowProps): ReactElement {
|
||||
const { t } = useTranslation();
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const revealsWithoutHover = useRevealsWithoutHover();
|
||||
const rowServerId = row.kind === "paseo" ? row.address.serverId : serverId;
|
||||
const hostLabel = useHosts().find((host) => host.serverId === rowServerId)?.label ?? rowServerId;
|
||||
const presentation = useRowPresentation(row, rowServerId);
|
||||
@@ -226,7 +225,7 @@ function SubagentsTrackRow({
|
||||
const handleDetachPress = useCallback(() => {
|
||||
if (row.kind === "paseo") onDetachSubagent?.(row.address);
|
||||
}, [onDetachSubagent, row]);
|
||||
const actionsAlwaysVisible = revealsWithoutHover;
|
||||
const actionsAlwaysVisible = isNative || isCompact;
|
||||
|
||||
const renderRow = useCallback(
|
||||
({ active }: { active: boolean }) => (
|
||||
|
||||
@@ -13,7 +13,7 @@ import { LoadingSpinner } from "@/components/ui/loading-spinner";
|
||||
import { ToolbarButton, paneContentToolbarIconSize } from "@/components/ui/pane-content-toolbar";
|
||||
import { StatusBadge } from "@/components/ui/status-badge";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import { isNative } from "@/constants/platform";
|
||||
import type { TFunction } from "i18next";
|
||||
import { useCallback } from "react";
|
||||
import { UsageBalanceBar } from "./balance-bar";
|
||||
@@ -67,10 +67,9 @@ export function UsageCard({
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const revealsWithoutHover = useRevealsWithoutHover();
|
||||
const { refresh, refreshState } = useReportRefresh(serverId, entry, agentId);
|
||||
// Where there is no hover the freshness is printed on the card; elsewhere the Refresh tooltip.
|
||||
const showsFreshnessInline = revealsWithoutHover || !refreshable;
|
||||
const showsFreshnessInline = isNative || isCompact || !refreshable;
|
||||
const usage = entry.report;
|
||||
const status = statusText(usage, t);
|
||||
// A failure that says when it is retried counts down to that time.
|
||||
|
||||
@@ -3,7 +3,8 @@ import { View } from "react-native";
|
||||
import { StyleSheet } from "react-native-unistyles";
|
||||
import { DraggableList } from "@/components/draggable-list";
|
||||
import type { DraggableRenderItemInfo } from "@/components/draggable-list.types";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { isNative } from "@/constants/platform";
|
||||
import { settingsStyles } from "@/styles/settings";
|
||||
import { UsageCard } from "./card";
|
||||
import type { UsageDisplay } from "./display";
|
||||
@@ -80,7 +81,7 @@ function UsageListCard({
|
||||
pinnable: boolean;
|
||||
dragging: boolean;
|
||||
}) {
|
||||
const revealsWithoutHover = useRevealsWithoutHover();
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const handlePointerEnter = useCallback(() => setIsHovered(true), []);
|
||||
const handlePointerLeave = useCallback(() => setIsHovered(false), []);
|
||||
@@ -90,9 +91,9 @@ function UsageListCard({
|
||||
const handleBlur = useCallback(() => setHasFocus(false), []);
|
||||
const arrangement = useMemo(
|
||||
() => ({
|
||||
handleVisible: isHovered || hasFocus || dragging || revealsWithoutHover,
|
||||
handleVisible: isHovered || hasFocus || dragging || isNative || isCompact,
|
||||
}),
|
||||
[dragging, hasFocus, isHovered, revealsWithoutHover],
|
||||
[dragging, hasFocus, isCompact, isHovered],
|
||||
);
|
||||
return (
|
||||
<View
|
||||
|
||||
@@ -19,7 +19,8 @@ import { HostFilter } from "@/components/hosts/host-filter";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import type { ControlSize } from "@/components/ui/control-geometry";
|
||||
import { Field, FormTextInput } from "@/components/ui/form-field";
|
||||
import { useRevealsWithoutHover } from "@/hooks/hover-reveal";
|
||||
import { useIsCompactFormFactor } from "@/constants/layout";
|
||||
import { isNative } from "@/constants/platform";
|
||||
import { useHosts } from "@/runtime/host-runtime";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
import { confirmDialog } from "@/utils/confirm-dialog";
|
||||
@@ -244,12 +245,12 @@ function WorkspaceLabelManagerRow({
|
||||
onEdit: (label: WorkspaceLabelDefinition) => void;
|
||||
}): ReactElement {
|
||||
const { t } = useTranslation();
|
||||
const revealsWithoutHover = useRevealsWithoutHover();
|
||||
const isCompact = useIsCompactFormFactor();
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const handlePointerEnter = useCallback(() => setIsHovered(true), []);
|
||||
const handlePointerLeave = useCallback(() => setIsHovered(false), []);
|
||||
const edit = useCallback(() => onEdit(label), [label, onEdit]);
|
||||
const revealed = isHovered || revealsWithoutHover;
|
||||
const revealed = isHovered || isNative || isCompact;
|
||||
const editStyle = useCallback(
|
||||
({ pressed }: PressableStateCallbackType) => [
|
||||
styles.rowEdit,
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
// A CI runner has no pointing device, and its Chromium reports a coarse pointer whatever the launch
|
||||
// flags say. Browser tests run as on a desktop with a mouse: hover cards open on hover and
|
||||
// hover-revealed controls wait for hover. Everything else reads the real media queries.
|
||||
const DESKTOP_POINTER: Record<string, boolean> = {
|
||||
"(hover: hover) and (pointer: fine)": true,
|
||||
"(any-pointer: coarse)": false,
|
||||
"(pointer: coarse)": false,
|
||||
};
|
||||
|
||||
const realMatchMedia = window.matchMedia.bind(window);
|
||||
|
||||
window.matchMedia = (query: string): MediaQueryList => {
|
||||
const list = realMatchMedia(query);
|
||||
if (!(query in DESKTOP_POINTER)) return list;
|
||||
return new Proxy(list, {
|
||||
get(target, property) {
|
||||
if (property === "matches") return DESKTOP_POINTER[query];
|
||||
const value = Reflect.get(target, property, target);
|
||||
return typeof value === "function" ? value.bind(target) : value;
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -149,16 +149,11 @@ export default defineConfig({
|
||||
name: "browser",
|
||||
fileParallelism: false,
|
||||
include: ["src/**/*.browser.{test,spec}.{ts,tsx}"],
|
||||
setupFiles: [path.resolve(__dirname, "vitest.browser.setup.ts")],
|
||||
browser: {
|
||||
enabled: true,
|
||||
provider: playwright({
|
||||
launchOptions: {
|
||||
args: [
|
||||
// Exercise real WebGL glyph rendering on GPU-less CI runners.
|
||||
"--enable-unsafe-swiftshader",
|
||||
],
|
||||
},
|
||||
// Exercise real WebGL glyph rendering on GPU-less CI runners.
|
||||
launchOptions: { args: ["--enable-unsafe-swiftshader"] },
|
||||
}),
|
||||
headless: true,
|
||||
connectTimeout: 180_000,
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
validatePort,
|
||||
validateSshHost,
|
||||
} from "@getpaseo/protocol/ssh-transport";
|
||||
import { stripAppImageRuntimeEnv } from "@getpaseo/server/process";
|
||||
import { stripLinuxDesktopRuntimeEnv } from "@getpaseo/server/process";
|
||||
|
||||
export interface SshProxyTarget {
|
||||
host: string;
|
||||
@@ -59,7 +59,7 @@ export function buildSshSpawnEnv(
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
): NodeJS.ProcessEnv {
|
||||
const env = { ...baseEnv };
|
||||
stripAppImageRuntimeEnv(env, { platform });
|
||||
stripLinuxDesktopRuntimeEnv(env, { platform });
|
||||
return env;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { existsSync as nodeExistsSync, readdirSync as nodeReaddirSync } from "no
|
||||
import { readFile } from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path, { posix, win32 } from "node:path";
|
||||
import { stripAppImageRuntimeEnv } from "@getpaseo/server/process";
|
||||
import { stripLinuxDesktopRuntimeEnv } from "@getpaseo/server/process";
|
||||
import { app, shell } from "electron";
|
||||
|
||||
import type {
|
||||
@@ -53,7 +53,7 @@ function createExternalProcessEnv(
|
||||
for (const key of RUNTIME_CONTROL_ENV_KEYS) {
|
||||
delete env[key];
|
||||
}
|
||||
stripAppImageRuntimeEnv(env, { platform });
|
||||
stripLinuxDesktopRuntimeEnv(env, { platform });
|
||||
for (const [key, value] of Object.entries(env)) {
|
||||
if (value === undefined) {
|
||||
delete env[key];
|
||||
|
||||
@@ -7,7 +7,7 @@ import { spawnSync as defaultSpawnSync } from "node:child_process";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { userInfo as defaultUserInfo } from "node:os";
|
||||
import { basename } from "node:path";
|
||||
import { stripAppImageRuntimeEnv } from "@getpaseo/server/process";
|
||||
import { stripLinuxDesktopRuntimeEnv } from "@getpaseo/server/process";
|
||||
import defaultLog from "electron-log/main";
|
||||
|
||||
const DEFAULT_RESOLVE_TIMEOUT_MS = 30_000;
|
||||
@@ -410,7 +410,7 @@ function resolveShellEnv({ deps, timeoutMs }: ResolveShellEnvInput): ResolvedShe
|
||||
delete shellEnv.PASEO_NODE_ENV;
|
||||
delete shellEnv.PASEO_DESKTOP_MANAGED;
|
||||
delete shellEnv.PASEO_SUPERVISED;
|
||||
stripAppImageRuntimeEnv(shellEnv, { platform: deps.platform });
|
||||
stripLinuxDesktopRuntimeEnv(shellEnv, { platform: deps.platform });
|
||||
|
||||
deps.logger.info("[login-shell-env] start", {
|
||||
shell,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { daemonLaunchEnvironment } from "./config-environment.js";
|
||||
|
||||
describe("daemonLaunchEnvironment AppImage sanitization", () => {
|
||||
describe("daemonLaunchEnvironment", () => {
|
||||
const appDir = "/tmp/.mount_Paseo-abcdef";
|
||||
|
||||
test("strips AppImage runtime variables in both managed and deployment modes", () => {
|
||||
@@ -47,6 +47,40 @@ describe("daemonLaunchEnvironment AppImage sanitization", () => {
|
||||
}
|
||||
});
|
||||
|
||||
test.each(["Paseo.desktop", "paseo-desktop.desktop"])(
|
||||
"keeps the desktop identity %s out of a Linux managed daemon",
|
||||
(identity) => {
|
||||
const inputEnv = {
|
||||
CHROME_DESKTOP: identity,
|
||||
PASEO_DESKTOP_SANDBOX_REASON: "user namespaces available",
|
||||
PATH: "/usr/bin",
|
||||
};
|
||||
const result = daemonLaunchEnvironment({
|
||||
env: inputEnv,
|
||||
home: "/home/user/.paseo",
|
||||
mode: "managed",
|
||||
desktopManaged: true,
|
||||
platform: "linux",
|
||||
});
|
||||
|
||||
expect(result.CHROME_DESKTOP).toBeUndefined();
|
||||
expect(result.PASEO_DESKTOP_SANDBOX_REASON).toBeUndefined();
|
||||
expect(result.PATH).toBe("/usr/bin");
|
||||
expect(result.PASEO_DESKTOP_MANAGED).toBe("1");
|
||||
expect(inputEnv.CHROME_DESKTOP).toBe(identity);
|
||||
},
|
||||
);
|
||||
|
||||
test("preserves an unrelated Chromium desktop identity", () => {
|
||||
const result = daemonLaunchEnvironment({
|
||||
env: { CHROME_DESKTOP: "chromium.desktop" },
|
||||
home: "/home/user/.paseo",
|
||||
mode: "deployment",
|
||||
platform: "linux",
|
||||
});
|
||||
expect(result.CHROME_DESKTOP).toBe("chromium.desktop");
|
||||
});
|
||||
|
||||
test("preserves user ARGV0 without APPIMAGE or APPDIR", () => {
|
||||
const result = daemonLaunchEnvironment({
|
||||
env: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { stripAppImageRuntimeEnv } from "./paseo-env.js";
|
||||
import { stripLinuxDesktopRuntimeEnv } from "./paseo-env.js";
|
||||
|
||||
// Daemon configuration inputs. General provider credentials and executable/runtime
|
||||
// controls remain available to managed launches and their agent processes.
|
||||
@@ -90,7 +90,7 @@ export function daemonLaunchEnvironment(input: {
|
||||
}
|
||||
delete env.PASEO_HOST;
|
||||
delete env.PASEO_DESKTOP_MANAGED;
|
||||
stripAppImageRuntimeEnv(env, { platform: input.platform });
|
||||
stripLinuxDesktopRuntimeEnv(env, { platform: input.platform });
|
||||
env.PASEO_HOME = input.home;
|
||||
if (input.desktopManaged) env.PASEO_DESKTOP_MANAGED = "1";
|
||||
return env;
|
||||
|
||||
@@ -66,6 +66,15 @@ describe("paseo env contract", () => {
|
||||
expect(env.PATH).toBe("/custom/bin");
|
||||
});
|
||||
|
||||
test.runIf(process.platform === "linux")("strips Paseo desktop metadata after overlays", () => {
|
||||
const env = createExternalProcessEnv(baseEnv, {
|
||||
CHROME_DESKTOP: "Paseo.desktop",
|
||||
PASEO_DESKTOP_SANDBOX_REASON: "user namespaces available",
|
||||
});
|
||||
expect(env.CHROME_DESKTOP).toBeUndefined();
|
||||
expect(env.PASEO_DESKTOP_SANDBOX_REASON).toBeUndefined();
|
||||
});
|
||||
|
||||
test("applies non-control overlays to external process env", () => {
|
||||
const env = createExternalProcessEnv(baseEnv, { PATH: "/custom/bin" }, { CUSTOM: "value" });
|
||||
|
||||
|
||||
@@ -89,6 +89,21 @@ export function stripAppImageRuntimeEnv(
|
||||
}
|
||||
}
|
||||
|
||||
/** Keep Linux launcher metadata in the desktop process that owns it. */
|
||||
export function stripLinuxDesktopRuntimeEnv(
|
||||
env: ProcessEnvRecord,
|
||||
options?: { platform?: NodeJS.Platform },
|
||||
): void {
|
||||
const platform = options?.platform ?? process.platform;
|
||||
if (platform !== "linux") return;
|
||||
|
||||
if (env.CHROME_DESKTOP === "Paseo.desktop" || env.CHROME_DESKTOP === "paseo-desktop.desktop") {
|
||||
delete env.CHROME_DESKTOP;
|
||||
}
|
||||
delete env.PASEO_DESKTOP_SANDBOX_REASON;
|
||||
stripAppImageRuntimeEnv(env, { platform });
|
||||
}
|
||||
|
||||
function buildInternalProcessEnv<T extends ProcessEnvRecord>(baseEnv: T): T {
|
||||
return { ...baseEnv };
|
||||
}
|
||||
@@ -101,7 +116,7 @@ function buildExternalProcessEnv(
|
||||
for (const key of RUNTIME_CONTROL_ENV_KEYS) {
|
||||
delete sanitized[key];
|
||||
}
|
||||
stripAppImageRuntimeEnv(sanitized);
|
||||
stripLinuxDesktopRuntimeEnv(sanitized);
|
||||
for (const [key, value] of Object.entries(sanitized)) {
|
||||
if (value === undefined) {
|
||||
delete sanitized[key];
|
||||
|
||||
@@ -7,10 +7,11 @@ import {
|
||||
import {
|
||||
createExternalCommandProcessEnv,
|
||||
stripAppImageRuntimeEnv,
|
||||
stripLinuxDesktopRuntimeEnv,
|
||||
type ProcessEnvRecord,
|
||||
} from "../server/paseo-env.js";
|
||||
|
||||
export { stripAppImageRuntimeEnv };
|
||||
export { stripAppImageRuntimeEnv, stripLinuxDesktopRuntimeEnv };
|
||||
|
||||
interface ExternalEnvOptions {
|
||||
baseEnv?: ProcessEnvRecord;
|
||||
|
||||
Reference in New Issue
Block a user