Files
hyperframes/packages/studio/src/hooks/useTimelineAddAtPlayhead.ts
T
Miguel Ángel 438ea9d59f perf(studio): manual edits stay under 8 ms per frame (#4898)
* ci(studio): measure any edit cases on quiet runners, five runs in parallel

* perf(studio): an undo or save stops re-rendering every panel

* test(studio): the edit bench types one key per frame, as a person does

* fix(studio): the edit bench measures frame work when a task outside the drag has no thread time

* refactor(studio): hooks hand back stable handlers themselves, keeping App.tsx under 600 lines

* test(studio): the edit bench says why a case's frame work is unknown

* fix(studio): the edit bench counts a task without thread time at its wall time

* perf(studio): draw toasts on an opaque surface without backdrop blur

* fix(studio): keep stable handlers bound to the project they were made in

* fix(studio): every stable handler names the project it belongs to

* style(studio): format the stable handler call sites

* refactor(studio): name the timeline editing handler objects before wrapping them
2026-10-02 21:15:19 +00:00

24 lines
760 B
TypeScript

import { useCallback } from "react";
import { usePlayerStore } from "../player";
import { useStableHandlers } from "./useStableHandlers";
type AddAtPlacement = (path: string, placement: { start: number; track: number }) => unknown;
export function useTimelineAddAtPlayhead(
addAsset: AddAtPlacement,
addComposition: AddAtPlacement,
projectId: string | null,
) {
const placement = () => ({ start: usePlayerStore.getState().currentTime, track: 0 });
return useStableHandlers(
{
addAssetAtPlayhead: useCallback((path: string) => addAsset(path, placement()), [addAsset]),
addCompositionAtPlayhead: useCallback(
(path: string) => addComposition(path, placement()),
[addComposition],
),
},
projectId,
);
}