Polish Yaak Proxy's flow list, sidebar and header

Columns keep fixed widths, Path included, and the list scrolls sideways
with the header in step instead of dropping columns or capping Host.
Resize handles sit on every column boundary, a double-click resets one,
and a third click on a sorted header goes back to start time, with empty
values sorting lowest. The search box takes up to 44rem and wraps over
the list while focused, its completions as wide as it. The list/detail
handle fills the gutter. Native title tooltips become Yaak's tooltip,
shared buttons gain an opt-in for it, and folder and program rows in the
sidebar get Reveal in Finder and Copy path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Gregory SchierandClaude Opus 5.5 authored and Stetta task tk_mw9j1flbfooxxx0a committed 2026-11-09 10:45:46 -07:00
1 parent 77226dbedb
commit c78732ecaf
30 files changed
+1032 -421

No files matched your search

+19 -2
View File
@@ -4,6 +4,10 @@ import type { HTMLAttributes, ReactNode } from "react";
import { forwardRef } from "react";
import { Icon } from "./Icon";
import { LoadingIcon } from "./LoadingIcon";
import { Tooltip } from "./Tooltip";
/** How long the pointer rests on a control before its tooltip shows, in milliseconds */
export const CONTROL_TOOLTIP_DELAY = 300;
type ButtonVariant = "border" | "solid" | "input";
type ButtonSize = "2xs" | "xs" | "sm" | "md" | "auto";
@@ -22,6 +26,8 @@ export type ButtonProps = Omit<HTMLAttributes<HTMLButtonElement>, "color" | "onC
forDropdown?: boolean;
disabled?: boolean;
title?: string;
/** Shows `title` in Yaak's tooltip, quickly, rather than the browser's */
tooltip?: boolean;
leftSlot?: ReactNode;
rightSlot?: ReactNode;
};
@@ -43,6 +49,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button
rightSlot,
disabled,
title,
tooltip,
onClick,
...props
}: ButtonProps,
@@ -50,8 +57,9 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button
) {
const resolvedColor = color ?? tone ?? "default";
const isDisabled = disabled || isLoading;
const withTooltip = tooltip === true && title != null && title !== "";
return (
const button = (
<button
ref={ref}
type={type}
@@ -99,7 +107,8 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button
onDoubleClick={(e) => {
e.stopPropagation();
}}
title={title}
title={withTooltip ? undefined : title}
aria-label={withTooltip ? title : undefined}
{...props}
>
{isLoading ? (
@@ -126,4 +135,12 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button
)}
</button>
);
return withTooltip ? (
<Tooltip wrap content={title} delay={CONTROL_TOOLTIP_DELAY}>
{button}
</Tooltip>
) : (
button
);
});
+18 -2
View File
@@ -19,6 +19,8 @@ interface Props {
onReset?: () => void;
side: "left" | "right" | "top";
justify: "center" | "end" | "start";
/** Fills the space it is given, all of it taking the pointer, with its bar centred in it */
fill?: boolean;
}
export function ResizeHandle({
@@ -30,6 +32,7 @@ export function ResizeHandle({
onResizeMove,
onReset,
side,
fill = false,
}: Props) {
const vertical = side === "top";
const [isResizing, setIsResizing] = useState<boolean>(false);
@@ -89,8 +92,12 @@ export function ResizeHandle({
onPointerDown={handlePointerDown}
className={classNames(
className,
"group z-10 flex select-none transition-colors hover:bg-surface-active rounded-full",
vertical ? "w-full h-1.5 cursor-row-resize" : "h-full w-1.5 cursor-col-resize",
"group z-10 flex select-none",
vertical ? "cursor-row-resize" : "cursor-col-resize",
fill
? "w-full h-full items-center"
: "transition-colors hover:bg-surface-active rounded-full",
!fill && (vertical ? "w-full h-1.5" : "h-full w-1.5"),
justify === "center" && "justify-center",
justify === "end" && "justify-end",
justify === "start" && "justify-start",
@@ -99,6 +106,15 @@ export function ResizeHandle({
side === "top" && "top-0",
)}
>
{fill && (
<div
className={classNames(
"rounded-full transition-colors group-hover:bg-surface-active",
vertical ? "w-full h-1.5" : "h-full w-1.5",
isResizing && "bg-surface-active",
)}
/>
)}
{isResizing && (
<div
className={classNames(
+28 -9
View File
@@ -26,6 +26,11 @@ interface Props {
minWidthPx?: number;
layout?: SplitLayoutLayout;
resizeHandleClassName?: string;
/**
* Pixels between the panes, all of it the handle, its bar centred. Without it the panes meet
* and the handle straddles their edge.
*/
gutter?: number;
}
const baseProperties = { minHeight: 0, minWidth: 0 };
@@ -43,6 +48,7 @@ export function SplitLayout({
storageKey,
layout = "responsive",
resizeHandleClassName,
gutter = 0,
defaultRatio = 0.5,
minHeightPx = 10,
minWidthPx = 10,
@@ -56,6 +62,7 @@ export function SplitLayout({
if (!secondSlot) {
height = 0;
minHeightPx = 0;
gutter = 0;
}
const size = useContainerSize(containerRef);
@@ -67,19 +74,22 @@ export function SplitLayout({
const styles = useMemo<CSSProperties>(
() => ({
...style,
gridTemplate: splitGridTemplate(vertical, vertical ? renderedHeight : renderedWidth),
gridTemplate: splitGridTemplate(vertical, vertical ? renderedHeight : renderedWidth, gutter),
}),
[style, vertical, renderedHeight, renderedWidth],
[style, vertical, renderedHeight, renderedWidth, gutter],
);
// While dragging, the split is written straight to the DOM and only saved (and rendered) when
// the drag ends, so the panes are not re-rendered on every move.
const liveDrag = useRef<SplitDrag | null>(null);
const applySplit = useCallback((vertical: boolean, ratio: number) => {
if (containerRef.current == null) return;
containerRef.current.style.gridTemplate = splitGridTemplate(vertical, ratio);
}, []);
const applySplit = useCallback(
(vertical: boolean, ratio: number) => {
if (containerRef.current == null) return;
containerRef.current.style.gridTemplate = splitGridTemplate(vertical, ratio, gutter);
},
[gutter],
);
// Something else re-rendering mid-drag (a response arriving, say) may write the saved split
// back; put the live one back before it is painted.
@@ -102,9 +112,16 @@ export function SplitLayout({
const $c = containerRef.current;
if ($c == null) return 0;
const { paddingLeft, paddingRight, paddingTop, paddingBottom } = getComputedStyle($c);
// The panes share what the gutter leaves
return vertical
? $c.clientHeight - Number.parseFloat(paddingTop) - Number.parseFloat(paddingBottom)
: $c.clientWidth - Number.parseFloat(paddingLeft) - Number.parseFloat(paddingRight);
? $c.clientHeight -
Number.parseFloat(paddingTop) -
Number.parseFloat(paddingBottom) -
gutter
: $c.clientWidth -
Number.parseFloat(paddingLeft) -
Number.parseFloat(paddingRight) -
gutter;
},
apply: (ratio) => applySplit(vertical, ratio),
commit: (ratio) => (vertical ? setHeight(ratio) : setWidth(ratio)),
@@ -115,6 +132,7 @@ export function SplitLayout({
renderedWidth,
minHeightPx,
minWidthPx,
gutter,
applySplit,
setHeight,
setWidth,
@@ -151,8 +169,9 @@ export function SplitLayout({
style={areaD}
className={classNames(
resizeHandleClassName,
vertical ? "-translate-y-1" : "-translate-x-1",
gutter === 0 && (vertical ? "-translate-y-1" : "-translate-x-1"),
)}
fill={gutter > 0}
onResizeStart={handleResizeStart}
onResizeMove={handleResizeMove}
onResizeEnd={handleResizeEnd}
+120 -50
View File
@@ -1,6 +1,6 @@
import classNames from "classnames";
import type { CSSProperties, KeyboardEvent, ReactNode } from "react";
import { useRef, useState } from "react";
import { useEffect, useLayoutEffect, useRef, useState } from "react";
import { generateId } from "@yaakapp-internal/lib/generateId";
import { Portal } from "./Portal";
@@ -10,6 +10,15 @@ export interface TooltipProps {
tabIndex?: number;
size?: "md" | "lg";
className?: string;
/** How long the pointer rests before it shows, in milliseconds */
delay?: number;
/**
* Wraps a control or a cell without a box of its own: shown on hover alone, hidden on a press,
* and placed against the first element inside, which keeps its own focus and clicks
*/
wrap?: boolean;
/** Shown only while something inside is cut short, as a long host in a narrow column is */
onlyWhenTruncated?: boolean;
}
const hiddenStyles: CSSProperties = {
@@ -27,27 +36,46 @@ interface TooltipOpenState {
position: TooltipPosition;
}
export function Tooltip({ children, className, content, tabIndex, size = "md" }: TooltipProps) {
export function Tooltip({
children,
className,
content,
tabIndex,
size = "md",
delay = 500,
wrap = false,
onlyWhenTruncated = false,
}: TooltipProps) {
// Open, then placed once measured; the tooltip is only in the page while open.
const [open, setOpen] = useState(false);
const [openState, setOpenState] = useState<TooltipOpenState | null>(null);
const triggerRef = useRef<HTMLButtonElement>(null);
const triggerRef = useRef<HTMLSpanElement>(null);
const tooltipRef = useRef<HTMLDivElement>(null);
const showTimeout = useRef<ReturnType<typeof setTimeout>>(undefined);
const handleOpenImmediate = () => {
if (triggerRef.current == null || tooltipRef.current == null) return;
clearTimeout(showTimeout.current);
const triggerRect = triggerRef.current.getBoundingClientRect();
useEffect(() => () => clearTimeout(showTimeout.current), []);
useLayoutEffect(() => {
if (!open) {
setOpenState(null);
return;
}
const trigger = anchorOf(triggerRef.current, wrap);
if (trigger == null || tooltipRef.current == null) return;
const triggerRect = trigger.getBoundingClientRect();
const tooltipRect = tooltipRef.current.getBoundingClientRect();
const viewportHeight = document.documentElement.clientHeight;
const viewportWidth = document.documentElement.clientWidth;
const margin = 8;
const spaceAbove = Math.max(0, triggerRect.top - margin);
const spaceBelow = Math.max(0, viewportHeight - triggerRect.bottom - margin);
const preferBottom = spaceAbove < tooltipRect.height + margin && spaceBelow > spaceAbove;
const position: TooltipPosition = preferBottom ? "bottom" : "top";
const centred = triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2;
const styles: CSSProperties = {
left: Math.max(0, triggerRect.left + triggerRect.width / 2 - tooltipRect.width / 2),
left: Math.max(0, Math.min(centred, viewportWidth - tooltipRect.width)),
maxHeight: position === "top" ? spaceAbove : spaceBelow,
...(position === "top"
? { bottom: viewportHeight - triggerRect.top }
@@ -55,25 +83,31 @@ export function Tooltip({ children, className, content, tabIndex, size = "md" }:
};
setOpenState({ styles, position });
}, [open, wrap]);
const handleOpenImmediate = () => {
clearTimeout(showTimeout.current);
if (onlyWhenTruncated && !isTruncated(anchorOf(triggerRef.current, wrap))) return;
setOpen(true);
};
const handleOpen = () => {
clearTimeout(showTimeout.current);
showTimeout.current = setTimeout(handleOpenImmediate, 500);
showTimeout.current = setTimeout(handleOpenImmediate, delay);
};
const handleClose = () => {
clearTimeout(showTimeout.current);
setOpenState(null);
setOpen(false);
};
const handleToggleImmediate = () => {
if (openState) handleClose();
if (open) handleClose();
else handleOpenImmediate();
};
const handleKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {
if (openState && e.key === "Escape") {
const handleKeyDown = (e: KeyboardEvent<HTMLSpanElement>) => {
if (open && e.key === "Escape") {
e.preventDefault();
e.stopPropagation();
handleClose();
@@ -84,52 +118,88 @@ export function Tooltip({ children, className, content, tabIndex, size = "md" }:
return (
<>
<Portal name="tooltip">
<div
ref={tooltipRef}
style={openState?.styles ?? hiddenStyles}
id={id.current}
role="tooltip"
aria-hidden={openState == null}
onMouseEnter={handleOpenImmediate}
onMouseLeave={handleClose}
className="p-2 fixed z-50 text-sm transition-opacity grid grid-rows-[minmax(0,1fr)]"
>
{open && (
<Portal name="tooltip">
<div
ref={tooltipRef}
style={openState?.styles ?? hiddenStyles}
id={id.current}
role="tooltip"
onMouseEnter={wrap ? undefined : handleOpenImmediate}
onMouseLeave={wrap ? undefined : handleClose}
className={classNames(
"bg-surface-highlight rounded-md px-3 py-2 z-50 border border-border overflow-auto",
size === "md" && "max-w-sm",
size === "lg" && "max-w-md",
"p-2 fixed z-50 text-sm transition-opacity grid grid-rows-[minmax(0,1fr)]",
wrap && "pointer-events-none",
)}
>
{content}
<div
className={classNames(
"bg-surface-highlight rounded-md px-3 py-2 z-50 border border-border overflow-auto",
// Text keeps its line breaks, for a tooltip listing a few things
typeof content === "string" && "break-words whitespace-pre-line",
size === "md" && "max-w-sm",
size === "lg" && "max-w-md",
)}
>
{content}
</div>
<Triangle
className="text-border"
position={openState?.position === "bottom" ? "top" : "bottom"}
/>
</div>
<Triangle
className="text-border"
position={openState?.position === "bottom" ? "top" : "bottom"}
/>
</div>
</Portal>
{/* oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- Needs to be usable in other buttons */}
<span
ref={triggerRef}
role="button"
aria-describedby={openState ? id.current : undefined}
tabIndex={tabIndex ?? -1}
className={classNames(className, "grow-0 flex items-center")}
onClick={handleToggleImmediate}
onMouseEnter={handleOpen}
onMouseLeave={handleClose}
onFocus={handleOpenImmediate}
onBlur={handleClose}
onKeyDown={handleKeyDown}
>
{children}
</span>
</Portal>
)}
{wrap ? (
// oxlint-disable-next-line jsx-a11y/no-static-element-interactions -- hover only; what it wraps keeps its own focus and clicks
<span
ref={triggerRef}
aria-describedby={openState ? id.current : undefined}
className={classNames(className, "contents")}
onMouseEnter={handleOpen}
onMouseLeave={handleClose}
onMouseDown={handleClose}
>
{children}
</span>
) : (
// oxlint-disable-next-line jsx-a11y/prefer-tag-over-role -- Needs to be usable in other buttons
<span
ref={triggerRef}
role="button"
aria-describedby={openState ? id.current : undefined}
tabIndex={tabIndex ?? -1}
className={classNames(className, "grow-0 flex items-center")}
onClick={handleToggleImmediate}
onMouseEnter={handleOpen}
onMouseLeave={handleClose}
onFocus={handleOpenImmediate}
onBlur={handleClose}
onKeyDown={handleKeyDown}
>
{children}
</span>
)}
</>
);
}
/** What the tooltip is placed against: the trigger, or a wrapping one's first element */
function anchorOf(trigger: HTMLElement | null, wrap: boolean): Element | null {
if (trigger == null) return null;
return wrap ? (trigger.firstElementChild ?? trigger) : trigger;
}
/** Whether `el`, or anything in it, is cut short */
function isTruncated(el: Element | null): boolean {
if (el == null) return false;
if (el.scrollWidth > el.clientWidth + 1) return true;
for (const child of el.querySelectorAll("*")) {
if (child.scrollWidth > child.clientWidth + 1) return true;
}
return false;
}
function Triangle({ className, position }: { className?: string; position: "top" | "bottom" }) {
const isBottom = position === "bottom";
@@ -6,6 +6,7 @@ import {
createHandleDrag,
createSidebarDrag,
createSplitDrag,
splitGridTemplate,
} from "./resizeDrag";
let frames: Map<number, FrameRequestCallback>;
@@ -225,6 +226,23 @@ describe("clampSplitRatio", () => {
});
});
describe("splitGridTemplate", () => {
const tracks = (t: string) => t.replace(/\s+/g, " ").trim();
test("puts the gutter between the panes, the handle's track", () => {
expect(tracks(splitGridTemplate(false, 0.4, 20))).toBe(
"' left drag right' minmax(0,1fr) / 0.6fr 20px 0.4fr",
);
expect(tracks(splitGridTemplate(true, 0.5, 8))).toBe(
"' left' minmax(0,0.5fr) ' drag' 8px ' right' minmax(0,0.5fr) / 1fr",
);
});
test("lets the panes meet without one", () => {
expect(tracks(splitGridTemplate(false, 0.5))).toContain("0.5fr 0px 0.5fr");
});
});
describe("createSidebarDrag", () => {
function sidebar() {
const apply = vi.fn();
+4 -3
View File
@@ -93,17 +93,18 @@ export function createHandleDrag({
};
}
export function splitGridTemplate(vertical: boolean, ratio: number): string {
/** The split's grid: the two panes by `ratio`, and between them `gutter` pixels for the handle */
export function splitGridTemplate(vertical: boolean, ratio: number, gutter = 0): string {
return vertical
? `
' left' minmax(0,${1 - ratio}fr)
' drag' 0
' drag' ${gutter}px
' right' minmax(0,${ratio}fr)
/ 1fr
`
: `
' left drag right' minmax(0,1fr)
/ ${1 - ratio}fr 0 ${ratio}fr
/ ${1 - ratio}fr ${gutter}px ${ratio}fr
`;
}