Commit Graph

124 Commits

Author SHA1 Message Date
test
f45d3df385 fix(component): fix stale closure in MaterialTypeManagementDialog
Fix issue where keyword field was not editable after adding new row via Insert key or Add button. Root cause was incomplete useCallback dependencies in handleKeyDown, causing it to capture stale references to insertNewRow, deleteRow, saveEdit, and cancelEdit functions.

Changes:
- Wrap insertNewRow with useCallback (deps: isAdmin, currentUsername)
- Wrap deleteRow with useCallback (deps: none)
- Wrap startEdit with useCallback (deps: rows)
- Wrap saveEdit with useCallback (deps: editingCell, editValue)
- Wrap cancelEdit with useCallback (deps: none)
- Update handleKeyDown dependency array to include all referenced functions

This ensures all callbacks have access to the latest props and state, preventing the edit mode initialization failure.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-08 13:22:43 +08:00
test
8f3e5273e2 refactor(ipc): harden channels and unify IPC contracts 2026-03-08 12:35:00 +08:00
test
616e2b31a5 fix: add 'nul' to .gitignore to prevent tracking of nul files 2026-03-08 11:22:00 +08:00
test
b3abad7fae feat(playwright): enable Playwright in production builds with custom browser path
Move Playwright from dev to production dependencies and implement robust browser
management for company deployment environment:

- Move playwright and playwright-core to dependencies
- Set PLAYWRIGHT_BROWSERS_PATH to user data directory before imports
- Add startup validation for Chromium browser with friendly error dialog
- Update build scripts to skip browser download during build process
- Configure electron-builder to unpack Playwright for native module access
- Add deployment documentation for browser setup in restricted environments

This allows manual browser installation in company environments where direct
downloads are blocked during build.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-07 19:03:29 +08:00
test
9d15f7aca9 Merge branch 'cleanup/remove-env-variables' into dev 2026-03-07 17:28:14 +08:00
test
310d5e462f fix(hook): fix race condition in progress dialog initialization
Initialize progress state before opening the execution report dialog to ensure the progress view displays correctly from the start.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-07 17:26:57 +08:00
test
c4bacdaf2a fix: correct TypeScript type for YAML config parsing in migration script 2026-03-07 17:25:12 +08:00
test
54a82200b6 refactor: complete migration from .env to YAML configuration
BREAKING CHANGE: Application now uses config.yaml instead of .env files

## Changes:
- Remove dotenv dependency from package.json
- Update all services to use ConfigManager for configuration
- Update tests to use fixed credentials instead of env vars
- Delete obsolete config-manager.test.ts (used old .env API)
- Update documentation (README.md, CLAUDE.md) to reflect new config system

## Configuration Architecture:
- ConfigManager: Centralized YAML configuration with Zod validation
- config.yaml location:
  - Development: Project root (easy to edit and version control)
  - Production: User AppData (persists across updates)
- ERP credentials: Stored in database (dbo_BIPUsers) per user
- Other settings: Stored in config.yaml (database, paths, extraction, etc.)

## Files Modified:
- package.json: Removed dotenv dependency
- cleaner-handler.ts: Use ConfigManager.getDatabaseType()
- run-migration.ts: Read from config.yaml instead of .env
- All integration tests: Use fixed test credentials
- tests/setup.ts: Removed dotenv loading
- README.md, CLAUDE.md: Updated documentation

Migration is complete. Application no longer depends on .env files.
2026-03-07 17:22:13 +08:00
test
2d6838c0e7 fix(component): fix race condition in MaterialTypeManagementDialog row addition
Use functional setState to correctly calculate new row index based on
latest state, preventing stale closure issues.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-07 15:50:47 +08:00
test
73b8f2409a fix(validation): migrate DB config from env to ConfigManager
- Refactor getValidationDatabaseService() to use ConfigManager
- Refactor getTableName() to use ConfigManager.getDatabaseType()
- Replace all process.env.DB_TYPE references with ConfigManager API
- Simplify isSqlServer checks from 'sqlserver||mssql' to 'sqlserver'
- Preserve all business logic and dual-database support
- Typecheck passes successfully

Fixes issue where Cleaner page failed with 'Failed to connect to MySQL'
due to validation-handler.ts not being migrated in commit c13be9e
2026-03-07 15:14:15 +08:00
test
c7c192a703 chore(extractor): add error logging for ERP login failures
Added error message extraction and logging to improve user feedback and debugging when ERP login fails during material plan extraction.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-07 14:51:50 +08:00
test
42bd6dcb8a chore: remove config.yaml from tracking
Runtime config file should not be tracked in git

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-07 14:23:23 +08:00
test
e4a92e9be4 chore: ignore runtime config files and reorganize .gitignore
- Ignore *.yaml and *.yaml.backup files
- Reorganize sections with clear comments

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-07 14:17:49 +08:00
test
6f19890a84 refactor(erp-auth): implement precise login result detection with three outcomes
- Add waitForLoginResult() method using Promise.race to detect:
  - Success: .nc-workbench-icon element visible
  - Failure: '名称或密码错误' error text visible
  - Force login: click confirm button and re-detect
- Extract timeout constants (PAGE_LOAD_TIMEOUT, LOGIN_RESULT_TIMEOUT, FORCE_LOGIN_TIMEOUT)
- Improve error handling with clear error messages
- Add unit tests for class structure verification
- Fix test setup for Electron app mock

Fixes: ERP login success/failure detection was ambiguous
2026-03-07 14:07:08 +08:00
test
1ee33672dd refactor: implement precise login result detection in ERP auth service
Add waitForLoginResult() method with Promise.race to detect three login outcomes:
- Success: detects .nc-workbench-icon element
- Failure: detects '名称或密码错误' error text
- Force login: clicks confirm button and re-detects

Improves login reliability by properly handling all authentication scenarios.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-07 13:48:41 +08:00
test
8e0c37bf74 feat: add ERP login debug tool with documentation
Add interactive debugging tool for ERP login flow analysis:
- Add tsx dependency for TypeScript script execution
- Add npm scripts: debug:erp-login and debug:config-path
- Add erp-login-debug.ts with automated login and element inspection
- Add comprehensive usage guide and quick reference documentation

The debug tool automates ERP login and provides pause points for
manual element inspection using browser DevTools or Playwright Inspector.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-07 13:16:43 +08:00
test
c13be9e19a refactor: migrate configuration to YAML-based system 2026-03-07 11:30:09 +08:00
Misaka
48f1f51d76 refactor: remove unused UI and execution configuration
Remove unused configuration options that were not consumed by the UI:

- Remove UI configuration (UI_FONT_FAMILY, UI_FONT_SIZE, UI_PRODUCTION_ID_INPUT_WIDTH)
  - No UI components were using these settings
  - Settings page had no inputs for these options

- Remove execution configuration (EXECUTION_DRYRUN)
  - Dry run mode is controlled by Cleaner page UI toggle
  - State is managed via sessionStorage, not config file

Files modified:
- src/main/types/settings.types.ts: Remove UiConfig and ExecutionConfig interfaces
- src/main/services/config/config-manager.ts: Remove config read/write logic
- src/main/ipc/settings-handler.ts: Remove filtered fields
2026-03-05 22:02:53 +08:00
Misaka
5977254180 feat: migrate ERP configuration from .env to per-user database storage
- Moved ERP credentials (URL, username, password) from environment variables to dbo_BIPUsers table
- Each user now has their own ERP configuration stored in the database
- Added UserErpConfigService for managing per-user ERP settings
- Updated cleaner and extractor handlers to fetch ERP config from database instead of .env
- Removed ERP fields from ConfigManager UI editable fields
- Added new IPC handlers and preload APIs for user ERP config management
- Includes migration script to transfer existing .env ERP settings to database
- Added migration guide documentation

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-05 21:52:54 +08:00
Misaka
3d2127b660 fix: correct ComputerNmae typo to ComputerName in BIPUsers DAO
- Fix column name typo in BIP_USERS_CONFIG constant
- Update SQL queries to use correct ComputerName column
- Add migration scripts for database schema fix (JS and SQL)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-05 20:35:33 +08:00
google-labs-jules[bot]
7db7f513be refactor: hardcode erp headless and browser settings instead of env vars
- Removed ERP_HEADLESS, ERP_IGNORE_HTTPS_ERRORS, ERP_AUTO_CLOSE_BROWSER from ConfigManager .env operations.
- Hardcoded these values in ConfigManager's default settings and getAllSettings() return.
- Hardcoded ignoreHTTPSErrors to true inside ErpBrowserManager when creating a new browser context.

Co-authored-by: luwamgere15-crypto <255338376+luwamgere15-crypto@users.noreply.github.com>
2026-03-05 10:48:50 +00:00
Misaka_Company
a906f34ac2 feat: auto-generate markdown report after cleaner execution
- Add CleanerReportGenerator service to create execution reports
- Extend OrderCleanDetail with skippedMaterials for detailed tracking
- Record skip reasons for each material (protected range, pending qty, etc.)
- Generate timestamped markdown reports in logs/reports/ directory
- Reports include execution summary, order details, skip reasons, and errors
2026-03-05 16:19:40 +08:00
Misaka_Company
224a42e44b docs: update cleaner execution report error details section 2026-03-05 15:07:17 +08:00
Misaka_Company
7d2cf934f8 feat: add estimated completion time to cleaner progress dialog
- Display remaining time estimate (in minutes) when progress >= 5%
- Show estimated completion time in 12-hour format (上午/下午 HH:MM:SS)
- Update every second during execution
- Add startTime state tracking in useCleaner hook
2026-03-05 14:17:34 +08:00
Misaka_Company
49ac29e70c Merge feature/cleaner-progress into dev
Merged progress indicator feature for cleaner execution:
- CleanerProgress type for tracking execution progress
- Progress calculation: (1 + i + j/Mᵢ)/(1+N) × 100
- cleaner.onProgress IPC event for real-time updates
- Enhanced ExecutionReportDialog with progress bar
- Progress state management in useCleaner hook
2026-03-05 13:28:34 +08:00
Misaka_Company
dc01896d8b feat: add progress indicator to cleaner execution report dialog
- Add CleanerProgress type for tracking execution progress
- Implement progress calculation: (1 + i + j/Mᵢ)/(1+N) × 100
  - Login complete: 1/(1+N) × 100
  - Per material: (1 + orderIndex + materialIdx/totalMaterials)/(1+totalOrders) × 100
- Add cleaner.onProgress IPC event for real-time progress updates
- Enhance ExecutionReportDialog with progress bar and status display
- Update useCleaner hook with progress state management
- Dialog opens immediately on execution start, showing progress then results
2026-03-05 13:25:04 +08:00
Misaka_Company
ba64c27457 feat: allow editing manager field in cleaner table
- Add inline editing for manager column (Admin users can double-click to select from dropdown)
- Auto-assign current user as manager when User checks a material
- Defer database writes until 'Confirm Delete' button is clicked
- Add updateManager IPC handler and DAO method
- Update preload API with updateManager method
2026-03-05 13:19:12 +08:00
Misaka_Company
921ca15be6 feat: add execution report dialog for cleaner
- Create ExecutionReportDialog component with Ant Design style
- Replace native alert() with modal dialog after cleaner execution
- Display orders processed, materials deleted/skipped statistics
- Show error details in scrollable list
- Support dry-run mode indicator
2026-03-05 11:15:44 +08:00
Misaka_Company
121d49bfe8 docs: add configuration system architecture analysis 2026-03-05 10:55:15 +08:00
Misaka_Company
0783bc037c Fix: Set text color for login input fields 2026-03-05 10:19:19 +08:00
Misaka_Company
d855b3f84d Fix: Set dryRun mode default to false for User in Cleaner page 2026-03-05 10:15:21 +08:00
Misaka_Company
e0d7559cf7 Fix: Hide progress display when clearing order numbers and remove progress text from LogPanel 2026-03-05 10:12:09 +08:00
Misaka
302018f631 Feat: Add extraction complete status indicator with success message 2026-03-04 22:56:00 +08:00
Misaka
e49191d531 Add .gitattributes to enforce consistent line endings 2026-03-04 22:19:06 +08:00
Misaka
2dea1f9556 Feat: Add segmented progress bar for data extractor with dynamic phase calculation
- Add ExtractionProgress type with phase, batch, and subProgress fields
- Implement dynamic progress calculation: 1 (login) + N (batches) + 2 (merge/import)
- Create SegmentedProgressBar component with 4 colored phases (purple/blue/amber/green)
- Show batch-level progress during download phase (e.g., 批次 1/10)
- Display sub-progress during login phase (连接数据库/解析订单号/登录 ERP)
- Update IPC handler and extractor services to report detailed progress
- Add phase status indicators (completed/active/pending) with color-coded dots
2026-03-04 22:16:47 +08:00
Misaka
4494351e52 Merge branch 'dev' into extractor-page-refactoring-11498013679550826416 2026-03-04 21:03:21 +08:00
Misaka
9e1b5530ea Feat: Add real-time progress and logging to data extractor
- Implement IPC event system for pushing progress updates from main to renderer
- Add Zustand store for centralized extractor state management
- Refactor useExtractor hook to use store pattern
- Add chromium-bidi dependency and externalize Playwright for build compatibility
- Show detailed logs during extraction (DB connection, order resolution, ERP login, data import)
2026-03-04 20:51:54 +08:00
google-labs-jules[bot]
743d830b0d Refactor CleanerPage with custom hook useCleaner
* Extracted state management and IPC actions from `CleanerPage.tsx` into a custom hook `useCleaner.ts`.
* `CleanerPage.tsx` is now much more focused on UI layout and rendering.
* Addressed code responsibilities issue, minimizing the size of the component file from nearly 500 lines to just the necessary UI structure.
* Verified no regressions via type checking and application building.

Co-authored-by: luwamgere15-crypto <255338376+luwamgere15-crypto@users.noreply.github.com>
2026-03-04 12:18:35 +00:00
google-labs-jules[bot]
dcd3c6a571 Refactor ExtractorPage with custom hooks and UI components
* Extract logic and state management from `ExtractorPage.tsx` into a custom hook `useExtractor.ts`.
* Extract log rendering logic and auto-scrolling into a separate `LogPanel.tsx` component.
* `ExtractorPage.tsx` is now significantly smaller, focused purely on presentation.
* Verified no regressions via type checking and application building.

Co-authored-by: luwamgere15-crypto <255338376+luwamgere15-crypto@users.noreply.github.com>
2026-03-04 12:11:56 +00:00
Misaka
9939201ca1 Fix: Add chromium-bidi dependency and externalize Playwright to resolve module loading errors 2026-03-04 20:04:48 +08:00
google-labs-jules[bot]
fed76b4fe0 Refactor ExtractorPage with custom hooks and UI components
* Extract logic and state management from `ExtractorPage.tsx` into a custom hook `useExtractor.ts`.
* Extract log rendering logic and auto-scrolling into a separate `LogPanel.tsx` component.
* `ExtractorPage.tsx` is now significantly smaller, focused purely on presentation.
* Verified no regressions via type checking and application building.

Co-authored-by: luwamgere15-crypto <255338376+luwamgere15-crypto@users.noreply.github.com>
2026-03-04 11:18:04 +00:00
Misaka_Company
bfa2445c76 fix: add batch processing to prevent SQL Server 2100 parameter limit error
- Add batch processing in getSourceNumbersFromInputs() with 2000 batch size
- Reduce batch size from 2000 to 1500 in queryBySourceNumbers() and queryBySourceNumbersDistinct()
- Add batch processing to queryByPlanNumbers() and getUniqueMaterialNames()
- Fixes issue where large order quantities caused parameter limit exceeded error
2026-03-04 18:05:35 +08:00
Misaka_Company
b62ae10650 feat: add headless mode toggle and improve CleanerPage layout
- Add headless mode setting with session persistence in CleanerPage
- Move execution settings (dry-run, headless) to dropdown menu
- Improve responsive layout for admin/non-admin users
- Fix home page content overflow issue
2026-03-04 17:46:40 +08:00
Misaka_Company
974eaac6dd docs: update extractor-start-button-flow.md to v1.3
- Add file merging functionality (ExcelParser merges batch files)
- Add database auto-import feature (DataImportService)
- Update architecture diagrams to include ExtractorCore separation
- Update sequence diagram with 76-step workflow
- Add DataImportService and DiscreteMaterialPlanDAO to flow
- Document ImportResult type and import statistics
- Update error handling to include merge and import errors
- Add temporary file cleanup after merging
2026-03-04 17:01:50 +08:00
Misaka_Company
2f5dc7607d fix: disable TLS encryption by default to avoid ServerName IP address warning
- Set encrypt: false as default for SQL Server connections
- Fixes DEP0123 deprecation warning when connecting via IP address (VPN tunnel)
- trustServerCertificate option still configurable via environment variable
- Affects 6 files: sql-server.ts, bip-users-dao.ts, database/index.ts,
  database/data-source.ts, cleaner-handler.ts, validation-handler.ts
2026-03-04 16:53:58 +08:00
Misaka_Company
a06276127d fix: resolve Chinese character encoding issue in console output
- Set console code page to UTF-8 (65001) in build scripts
- Fix garbled Chinese characters in winston logger output
2026-03-04 16:24:13 +08:00
Misaka_Company
29cb79abfd style: improve UI layout and styling
- Increase default window width from 900 to 1200
- Beautify clear button in OrderNumberInput with icon and hover effects
- Simplify ExtractorPage layout by removing collapsible sidebar
- Center settings form controls horizontally in SettingsPage
2026-03-04 16:06:00 +08:00
Misaka_Company
dc3d577f6f refactor: optimize ExtractorPage layout and UX
- Use OrderNumberInput component with format statistics
- Add collapsible sidebar with smooth animation
- Improve log system with level-based coloring and auto-scroll
- Remove result display cards for cleaner interface
- Add file:openPath IPC handler for opening files in explorer
2026-03-04 15:52:41 +08:00
Misaka_Company
50041d2a7b fix: remove validationResults check from cleaner execute button
Allow execute button to be clickable by default, relying on backend validation instead of frontend disabled state
2026-03-04 15:14:59 +08:00
Misaka_Company
9833552652 fix: support both MySQL and SQL Server in cleaner handler 2026-03-04 14:56:19 +08:00