[PM-37255] feat: Integrate fill-assist targeting rules into autofill parser - #7066
Conversation
…assist-data-layer
…emoved unnecessary deserialization tests
…assist-data-layer
…ow updates Updating code to schema with required values
…assist-data-layer
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the net PR diff (11 files) wiring the fill-assist targeting-rules pipeline into the autofill parser. Focus was on the CSS selector parser in The Code Review DetailsNo blocking findings. Non-blocking observation (not posted inline): |
This reverts commit 2219e6f.
| val HtmlInfo?.isInputField: Boolean get() = this?.tag == "input" | ||
|
|
||
| /** | ||
| * Whether this [HtmlInfo] matches the given [SelectorClause]. |
There was a problem hiding this comment.
The link here is broken, can we make it [FillAssistRules.SelectorClause]
| clause.type == null && | ||
| clause.role == null | ||
| fun hasAttr(key: String, value: String) = attrs.any { it.first == key && it.second == value } | ||
| return listOf( |
| val data = toAutofillViewData(autofillId = id, website = website) | ||
| matchingEntries.firstNotNullOfOrNull { (key, _) -> | ||
| key.toAutofillViewForFieldKey( | ||
| data, |
There was a problem hiding this comment.
This should either have a name or be 1 line.
key.toAutofillViewForFieldKey(data)OR
key.toAutofillViewForFieldKey(
data = data,
)| "cardholderName" -> AutofillView.Card.CardholderName(data = data) | ||
| "cardExpirationDate" -> AutofillView.Card.ExpirationDate(data = data) | ||
| "cardExpirationMonth" -> AutofillView.Card.ExpirationMonth(data = data, monthValue = null) | ||
| "cardExpirationYear" -> AutofillView.Card.ExpirationYear(data = data, yearValue = null) |
There was a problem hiding this comment.
Can we make some consts for these magic strings?
| clause.id to "id", | ||
| clause.name to "name", | ||
| clause.type to "type", | ||
| clause.role to "role", |
There was a problem hiding this comment.
Can we make these consts?
# Conflicts: # app/src/test/kotlin/com/x8bit/bitwarden/data/autofill/parser/AutofillParserTests.kt
| assertEquals(expected, actual) | ||
| } | ||
|
|
||
| @Suppress("MaxLineLength") |
There was a problem hiding this comment.
Is this suppression actually needed?
| assertEquals(expected, actual) | ||
| } | ||
|
|
||
| @Suppress("MaxLineLength") |
There was a problem hiding this comment.
This suppression is not needed
|
Thanks @david-livefront |
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-37255
📔 Objective
Wires the fill-assist targeting-rules pipeline end-to-end into the Android autofill framework.
When the
FillAssistTargetingRulesfeature flag is enabled and rules are available for the current host, the autofill parser replaces heuristic field detection with site-specific CSS-selector-based matching. Unmatched nodes are excluded entirely — there is no heuristic fallback when rules are active.What's included:
FillAssistApi,FillAssistService,FillAssistManifestJson,FillAssistFormsJson: fetches a versioned manifest and forms JSON from the fill-assist CDN endpoint.FillAssistManagerImpl,FillAssistDiskSource: parses CSS selectors intoFillAssistRules(tag, id, name, type, role constraints per field), caches rules on disk, syncs on server-config change with a 6-hour re-fetch throttle.>>>Shadow DOM notation, space-separated CSS descendant selectors (split on whitespace outside[…]attribute brackets to preserve attribute values that contain spaces),#idshorthand, and[attr='value']/[attr="value"]attribute selectors.AutofillParserImpllooks up host rules for the focused view's URI and callsAssistStructure.buildFillAssistViewsto replace the heuristic view list when rules match.FillAssistViewNodeExtensions.traverseForFillAssisttraverses theAssistStructuretree;HtmlInfoExtensions.matchesSelectorClausedoes the per-node attribute comparison (kept inHtmlInfoExtensionsalongsidehints()sinceHtmlInfo.attributesusesandroid.util.Pairand is untestable in unit tests).FillAssistManagerTest,FillAssistServiceTest,FillAssistViewNodeExtensionsTest(all previously commented-out tests now passing viamockkStatic(HtmlInfo::matchesSelectorClause)), andAutofillParserTestsupdated for the new constructor parameters.