Files
hyperframes/packages/studio/src/contexts/PanelLayoutContext.tsx
T
Vance Ingalls 89069d24c3 fix(studio): keep preview state synchronized (#3450)
* fix(core): harden audio FX and group identity

* fix(core): address audio group review feedback

* fix(core): align preview transport with grouped audio

* test(core): pin audio group gain ceiling

* fix(core): preserve solo bridge through stack

* fix(engine): harden grouped audio rendering

* docs(engine): explain grouped mix fallback invariant

* test(engine): allow grouped mixes to finish on Windows

* feat(lint): validate audio group membership and timing

* test(lint): pin audio group membership guards

* fix(studio): unify audio IDs and group state

* fix(studio): make audio-group edits transactional

* fix(studio): keep preview state synchronized
2026-08-23 18:10:46 -07:00

82 lines
2.1 KiB
TypeScript

import type { usePanelLayout } from "../hooks/usePanelLayout";
import { useContext, useMemo, type ReactNode } from "react";
import { createStableContext } from "../utils/hmrStableContext";
type PanelLayoutValue = ReturnType<typeof usePanelLayout>;
const PanelLayoutContext = createStableContext<PanelLayoutValue | null>("PanelLayoutContext", null);
export function usePanelLayoutContext(): PanelLayoutValue {
const ctx = useContext(PanelLayoutContext);
if (!ctx) throw new Error("usePanelLayoutContext must be used within PanelLayoutProvider");
return ctx;
}
export function PanelLayoutProvider({
value: {
leftWidth,
rightWidth,
adjustPanelWidth,
leftCollapsed,
rightCollapsed,
setRightCollapsed,
effectiveLeftCollapsed,
effectiveRightCollapsed,
rightPanelTab,
setRightPanelTab,
rightInspectorPanes,
toggleRightInspectorPane,
setExclusiveRightInspectorPane,
toggleLeftSidebar,
handlePanelResizeStart,
handlePanelResizeMove,
handlePanelResizeEnd,
},
children,
}: {
value: PanelLayoutValue;
children: ReactNode;
}) {
const stable = useMemo<PanelLayoutValue>(
() => ({
leftWidth,
rightWidth,
adjustPanelWidth,
leftCollapsed,
rightCollapsed,
setRightCollapsed,
effectiveLeftCollapsed,
effectiveRightCollapsed,
rightPanelTab,
setRightPanelTab,
rightInspectorPanes,
toggleRightInspectorPane,
setExclusiveRightInspectorPane,
toggleLeftSidebar,
handlePanelResizeStart,
handlePanelResizeMove,
handlePanelResizeEnd,
}),
[
leftWidth,
rightWidth,
adjustPanelWidth,
leftCollapsed,
rightCollapsed,
setRightCollapsed,
effectiveLeftCollapsed,
effectiveRightCollapsed,
rightPanelTab,
setRightPanelTab,
rightInspectorPanes,
toggleRightInspectorPane,
setExclusiveRightInspectorPane,
toggleLeftSidebar,
handlePanelResizeStart,
handlePanelResizeMove,
handlePanelResizeEnd,
],
);
return <PanelLayoutContext value={stable}>{children}</PanelLayoutContext>;
}