Fix username field detection in autofill service #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
The autofill service was only triggering on password fields, not username fields, on sites like Instagram. The field detection logic had insufficient pattern coverage and no fallback for non-standard field naming.
Type of Change
Related Issues
Related to user report: username fields on Instagram not triggering autofill
Changes Made
Field Detection Patterns
account,identifier,userid,user_id,loginid,login_id,uidusername,nickname)e-mail,e_mail)Heuristic Fallback
Pattern Matching Refactor
isUsernamePattern(),isEmailPattern(),isPasswordPattern()\bpass\bwon't match "compass")matches()tocontainsMatchIn()for better performanceCode Quality
Example of enhanced detection:
Testing Done
Unit Tests
Manual Testing
Feature-Specific Testing (if applicable)
Note: Manual testing on physical device required to verify username field detection on Instagram and other login forms.
Screenshots (if applicable)
N/A - Behavioral change, no UI modifications
Security Considerations
Changes only affect field type classification logic, no sensitive data handling modified.
Performance Impact
Regex patterns compiled once at class loading instead of on each field check.
Breaking Changes
Does this PR introduce breaking changes?
Checklist
Code Quality
Architecture
Documentation
Git
Additional Notes
The heuristic fallback (classifying first unidentified text field as username when password is present) is conservative—only applies when explicit patterns fail to match. This handles sites with non-standard field naming without over-triggering.
For Reviewers
Areas to focus on:
applyUsernameHeuristics()- reasonable assumptions?Known limitations:
By submitting this pull request, I confirm that my contribution is made under the terms of the GPLv3 license.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
dl.google.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.2-bin/bbg7u40eoinfdyxsxr3z4i7ta/gradle-8.2/lib/gradle-launcher-8.2.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.2-bin/bbg7u40eoinfdyxsxr3z4i7ta/gradle-8.2/lib/agents/gradle-instrumentation-agent-8.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.2(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.