Mirror of design_agent_front/design-agent/ for shipping alongside backend.
Vite plugin (vitePluginPhaseZApi) endpoints :
- POST /api/run — spawn `python -m src.phase_z2_pipeline` with overrides
- GET /api/sample-mdx?mdx=03/04/05 — fixed sample MDX
- GET /frame-preview/{n} — figma preview thumbnails
- GET /data/runs/{run_id}/{path} — pipeline artifacts (final.html, step*.json, ...)
Env toggle forward (보고용) :
PHASE_Z_ALLOW_RESTRUCTURE / PHASE_Z_ALLOW_REJECT / PHASE_Z_MAX_RANK=32
Components :
- LeftMdxPanel (03/04/05 fix list + section tree)
- SlideCanvas (iframe + slideOverrideCss prop for inline CSS inject)
- FramePanel (label priority + confidence sort)
- LayoutPanel
README with mermaid diagrams covering the 5-step demo flow.
node_modules / dist / .manus-logs / .env excluded via .gitignore.
21 lines
471 B
TypeScript
21 lines
471 B
TypeScript
import { useRef } from "react";
|
|
|
|
type noop = (...args: any[]) => any;
|
|
|
|
/**
|
|
* usePersistFn instead of useCallback to reduce cognitive load
|
|
*/
|
|
export function usePersistFn<T extends noop>(fn: T) {
|
|
const fnRef = useRef<T>(fn);
|
|
fnRef.current = fn;
|
|
|
|
const persistFn = useRef<T>(null);
|
|
if (!persistFn.current) {
|
|
persistFn.current = function (this: unknown, ...args) {
|
|
return fnRef.current!.apply(this, args);
|
|
} as T;
|
|
}
|
|
|
|
return persistFn.current!;
|
|
}
|