feat: unify Direct Track PDF rendering and simplify export options

Backend changes:
- Apply background image + invisible text layer to all Direct Track PDFs
- Add CHART to regions_to_avoid for text extraction
- Improve visual fidelity for native PDFs and Office documents

Frontend changes:
- Remove JSON, UnifiedDocument, Markdown download buttons
- Simplify to 2-column layout with only Layout PDF and Reflow PDF
- Remove translation JSON download and Layout PDF option
- Keep only Reflow PDF for translated document downloads
- Clean up unused imports (FileJson, Database, FileOutput)

Archives two OpenSpec proposals:
- unify-direct-track-pdf-rendering
- simplify-frontend-export-options

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
egg
2025-12-12 07:50:43 +08:00
parent 53bfa88773
commit 24253ac15e
15 changed files with 891 additions and 195 deletions

View File

@@ -0,0 +1,59 @@
# Change: Simplify Frontend Export Options
## Why
The current frontend has accumulated export options that are no longer needed or rarely used. Following the "Simple OCR" architecture change, we need to streamline the user interface by:
1. Removing redundant export formats that add complexity without significant user value
2. Focusing on the most useful output formats (PDF)
3. Simplifying the translation download options
## What Changes
### TaskDetailPage Changes
**Download Options - Remove:**
- JSON download button
- UnifiedDocument (統一格式) download button
- Markdown download button
**Download Options - Keep:**
- 版面 PDF (Layout PDF)
- 流式 PDF (Reflow PDF)
**Translation Options - Remove:**
- Download translation JSON button
- Download translated Layout PDF option
**Translation Options - Keep:**
- Download translated Reflow PDF (流式 PDF)
**Statistics Section - Keep All:**
- 處理時間 (Processing time)
- 頁數 (Page count)
- 文本區域 (Text regions)
- 表格 (Tables)
- 圖片 (Images)
- 平均置信度 (Average confidence)
### Components - Keep All
- LayoutModelSelector
- PreprocessingSettings
- PreprocessingPreview
- ProcessingTrackSelector
### Pages to Review (Out of Scope)
- SettingsPage (Export rules) - May need separate review
- ResultsPage - May be unused, needs verification
## Impact
- **Affected files**: `frontend/src/pages/TaskDetailPage.tsx`
- **User experience**: Simplified interface with fewer but more relevant options
- **Backend**: No changes required (endpoints remain available for API users)
## Migration
- No data migration required
- Frontend-only changes
- Backend endpoints remain unchanged for API compatibility

View File

@@ -0,0 +1,24 @@
## MODIFIED Requirements
### Requirement: Export Interface
The Export interface in TaskDetailPage SHALL provide streamlined download options focusing on PDF formats.
#### Scenario: Download options for completed tasks
- **WHEN** viewing a completed task in TaskDetailPage
- **THEN** the download section SHALL display only two buttons: "版面 PDF" and "流式 PDF"
- **AND** JSON, UnifiedDocument, and Markdown download buttons SHALL NOT be displayed
- **AND** the download grid SHALL use a 2-column layout
#### Scenario: Translation download options
- **WHEN** viewing completed translations in TaskDetailPage
- **THEN** each translation item SHALL display only a "流式 PDF" download button
- **AND** translation JSON download button SHALL NOT be displayed
- **AND** Layout PDF option for translations SHALL NOT be displayed
- **AND** delete translation button SHALL remain available
#### Scenario: Backend API remains unchanged
- **WHEN** external clients call download endpoints directly
- **THEN** JSON, Markdown, and UnifiedDocument endpoints SHALL still function
- **AND** translated Layout PDF endpoint SHALL still function
- **AND** no backend changes are required for this frontend simplification

View File

@@ -0,0 +1,57 @@
# Tasks: Simplify Frontend Export Options
## 1. TaskDetailPage - Download Section
- [x] 1.1 Remove JSON download button
- File: `frontend/src/pages/TaskDetailPage.tsx`
- Remove: Button with `handleDownloadJSON` onClick
- Remove: `handleDownloadJSON` function (lines 245-261)
- [x] 1.2 Remove UnifiedDocument download button
- File: `frontend/src/pages/TaskDetailPage.tsx`
- Remove: Button with `handleDownloadUnified` onClick
- Remove: `handleDownloadUnified` function (lines 263-279)
- [x] 1.3 Remove Markdown download button
- File: `frontend/src/pages/TaskDetailPage.tsx`
- Remove: Button with `handleDownloadMarkdown` onClick
- Remove: `handleDownloadMarkdown` function (lines 227-243)
- [x] 1.4 Update download grid layout
- File: `frontend/src/pages/TaskDetailPage.tsx`
- Change: Grid from 5 columns to 2 columns (only Layout PDF and Reflow PDF)
- Update: `grid-cols-2 md:grid-cols-5``grid-cols-2`
## 2. TaskDetailPage - Translation Section
- [x] 2.1 Remove translation JSON download button
- File: `frontend/src/pages/TaskDetailPage.tsx`
- Remove: Button with `handleDownloadTranslation` onClick in translation list
- Remove: `handleDownloadTranslation` function (lines 322-338)
- [x] 2.2 Simplify translated PDF download (remove Layout option)
- File: `frontend/src/pages/TaskDetailPage.tsx`
- Change: Remove Select dropdown for PDF format
- Change: Replace with single "流式 PDF" download button
- Keep: `handleDownloadTranslatedPdf` function (always use 'reflow' format)
## 3. Cleanup - Remove Unused Imports
- [x] 3.1 Remove unused Lucide icons
- File: `frontend/src/pages/TaskDetailPage.tsx`
- Removed: `FileJson`, `Database`, `FileOutput`
- Keep: Icons still in use
## 4. Verification
- [ ] 4.1 Verify Layout PDF download works
- Test: Click "版面 PDF" button
- Expected: PDF downloads with preserved layout
- [ ] 4.2 Verify Reflow PDF download works
- Test: Click "流式 PDF" button
- Expected: PDF downloads with flowing text
- [ ] 4.3 Verify translated Reflow PDF download works
- Test: Complete a translation, then click download
- Expected: Translated PDF downloads in reflow format