Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix: preserve timeline base height when resizing capped tracks

Aiden Guan264975d8fcd2
diff --git a/src/components/ai-edition/NewEditorShell.timelineHeight.test.tsx b/src/components/ai-edition/NewEditorShell.timelineHeight.test.tsx
index 7a8d92580..7183ee1d4 100644
--- a/src/components/ai-edition/NewEditorShell.timelineHeight.test.tsx
+++ b/src/components/ai-edition/NewEditorShell.timelineHeight.test.tsx
@@ -285,4 +285,52 @@ describe("NewEditorShell timeline height", () => {
});
expect(root.style.gridTemplateRows).toBe(`58px 1fr ${DEFAULT_TIMELINE_HEIGHT_PX}px`);
});
+
+ it.each([
+ { rowCount: 10, deltaY: 0, expectedBase: DEFAULT_TIMELINE_HEIGHT_PX },
+ { rowCount: 10, deltaY: -1, expectedBase: DEFAULT_TIMELINE_HEIGHT_PX },
+ { rowCount: 10, deltaY: 1, expectedBase: DEFAULT_TIMELINE_HEIGHT_PX - 1 },
+ { rowCount: 16, deltaY: 0, expectedBase: DEFAULT_TIMELINE_HEIGHT_PX },
+ { rowCount: 16, deltaY: -1, expectedBase: DEFAULT_TIMELINE_HEIGHT_PX },
+ { rowCount: 16, deltaY: 1, expectedBase: DEFAULT_TIMELINE_HEIGHT_PX - 1 },
+ ])("preserves the base after a $deltaY px resize with $rowCount capped annotation rows", async ({
+ rowCount,
+ deltaY,
+ expectedBase,
+ }) => {
+ useProjectStore.getState().clear();
+ const doc = createEmptyDocument({ projectId: "p", title: "t" });
+ doc.annotations = Array.from({ length: rowCount }, (_, i) =>
+ annotationRegionSchema.parse({
+ id: `ann-${i}`,
+ startMs: 0,
+ endMs: 5000,
+ type: "text",
+ content: "Hello",
+ zIndex: i,
+ position: { x: 20, y: 20 },
+ size: { width: 30, height: 20 },
+ style: { color: "#ffffff", fontSize: 32, fontFamily: "Inter" },
+ }),
+ );
+ useProjectStore.setState({ document: doc });
+ const { container } = renderShell();
+ const root = container.firstElementChild as HTMLElement;
+ const handle = container.querySelector(
+ '[role="separator"][aria-orientation="horizontal"]',
+ ) as HTMLElement;
+ expect(root.style.gridTemplateRows).toBe(`58px 1fr ${MAX_TIMELINE_HEIGHT_PX}px`);
+
+ await act(async () => {
+ fireEvent.pointerDown(handle, { clientY: 400 });
+ fireEvent.pointerMove(window, { clientY: 400 + deltaY });
+ fireEvent.pointerUp(window);
+ });
+ expect(localStorage.getItem("os-editor-timeline-height")).toBe(String(expectedBase));
+
+ await act(async () => {
+ useProjectStore.setState({ document: { ...doc, annotations: [] } });
+ });
+ expect(root.style.gridTemplateRows).toBe(`58px 1fr ${expectedBase}px`);
+ });
});
diff --git a/src/components/ai-edition/NewEditorShell.tsx b/src/components/ai-edition/NewEditorShell.tsx
index 5b2478bab..f26a56c72 100644
--- a/src/components/ai-edition/NewEditorShell.tsx
+++ b/src/components/ai-edition/NewEditorShell.tsx
@@ -1502,15 +1502,20 @@ export function NewEditorShell() {
e.preventDefault();
const startY = e.clientY;
const startBase = timelineBaseHeightPx;
+ const startRendered = timelineHeightPx;
let latestBase = startBase;
const move = (ev: PointerEvent) => {
// Dragging the handle up (negative clientY delta) enlarges the
// timeline, since it sits below the handle.
const renderedTarget = Math.min(
MAX_TIMELINE_HEIGHT_PX,
- Math.max(MIN_TIMELINE_HEIGHT_PX, startBase + extraLaneHeightPx - (ev.clientY - startY)),
+ Math.max(MIN_TIMELINE_HEIGHT_PX, startRendered - (ev.clientY - startY)),
+ );
+ // Apply only the rendered-height delta, preserving the base when expansion hits the cap.
+ latestBase = Math.min(
+ MAX_TIMELINE_HEIGHT_PX,
+ Math.max(MIN_TIMELINE_HEIGHT_PX, startBase + (renderedTarget - startRendered)),
);
- latestBase = Math.max(MIN_TIMELINE_HEIGHT_PX, renderedTarget - extraLaneHeightPx);
setTimelineBaseHeightPx(latestBase);
};
const up = () => {
@@ -1521,7 +1526,7 @@ export function NewEditorShell() {
window.addEventListener("pointermove", move);
window.addEventListener("pointerup", up);
},
- [timelineBaseHeightPx, extraLaneHeightPx],
+ [timelineBaseHeightPx, timelineHeightPx],
);
const transcriptProps = {