[PM-40995] fix: Allow fill-assist to rescue autofill requests when heuristics find no fields - #7214
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the fill-assist rescue path added to The rescue path is well-guarded: it activates only when the feature flag and user setting are both enabled, host rules exist for the resolved host, and fill-assist actually matches a field on the page. The conservative empty-match guard for the Code Review DetailsNo findings. The change is well-reasoned, conservatively guarded, and adequately tested. Note: Codecov reports 0% patch coverage, but this appears to be an artifact of the heavy extension-function mocking in these tests rather than a genuine coverage gap — the new tests do exercise |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7214 +/- ##
==========================================
- Coverage 86.19% 85.42% -0.78%
==========================================
Files 888 962 +74
Lines 64776 66801 +2025
Branches 9691 9745 +54
==========================================
+ Hits 55836 57065 +1229
- Misses 5470 6260 +790
- Partials 3470 3476 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| is AutofillView.Login -> rule.category in LOGIN_FILL_ASSIST_CATEGORIES | ||
| is AutofillView.Unused -> false | ||
| is AutofillView.Unused -> rule.category in LOGIN_FILL_ASSIST_CATEGORIES || | ||
| rule.category in CARD_FILL_ASSIST_CATEGORIES |
There was a problem hiding this comment.
Since this is a multi-line statement, can we make sure it is wrapped in curly braces:
is AutofillView.Unused -> {
rule.category in LOGIN_FILL_ASSIST_CATEGORIES ||
rule.category in CARD_FILL_ASSIST_CATEGORIES
}
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-40995
📔 Objective
AutofillParserImpl.parseInternalreturnedAutofillRequest.Unfillableimmediately whenever the built-in heuristic field-classifier found zero non-Unusedfields on a page — before the app ever checked whether fill-assist (server-curated CSS-selector-based field targeting) was enabled or had matching rules for that host. This meant fill-assist could never rescue a page the heuristics failed to parse, defeating its purpose on pages designed to evade naive heuristics (e.g. generically-named, hint-less input fields). Confirmed via a live repro against a test page with no autofill suggestion offered at all.This PR:
parseInternalfall back to anUnused-inclusive candidate view when heuristics find nothing, but only when fill-assist is actually enabled (feature flag + setting) — the disabled path is unchanged in both behavior and cost.toEffectiveViews'sUnusedcase (previously dead code, since a heuristic-classified focused view could never beUnused) real behavior: it checks against both login and card fill-assist categories, since heuristics gave no signal for which one applies.Unusedcase when it actually matches a field on the page — an empty match falls back to heuristics instead of being treated as authoritative, so an unrelated host rule (e.g. one covering a different pathname/category on the same host) can't silently claim a page it has no real match for. The pre-existingCard/Loginbranches keep their existing "authoritative even if empty" behavior since those already carry real heuristic confirmation.setup()'s defaulttoAutofillViewDatamock stub, uncovered by the new tests: it usedfirstArg()/secondArg()for theautofillId/websiteparams, but since it mocks an extension function, the receiver occupies argument position 0 at the JVM level, so the stub was assigning theViewNodeitself into theautofillIdfield. Fixed by shifting tosecondArg()/thirdArg().