feat(ui,web): add Excel (.xlsx) upload with sheet selection and CSV normalization#39
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45466fae47
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const selected = UI.inputType?.value || 'auto'; | ||
| if (selected !== 'auto') return selected; | ||
| const name = String(file?.name || '').toLowerCase(); | ||
| if (name.endsWith('.xlsx') || name.endsWith('.xls')) return 'excel'; |
There was a problem hiding this comment.
Stop treating
.xls files as supported Excel uploads
The frontend now detects .xls as excel and routes those files through the Excel upload flow, but the backend parser only supports OOXML workbooks (it requires xl/workbook.xml from a ZIP package), so legacy .xls uploads will always fail in /api/sheets and /api/analyze. This creates a user-visible regression where a selectable file type is guaranteed to error unless support is removed or true .xls parsing is added.
Useful? React with 👍 / 👎.
| return { | ||
| input_type: 'csv', | ||
| source_name: file.name, | ||
| normalized_csv_text: await file.text(), |
There was a problem hiding this comment.
Preserve edited CSV text when a file is selected
For CSV uploads, buildAnalyzeRequest now always sends await file.text() when a file is present, which ignores the current csvText textarea content. This means if a user loads a CSV, edits/fixes it in the textarea, and clicks analyze, the server receives stale original file contents instead of the visible edited data, leading to incorrect analysis output.
Useful? React with 👍 / 👎.
Motivation
/api/analyzeand/api/multi-analyzeflows.Description
inputTypeselector,sheetSelectdropdown andrefreshSheetsBtn, and allowed.xlsx/.xlsaccept on single and multi file inputs inbitnet_tools/ui/index.html.bitnet_tools/ui/app.js(getInputTypeForFile,readFileAsBase64,fetchSheetsForFile,buildAnalyzeRequest,buildMultiPayloadFiles) and wired events so Excel files are sent as base64 +sheet_namewhile CSVs continue to sendnormalized_csv_text.bitnet_tools/web.pyusing OOXML parsing (ZIP + XML) to avoid an external dependency, with_normalize_excel_base64_to_csv_text,_extract_sheet_names, and_coerce_csv_text_from_file_payloadutilities that convert Excel sheets to CSV text and validate headers/rows./api/sheetsto return available sheet names; updated/api/analyze,/api/multi-analyze, and chart job preprocessing to accept file payloads withinput_type/file_base64and normalize them internally tonormalized_csv_textfor the existing analysis path.errormessage pluserror_detailwith the precise cause to show both a compact user message and actionable detail.Testing
python -m py_compile bitnet_tools/web.py(succeeded).node --check bitnet_tools/ui/app.js(succeeded)..xlsxsmoke test that exercised_extract_sheet_namesand_normalize_excel_base64_to_csv_textusing a generated OOXML ZIP payload (succeeded and produced expected CSV text and sheet list).Codex Task