* Build a rich focused thread from the current table's derivation chain. * Each step includes: user question, display instruction, chart type + encodings, * created table metadata, and agent summary.
(currentTable: DictTable)
| 115 | * created table metadata, and agent summary. |
| 116 | */ |
| 117 | function buildFocusedThread(currentTable: DictTable): any[] { |
| 118 | if (!currentTable.derive || currentTable.anchored) return []; |
| 119 | const triggers = getTriggers(currentTable, tables); |
| 120 | return triggers.map(trigger => { |
| 121 | const resultTable = tables.find(t2 => t2.id === trigger.resultTableId); |
| 122 | const interaction = trigger.interaction || []; |
| 123 | const userPrompt = interaction.find(e => e.role === 'prompt')?.content; |
| 124 | const instruction = interaction.find(e => e.role === 'instruction'); |
| 125 | const summary = interaction.find(e => e.role === 'summary'); |
| 126 | // Resolve the actual rendered chart (not the trigger's "Auto" stub) |
| 127 | // so chart_type + encodings reflect what the user is looking at. |
| 128 | const resolvedChart = resolveChartForTable(trigger.resultTableId); |
| 129 | return { |
| 130 | user_question: userPrompt || instruction?.content || '', |
| 131 | display_instruction: instruction?.displayContent || instruction?.content || '', |
| 132 | agent_thinking: instruction?.plan, |
| 133 | agent_summary: summary?.content, |
| 134 | table_name: resultTable?.virtual?.tableId || trigger.resultTableId, |
| 135 | columns: resultTable?.names || [], |
| 136 | row_count: resultTable?.virtual?.rowCount ?? resultTable?.rows?.length ?? 0, |
| 137 | chart_type: resolvedChart?.chartType || '', |
| 138 | encodings: chartEncodingsByName(resolvedChart), |
| 139 | }; |
| 140 | }); |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Build a legacy exploration thread (flat table list) for backward compatibility. |
no test coverage detected