Pulastya B commited on
Commit
9585bf4
·
1 Parent(s): f23a49f

Fix plot visibility - extract plots from result.plots array

Browse files

CRITICAL FIX: Frontend was only looking for plots in workflow_history steps,
but backend sends them in result.plots array from enhanced summary.

Changes:
- Added PRIORITY 1: Extract plots from result.plots (main array)
- Added PRIORITY 2: Fallback to workflow_history (backward compatibility)
- Fixed plot extraction to use step.result.result.output_path
- Only use fallback if result.plots is empty

This fixes the issue where correlation heatmap and other single-tool
visualizations weren't showing up in the UI despite being generated.

FRRONTEEEND/components/ChatInterface.tsx CHANGED
@@ -139,7 +139,18 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
139
  let reports: Array<{name: string, path: string}> = [];
140
  let plots: Array<{title: string, url: string, type?: 'image' | 'html'}> = [];
141
 
142
- // Extract plots and reports from workflow_history
 
 
 
 
 
 
 
 
 
 
 
143
  if (result.workflow_history) {
144
  const reportTools = ['generate_ydata_profiling_report', 'generate_plotly_dashboard', 'generate_all_plots'];
145
  const plotTools = [
@@ -164,13 +175,13 @@ export const ChatInterface: React.FC<{ onBack: () => void }> = ({ onBack }) => {
164
  }
165
  }
166
 
167
- if (plotTools.includes(step.tool) && step.result?.plots) {
168
- step.result.plots.forEach((plot: any) => {
169
- plots.push({
170
- title: plot.title || plot.type || 'Plot',
171
- url: plot.url || plot.path,
172
- type: plot.url?.endsWith('.html') ? 'html' : 'image'
173
- });
174
  });
175
  }
176
  });
 
139
  let reports: Array<{name: string, path: string}> = [];
140
  let plots: Array<{title: string, url: string, type?: 'image' | 'html'}> = [];
141
 
142
+ // PRIORITY 1: Extract plots from main result.plots array (backend enhanced summary)
143
+ if (result.plots && Array.isArray(result.plots)) {
144
+ result.plots.forEach((plot: any) => {
145
+ plots.push({
146
+ title: plot.title || 'Visualization',
147
+ url: plot.url || plot.path,
148
+ type: plot.type || (plot.url?.endsWith('.html') ? 'html' : 'image')
149
+ });
150
+ });
151
+ }
152
+
153
+ // PRIORITY 2: Extract plots and reports from workflow_history (for backward compatibility)
154
  if (result.workflow_history) {
155
  const reportTools = ['generate_ydata_profiling_report', 'generate_plotly_dashboard', 'generate_all_plots'];
156
  const plotTools = [
 
175
  }
176
  }
177
 
178
+ // Only extract from workflow if not already in result.plots
179
+ if (plotTools.includes(step.tool) && step.result?.result?.output_path && plots.length === 0) {
180
+ const outputPath = step.result.result.output_path;
181
+ plots.push({
182
+ title: step.tool.replace('generate_', '').replace('interactive_', '').replace(/_/g, ' ').trim(),
183
+ url: outputPath.startsWith('/') ? outputPath : `/outputs/${outputPath.replace('./outputs/', '')}`,
184
+ type: outputPath.endsWith('.html') ? 'html' : 'image'
185
  });
186
  }
187
  });