Fix username field detection in autofill service#5
Merged
Conversation
Co-authored-by: codegax <14095200+codegax@users.noreply.github.com>
Co-authored-by: codegax <14095200+codegax@users.noreply.github.com>
Co-authored-by: codegax <14095200+codegax@users.noreply.github.com>
Co-authored-by: codegax <14095200+codegax@users.noreply.github.com>
Co-authored-by: codegax <14095200+codegax@users.noreply.github.com>
Co-authored-by: codegax <14095200+codegax@users.noreply.github.com>
Co-authored-by: codegax <14095200+codegax@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix user field not being detected on login page
Fix username field detection in autofill service
Dec 5, 2025
codegax
approved these changes
Dec 5, 2025
codegax
left a comment
Owner
There was a problem hiding this comment.
Review: Approve ✅
Good fix for username field detection. The regex patterns in companion object and word boundary matching are solid improvements.
One consideration:
Heuristic edge case - applyUsernameHeuristics() takes the first unidentified text field as username. This could misfire on forms with extra fields before the username (CAPTCHA, phone selector, etc.). Consider validating the field appears before/near the password field in DOM order if issues arise.
Minor suggestion:
Consider adding mail to EMAIL_PATTERN for fields named just "mail":
private val EMAIL_PATTERN = Regex("\\b(email|e-mail|e_mail|mail)\\b")Tested logic looks correct. Manual testing on Instagram and other login forms recommended before merging.
codegax
marked this pull request as ready for review
December 5, 2025 01:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.