Browse Source

fix: embed directoryPath in workflow JSON for portable image hydration

When importing a workflow via file picker, loadWorkflow had no way to
find the image files on disk because directoryPath was only stored in
localStorage (which doesn't survive browser switches or clears).

Now auto-save embeds directoryPath in the workflow JSON, and
loadWorkflow uses it as a fallback after the workflowPath parameter
and localStorage config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 5 months ago
parent
commit
0e8cecc59c
  1. 6
      src/store/workflowStore.ts

6
src/store/workflowStore.ts

@ -102,6 +102,7 @@ export interface WorkflowFile {
version: 1;
id?: string; // Optional for backward compatibility with old/shared workflows
name: string;
directoryPath?: string; // Embedded save path so image hydration works on import
nodes: WorkflowNode[];
edges: WorkflowEdge[];
edgeStyle: EdgeStyle;
@ -1470,8 +1471,8 @@ export const useWorkflowStore = create<WorkflowStore>((set, get) => ({
const configs = loadSaveConfigs();
const savedConfig = workflow.id ? configs[workflow.id] : null;
// Determine the workflow directory path (passed in or from saved config)
const directoryPath = workflowPath || savedConfig?.directoryPath;
// Determine the workflow directory path (passed in, from saved config, or embedded in workflow)
const directoryPath = workflowPath || savedConfig?.directoryPath || workflow.directoryPath;
// Hydrate images if we have a directory path and the workflow has image refs
let hydratedWorkflow = workflow;
@ -1666,6 +1667,7 @@ export const useWorkflowStore = create<WorkflowStore>((set, get) => ({
version: 1,
id: workflowId,
name: workflowName,
directoryPath: saveDirectoryPath,
nodes: currentNodes,
edges,
edgeStyle,

Loading…
Cancel
Save