The dashboard dynamically imports `@fusion-plugin-examples/dependency-graph/dashboard-view`, which resolved through the plugin's package.json exports to `dist/`. When plugin source was edited without rebuilding, stale `dist/` (extensionless ESM imports) made the import throw and the UI surfaced "Bundled plugin view unavailable". Add vite/vitest aliases mapping the plugin (and its `/dashboard-view` subpath) to `src/` so the dashboard never depends on `dist/`. Mirrors the existing pattern for hermes/openclaw/paperclip runtimes. Also extends the runtime-plugin alias regression test, and emits `.js` extensions from the plugin source for the CLI-bundled path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { useCallback, useEffect, useState } from "react";
|
|
import { clearPositions, loadPositions, savePositions, type NodePositions } from "../utils/graphPositionStorage.js";
|
|
|
|
function filterVisiblePositions(positions: NodePositions, visibleTaskIds: Set<string>): NodePositions {
|
|
const filtered: NodePositions = {};
|
|
for (const [taskId, position] of Object.entries(positions)) {
|
|
if (visibleTaskIds.has(taskId)) {
|
|
filtered[taskId] = position;
|
|
}
|
|
}
|
|
return filtered;
|
|
}
|
|
|
|
export function useGraphPositions({
|
|
projectId,
|
|
visibleTaskIds,
|
|
}: {
|
|
projectId: string | undefined;
|
|
visibleTaskIds: Set<string>;
|
|
}): {
|
|
savedPositions: NodePositions | null;
|
|
persistPositions: (positions: NodePositions) => void;
|
|
clearSavedPositions: () => void;
|
|
} {
|
|
const [savedPositions, setSavedPositions] = useState<NodePositions | null>(null);
|
|
|
|
useEffect(() => {
|
|
setSavedPositions(loadPositions(projectId));
|
|
}, [projectId]);
|
|
|
|
const persistPositions = useCallback(
|
|
(positions: NodePositions) => {
|
|
savePositions(positions, visibleTaskIds, projectId);
|
|
setSavedPositions(filterVisiblePositions(positions, visibleTaskIds));
|
|
},
|
|
[projectId, visibleTaskIds],
|
|
);
|
|
|
|
const clearSavedPositions = useCallback(() => {
|
|
clearPositions(projectId);
|
|
setSavedPositions(null);
|
|
}, [projectId]);
|
|
|
|
return { savedPositions, persistPositions, clearSavedPositions };
|
|
}
|