9.1 KiB
9.1 KiB
Tasks: Analysis Dashboard Redesign
Phase 1: Backend Data Model + API Changes (Foundation)
-
1. Extend SessionData model
- 1.1 Add
rounds: List[Dict]attribute toSessionData.__init__()inweb/main.py, initialized to empty list - 1.2 Add
data_files: List[Dict]attribute toSessionData.__init__()inweb/main.py, initialized to empty list - 1.3 Update
_reconstruct_session()to loadroundsanddata_filesfromresults.jsonwhen reconstructing historical sessions - 1.4 Update
run_analysis_task()to persistsession.roundsandsession.data_filestoresults.jsonon analysis completion
- 1.1 Add
-
2. Update Status API response
- 2.1 Add
roundsfield toGET /api/statusresponse dict, returningsession.rounds - 2.2 Verify backward compatibility: ensure
log,is_running,has_report,progress_percentage,current_round,max_rounds,status_messagefields remain unchanged
- 2.1 Add
-
3. Add Data Files API endpoints
- 3.1 Implement
GET /api/data-filesendpoint: returnsession.data_filesmerged with fallback directory scan for CSV/XLSX files, each entry containing filename, description, rows, cols, size_bytes - 3.2 Implement
GET /api/data-files/previewendpoint: read CSV/XLSX via pandas, return{columns: [...], rows: [...first 5 rows as dicts...]}; return 404 if file not found - 3.3 Implement
GET /api/data-files/downloadendpoint: returnFileResponsewith correct MIME type (text/csvorapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet); return 404 if file not found
- 3.1 Implement
-
4. Enhance Report API for evidence linking
- 4.1 Implement
_extract_evidence_annotations(paragraphs, session)function: parse<!-- evidence:round_N -->comments from paragraph content, look upsession.rounds[N-1].evidence_rows, buildsupporting_datamapping keyed by paragraph ID - 4.2 Update
GET /api/reportto includesupporting_datamapping in response JSON
- 4.1 Implement
Phase 2: CodeExecutor Enhancements
-
5. Add evidence capture to CodeExecutor
- 5.1 In
execute_code(), after successful execution, check ifresult.resultis a DataFrame; if so, captureresult.result.head(10).to_dict(orient='records')asevidence_rows; wrap in try/except returning empty list on failure - 5.2 Also check the last-assigned DataFrame variable in the namespace as a fallback evidence source when
result.resultis not a DataFrame - 5.3 Include
evidence_rowskey in the returned result dict
- 5.1 In
-
6. Add DataFrame auto-detection and export
- 6.1 Before
shell.run_cell(code), snapshot DataFrame variables:{name: id(obj) for name, obj in shell.user_ns.items() if isinstance(obj, pd.DataFrame)} - 6.2 After execution, compare snapshots to detect new or changed DataFrame variables
- 6.3 For each new DataFrame, export to
{output_dir}/{var_name}.csvwith numeric suffix deduplication if file exists - 6.4 Record metadata for each export:
{variable_name, filename, rows, cols, columns}inauto_exported_fileslist - 6.5 Include
auto_exported_fileskey in the returned result dict
- 6.1 Before
-
7. Add DATA_FILE_SAVED marker parsing
- 7.1 After execution, scan
captured.stdoutfor lines matching[DATA_FILE_SAVED] filename: {name}, rows: {count}, description: {desc} - 7.2 Parse each marker line and record
{filename, rows, description}inprompt_saved_fileslist - 7.3 Include
prompt_saved_fileskey in the returned result dict
- 7.1 After execution, scan
Phase 3: Agent Changes
-
8. Structured Round_Data construction in DataAnalysisAgent
- 8.1 Add
_summarize_result(result)method: produce one-line summary from execution result (e.g., "执行成功,输出 DataFrame (150行×8列)" or "执行失败: {error}") - 8.2 In
_handle_generate_code(), constructround_datadict with fields: round, reasoning (fromyaml_data.get("reasoning", "")), code, result_summary, evidence_rows, raw_log, auto_exported_files, prompt_saved_files - 8.3 After constructing round_data, append it to
SessionData.rounds(via progress callback or direct reference) - 8.4 Merge file metadata from
auto_exported_filesandprompt_saved_filesintoSessionData.data_files
- 8.1 Add
-
9. Update system prompts
- 9.1 Add intermediate data saving instructions to
data_analysis_system_promptinprompts.py: instruct LLM to save intermediate results and print[DATA_FILE_SAVED]marker - 9.2 Add evidence annotation instructions to
final_report_system_promptinprompts.py: instruct LLM to add<!-- evidence:round_N -->comments to report paragraphs - 9.3 Update
_build_final_report_prompt()indata_analysis_agent.pyto include collected evidence data from all rounds in the prompt context
- 9.1 Add intermediate data saving instructions to
Phase 4: Frontend Tab Restructuring
-
10. HTML restructuring
- 10.1 In
index.html, replace tab labels: "Live Log" → "执行过程", add "数据文件" tab, keep "Report"; remove "Gallery" tab - 10.2 Replace the
logsTabdiv content with an Execution Process container (executionTab) containing a scrollable round-cards wrapper - 10.3 Add a
datafilesTabdiv with a file-cards grid container and a preview panel area - 10.4 Remove the Gallery tab HTML: carousel container, navigation buttons, image info panel
- 10.1 In
-
11. JavaScript: Execution Process Tab
- 11.1 Add
lastRenderedRoundstate variable andrenderRoundCards(rounds)function: comparerounds.lengthwithlastRenderedRound, create and append new Round_Card DOM elements for new entries only - 11.2 Implement Round_Card HTML generation: collapsed state shows round number + result_summary; expanded state shows reasoning, code (collapsible), result_summary, evidence table ("本轮数据案例"), raw log (collapsible)
- 11.3 Add click handler for Round_Card toggle (collapse/expand)
- 11.4 Add auto-scroll logic: when analysis is running, scroll Execution Process container to bottom after appending new cards
- 11.1 Add
-
12. JavaScript: Data Files Tab
- 12.1 Implement
loadDataFiles(): fetchGET /api/data-files, render file cards showing filename, description, row count - 12.2 Implement
previewDataFile(filename): fetchGET /api/data-files/preview, render a table with column headers and up to 5 rows - 12.3 Implement
downloadDataFile(filename): trigger download viaGET /api/data-files/download - 12.4 In
startPolling(), callloadDataFiles()on each polling cycle when Data Files tab is active or when analysis is running
- 12.1 Implement
-
13. JavaScript: Gallery removal and tab updates
- 13.1 Remove gallery functions:
loadGallery,renderGalleryImage,prevImage,nextImageand state variablesgalleryImages,currentImageIndex - 13.2 Update
switchTab()to handleexecution,datafiles,reportidentifiers instead oflogs,report,gallery - 13.3 Update
startPolling()to callrenderRoundCards()withdata.roundson each polling cycle
- 13.1 Remove gallery functions:
-
14. JavaScript: Supporting data in Report
- 14.1 Update
loadReport()to storesupporting_datamapping from API response - 14.2 Update
renderParagraphReport()to add "查看支撑数据" button below paragraphs that have entries insupporting_data - 14.3 Implement
showSupportingData(paraId): display a popover/modal with evidence rows rendered as a table
- 14.1 Update
-
15. CSS updates
- 15.1 Add
.round-card,.round-card-header,.round-card-body,.round-card-collapsed,.round-card-expandedstyles - 15.2 Add
.data-file-card,.data-preview-tablestyles - 15.3 Add
.supporting-data-btn,.supporting-data-popoverstyles - 15.4 Remove
.carousel-*styles (carousel-container, carousel-slide, carousel-btn, image-info, image-title, image-desc)
- 15.1 Add
Phase 5: Property-Based Tests
- 16. Write property-based tests
- 16.1
PBTProperty 1: Round_Data structural completeness — generate random execution results, verify all required fields present with correct types and insertion order preserved - 16.2
PBTProperty 2: Evidence capture bounded — generate random DataFrames (0-10000 rows, 1-50 cols), verify evidence_rows length <= 10 and each row dict has correct keys - 16.3
PBTProperty 3: Filename deduplication — generate sequences of same-name exports (1-20), verify all filenames unique - 16.4
PBTProperty 4: Auto-export metadata completeness — generate random DataFrames, verify metadata contains variable_name, filename, rows, cols, columns with correct values - 16.5
PBTProperty 5: DATA_FILE_SAVED marker parsing round-trip — generate random filenames/rows/descriptions, verify parse(format(x)) == x - 16.6
PBTProperty 6: Data file preview bounded rows — generate random CSVs (0-10000 rows), verify preview returns at most 5 rows with correct column names - 16.7
PBTProperty 7: Evidence annotation parsing — generate random annotated Markdown, verify correct round extraction and non-annotated paragraph exclusion - 16.8
PBTProperty 8: SessionData JSON round-trip — generate random rounds/data_files, verify serialize then deserialize produces equal data
- 16.1