MCPcopy Create free account
hub / github.com/microsoft/data-formulator / EncodingShelfCard

Function EncodingShelfCard

src/views/EncodingShelfCard.tsx:361–1733  ·  view source on GitHub ↗
({ chartId })

Source from the content-addressed store, hash-verified

359
360
361export const EncodingShelfCard: FC<EncodingShelfCardProps> = function ({ chartId }) {
362 const { t } = useTranslation();
363 const theme = useTheme();
364
365 const getChartNameTip = (chartName: string) => {
366 const key = chartNameToI18nKey[chartName];
367 return key ? t(`chart.templateNames.${key}`) : '';
368 };
369 const getChartCategoryTip = (category: string) => {
370 const key = chartCategoryToI18nKey[category];
371 return key ? t(`chart.chartCategoryTip.${key}`) : '';
372 };
373
374 // reference to states
375 const tables = useSelector((state: DataFormulatorState) => state.tables);
376 const focusedId = useSelector((state: DataFormulatorState) => state.focusedId);
377
378 let allCharts = useSelector(dfSelectors.getAllCharts);
379
380 // The table the user is currently looking at (from focused state)
381 const focusedTableId = (() => {
382 if (!focusedId) return undefined;
383 if (focusedId.type === 'table') return focusedId.tableId;
384 if (focusedId.type === 'chart') {
385 const focusedChart = allCharts.find(c => c.id === focusedId.chartId);
386 return focusedChart?.tableRef;
387 }
388 return undefined;
389 })();
390
391 let chart = allCharts.find(c => c.id == chartId) as Chart;
392 let trigger = chart.source == "trigger" ? tables.find(t => t.derive?.trigger?.chart?.id == chartId)?.derive?.trigger : undefined;
393
394 const triggerPrompt = trigger?.interaction?.find(e => e.role === 'instruction')?.content || '';
395 let [prompt, setPrompt] = useState<string>(triggerPrompt);
396
397 // Restyle (chart style refinement agent) — see design-docs/28-chart-style-refinement-agent.md
398 const [isRestyling, setIsRestyling] = useState<boolean>(false);
399 // Per-variant refresh in progress (variantId being refreshed, or null).
400 const [refreshingVariantId, setRefreshingVariantId] = useState<string | null>(null);
401 // Intent-classifier round-trip in progress. Distinct from isRestyling so
402 // the UI can show a single "thinking" state on the submit button covering
403 // classify → route → execute. See submitPrompt() and the discussion in
404 // chat about routing on Enter.
405 const [isClassifying, setIsClassifying] = useState<boolean>(false);
406 // Phase shown in the inline status banner below the prompt input. Covers
407 // the whole submit pipeline so the user always knows what's happening:
408 // classifying → restyling | formulating → idle.
409 // Set explicitly inside submitPrompt() and cleared by the effect below
410 // that watches chartSynthesisInProgress for the data-agent path.
411 const [submitPhase, setSubmitPhase] = useState<
412 'idle' | 'classifying' | 'restyling' | 'formulating'
413 >('idle');
414 const chartSynthesisInProgress = useSelector(
415 (state: DataFormulatorState) => state.chartSynthesisInProgress,
416 );
417 const isDataAgentRunning = chartSynthesisInProgress.includes(chartId);
418 // While we're in 'formulating' phase, watch the redux flag and clear the

Callers

nothing calls this directly

Calls 15

useFormulateDataFunction · 0.90
getDataTableFunction · 0.90
checkChartAvailabilityFunction · 0.90
getChartChannelsFunction · 0.90
isVariantStaleFunction · 0.90
getChartTemplateFunction · 0.90
ThinkingBannerFunction · 0.90
renderVariantChipFunction · 0.85
handleRefreshVariantFunction · 0.85
submitPromptFunction · 0.85
handleRestyleSubmitFunction · 0.85
getIdeasForVisualizationFunction · 0.85

Tested by

no test coverage detected