Skip to content

Fix manual Bangumi rescrape search hang#33

Merged
ModerRAS merged 1 commit into
masterfrom
fix/rescrape-keyword-search-hang
Jul 7, 2026
Merged

Fix manual Bangumi rescrape search hang#33
ModerRAS merged 1 commit into
masterfrom
fix/rescrape-keyword-search-hang

Conversation

@ModerRAS

@ModerRAS ModerRAS commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • keep anime manual rescrape searches scoped to selected/manual terms instead of expanding into title/cache/path-derived queries
  • keep anime metadata matching Bangumi-only by removing AniList from the anime metadata provider and scraper DI sets
  • add a bounded timeout for manual match search
  • reset search/sync busy state on timeout or provider errors so the dialog does not stay stuck

Root Cause

The rescrape dialog does not load the ONNX filename parser. It goes through AnimeDetailViewModel.searchManualMatches() -> AnimeMetadataSearchAggregator -> Bangumi archive/API. The old flow expanded selected keywords into up to 10 planner queries and did not reset busy state if aggregation failed or stalled. AniList had also been wired into the anime aggregation path, but anime matching should be Bangumi-only.

Validation

  • ./gradlew --stop
  • ./gradlew :core:model:clean :repository-api:test --tests com.miruplay.tv.repository.MetadataBatchPlannerTest --tests com.miruplay.tv.repository.MetadataSearchAggregationTest
  • ./gradlew :ui-tv:testDebugUnitTest --tests com.miruplay.tv.ui.detail.AnimeDetailViewModelTest
  • ./gradlew :app:assembleDebug

Note: the first validation run hit the known Kotlin incremental cache EOFException; stopping Gradle and cleaning :core:model fixed it.

Version

Patch-level bug fix. Current release line is 0.8.x (v0.8.544 latest), and baseAppVersionName already matches 0.8.0, so no version bump.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Manual Bangumi metadata match search in AnimeDetailViewModel now runs under a per-query timeout via withTimeout, with try/catch/finally handling distinguishing success, timeout, cancellation, and general error cases. The search context construction was simplified, and tests were updated with a shared factory and a new failure-path test.

Changes

Manual Match Search Rework

Layer / File(s) Summary
Timeout-aware search with structured error handling
ui-tv/src/main/kotlin/com/miruplay/tv/ui/detail/AnimeDetailViewModel.kt
searchManualMatches() computes a per-query timeout and wraps the aggregation call in withTimeout, handling success/timeout/cancellation/exception via try/catch/finally, resetting _isSyncing in finally, simplifying the MetadataSearchContext fields passed, and removing the unused boundProviderRef helper/import.
Test coverage for new search behavior
ui-tv/src/test/kotlin/com/miruplay/tv/ui/detail/AnimeDetailViewModelTest.kt
Adds a shared animeDetailViewModel(aggregator) factory, updates existing assertions for the simplified search context, and adds a FailingAnimeSearchAggregator-based test verifying busy-state reset and error status message.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • ModerRAS/MiruPlay#27: Both PRs modify the manual Bangumi match search pipeline—this PR changes the UI-side request construction and timeout handling, while the related PR changes the backend search logic used for manual matches.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main fix: preventing the manual Bangumi rescrape search from hanging.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rescrape-keyword-search-hang

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
ui-tv/src/main/kotlin/com/miruplay/tv/ui/detail/AnimeDetailViewModel.kt (1)

210-214: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider logging the timeout before swallowing it.

The TimeoutCancellationException is handled purely by updating statusMessage, so no diagnostic trace is emitted when a manual search hangs — which is exactly the failure mode this PR targets. A warn-level log (including queries.size and the computed timeout) would make future hang investigations far easier without changing behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui-tv/src/main/kotlin/com/miruplay/tv/ui/detail/AnimeDetailViewModel.kt`
around lines 210 - 214, In AnimeDetailViewModel’s manual search timeout
handling, the TimeoutCancellationException is being swallowed after only
updating _manualMatch, so add a warn-level log in the catch block before
returning. Include the relevant context from the search flow, especially
queries.size and the computed timeout used by the search, so hangs can be
diagnosed later without changing behavior.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@ui-tv/src/main/kotlin/com/miruplay/tv/ui/detail/AnimeDetailViewModel.kt`:
- Around line 210-214: In AnimeDetailViewModel’s manual search timeout handling,
the TimeoutCancellationException is being swallowed after only updating
_manualMatch, so add a warn-level log in the catch block before returning.
Include the relevant context from the search flow, especially queries.size and
the computed timeout used by the search, so hangs can be diagnosed later without
changing behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bc96a35f-3003-4941-b301-02cc5b2468db

📥 Commits

Reviewing files that changed from the base of the PR and between 2aaef53 and 016c19b.

📒 Files selected for processing (2)
  • ui-tv/src/main/kotlin/com/miruplay/tv/ui/detail/AnimeDetailViewModel.kt
  • ui-tv/src/test/kotlin/com/miruplay/tv/ui/detail/AnimeDetailViewModelTest.kt

@ModerRAS ModerRAS force-pushed the fix/rescrape-keyword-search-hang branch from 016c19b to 0e6e5bc Compare July 7, 2026 11:17
@ModerRAS ModerRAS changed the title Fix manual rescrape search hang Fix manual Bangumi rescrape search hang Jul 7, 2026
@ModerRAS ModerRAS merged commit 9dd800e into master Jul 7, 2026
11 checks passed
@ModerRAS ModerRAS deleted the fix/rescrape-keyword-search-hang branch July 7, 2026 11:19
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