| 804 | |
| 805 | // Helper: process action objects (used in both tool_result and actions events) |
| 806 | const processActions = (actionList: any[]) => { |
| 807 | for (const action of actionList) { |
| 808 | console.log('[DataLoadingChat] processing action:', action.type, action.name); |
| 809 | if (action.type === 'preview_table') { |
| 810 | const preview: InlineTablePreview = { |
| 811 | name: action.name, |
| 812 | columns: action.columns || [], |
| 813 | sampleRows: action.sample_rows || [], |
| 814 | totalRows: action.total_rows || 0, |
| 815 | csvScratchPath: action.csv_scratch_path, |
| 816 | }; |
| 817 | tables.push(preview); |
| 818 | pendingLoads.push({ |
| 819 | name: action.name, |
| 820 | csvScratchPath: action.csv_scratch_path || '', |
| 821 | preview, confirmed: false, |
| 822 | }); |
| 823 | } else if (action.type === 'load_plan') { |
| 824 | loadPlanRef = { |
| 825 | candidates: (action.candidates || []).map((c: any) => ({ |
| 826 | sourceId: c.source_id, |
| 827 | tableKey: c.table_key, |
| 828 | displayName: c.display_name, |
| 829 | sourceTable: c.source_table, |
| 830 | sourceTableName: c.source_table_name, |
| 831 | filters: c.filters, |
| 832 | sortBy: c.sort_by, |
| 833 | sortOrder: c.sort_order, |
| 834 | resolutionError: c.resolution_error, |
| 835 | selected: !c.resolution_error, |
| 836 | })), |
| 837 | reasoning: action.reasoning, |
| 838 | }; |
| 839 | } |
| 840 | } |
| 841 | }; |
| 842 | |
| 843 | for await (const event of streamRequest(getUrls().DATA_LOADING_CHAT_URL, { |
| 844 | method: 'POST', |