Skip to content

fix(ui): normalize ship selection matching and level filtering (copilot addressed v5)#442

Merged
yltx merged 9 commits intomainfrom
fix/ship-selection-level-filter-clean-r6
Apr 14, 2026
Merged

fix(ui): normalize ship selection matching and level filtering (copilot addressed v5)#442
yltx merged 9 commits intomainfrom
fix/ship-selection-level-filter-clean-r6

Conversation

@yltx
Copy link
Copy Markdown
Contributor

@yltx yltx commented Apr 14, 2026

Summary

Fallback policy

  • Treat letters after Lv. as OCR noise, not game-state data.
  • Allow lightweight coercion for common single-character OCR noise.
  • If noisy level-like hits exceed threshold, raise retry signal and re-run OCR from fresh screenshot.
  • If retries are exhausted, raise explicit runtime error instead of continuing with uncertain level data.

What changed

  1. Add bounded OCR fallback threshold and retry signal in level probing.
  2. Handle retry signal in choose-ship flow with bounded retries.
  3. Keep docs aligned with normalized name matching behavior.

Files

  • autowsgr/ui/utils/ship_list.py
  • autowsgr/ui/choose_ship_page.py
  • autowsgr/init.py

Notes

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves ship selection reliability by strengthening OCR-based level parsing and by normalizing ship-name matching so level filtering aligns with name hits, adding bounded retries when OCR noise is too high.

Changes:

  • Add stricter level parsing with OCR-noise detection, plus a retry signal/error path when noise exceeds a threshold.
  • Update choose-ship flow to normalize names before matching and to retry when level OCR requests a re-screenshot.
  • Bump package version to 2.1.9.post6.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
autowsgr/ui/utils/ship_list.py Expands level regex/coercion, adds noisy-OCR retry exception, and pairs level hits with name hits using bbox x-coordinates plus a local probing fallback.
autowsgr/ui/choose_ship_page.py Normalizes ship-name matching (remove “·改” and trailing parenthetical alias) and handles bounded retries on noisy level OCR.
autowsgr/init.py Version bump for release.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{
'I': '1',
'i': '1',
'l': '1',
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

_LEVEL_PATTERN/_LEVEL_NOISY_PATTERN allow uppercase L in the captured level digits ([0-9ILilOo]), but _coerce_level_digits() does not translate 'L' -> '1'. If OCR returns something like Lv.L8, the L will be dropped by the isdigit() filter and the parsed level can become incorrect. Add 'L': '1' to the translation table (or remove L from the capture set if it should never be treated as a digit).

Suggested change
'l': '1',
'l': '1',
'L': '1',

Copilot uses AI. Check for mistakes.
Comment on lines +311 to +316
collect_levels(binary_rgb)

if not parsed_levels and noisy_level_hits > _MAX_NOISY_LEVEL_HITS_BEFORE_RETRY:
raise LevelOCRRetryNeededError(
f'等级 OCR 噪声过高: {noisy_level_hits} 条异常等级文本 (阈值 {_MAX_NOISY_LEVEL_HITS_BEFORE_RETRY})',
)
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

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

The retry signal is currently only raised when no levels were parsed (if not parsed_levels and noisy_level_hits > ...). This conflicts with the PR’s stated fallback policy (“If noisy level-like hits exceed threshold, raise retry signal”), and can allow returning a level even when the OCR output is clearly too noisy. Consider triggering LevelOCRRetryNeededError whenever noisy_level_hits exceeds the threshold (regardless of parsed_levels), or document why noisy hits are ignored when a level is also parsed.

Copilot uses AI. Check for mistakes.
@yltx yltx merged commit 7a26b4e into main Apr 14, 2026
0 of 2 checks passed
@yltx yltx deleted the fix/ship-selection-level-filter-clean-r6 branch April 14, 2026 17:59
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.

2 participants