Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-12190): make timeline/block-detail split vertically resizable (#7270)
Celal Zamanoğlud79f9109dab9
diff --git a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsxindex b7c3af835..5405fcc5b 100644--- a/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx+++ b/skyvern-frontend/src/routes/workflows/WorkflowRun.tsx@@ -48,6 +48,7 @@ import {} from "../tasks/types";import { useWorkflowRunWithWorkflowQuery } from "./hooks/useWorkflowRunWithWorkflowQuery";import { useRefreshOnboardingOnRunCompletion } from "./hooks/useRefreshOnboardingOnRunCompletion";+import { ResizableTimelineSplit } from "./workflowRun/ResizableTimelineSplit";import { WorkflowRunBlockDetail } from "./workflowRun/WorkflowRunBlockDetail";import { WorkflowRunTimeline } from "./workflowRun/WorkflowRunTimeline";import { useWorkflowRunTimelineQuery } from "./hooks/useWorkflowRunTimelineQuery";@@ -97,43 +98,48 @@ function WorkflowRunRightColumn({onSetActiveIteration: (loopBlockId: string, iterationIndex: number) => void;}) {return (- <div className="grid min-h-0 w-[clamp(28rem,34vw,36rem)] shrink-0 grid-rows-[minmax(0,1fr)_minmax(0,1fr)] gap-3">- <div className="min-h-0 w-full overflow-hidden">- <WorkflowRunTimeline- activeItem={activeItem}- activeIteration={activeIteration}- onActionItemSelected={(item) => {- onSetActiveItem(item.action.action_id);- }}- onBlockItemSelected={(item) => {- onSetActiveItem(item.workflow_run_block_id);- }}- onThoughtItemSelected={(item) => {- onSetActiveItem(item.thought_id);- }}- onLiveStreamSelected={() => {- onSetActiveItem("stream");- }}- onIterationSelected={(loopBlock, iterationIndex) => {- onSetActiveIteration(- loopBlock.workflow_run_block_id,- iterationIndex,- );- }}- />- </div>- <div className="flex min-h-0 w-full flex-col overflow-hidden rounded-md border border-slate-700 bg-slate-elevation1">- <WorkflowRunBlockDetail- activeItem={activeItem}- activeIteration={activeIteration}- timeline={timeline}- timelineReady={timelineReady}- onThoughtSelect={(thought) => {- onSetActiveItem(thought.thought_id);- }}- />- </div>- </div>+ <ResizableTimelineSplit+ className="w-[clamp(28rem,34vw,36rem)] shrink-0"+ top={+ <div className="min-h-0 w-full overflow-hidden">+ <WorkflowRunTimeline+ activeItem={activeItem}+ activeIteration={activeIteration}+ onActionItemSelected={(item) => {+ onSetActiveItem(item.action.action_id);+ }}+ onBlockItemSelected={(item) => {+ onSetActiveItem(item.workflow_run_block_id);+ }}+ onThoughtItemSelected={(item) => {+ onSetActiveItem(item.thought_id);+ }}+ onLiveStreamSelected={() => {+ onSetActiveItem("stream");+ }}+ onIterationSelected={(loopBlock, iterationIndex) => {+ onSetActiveIteration(+ loopBlock.workflow_run_block_id,+ iterationIndex,+ );+ }}+ />+ </div>+ }+ bottom={+ <div className="flex min-h-0 w-full flex-col overflow-hidden rounded-md border border-slate-700 bg-slate-elevation1">+ <WorkflowRunBlockDetail+ activeItem={activeItem}+ activeIteration={activeIteration}+ timeline={timeline}+ timelineReady={timelineReady}+ onThoughtSelect={(thought) => {+ onSetActiveItem(thought.thought_id);+ }}+ />+ </div>+ }+ />);}diff --git a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsxindex ffe0bc204..fb4eb3c87 100644--- a/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx+++ b/skyvern-frontend/src/routes/workflows/studio/runview/RunView.tsx@@ -16,6 +16,7 @@ import { isRecord } from "@/util/utils";import { useWorkflowRunTimelineQuery } from "../../hooks/useWorkflowRunTimelineQuery";import { useWorkflowRunWithWorkflowQuery } from "../../hooks/useWorkflowRunWithWorkflowQuery";+import { ResizableTimelineSplit } from "../../workflowRun/ResizableTimelineSplit";import { WorkflowRunBlockDetail } from "../../workflowRun/WorkflowRunBlockDetail";import { WorkflowRunCode } from "../../workflowRun/WorkflowRunCode";import { WorkflowRunTimeline } from "../../workflowRun/WorkflowRunTimeline";@@ -391,42 +392,47 @@ export function RunView({{view === "timeline" ? (<div className="flex min-h-0 flex-1 flex-col gap-3"><RunSummaryStrip workflowRun={workflowRun} elapsed={elapsed} />- <div className="grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)_minmax(0,1fr)] gap-3">- <div className="min-h-0 overflow-hidden">- <WorkflowRunTimeline- workflowRunId={workflowRunId}- hideLiveBadge- activeItem={activeItem}- activeIteration={activeIteration}- onActionItemSelected={(item) => {- pinFrame(item.action.action_id);- }}- onBlockItemSelected={(block) => {- pinFrame(block.workflow_run_block_id);- }}- onThoughtItemSelected={(thought) => {- pinFrame(thought.thought_id);- }}- onLiveStreamSelected={() => {- pinFrame("stream");- }}- onIterationSelected={(loopBlock, iterationIndex) => {- pinFrame(loopBlock.workflow_run_block_id, iterationIndex);- }}- />- </div>- <div className="flex min-h-0 flex-col overflow-hidden rounded-lg border border-border bg-slate-elevation1">- <WorkflowRunBlockDetail- activeItem={activeItem}- activeIteration={activeIteration}- timeline={timeline ?? []}- timelineReady={Boolean(timeline)}- showDownloadedFiles- workflowRunId={workflowRunId}- onThoughtSelect={(thought) => pinFrame(thought.thought_id)}- />- </div>- </div>+ <ResizableTimelineSplit+ className="flex-1"+ top={+ <div className="min-h-0 overflow-hidden">+ <WorkflowRunTimeline+ workflowRunId={workflowRunId}+ hideLiveBadge+ activeItem={activeItem}+ activeIteration={activeIteration}+ onActionItemSelected={(item) => {+ pinFrame(item.action.action_id);+ }}+ onBlockItemSelected={(block) => {+ pinFrame(block.workflow_run_block_id);+ }}+ onThoughtItemSelected={(thought) => {+ pinFrame(thought.thought_id);+ }}+ onLiveStreamSelected={() => {+ pinFrame("stream");+ }}+ onIterationSelected={(loopBlock, iterationIndex) => {+ pinFrame(loopBlock.workflow_run_block_id, iterationIndex);+ }}+ />+ </div>+ }+ bottom={+ <div className="flex min-h-0 flex-col overflow-hidden rounded-lg border border-border bg-slate-elevation1">+ <WorkflowRunBlockDetail+ activeItem={activeItem}+ activeIteration={activeIteration}+ timeline={timeline ?? []}+ timelineReady={Boolean(timeline)}+ showDownloadedFiles+ workflowRunId={workflowRunId}+ onThoughtSelect={(thought) => pinFrame(thought.thought_id)}+ />+ </div>+ }+ /></div>) : view === "inputs" ? (<div className="min-h-0 flex-1 overflow-y-auto rounded-lg border border-border bg-slate-elevation1 p-4">diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/ResizableTimelineSplit.test.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/ResizableTimelineSplit.test.tsxnew file mode 100644index 000000000..3a9bc877b--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/workflowRun/ResizableTimelineSplit.test.tsx@@ -0,0 +1,143 @@+import { fireEvent, render } from "@testing-library/react";+import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";++import {+ DEFAULT_SPLIT_FRACTION,+ TIMELINE_SPLIT_STORAGE_KEY,+} from "./resizableTimelineSplitMath";+import { ResizableTimelineSplit } from "./ResizableTimelineSplit";++describe("ResizableTimelineSplit", () => {+ beforeEach(() => {+ localStorage.clear();+ });+ afterEach(() => {+ localStorage.clear();+ });++ function renderSplit() {+ return render(+ <ResizableTimelineSplit+ top={<div>top pane</div>}+ bottom={<div>bottom pane</div>}+ />,+ );+ }++ test("defaults to an even split with no persisted value", () => {+ const { container } = renderSplit();+ const divider = container.querySelector('[role="separator"]')!;+ expect(divider.getAttribute("aria-orientation")).toBe("horizontal");+ expect(divider.getAttribute("tabindex")).toBe("0");+ expect(divider.getAttribute("aria-valuenow")).toBe("50");+ expect(divider.getAttribute("aria-valuemin")).toBe("0");+ expect(divider.getAttribute("aria-valuemax")).toBe("100");+ });++ test("restores a previously persisted split", () => {+ localStorage.setItem(TIMELINE_SPLIT_STORAGE_KEY, JSON.stringify(0.3));+ const { container } = renderSplit();+ const divider = container.querySelector('[role="separator"]')!;+ expect(divider.getAttribute("aria-valuenow")).toBe("30");+ });++ test("sanitizes a corrupted persisted value back to the default", () => {+ localStorage.setItem(TIMELINE_SPLIT_STORAGE_KEY, "not-json");+ const { container } = renderSplit();+ const divider = container.querySelector('[role="separator"]')!;+ expect(divider.getAttribute("aria-valuenow")).toBe("50");+ });++ test("is invisible at rest", () => {+ const { container } = renderSplit();+ const indicator = container.querySelector("span[aria-hidden]")!;+ expect(indicator.className).toContain("bg-transparent");+ expect(indicator.className).not.toContain("bg-muted-foreground");+ });++ test("double-click resets to the default split and persists it", () => {+ localStorage.setItem(TIMELINE_SPLIT_STORAGE_KEY, JSON.stringify(0.25));+ const { container } = renderSplit();+ const divider = container.querySelector('[role="separator"]')!;+ fireEvent.doubleClick(divider);+ expect(divider.getAttribute("aria-valuenow")).toBe("50");+ expect(localStorage.getItem(TIMELINE_SPLIT_STORAGE_KEY)).toBe(+ JSON.stringify(DEFAULT_SPLIT_FRACTION),+ );+ });++ // jsdom has no layout engine, so getBoundingClientRect() is always a zero+ // rect — stubbing it to a fixed size is the only way to exercise the+ // keyboard-nudge wiring here. It pins the ArrowUp/ArrowDown contract; it+ // cannot stand in for the real pointer-drag geometry check (see the+ // Playwright harness referenced in the PR description).+ describe("keyboard nudge (stubbed layout)", () => {+ const CONTAINER_HEIGHT = 400;++ beforeEach(() => {+ vi.spyOn(Element.prototype, "getBoundingClientRect").mockReturnValue({+ height: CONTAINER_HEIGHT,+ width: 0,+ top: 0,+ left: 0,+ bottom: CONTAINER_HEIGHT,+ right: 0,+ x: 0,+ y: 0,+ toJSON() {+ return this;+ },+ });+ });++ afterEach(() => {+ vi.restoreAllMocks();+ });++ test("ArrowDown grows the top pane by one step and persists it", () => {+ const { container } = renderSplit();+ const divider = container.querySelector('[role="separator"]')!;+ fireEvent.keyDown(divider, { key: "ArrowDown" });+ // contentHeight = 400 - 12 (divider) = 388; 50% + 24px = 218/388 ≈ 56%.+ expect(divider.getAttribute("aria-valuenow")).toBe("56");+ expect(localStorage.getItem(TIMELINE_SPLIT_STORAGE_KEY)).toBe(+ JSON.stringify(218 / 388),+ );+ });++ test("ArrowUp shrinks the top pane by one step", () => {+ const { container } = renderSplit();+ const divider = container.querySelector('[role="separator"]')!;+ fireEvent.keyDown(divider, { key: "ArrowUp" });+ expect(divider.getAttribute("aria-valuenow")).toBe("44");+ });++ test("ignores keys other than the arrow keys", () => {+ const { container } = renderSplit();+ const divider = container.querySelector('[role="separator"]')!;+ fireEvent.keyDown(divider, { key: "Enter" });+ expect(divider.getAttribute("aria-valuenow")).toBe("50");+ expect(localStorage.getItem(TIMELINE_SPLIT_STORAGE_KEY)).toBeNull();+ });++ test("a second pointer's up/cancel does not end a different pointer's drag", () => {+ if (!Element.prototype.setPointerCapture) {+ Element.prototype.setPointerCapture = vi.fn();+ }+ const { container } = renderSplit();+ const divider = container.querySelector('[role="separator"]')!;+ fireEvent.pointerDown(divider, { pointerId: 1, clientY: 200, button: 0 });+ fireEvent.pointerMove(divider, { pointerId: 1, clientY: 230 });+ // A stray second pointer (e.g. an incidental touch) ending on the same+ // element must not terminate pointer 1's still-active drag.+ fireEvent.pointerUp(divider, { pointerId: 2 });+ fireEvent.pointerMove(divider, { pointerId: 1, clientY: 250 });+ fireEvent.pointerUp(divider, { pointerId: 1 });+ // contentHeight=388, startTopPx=194, +50px move -> 244/388 (well clear+ // of the [120, 268] clamp bounds either move would land in).+ expect(localStorage.getItem(TIMELINE_SPLIT_STORAGE_KEY)).toBe(+ JSON.stringify(244 / 388),+ );+ });+ });+});diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/ResizableTimelineSplit.tsx b/skyvern-frontend/src/routes/workflows/workflowRun/ResizableTimelineSplit.tsxnew file mode 100644index 000000000..cad7a78de--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/workflowRun/ResizableTimelineSplit.tsx@@ -0,0 +1,173 @@+import { useEffect, useRef, useState, type ReactNode } from "react";++import { cn } from "@/util/utils";++import {+ clampSplitFraction,+ DEFAULT_SPLIT_FRACTION,+ DIVIDER_HEIGHT_PX,+ DIVIDER_KEY_STEP_PX,+ gridTemplateRowsFor,+ persistFraction,+ readStoredFraction,+} from "./resizableTimelineSplitMath";++/**+ * Vertical split between two stacked panes (run timeline above block detail)+ * with a draggable divider that is exactly the old inter-pane gap —+ * invisible at rest, visible on hover/focus/drag. Mirrors StudioPaneDivider's+ * pointer-capture idiom (studio/StudioShell.tsx), generalized from per-pane+ * pixel widths to a single 0..1 fraction shared by exactly two panes.+ */+export function ResizableTimelineSplit({+ top,+ bottom,+ className,+}: {+ top: ReactNode;+ bottom: ReactNode;+ className?: string;+}) {+ const containerRef = useRef<HTMLDivElement | null>(null);+ const [fraction, setFraction] = useState(readStoredFraction);+ const [active, setActive] = useState(false);+ const dragRef = useRef<{+ pointerId: number;+ startY: number;+ startFraction: number;+ contentHeight: number;+ lastFraction: number;+ } | null>(null);++ // A route change can unmount the divider mid-drag; put back the cursor.+ useEffect(() => {+ return () => {+ if (dragRef.current) {+ dragRef.current = null;+ document.body.style.cursor = "";+ }+ };+ }, []);++ const contentHeight = () => {+ const el = containerRef.current;+ if (!el) return 0;+ return el.getBoundingClientRect().height - DIVIDER_HEIGHT_PX;+ };++ const beginDrag = (event: React.PointerEvent<HTMLDivElement>) => {+ if (event.button !== 0 || dragRef.current) {+ return;+ }+ const height = contentHeight();+ if (height <= 0) {+ return;+ }+ event.preventDefault();+ event.currentTarget.setPointerCapture(event.pointerId);+ dragRef.current = {+ pointerId: event.pointerId,+ startY: event.clientY,+ startFraction: fraction,+ contentHeight: height,+ lastFraction: fraction,+ };+ document.body.style.cursor = "row-resize";+ setActive(true);+ };++ const moveDrag = (event: React.PointerEvent<HTMLDivElement>) => {+ const drag = dragRef.current;+ if (!drag || event.pointerId !== drag.pointerId) {+ return;+ }+ const desiredTopPx =+ drag.startFraction * drag.contentHeight + (event.clientY - drag.startY);+ const next = clampSplitFraction(desiredTopPx, drag.contentHeight);+ drag.lastFraction = next;+ if (containerRef.current) {+ containerRef.current.style.gridTemplateRows = gridTemplateRowsFor(next);+ }+ };++ const endDrag = (event: React.PointerEvent<HTMLDivElement>) => {+ const drag = dragRef.current;+ if (!drag || event.pointerId !== drag.pointerId) {+ return;+ }+ dragRef.current = null;+ document.body.style.cursor = "";+ setActive(false);+ // A click without a move (or a drag clamped back to where it started)+ // leaves nothing to commit — skip the redundant render + storage write.+ if (drag.lastFraction === drag.startFraction) {+ return;+ }+ setFraction(drag.lastFraction);+ persistFraction(drag.lastFraction);+ };++ const keyResize = (event: React.KeyboardEvent<HTMLDivElement>) => {+ if (event.key !== "ArrowUp" && event.key !== "ArrowDown") {+ return;+ }+ event.preventDefault();+ const height = contentHeight();+ if (height <= 0) {+ return;+ }+ const currentTopPx = fraction * height;+ const delta =+ event.key === "ArrowUp" ? -DIVIDER_KEY_STEP_PX : DIVIDER_KEY_STEP_PX;+ const next = clampSplitFraction(currentTopPx + delta, height);+ if (next === fraction) {+ return;+ }+ setFraction(next);+ persistFraction(next);+ };++ const resetSplit = () => {+ setFraction(DEFAULT_SPLIT_FRACTION);+ persistFraction(DEFAULT_SPLIT_FRACTION);+ };++ return (+ <div+ ref={containerRef}+ className={cn("grid min-h-0", className)}+ style={{ gridTemplateRows: gridTemplateRowsFor(fraction) }}+ >+ {top}+ <div+ role="separator"+ aria-orientation="horizontal"+ aria-label="Resize timeline and block details"+ aria-valuenow={Math.round(fraction * 100)}+ aria-valuemin={0}+ aria-valuemax={100}+ tabIndex={0}+ title="Drag to resize · double-click to reset · arrow keys to adjust"+ onPointerDown={beginDrag}+ onPointerMove={moveDrag}+ onPointerUp={endDrag}+ onPointerCancel={endDrag}+ onLostPointerCapture={endDrag}+ onDoubleClick={resetSplit}+ onKeyDown={keyResize}+ className="group relative cursor-row-resize touch-none focus-visible:outline-none"+ >+ <span+ aria-hidden+ className={cn(+ "absolute inset-x-3 top-1/2 h-0.5 -translate-y-1/2 rounded-full motion-safe:transition-colors",+ active+ ? "bg-muted-foreground"+ : "bg-transparent group-hover:bg-border group-focus-visible:bg-ring",+ )}+ />+ </div>+ {bottom}+ </div>+ );+}diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/resizableTimelineSplitMath.test.ts b/skyvern-frontend/src/routes/workflows/workflowRun/resizableTimelineSplitMath.test.tsnew file mode 100644index 000000000..a15a83191--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/workflowRun/resizableTimelineSplitMath.test.ts@@ -0,0 +1,69 @@+import { describe, expect, test } from "vitest";++import {+ clampSplitFraction,+ DEFAULT_SPLIT_FRACTION,+ gridTemplateRowsFor,+ MIN_PANE_HEIGHT_PX,+ sanitizeSplitFraction,+} from "./resizableTimelineSplitMath";++describe("sanitizeSplitFraction", () => {+ test("passes through a valid fraction", () => {+ expect(sanitizeSplitFraction(0.3)).toBe(0.3);+ });++ test("falls back to the default for out-of-range or malformed values", () => {+ for (const value of [0, 1, -0.2, 1.2, NaN, "0.5", null, undefined, {}]) {+ expect(sanitizeSplitFraction(value)).toBe(DEFAULT_SPLIT_FRACTION);+ }+ });+});++describe("clampSplitFraction", () => {+ test("passes through a mid-range value untouched", () => {+ expect(clampSplitFraction(500, 1000)).toBeCloseTo(0.5);+ });++ test("clamps below the top floor", () => {+ expect(clampSplitFraction(10, 1000)).toBeCloseTo(MIN_PANE_HEIGHT_PX / 1000);+ });++ test("clamps above the bottom floor", () => {+ expect(clampSplitFraction(990, 1000)).toBeCloseTo(+ (1000 - MIN_PANE_HEIGHT_PX) / 1000,+ );+ });++ test("falls back to 50/50 when the container can't fit both floors", () => {+ expect(clampSplitFraction(100, MIN_PANE_HEIGHT_PX * 2)).toBe(+ DEFAULT_SPLIT_FRACTION,+ );+ expect(clampSplitFraction(100, MIN_PANE_HEIGHT_PX * 2 - 1)).toBe(+ DEFAULT_SPLIT_FRACTION,+ );+ });++ test("degrades proportionally just above that boundary, never overflowing", () => {+ const contentHeight = MIN_PANE_HEIGHT_PX * 2 + 1;+ const result = clampSplitFraction(MIN_PANE_HEIGHT_PX, contentHeight);+ expect(result).toBeCloseTo(MIN_PANE_HEIGHT_PX / contentHeight);+ expect(result).toBeGreaterThan(0);+ expect(result).toBeLessThan(1);+ });+});++describe("gridTemplateRowsFor", () => {+ test("emitted fr factors always sum to the row scale, even at clamp bounds", () => {+ const fractions = [0, 0.001, 0.1, 1 / 3, 0.5, 0.6, 0.9, 0.999, 1];+ for (const fraction of fractions) {+ const template = gridTemplateRowsFor(fraction);+ const match = template.match(+ /^minmax\(0, (\d+)fr\) 12px minmax\(0, (\d+)fr\)$/,+ );+ expect(match).not.toBeNull();+ const [, top, bottom] = match!;+ expect(Number(top) + Number(bottom)).toBe(1000);+ }+ });+});diff --git a/skyvern-frontend/src/routes/workflows/workflowRun/resizableTimelineSplitMath.ts b/skyvern-frontend/src/routes/workflows/workflowRun/resizableTimelineSplitMath.tsnew file mode 100644index 000000000..5baaf13bd--- /dev/null+++ b/skyvern-frontend/src/routes/workflows/workflowRun/resizableTimelineSplitMath.ts@@ -0,0 +1,72 @@+export const TIMELINE_SPLIT_STORAGE_KEY = "skyvern.runView.timelineSplit";+export const DEFAULT_SPLIT_FRACTION = 0.5;+export const DIVIDER_HEIGHT_PX = 12;+// Measured (real-layout headless Chrome, getBoundingClientRect) against the+// two panes' actual always-present header chrome: WorkflowRunTimeline's own+// header row is ~33px; BlockDetailHeader's (blockDetail/shared.tsx) compound+// info+meta rows are ~61px, the taller of the two. 120px clears both with+// room for a few lines of body content and never clips a header — if either+// header grows, re-measure and bump this constant to match.+export const MIN_PANE_HEIGHT_PX = 120;+export const DIVIDER_KEY_STEP_PX = 24;+// CSS grid (like flexbox) special-cases flex factors that sum to < 1: it only+// distributes that fraction of the leftover space, leaving a sliver+// unfilled. A float round-tripped through localStorage can land the two+// factors just under 1 (e.g. 0.4999999999999999 + 0.5). Emitting integer fr+// values that always sum to ROW_SCALE (far above 1) avoids that range+// entirely.+const ROW_SCALE = 1000;++export function sanitizeSplitFraction(value: unknown): number {+ return typeof value === "number" &&+ Number.isFinite(value) &&+ value > 0 &&+ value < 1+ ? value+ : DEFAULT_SPLIT_FRACTION;+}++export function readStoredFraction(): number {+ try {+ const raw = localStorage.getItem(TIMELINE_SPLIT_STORAGE_KEY);+ return raw === null+ ? DEFAULT_SPLIT_FRACTION+ : sanitizeSplitFraction(JSON.parse(raw));+ } catch {+ // Safari private-mode throws on access, not just on write.+ return DEFAULT_SPLIT_FRACTION;+ }+}++export function persistFraction(fraction: number) {+ try {+ localStorage.setItem(TIMELINE_SPLIT_STORAGE_KEY, JSON.stringify(fraction));+ } catch {+ // Quota exceeded or storage blocked — losing persistence is fine.+ }+}++// Clamp a divider drag so neither pane goes under its min height.+// contentHeightPx excludes the divider's own fixed height. A container too+// short to honor both floors falls back to an even split (grid's+// minmax(0, Nfr) rows still degrade proportionally with the space actually+// available — they never overflow the container).+export function clampSplitFraction(+ topPx: number,+ contentHeightPx: number,+): number {+ if (contentHeightPx <= MIN_PANE_HEIGHT_PX * 2) {+ return DEFAULT_SPLIT_FRACTION;+ }+ const clampedTopPx = Math.min(+ Math.max(topPx, MIN_PANE_HEIGHT_PX),+ contentHeightPx - MIN_PANE_HEIGHT_PX,+ );+ return clampedTopPx / contentHeightPx;+}++export function gridTemplateRowsFor(fraction: number): string {+ const top = Math.round(fraction * ROW_SCALE);+ const bottom = ROW_SCALE - top;+ return `minmax(0, ${top}fr) ${DIVIDER_HEIGHT_PX}px minmax(0, ${bottom}fr)`;+}