feat(canvas): Add file browser, introspection, and improve node flow
Phase 1-7 of Canvas V4 Ralph Loop implementation: Backend: - Add /api/files routes for browsing model files - Add /api/nx routes for NX model introspection - Add NXIntrospector service to discover expressions and extractors - Add health check with database status Frontend: - Add FileBrowser component for selecting .sim/.prt/.fem files - Add IntrospectionPanel to discover expressions and extractors - Update NodeConfigPanel with browse and introspect buttons - Update schema with NODE_HANDLES for proper flow direction - Update validation for correct DesignVar -> Model -> Solver flow - Update useCanvasStore.addNode() to accept custom data Flow correction: Design Variables now connect TO Model (as source), not FROM Model. This matches the actual data flow in optimization. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -89,14 +89,63 @@ export interface CanvasEdge {
|
||||
targetHandle?: string;
|
||||
}
|
||||
|
||||
// Valid connections
|
||||
// Valid connections - defines what a node can connect TO (as source)
|
||||
// Flow: DesignVar -> Model -> Solver -> Extractor -> Objective/Constraint -> Algorithm -> Surrogate
|
||||
export const VALID_CONNECTIONS: Record<NodeType, NodeType[]> = {
|
||||
model: ['solver', 'designVar'],
|
||||
solver: ['extractor'],
|
||||
designVar: ['model'],
|
||||
extractor: ['objective', 'constraint'],
|
||||
objective: ['algorithm'],
|
||||
constraint: ['algorithm'],
|
||||
algorithm: ['surrogate'],
|
||||
surrogate: [],
|
||||
model: ['solver'], // Model outputs to Solver
|
||||
solver: ['extractor'], // Solver outputs to Extractor
|
||||
designVar: ['model'], // DesignVar outputs to Model (expressions feed into model)
|
||||
extractor: ['objective', 'constraint'], // Extractor outputs to Objective/Constraint
|
||||
objective: ['algorithm'], // Objective outputs to Algorithm
|
||||
constraint: ['algorithm'], // Constraint outputs to Algorithm
|
||||
algorithm: ['surrogate'], // Algorithm outputs to Surrogate
|
||||
surrogate: [], // Surrogate is terminal
|
||||
};
|
||||
|
||||
// Node handle configuration for proper flow direction
|
||||
export interface HandleConfig {
|
||||
id: string;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export interface NodeHandleConfig {
|
||||
inputs: HandleConfig[];
|
||||
outputs: HandleConfig[];
|
||||
}
|
||||
|
||||
// Define handles for each node type
|
||||
// Flow: DesignVar(s) -> Model -> Solver -> Extractor(s) -> Objective(s) -> Algorithm
|
||||
export const NODE_HANDLES: Record<NodeType, NodeHandleConfig> = {
|
||||
model: {
|
||||
inputs: [{ id: 'params', label: 'Parameters' }], // Receives from DesignVars
|
||||
outputs: [{ id: 'sim', label: 'Simulation' }], // Sends to Solver
|
||||
},
|
||||
solver: {
|
||||
inputs: [{ id: 'model', label: 'Model' }], // Receives from Model
|
||||
outputs: [{ id: 'results', label: 'Results' }], // Sends to Extractors
|
||||
},
|
||||
designVar: {
|
||||
inputs: [], // No inputs - this is a source
|
||||
outputs: [{ id: 'value', label: 'Value' }], // Sends to Model
|
||||
},
|
||||
extractor: {
|
||||
inputs: [{ id: 'results', label: 'Results' }], // Receives from Solver
|
||||
outputs: [{ id: 'value', label: 'Value' }], // Sends to Objective/Constraint
|
||||
},
|
||||
objective: {
|
||||
inputs: [{ id: 'value', label: 'Value' }], // Receives from Extractor
|
||||
outputs: [{ id: 'objective', label: 'Objective' }], // Sends to Algorithm
|
||||
},
|
||||
constraint: {
|
||||
inputs: [{ id: 'value', label: 'Value' }], // Receives from Extractor
|
||||
outputs: [{ id: 'constraint', label: 'Constraint' }], // Sends to Algorithm
|
||||
},
|
||||
algorithm: {
|
||||
inputs: [{ id: 'objectives', label: 'Objectives' }], // Receives from Objectives/Constraints
|
||||
outputs: [{ id: 'algo', label: 'Algorithm' }], // Sends to Surrogate
|
||||
},
|
||||
surrogate: {
|
||||
inputs: [{ id: 'algo', label: 'Algorithm' }], // Receives from Algorithm
|
||||
outputs: [], // No outputs - this is a sink
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user