- Make logAudit and closeAuditLogger synchronous (were async for no reason)
- Set audit-logger silent:true initially, enable on applyAuditConfig()
- Add try-catch for circular references in consoleFormat meta JSON
- Update all callers to remove unnecessary await/.catch() on sync functions
- Add comment to shared.ts explaining acceptable sync FS usage
- Fix audit-logger test for sync closeAuditLogger
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add LOGGER_LEVEL_CHANGED IPC channel for broadcasting level changes
- setLogLevel() now notifies all BrowserWindows when level changes
- Add verbose case in IPC forwardToWinston (was falling through to info)
- Renderer logger API listens for level changes and updates cached level
- Add cleanup() method to remove level change listener
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cache isProduction() result at module load to avoid repeated property
lookups. Add isSerializedError() check in format functions to skip
re-serialization when error objects have already been processed by
logError/formatErrorForLogging.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move logger close from before-quit to will-quit to keep the logger available
for uncaughtException handlers that may fire during shutdown. Remove 4
redundant console.error calls that duplicate Winston logger output.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. Extract shared module: consolidate getLogDir() and isProduction()
into shared.ts, eliminate duplication across logger modules
2. Make retention config effective: delay file transport creation
until config is loaded, apply appRetention/auditRetention from config.yaml
3. Add before-quit log flush: close logger and audit logger on
app exit to prevent log loss
4. Unify logError entry point: remove duplicate logError from index.ts,
re-export from error-utils.ts with richer error context
5. Renderer log level filtering: add client-side level check in preload
to skip IPC for filtered-out messages
6. Child logger cache + audit cleanup: cache child loggers in IPC
handler for performance, remove redundant timestamp format in audit logger
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When Admin switches user and the switched user logs out, instead of
showing the login dialog, re-run silent login to detect if the
computer belongs to an Admin user and show user selection dialog.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add Admin-only delete button in operation history modal
- Replace dropdown with multi-select chip filters for Admin users
- Support filtering by multiple usernames using IN clause
- Fix user state propagation by passing currentUser via props
- Change GetBatchesOptions.username to usernames (array)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The database stores time in UTC format, and the UI should display UTC
time without timezone conversion. Use getUTCXxx() methods instead of
getHours() to avoid adding 8-hour timezone offset.
Also extract common datetime formatting logic to reduce code duplication.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add copy buttons in table headers for "总排号" and "订单号" columns
- Copy all non-empty values as newline-separated text
- Show toast notification with copied data count
- Handle clipboard errors gracefully
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously updateBatchStatus wrote the batch-level total recordCount to
every row, causing the detail view to show misleading identical counts.
Now mergeFiles collects per-order material counts, the handler writes
each order's count individually via updateRecordStatus, and batch
aggregation uses SUM instead of MAX for accurate totals.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MySQL binary protocol prepared statements (connection.execute()) do not
support ? placeholders in LIMIT/OFFSET clauses, causing "Incorrect
arguments to mysqld_stmt_execute". Embed validated integer values directly
for MySQL while keeping parameterized queries for SQL Server.
Also apply React best practices to ExtractorOperationHistoryModal:
- Hoist formatDateTime to module level
- Wrap async handlers with useCallback for stable effect dependencies
- Import shared types instead of duplicating definitions
- Use ternary for conditional rendering
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a new operation history feature for the extractor module that tracks
all extraction operations with persistent database storage.
Features:
- Records extraction operations with batch tracking (UUID-based)
- Preserves production ID to order number mapping
- Shows batch statistics (orders, records, success/failure counts)
- Expandable details for each batch showing individual order records
- User-based permission: Admin sees all records, User sees own records only
- Delete functionality with permission validation
Database:
- New ExtractorOperationHistory table schema
- Supports both SQL Server and MySQL
- Indexed on BatchId, UserId, and OperationTime
Files:
- Add DAO class for history operations
- Add IPC handler with permission checks
- Add preload API wrapper
- Add React modal component with expandable batch details
- Integrate history recording into extractor handler
- Add operation history button to ExtractorPage
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove all references to 'Guest' user type from the codebase, simplifying the role system to only support 'Admin' and 'User' roles.
Changes:
- Update type definitions to exclude 'Guest' from UserType
- Remove isGuest() method from SessionManager
- Remove Guest-specific logic from update services
- Update all type assertions from 'Admin | User | Guest' to 'Admin | User'
- Remove Guest UI styling from UserSelectionDialog
- Replace Guest fallback with ValidationError in settings handler
Error handling:
- Zod schema now rejects 'Guest' as invalid user type
- TypeScript will fail compilation if 'Guest' is referenced
- Runtime errors occur if database contains Guest users
No database migration needed (confirmed: no Guest users exist)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Document the major refactoring work and improvements in 1.6.1:
- Component architecture restructure (948 → 200 lines)
- Tooltip display fixes and formatting improvements
- Performance optimizations following Vercel React best practices
- Enhanced code maintainability and developer experience
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Break down 948-line monolithic component into 11 focused modules following
Vercel React best practices:
**Module Structure:**
- types.ts: Centralized type definitions and constants
- hooks/: Custom hooks for data management (useReportData, useChartData, useReportFilters)
- components/: Reusable UI components (MetricSelector, ViewModeToggle, UserFilter, ReportChart, Tooltips)
- utils/: Parser and aggregator utility functions
**Key Improvements:**
- Reduced main component from 948 to ~200 lines (79% reduction)
- Separated concerns: data fetching, state management, and UI rendering
- Enhanced reusability and testability of individual components
- Maintained backward compatibility with existing imports
**Additional Fixes:**
- Fixed tooltip displaying duplicate average time values
- Formatted time values to 1 decimal place in both views
- Removed redundant time display from tooltip footer
**Performance Optimizations Applied:**
- Moved tooltip components outside parent component (rerender-no-inline-components)
- Hoisted regex pattern creation outside loops (js-hoist-regexp)
- Used functional setState updates (rerender-functional-setState)
- Memoized expensive computations and callbacks
All changes maintain existing functionality while improving code quality
and maintainability.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Restrict metric selection to single choice in user comparison view
- Auto-keep first selected metric when switching to comparison mode
- Update UI label to show "单选" or "多选" based on view mode
- Improve chart readability by preventing metric overload in comparison mode
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix bug where chart displayed accumulated total execution time instead of per-order average. The executionTimeSecs field now correctly shows average time per order (total time / total orders) for proper performance metrics.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This merge brings in the report analysis feature for admin users, including:
- Report analysis dialog with metrics visualization
- Execution time statistics parsing improvements
- Daily aggregated metrics with charts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Enhanced value extraction with multi-pattern regex approach to handle various markdown table formats. Improved parseDurationToSeconds error handling for edge cases. Added debug logging for failed extractions.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Added a new ReportAnalysisDialog component, accessible from the ReportViewerDialog, strictly for Admin users. It parses execution reports, extracts markdown metrics like processed orders, skipped materials, errors, and execution time, and presents them in an interactive recharts line chart aggregated by day.
Co-authored-by: luwamgere15-crypto <255338376+luwamgere15-crypto@users.noreply.github.com>
- Change update check and download to async execution, allowing immediate app entry for User users
- Updates run in background, showing update prompt when download completes
- Optimize login flow experience, eliminating blocking time caused by update downloads
- Add release notes for version 1.5.1
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>