Skip to content

fix(fleet): ship_type validation and diagnostics improvements#445

Merged
yltx merged 4 commits intomainfrom
fix/fleet-rule-shiptype-searchname-post7-r2
Apr 15, 2026
Merged

fix(fleet): ship_type validation and diagnostics improvements#445
yltx merged 4 commits intomainfrom
fix/fleet-rule-shiptype-searchname-post7-r2

Conversation

@yltx
Copy link
Copy Markdown
Contributor

@yltx yltx commented Apr 15, 2026

Summary

Address Copilot review comments on PR #444.

Changes

  • add strict ship_type normalization + validation in FleetRuleRequest
  • update change_fleet() selector doc to include ship_type
  • include ship_type constraint in choose-ship final error/log for diagnosability

Notes

yltx added 3 commits April 15, 2026 18:55
- add ship_type to FleetRuleRequest and slot selector

- normalize search_name for first search and in-compare matching

- filter choose-ship hits by OCR-detected ship type
- validate and normalize ship_type in FleetRuleRequest

- update change_fleet selector docs to include ship_type

- include ship_type constraint in choose-ship final failure diagnostics
Copilot AI review requested due to automatic review settings April 15, 2026 12:47
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 tightens ship_type handling end-to-end for fleet replacement: validating/normalizing ship_type on the server, threading it through fleet slot selectors, and using OCR-based ship-type detection in the choose-ship UI to disambiguate same-name ships while improving diagnostics when selection fails.

Changes:

  • Add ship_type to FleetRuleRequest with strict normalization + validation.
  • Pass ship_type through fleet-change selector extraction and update selector docs.
  • Add ship-type OCR detection/filtering in choose-ship selection, and include ship_type in final error/log messages.

Reviewed changes

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

File Description
autowsgr/ui/choose_ship_page.py Adds ship-type OCR detection + filtering during list click selection; improves error diagnostics and normalizes search keywords.
autowsgr/ui/battle/fleet_change/_change.py Extends selector extraction/matching to include ship_type and improves search-name comparison normalization.
autowsgr/server/schemas.py Adds ship_type to FleetRuleRequest with allowed-code validation and normalization.
autowsgr/init.py Bumps version to 2.1.9.post7.

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

Comment on lines +524 to +529
return None
normalized = text.replace(' ', '')
for ship_type, keywords in _SHIP_TYPE_KEYWORDS.items():
if any(keyword in normalized for keyword in keywords):
return ship_type
return None
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

_extract_ship_type_from_text() only removes literal spaces (text.replace(' ', '')). OCR output commonly contains other whitespace (e.g., newlines/tabs), which will prevent keyword matching and make ship_type filtering flaky. Consider normalizing by removing all whitespace characters (not just ASCII spaces) before searching keywords.

Copilot uses AI. Check for mistakes.
Comment on lines +38 to +40
# 舰名尾部别名后缀,如“(苍青幻影)”
_SHIP_ALIAS_SUFFIX_RE = re.compile(r'\s*[((][^()()]*[))]\s*$')

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

_SHIP_ALIAS_SUFFIX_RE and the associated alias-suffix normalization logic are now duplicated across modules (here and ChooseShipPage). This duplication is easy to let drift and will cause inconsistent matching behavior over time; consider centralizing it in a shared util (or importing the existing helper) so both fleet-change short-circuiting and choose-ship searching stay consistent.

Copilot uses AI. Check for mistakes.
@yltx yltx merged commit 3aea5a4 into main Apr 15, 2026
0 of 2 checks passed
@yltx yltx deleted the fix/fleet-rule-shiptype-searchname-post7-r2 branch April 15, 2026 13:00
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