Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
feat(files): long-press opens the context menu, so Preview is reachable on a phone
Rahman11828a2f65f5
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex e6ce3b44..3945280f 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -8,6 +8,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Added**+- `files` long-press opens the context menu, so Preview is reachable on a phone- `update` tell the running build from the checkout, so a pending rebuild is visible- `settings,preview` update MSO from the app, and preview the formats a real disk hasdiff --git a/frontend/slices/files-manager/components/file-context-menu.tsx b/frontend/slices/files-manager/components/file-context-menu.tsxindex 82b685b4..f7145694 100644--- a/frontend/slices/files-manager/components/file-context-menu.tsx+++ b/frontend/slices/files-manager/components/file-context-menu.tsx@@ -20,7 +20,9 @@ function Row({ a, onClose }: { a: Action; onClose: () => void }) {onClose();}}className={cn(- "flex w-full items-center justify-between gap-6 rounded-md px-2.5 py-1.5 text-left text-[13px] outline-none transition-colors hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",+ // A long-press opens this on a phone now, so the rows have to be thumb-sized+ // there — 28px rows are a mis-tap generator.+ "flex w-full items-center justify-between gap-6 rounded-md px-2.5 py-1.5 text-left text-[13px] outline-none transition-colors hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground [@media(pointer:coarse)]:min-h-[44px]",a.danger && "text-destructive hover:bg-destructive hover:text-white focus:bg-destructive focus:text-white",)}>diff --git a/frontend/slices/files-manager/components/file-item.tsx b/frontend/slices/files-manager/components/file-item.tsxindex c944e560..4ebb2000 100644--- a/frontend/slices/files-manager/components/file-item.tsx+++ b/frontend/slices/files-manager/components/file-item.tsx@@ -9,6 +9,7 @@ import { rawUrl, type FsEntry } from "../lib/host";import { iconFor, colorFor, isImage } from "../lib/icons";import { fmtSize, joinPath } from "../lib/format";import type { ViewMode } from "../lib/types";+import { useLongPress } from "../hooks/use-long-press";function RenameInput({initial,@@ -80,10 +81,13 @@ export function FileItem({const [thumbFail, setThumbFail] = useState(false);// Touch has no double-click — on phones a single tap selects AND opens// (navigate for dirs, preview for files). Desktop keeps select / dbl-open.+ const { handlers: touchProps, swallowTap } = useLongPress(isMobile, onContext);const onTap = (e: MouseEvent) => {+ if (swallowTap(e)) return;onClick(e);if (isMobile) onOpen();};+const showThumb = view === "grid" && !!dirPath && isImage(entry) && !thumbFail;const commit = (v: string) => {const t = v.trim();@@ -105,6 +109,7 @@ export function FileItem({onClick={onTap}onDoubleClick={onOpen}onContextMenu={onContext}+ {...touchProps}className={cn("flex h-auto w-full flex-col items-center gap-1.5 rounded-lg p-3 text-center transition-colors",selected ? "bg-primary text-primary-foreground" : "hover:bg-accent",@@ -169,6 +174,7 @@ export function FileItem({onClick={onTap}onDoubleClick={onOpen}onContextMenu={onContext}+ {...touchProps}className={cn("grid cursor-default grid-cols-[1fr_92px_96px] items-center gap-2 px-3 py-1.5 text-xs transition-colors @max-[430px]:grid-cols-[1fr_72px] [@media(pointer:coarse)]:min-h-[44px]",selected ? "bg-primary text-primary-foreground" : "hover:bg-accent",diff --git a/frontend/slices/files-manager/hooks/use-long-press.ts b/frontend/slices/files-manager/hooks/use-long-press.tsnew file mode 100644index 00000000..3e69ee78--- /dev/null+++ b/frontend/slices/files-manager/hooks/use-long-press.ts@@ -0,0 +1,65 @@+"use client";++import { useRef, type MouseEvent, type PointerEvent as ReactPointerEvent } from "react";++// LONG-PRESS = right-click, for the file grid/list.+//+// Touch has no contextmenu event worth relying on (Chrome Android fires one, iOS+// Safari mostly does not), so on a phone every action in the file context menu —+// Preview, Rename, Download, Move to Trash — was simply unreachable. 500 ms is the+// platform convention on both; a 10 px drift cancels it so a scroll flick never+// opens a menu.+const HOLD_MS = 500;+const DRIFT_PX = 10;++export function useLongPress(enabled: boolean, onContext: (e: MouseEvent) => void) {+ const press = useRef<{ timer: number; x: number; y: number } | null>(null);+ // Set when a long-press opened the menu: the finger lifting still fires a click,+ // which would both open the file underneath and — because the menu closes on any+ // window click — dismiss the menu it just opened.+ const swallow = useRef(false);++ const cancel = () => {+ if (press.current) window.clearTimeout(press.current.timer);+ press.current = null;+ };++ /** Wrap the item's own tap handler. Returns true when the tap was swallowed. */+ const swallowTap = (e: MouseEvent): boolean => {+ if (!swallow.current) return false;+ swallow.current = false;+ e.preventDefault();+ // Stops the native event before the menu's window-level close listener.+ e.stopPropagation();+ return true;+ };++ const handlers = enabled+ ? {+ onPointerDown: (e: ReactPointerEvent<HTMLElement>) => {+ if (e.pointerType === "mouse") return;+ const { clientX, clientY } = e;+ const currentTarget = e.currentTarget;+ press.current = {+ x: clientX,+ y: clientY,+ timer: window.setTimeout(() => {+ press.current = null;+ swallow.current = true;+ // Synthetic enough: the handler only reads coords and stops+ // propagation on what it is given.+ onContext({ clientX, clientY, currentTarget, preventDefault() {}, stopPropagation() {} } as unknown as MouseEvent);+ }, HOLD_MS),+ };+ },+ onPointerMove: (e: ReactPointerEvent<HTMLElement>) => {+ const p = press.current;+ if (p && (Math.abs(e.clientX - p.x) > DRIFT_PX || Math.abs(e.clientY - p.y) > DRIFT_PX)) cancel();+ },+ onPointerUp: cancel,+ onPointerCancel: cancel,+ }+ : {};++ return { handlers, swallowTap };+}