[PM-42523] fix: Restore AppIntents localization strings and detect their usage - #3005
[PM-42523] fix: Restore AppIntents localization strings and detect their usage#3005fedemkr wants to merge 2 commits into
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the restoration of 11 Code Review Details
|
| _APPINTENT_LITERAL_KEY_RE = re.compile( | ||
| r'(?:' | ||
| r'static\s+var\s+title\s*:\s*LocalizedStringResource\s*=\s*' | ||
| r'|IntentDescription\(\s*' | ||
| r'|shortTitle\s*:\s*' | ||
| r'|dialog\s*:\s*' | ||
| r')"([^"\\]*)"' | ||
| ) |
There was a problem hiding this comment.
🎨 SUGGESTED: The title arm requires static var, so a static let title would silently regress this fix.
Details and fix
All four current intents use static var title: LocalizedStringResource = "Key", so the regex matches today. But static var on an AppIntent is exactly the declaration Swift 6 strict-concurrency checking pushes toward static let. If any intent is migrated (or a new one is written that way), the key stops being detected and the weekly cron-fix-localizable-strings job deletes the entry again — the same silent failure this PR is fixing.
Anchoring on title: instead of static var title covers static var, static let, and non-static forms with no added false-match surface:
| _APPINTENT_LITERAL_KEY_RE = re.compile( | |
| r'(?:' | |
| r'static\s+var\s+title\s*:\s*LocalizedStringResource\s*=\s*' | |
| r'|IntentDescription\(\s*' | |
| r'|shortTitle\s*:\s*' | |
| r'|dialog\s*:\s*' | |
| r')"([^"\\]*)"' | |
| ) | |
| _APPINTENT_LITERAL_KEY_RE = re.compile( | |
| r'(?:' | |
| r'title\s*:\s*LocalizedStringResource\s*=\s*' | |
| r'|IntentDescription\(\s*' | |
| r'|shortTitle\s*:\s*' | |
| r'|dialog\s*:\s*' | |
| r')"([^"\\]*)"' | |
| ) |
Note the LocalizedStringResource { ... } block extractor does not cover this case either, since it only matches a brace-opened body, not an = "literal" assignment.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3005 +/- ##
==========================================
- Coverage 79.54% 79.51% -0.03%
==========================================
Files 1169 1169
Lines 75095 75095
==========================================
- Hits 59731 59711 -20
- Misses 15364 15384 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-42523
📔 Objective
PM-26292 ("chore: Remove unused strings", #2003) removed 10
Localizable.stringsentries that are actually referenced byBitwarden/Application/AppIntents/*.swiftandShortcutsProvider.swift— but only as raw string literals (title,description,shortTitle,dialog, and aCustomLocalizedStringResourceConvertible.localizedStringResourceswitch), not via the generatedLocalizations.Xenum. Without a matching entry, Siri/Shortcuts falls back to showing the raw key text instead of the intended English string.This PR:
BitwardenResources/Localizations/en.lproj/Localizable.strings, at their original positions, with values matching what was deleted.Scripts/fix-localizable-strings/delete_unused_strings.py(used by the weeklycron-fix-localizable-stringsGitHub Action) so itsdelete-unuseddetector recognizes these AppIntents literal-key usage patterns as "used" — otherwise the bot would silently delete them again on its next run. Adds test coverage for each pattern, including the actualAppIntentErrorshape inAppIntentMediator.swift.Verified via
bash Scripts/fix-localizable-strings.sh --dry-run, which now reports no unused strings inLocalizable.strings, and the full Python test suite (Scripts/test-fix-localizable-strings.sh, 88/88 passing).