Skip to content

Dev2alpha#183

Merged
mkdir700 merged 8 commits intoalphafrom
dev2alpha
Sep 16, 2025
Merged

Dev2alpha#183
mkdir700 merged 8 commits intoalphafrom
dev2alpha

Conversation

@mkdir700
Copy link
Owner

@mkdir700 mkdir700 commented Sep 16, 2025

Summary by CodeRabbit

  • New Features

    • Click words in subtitles to open a dictionary popover with pronunciations, definitions, and translations, including audio playback. Added Chinese localization for dictionary UI.
    • Integrated error/crash monitoring to improve stability.
    • Optimized update channels with region-aware routing for users in China.
  • Bug Fixes

    • Prevented crashes on environments without ResizeObserver.
    • More resilient dictionary parsing across varied formats.
  • Chores

    • Added prerelease support to release sync workflow.
    • Updated update feed URLs and added Sentry dependency.
  • Tests

    • Added end-to-end tests for subtitle dictionary lookup and playback behavior.

… theme support (#171)

* feat(player): show inline dictionary popover

* enhance(player): improve word lookup popup UI and functionality

- Enhanced dictionary popover with better visual design
- Added pronunciation button with speech synthesis
- Improved loading and error states display
- Limited definitions display to 6 items with more indicator
- Added translation section with tags layout
- Implemented responsive design and custom scrollbar
- Enhanced fade-in animation for better UX
- Fixed ResizeObserver compatibility in test environment
- Updated tests to cover new features and error states

Fixes: Improve word lookup popup appearance and functionality

* refactor(player): optimize part-of-speech tags layout in dictionary popup

- Changed definition layout from column to row for better space usage
- Made part-of-speech tags more compact with inline layout
- Reduced vertical space occupied by multiple definitions
- Improved visual balance with fixed-width centered tags
- Enhanced readability with better alignment and spacing

Resolves space efficiency issues with multiple part-of-speech tags

* refactor(player): extract DictionaryPopover as independent component

- Created standalone DictionaryPopover component with complete UI
- Moved all dictionary-related logic and styles to separate component
- Simplified SubtitleOverlay by removing 200+ lines of dictionary code
- Maintained all existing functionality (pronunciation, loading states, error handling)
- Improved code organization and maintainability
- Enhanced component reusability and testability

Benefits:
- Better separation of concerns
- Easier to maintain and test dictionary functionality
- Reduced SubtitleOverlay complexity
- Improved code organization

* fix(player): prevent DictionaryPopover overflow on screen edges

- Added intelligent position calculation algorithm
- Implemented 6 placement modes: top/bottom with left/right/center alignment
- Automatic position adjustment based on viewport boundaries
- Prevents horizontal overflow with 10px safety margin
- Dynamic transform calculations for different placements
- Maintains optimal positioning while avoiding screen edges
- Enhanced user experience for edge-case word selections

Benefits:
- No more cutoff popover on right/left screen edges
- Smart positioning adapts to available space
- Consistent visual appearance across all positions
- Improved accessibility and usability

* feat(player): add comprehensive dictionary popover with theme support and pronunciation

- Implement new DictionaryPopover component using Ant Design Popover for intelligent positioning
- Add comprehensive pronunciation parsing with UK/US audio support and voice parameters
- Enhance dictionary service parsing to handle complex HTML structures and <i> tag formats
- Add theme compatibility using Ant Design CSS variables for light/dark mode adaptation
- Implement internationalization support with loading/error state translations
- Add robust test coverage for various dictionary HTML parsing scenarios

Features:
- Pronunciation: Extract audio URLs, phonetic symbols, and support both UK/US variants
- Parsing: Handle mixed part-of-speech formats (tagged vs plain text) with comprehensive coverage
- UI: Smart positioning, theme-aware styling, and accessibility improvements
- Testing: Edge cases for "need", mixed formats, and complex part-of-speech structures

This feature provides users with comprehensive word lookup functionality including
native pronunciation support and seamless theme integration for enhanced
subtitle reading experience.

* test(DictionaryPopover): update tests to match current data structure and remove deprecated features

- Remove phonetic field support in favor of pronunciations array structure
- Update test mocks to use pronunciations with type and phonetic properties
- Fix translation mocks to return actual Chinese translations instead of keys
- Add data-testid to error content for proper test coverage
- Remove definitions limitation logic and update test expectations accordingly
- Change test from "limits to 6 definitions" to "displays all definitions"

Changes:
- DictionaryPopover: Remove phonetic field fallback, use only pronunciations array
- Tests: Replace phonetic field with pronunciations array in mock data
- Tests: Add proper Chinese translations for dictionary keys
- Tests: Update definition display expectations to match unlimited display

This ensures tests align with the current component implementation that uses
the pronunciations array structure and displays all definitions without limitation
…nction (#172)

* fix(dictionary): support pronunciation extraction without UK/US distinction

- Update PronunciationInfo type to allow null type for unknown pronunciation
- Enhance pronunciation parsing to handle cases without explicit UK/US labels
- Add support for extracting pronunciation from `<span class="Phonitic">` without phontype
- Update DictionaryPopover to display "通用" for unknown pronunciation types
- Add comprehensive test cases for crystal-like pronunciation scenarios
- Ensure backward compatibility with existing UK/US pronunciation formats

Fixes pronunciation extraction for words like "crystal" where the HTML structure
doesn't explicitly distinguish between UK and US pronunciation types.

* refactor(dictionary): improve audio URL building and UI presentation

- Simplify audio URL parameter building logic in buildAudioUrl
- Remove voicename requirement check (only langid and txt are essential)
- Simplify pronunciation type display in DictionaryPopover
- Only show type label when type is explicitly known (uk/us)
- Default to 'uk' when calling handlePronunciation for unknown types
)

* fix(player): resolve focus loss after dictionary popup interaction

修复点击查词后焦点丢失导致快捷键失效的问题

- 阻止 DictionaryPopover 中发音按钮获得焦点
- 添加弹窗关闭时的焦点恢复机制
- 确保快捷键(如空格播放/暂停)在查词后仍能正常工作

Changes:
- 在发音按钮的 onClick 事件中调用 blur() 移除焦点
- 在发音按钮的 onMouseDown 事件中调用 preventDefault() 阻止默认焦点行为
- 在词典弹窗关闭时自动将焦点恢复到视频表面或字幕覆盖层
- 保持查词和发音功能的完整性

影响范围:
- 修复播放器快捷键在查词后失效的问题
- 提升用户交互体验
- 保持现有功能不受影响

* fix: fix type error
…on (#174)

* fix(player): resolve shortcut pause failure caused by state oscillation

Remove problematic automatic retry mechanisms in PlayerOrchestrator that were causing infinite state oscillation loops between play and pause operations.

**Problem**:
- Shortcut pause commands (spacebar) would fail and immediately resume playback
- Logs showed repeating "Video element still playing after pause() call" warnings
- Root cause: setTimeout-based verification logic in requestPlay() and requestPause() created mutual triggering loops

**Solution**:
- Remove 150ms retry logic from requestPlay() (lines 283-297)
- Remove 50ms retry logic from requestPause() (lines 320-333)
- Remove verification timeouts from requestTogglePlay() (lines 345-360)
- Trust browser's native play()/pause() API reliability

**Impact**:
- ✅ Shortcut pause now works immediately without interference
- ✅ Eliminates state oscillation loop warnings from logs
- ✅ Mouse click controls remain unaffected
- ✅ All other player functionality preserved

Fixes #170

* test: update PlayerOrchestrator tests to reflect removed retry mechanisms

Update reliability tests that previously validated automatic retry behavior:

- 'should detect play failure in delayed verification' → 'should only call play once without retry'
- 'should detect pause failure in delayed verification' → 'should only call pause once without retry'

These tests now correctly validate the simplified behavior where play() and pause()
are called exactly once without automatic retry mechanisms, aligning with the fix
that removes state oscillation loops.

All 578 tests now pass ✅
…nderer processes (#175)

- Add @sentry/electron dependency for comprehensive error tracking and performance monitoring
- Create shared TypeScript definitions for main and renderer Sentry configurations
- Implement SentryService for main process with native crash reporting and breadcrumb collection
- Implement SentryService for renderer process with web-specific error handling
- Initialize Sentry in both main index and renderer init files for full coverage
- Configure error boundaries, performance monitoring, and user context tracking
- Add support for release tracking, environment detection, and custom integrations
- Enable automatic breadcrumb collection and unhandled rejection capture

This implementation provides:
- Centralized error monitoring and crash reporting
- Performance tracking and bottleneck identification
- User session tracking with privacy-conscious defaults
- Development/production environment separation
- Comprehensive error context for debugging production issues
…xperience (#177)

- Set PRODUCTION URL to China mirror (http://release.echoplayer.z2blog.com/api/releases)
- Add CN_ALPHA and CN_BETA URLs for Chinese users' pre-release channels
- Simplify AppUpdater logic to use PRODUCTION URL for all stable releases
- Maintain GitHub URLs for non-CN users in test mode
- Improve logging to distinguish China mirror usage
…gger without description (#179)

- Add logic to automatically fetch release description from GitHub API when manual workflow trigger doesn't provide release_body
- Fallback to informative default message if release not found or has no description
- Maintain existing behavior when release_body is explicitly provided
- Improve user experience by eliminating need to manually copy descriptions
…pause (#182)

* fix(player): resolve spacebar shortcut not working after clicking to pause

- Remove duplicate onKeyDown handler from VideoSurface component that was intercepting space key events and preventing global shortcuts from working
- Add enhanced debug logging to track shortcut trigger events and focus state
- Ensure consistent play/pause behavior regardless of focus location

Fixes issue where clicking VideoSurface to pause would prevent spacebar from resuming playback

* test: fix Windows timing race conditions in VideoLibraryDAO tests

- Replace multiple Date.now() calls with fixed timestamps to prevent 1ms differences
- Use consistent FIXED_NOW and FIXED_FIRST_PLAYED_AT constants across all mock data
- Fix failing tests on Windows where Date.now() calls had microsecond variations

Resolves test failures where expected timestamps differed by 1ms from actual values
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 16, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds Sentry error tracking (main and renderer), implements dictionary popover with pronunciation parsing and UI, updates feed selection with CN routing, adjusts workflows to include prereleases and body fetching, modifies player orchestrator by removing retry checks, updates types/i18n/tests accordingly, and tweaks docs and test utilities.

Changes

Cohort / File(s) Summary
Release workflow updates
.github/workflows/sync-release-to-gitcode.yml
Trigger includes prereleased; workflow_dispatch fetches release body when absent; no functional changes to asset steps.
Documentation update
CLAUDE.md
Removes outdated guidance; adds theming fix notes for DictionaryPopover using Ant Design CSS variables.
Sentry dependencies and typings
package.json, packages/shared/types/sentry.d.ts
Adds @sentry/electron dependency; introduces TS declarations for Sentry Electron main/renderer APIs and option types.
Sentry services & early init
src/main/index.ts, src/main/services/SentryService.ts, src/renderer/src/init.ts, src/renderer/src/services/SentryService.ts
Adds Sentry services for main/renderer with privacy filters, logger integration, dynamic loading; early initialization in app startup paths.
Updater feed routing & constants
packages/shared/config/constant.ts, src/main/services/AppUpdater.ts
Changes production feed URL; adds CN_BETA/CN_ALPHA; selects feeds by IP country (CN vs non-CN) for latest and prerelease channels.
Dictionary backend parsing
src/main/services/DictionaryService.ts
Switches from single phonetic to pronunciations array; adds parsing utilities for voice params, audio URLs, and robust definition extraction.
Dictionary types & i18n
src/renderer/src/infrastructure/types/dictionary.ts, src/renderer/src/i18n/locales/zh-cn.json
Adds PronunciationInfo; updates DictionaryResult to pronunciations?; adds zh-CN strings for dictionary UI.
Dictionary UI & integration
src/renderer/src/pages/player/components/DictionaryPopover.tsx, src/renderer/src/pages/player/components/SubtitleContent.tsx
New popover component with playback and states; integrates per-token lookup; removes onWordClick prop; manages focus and visibility.
Subtitle overlay and surface tweaks
src/renderer/src/pages/player/components/SubtitleOverlay.tsx, src/renderer/src/pages/player/components/VideoSurface.tsx
Guarded ResizeObserver usage; removes onWordClick wiring; removes surface onKeyDown.
Player shortcuts logging
src/renderer/src/pages/player/hooks/usePlayerShortcuts.ts
Adds debug logging for play/pause shortcut; tweaks log message.
Playback orchestrator behavior
src/renderer/src/pages/player/engine/PlayerOrchestrator.ts, src/renderer/src/pages/player/engine/__tests__/PlayerOrchestrator.playback-reliability.test.ts
Removes delayed verification/retries after play/pause; updates tests to expect single calls.
Dictionary tests
src/main/__tests__/DictionaryService.test.ts, tests/SubtitleDictionaryLookup.test.tsx
Expands tests for pronunciations and parsing; adds renderer-level dictionary lookup tests with mocked UI and API.
DB DAO test stabilization
src/main/db/dao/__tests__/VideoLibraryDAO.test.ts
Introduces fixed timestamps and thumbnail path for deterministic tests.
Test environment scaffolding
tests/setup.ts
Mocks window.api.dictionary.queryEudic, ResizeObserver, speechSynthesis, getComputedStyle, and DOM selectors for stable tests.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Subtitle as SubtitleContent
  participant API as window.api.dictionary
  participant Popover as DictionaryPopover

  User->>Subtitle: Click word token
  Subtitle->>Popover: Open with loading
  Subtitle->>API: queryEudic(word)
  API-->>Subtitle: DictionaryResult (pronunciations, definitions, translations)
  Subtitle->>Popover: Update with data or error
  User->>Popover: Click pronunciation play
  Popover->>PopAudio: Try audioUrl
  alt audio fails
    Popover->>SpeechSynthesis: Fallback speak (uk/en-GB else en-US)
  end
  User->>Popover: Close
  Popover-->>Subtitle: onClose
  Subtitle->>UI: Restore focus
Loading
sequenceDiagram
  autonumber
  participant App as Electron Main
  participant Svc as SentryService (main)
  participant Rend as Renderer Init
  participant RSvc as SentryService (renderer)

  App->>Svc: init()
  Svc->>SentryMain: dynamic import + init(config)
  Note over Svc: Set tags/contexts, filters
  Rend->>RSvc: init()
  RSvc->>SentryRenderer: dynamic import + init(config)
  Note over RSvc: Hook logger, window error handlers
Loading
sequenceDiagram
  autonumber
  participant Updater as AppUpdater
  participant Geo as IP Country Lookup
  participant Feeds as FeedUrl

  Updater->>Geo: get ipCountry
  Geo-->>Updater: 'cn' or other
  alt Production or Latest
    alt ipCountry == 'cn'
      Updater->>Feeds: Use PRODUCTION (latest) / CN_* (prerelease)
    else non-CN
      Updater->>Feeds: Use GITHUB_LATEST or GitHub prerelease tag
    end
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Poem

A rabbit taps the keys with cheer,
Sentry awake, it lends an ear.
Words now bloom in popovers bright,
UK, US—both sound just right.
Feeds hop east when China’s near—
Play, pause, tidy code, all clear.
Thump-thump! Ship it—burrow’s here. 🐇✨

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev2alpha

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1767260 and 19bdd26.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (24)
  • .github/workflows/sync-release-to-gitcode.yml (4 hunks)
  • CLAUDE.md (1 hunks)
  • package.json (1 hunks)
  • packages/shared/config/constant.ts (1 hunks)
  • packages/shared/types/sentry.d.ts (1 hunks)
  • src/main/__tests__/DictionaryService.test.ts (5 hunks)
  • src/main/db/dao/__tests__/VideoLibraryDAO.test.ts (7 hunks)
  • src/main/index.ts (1 hunks)
  • src/main/services/AppUpdater.ts (1 hunks)
  • src/main/services/DictionaryService.ts (6 hunks)
  • src/main/services/SentryService.ts (1 hunks)
  • src/renderer/src/i18n/locales/zh-cn.json (1 hunks)
  • src/renderer/src/infrastructure/types/dictionary.ts (1 hunks)
  • src/renderer/src/init.ts (1 hunks)
  • src/renderer/src/pages/player/components/DictionaryPopover.tsx (1 hunks)
  • src/renderer/src/pages/player/components/SubtitleContent.tsx (6 hunks)
  • src/renderer/src/pages/player/components/SubtitleOverlay.tsx (1 hunks)
  • src/renderer/src/pages/player/components/VideoSurface.tsx (0 hunks)
  • src/renderer/src/pages/player/engine/PlayerOrchestrator.ts (0 hunks)
  • src/renderer/src/pages/player/engine/__tests__/PlayerOrchestrator.playback-reliability.test.ts (2 hunks)
  • src/renderer/src/pages/player/hooks/usePlayerShortcuts.ts (1 hunks)
  • src/renderer/src/services/SentryService.ts (1 hunks)
  • tests/SubtitleDictionaryLookup.test.tsx (1 hunks)
  • tests/setup.ts (2 hunks)

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mkdir700 mkdir700 merged commit 7a6b43e into alpha Sep 16, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant