Skip to content

ADFA-3900 | Fix password inputType parsing from sketch annotations#1284

Merged
jatezzz merged 3 commits into
stagefrom
fix/ADFA-3900-password-input-type-experimental
May 11, 2026
Merged

ADFA-3900 | Fix password inputType parsing from sketch annotations#1284
jatezzz merged 3 commits into
stagefrom
fix/ADFA-3900-password-input-type-experimental

Conversation

@jatezzz
Copy link
Copy Markdown
Collaborator

@jatezzz jatezzz commented May 7, 2026

Description

Updates the sketch-to-UI computer vision logic to properly assign the textPassword inputType to EditText widgets when the hint indicates a password field. This ensures the generated Android XML correctly hides input characters instead of rendering a standard visible text entry box. Additionally, this PR introduces a structural refactor to the attribute parsing logic by breaking down the monolithic FuzzyAttributeParser into modular, domain-specific cleaner components.

Details

  • Updated AndroidWidget.kt to handle password hints appropriately.
  • Refactored FuzzyAttributeParser.kt into modular components (AttributeModels.kt, ValueCleaner.kt, ValueCleanersImpl.kt).
  • Improved margin annotation bounds and implicit block resolution in MarginAnnotationParser.kt.
  • Enhanced proximity and alignment calculations in LayoutGeometryProcessor.kt.
  • Updated WidgetGrammar definitions with structured attribute value sets.
Screen.Recording.2026-05-07.at.12.59.49.PM.mov

Ticket

ADFA-3900

Observation

Note: This PR also includes a structural refactor of FuzzyAttributeParser into a dedicated parser package (separating out AttributeModels, ValueCleaner, and ValueCleanersImpl) to improve maintainability and cleanliness of the parsing domain.

@jatezzz jatezzz requested review from a team, Daniel-ADFA and avestaadfa May 7, 2026 18:44
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack

Warning

Rate limit exceeded

@jatezzz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 21 minutes and 13 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dcdd00a1-4791-425a-8146-3780230ee80b

📥 Commits

Reviewing files that changed from the base of the PR and between 04420cc and c204d68.

📒 Files selected for processing (15)
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/FuzzyAttributeParser.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/LayoutGeometryProcessor.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/MarginAnnotationParser.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/WidgetAnnotationMatcher.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/WidgetTagParser.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/AttributeValidator.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/WidgetGrammar.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/AttributeModels.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleaner.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/WidgetFactory.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/ui/viewmodel/ComputerVisionViewModel.kt
  • cv-image-to-xml/src/test/java/org/appdevforall/codeonthego/computervision/domain/FuzzyAttributeParserTest.kt
📝 Walkthrough

Walkthrough

This pull request modularizes fuzzy attribute parsing into a new parser package with explicit attribute models and value cleaners, adds stricter tag extraction, rewrites margin block resolution, refactors nearby-text matching helpers, updates grammar validators, and adjusts widget input-type inference and related imports.

Changes

Attribute Parsing Architecture Refactoring

Layer / File(s) Summary
Data Models & Type Schemas
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/AttributeModels.kt
New file introduces AttributeValueSet, GravityValueSet, VisibilityValueSet, InputTypeValueSet, ValueType enum, and AttributeKey enum with aliases and lookup utilities.
Value Cleaning Abstraction
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleaner.kt
New functional interface ValueCleaner with clean(rawValue: String): String.
Value Cleaner Implementations
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt
Adds nine cleaners: TextContentCleaner, NumberCleaner, DimensionCleaner, SpDimensionCleaner, ColorCleaner, IdCleaner, DrawableCleaner, TextStyleCleaner, FloatCleaner.
Core Attribute Parser
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt
New parser singleton: tokenizes annotations (pipe or colon/semicolon), fuzzy-matches keys to AttributeKey aliases, applies type-specific cleaners, resolves XML names (including Button background → app:backgroundTint), and enforces grammar via UiGrammarValidator.
Trailing Attributes & Color Heuristics
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt
Implements heuristics to detect embedded trailing attributes inside value spans and to treat likely color tokens as background when appropriate.
Grammar Validation Wiring
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/WidgetGrammar.kt
Replaces hardcoded string lists with CategoricalValidator backed by GravityValueSet, VisibilityValueSet, InputTypeValueSet in Layout/Image/EditText grammars.
Stricter Tag Detection
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/WidgetTagParser.kt
Refactors isTag, normalizeTagText, and extractTag to use capture-group extraction, isValidTagMatch guard, duplicated-prefix stripping, and stricter trailing-content validation.
Margin Annotation Refactoring
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/MarginAnnotationParser.kt
Rewrites margin parsing: distributeDetections, extractCanvasTags, splitCanvasTags, extractBlocks, resolveImplicitBlocks; replaces prior cluster/tag-split helpers and reassigns implicit blocks to nearest tags.
Layout Text Matching
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/LayoutGeometryProcessor.kt
Refactors assignNearbyTextToWidgets to use cleanWidgetText, isVerticallyAlignedWith, and calculateProximityScoreTo helpers for candidate selection and ranking.
Input Type Inference
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt
InputWidget.specificAttributes() now resolves hint then infers android:inputType from hint when missing, falling back to "text" if inference yields none.
Integration & Imports
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/WidgetFactory.kt, cv-image-to-xml/src/test/java/.../FuzzyAttributeParserTest.kt, cv-image-to-xml/src/main/java/.../WidgetAnnotationMatcher.kt
Update imports to domain.parser.FuzzyAttributeParser, add test import, minor whitespace change in WidgetAnnotationMatcher.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • avestaadfa
  • Daniel-ADFA

Poem

🐰 In OCR fields the rabbit hops with glee,

cleaners scrub the muddled key,
tags stand straighter, margins fall in line,
hints whisper types and parsers shine—hooray, design!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.07% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The PR title 'Fix password inputType parsing from sketch annotations' aligns with the core functional change of inferring password inputType from widget hints, as documented in the PR objectives.
Description check ✅ Passed The PR description clearly explains the main objective (password inputType handling) and documents the structural refactor of FuzzyAttributeParser into modular components, directly relating to the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ADFA-3900-password-input-type-experimental

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (6)
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt (3)

3-3: 💤 Low value

Unused android.util.Log import.

Log is not referenced anywhere in this file. Likely a leftover from the move out of domain/.

-import android.util.Log
 import com.itsaky.androidide.fuzzysearch.FuzzySearch
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt`
at line 3, Remove the unused import of android.util.Log from
FuzzyAttributeParser.kt; open the FuzzyAttributeParser file (class/object
FuzzyAttributeParser) and delete the line "import android.util.Log" since Log is
not referenced anywhere in that file to avoid unused-import warnings.

38-49: 💤 Low value

Hardcoded OCR fix-ups in tokenizeAnnotation will not scale.

The backgroundired / backgroundred / horizontal gravity: center layout substitutions look like patches added to satisfy specific failing samples. As more OCR oddities appear, this list will grow unbounded inside the tokenizer. Consider isolating these into a dedicated OcrSanitizer (data-driven list of (pattern, replacement) pairs) so the list can be extended/tested independently of the tokenization pipeline.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt`
around lines 38 - 49, tokenizeAnnotation currently contains hardcoded OCR
workaround replace calls (e.g., "backgroundired", "backgroundred", "horizontal
gravity: center layout") which don't scale; extract these substitutions into a
dedicated OcrSanitizer (a data-driven list of (pattern, replacement) pairs) and
call it from tokenizeAnnotation so the sanitizer can be extended and tested
independently. Implement an OcrSanitizer class/object that exposes a
sanitize(String):String method (used by tokenizeAnnotation) backed by a
configurable list of Regex->replacement entries, ensure tokenizeAnnotation uses
PIPE_DELIMITER and the same split logic after calling OcrSanitizer.sanitize, and
update tests to exercise sanitizer rules separately.

97-97: 💤 Low value

Threshold carve-out for length==6 is hard to reason about.

length <= 3 → 65, length == 6 → 75, else → 80 leaves length 4–5 and 7+ at 80 while singling out 6. This pattern reads as ad-hoc test fitting and will be brittle to extend. If this is intentional to capture a specific OCR class (e.g., 6-char garbled aliases like wldth-style), please add an inline comment with an example so the carve-out is grep-able later; otherwise, smoothing to a monotonic ladder (e.g., ≤3 → 65, ≤6 → 75, else → 80) would be more defensible.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt`
at line 97, The threshold calculation in FuzzyAttributeParser (the line
computing threshold from normalizedKey.length) special-cases length == 6 which
is unclear and brittle; either make the rule monotonic by changing the condition
to "≤3 → 65, ≤6 → 75, else → 80" (i.e., replace the length==6 branch with length
<= 6) or, if the carve-out for length==6 is intentional, add a concise inline
comment on that same line referencing a concrete example (e.g., an OCR mis-parse
like "wldth") and why 75 was chosen so future readers can grep for it; update
the code in FuzzyAttributeParser.kt accordingly and keep the variable
normalizedKey as the referenced symbol.
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt (1)

284-303: 💤 Low value

Password inference logic LGTM.

Precedence is right: an explicit android:inputType from parsedAttrs wins, falling back to hint inference, then to "text". The two-pattern check ("password" and "pass word") handles both joined and OCR-split tokens, and lowercase() normalizes capitalization. One minor consideration for a follow-up: the heuristic is English-only — non-English hints (e.g., "Contraseña", "Mot de passe") won't be detected. Acceptable for now given the OCR pipeline's English bias, but worth tracking if i18n hints are expected.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt`
around lines 284 - 303, Password inference is currently English-only; update
inferInputTypeFromHint to support common non-English password tokens by
replacing the hardcoded contains checks with a configurable keyword list (e.g.,
LOCAL_PASSWORD_KEYWORDS) and matching against normalizedHint, so
specificAttributes still prefers parsedAttrs[AttributeKey.INPUT_TYPE.xmlName]
but falls back to inferInputTypeFromHint(normalizedHint) which now checks
multiple localized tokens (reference functions inferInputTypeFromHint and
specificAttributes, and keys AttributeKey.HINT.xmlName /
AttributeKey.INPUT_TYPE.xmlName); consider making the keyword list injectable or
a companion object constant so it can be extended without changing logic.
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt (2)

57-60: 💤 Low value

DimensionCleaner silently drops decimal precision for values like "16.5dp".

NumberCleaner only matches [-\doOlIzZsSbB]+ (no decimal point), so the integer-only regex truncates the fractional part. "16.5dp" would normalize to "16dp".

If sub-pixel dimension values are not expected from OCR (which is common), this is acceptable — but it's worth an explicit comment. If they are expected, the numeric extraction path should delegate to FloatCleaner (or use its regex) instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt`
around lines 57 - 60, DimensionCleaner is dropping fractional parts because it
uses NumberCleaner (integer-only) when extracting numericPart from fixedUnit;
update the extraction to preserve decimals by delegating to FloatCleaner (or
using FloatCleaner’s regex) instead of NumberCleaner, then reconstruct the unit
as "${numericPart}dp" (or, if fractional values are not expected, add an
explicit comment in DimensionCleaner explaining the choice and leave
NumberCleaner but document behavior); refer to DimensionCleaner, NumberCleaner,
FloatCleaner, numericPart, fixedUnit, and rawValue when making the change.

46-46: 💤 Low value

"wrapcan" in wrapKeywords looks like a stale OCR-artifact token.

"wrapcan" is not a recognizable dimension keyword. If it was meant to catch OCR-misread "wrap_content", it's already covered by the "wrap" and "content" entries. If it's intentional (e.g., a specific OCR output you observed), a short inline comment would clarify its purpose.

♻️ Proposed cleanup
-    private val wrapKeywords = setOf("wrap", "content", "wrapcan")
+    private val wrapKeywords = setOf("wrap", "content")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt`
at line 46, The set wrapKeywords in ValueCleanersImpl.kt contains a stale
OCR-like token "wrapcan"; remove "wrapcan" from the set (leaving "wrap" and
"content") or, if you intentionally want to handle a specific OCR artifact,
replace it with a short inline comment explaining the rationale; update the
declaration of wrapKeywords to reflect the removal/comment so the intent is
clear.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/WidgetGrammar.kt`:
- Line 79: The InputType validation currently uses CategoricalValidator with
fuzzy matching which fails on pipe-combined flags and a too-small
InputTypeValueSet; update validation so AttributeKey.INPUT_TYPE.xmlName is
validated by splitting the raw attribute value on '|' and validating each token
against an expanded InputTypeValueSet (add textVisiblePassword, textPersonName,
textCapSentences, textCapWords, textMultiLine, date, time, datetime, etc.), and
switch to exact (case-insensitive) token matching instead of fuzzy matching (or
implement a dedicated InputTypeValidator that performs this
split-and-exact-match logic) so combined flags are preserved rather than
dropped.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/MarginAnnotationParser.kt`:
- Around line 121-164: The extractBlocks function currently promotes any
tag-shaped text to explicit when validPrefixes is empty and overwrites duplicate
entries; change the explicit-detection logic in extractBlocks so an extraction
only becomes explicit when validPrefixes is non-empty and the extracted prefix
is in validPrefixes (e.g., require validPrefixes.isNotEmpty() &&
extraction.first.substringBefore('-') in validPrefixes), and modify the
save/update of blocks.explicitAnnotations (in GroupedBlocks handling inside
extractBlocks) to merge duplicates instead of overwriting — if a key already
exists concatenate the new text (with a separating space) or otherwise
append/log the collision so content isn’t silently dropped; reference
WidgetTagParser.extractTag, explicitAnnotations, ParsedBlock, and validPrefixes
when making these edits.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/AttributeModels.kt`:
- Line 71: The TEXT_STYLE enum/constant in AttributeModels.kt currently lists
"style" as an alias which collides with the STYLE entry and makes STYLE
unreachable; remove the "style" alias from TEXT_STYLE's alias list (leave
aliases like "textstyle" and "text_style"), so that AttributeKey.findByAlias /
fuzzyMatchKey will resolve "style" to the STYLE entry (xmlName = "style") and
resolveXmlAttribute will route style values through the correct cleaner instead
of TextStyleCleaner; verify no other entries duplicate the "style" alias.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt`:
- Around line 133-134: The DrawableCleaner logic in ValueCleanersImpl.kt
currently strips all non [a-z0-9_] characters which removes spaces and can yield
an empty name; update the cleaning pipeline for the code that computes `cleaned`
from `rawValue` (the block using `rawValue.lowercase()` and the two
`replace(Regex(...))` calls) to: 1) replace any whitespace and sequences of
non-alphanumeric characters with a single underscore, 2) collapse consecutive
underscores and trim leading/trailing underscores so names like "  my  image!! "
become "my_image", and 3) if the final cleaned result is empty, return a safe
fallback drawable reference (for example "@drawable/ic_placeholder" or another
project-standard default) instead of "@drawable/". Ensure you reference and
update the same symbol that returns `@drawable/$cleaned` in
ValueCleanersImpl.kt.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/WidgetTagParser.kt`:
- Around line 32-34: The code in WidgetTagParser unconditionally strips a
leading prefix from tokenRaw (tokenRaw.uppercase().startsWith(prefix)), which
mangles valid tags like "B-BOX"; change the condition to only strip when the
prefix is duplicated (e.g., patterns like prefix+prefix or prefix + "-" +
prefix) so you only remove an accidental repeated prefix. Locate the occurrences
around the tokenRaw manipulation (the block using
tokenRaw.uppercase().startsWith(prefix) and the substring(...).trim('-') logic)
and replace the check with a test for duplicated-prefix patterns
(tokenRaw.uppercase().startsWith(prefix + prefix) or
tokenRaw.uppercase().startsWith(prefix + "-" + prefix)), then perform the
substring/trimming only in those cases; apply the same change to the second
occurrence noted (lines around 49-51).

---

Nitpick comments:
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt`:
- Line 3: Remove the unused import of android.util.Log from
FuzzyAttributeParser.kt; open the FuzzyAttributeParser file (class/object
FuzzyAttributeParser) and delete the line "import android.util.Log" since Log is
not referenced anywhere in that file to avoid unused-import warnings.
- Around line 38-49: tokenizeAnnotation currently contains hardcoded OCR
workaround replace calls (e.g., "backgroundired", "backgroundred", "horizontal
gravity: center layout") which don't scale; extract these substitutions into a
dedicated OcrSanitizer (a data-driven list of (pattern, replacement) pairs) and
call it from tokenizeAnnotation so the sanitizer can be extended and tested
independently. Implement an OcrSanitizer class/object that exposes a
sanitize(String):String method (used by tokenizeAnnotation) backed by a
configurable list of Regex->replacement entries, ensure tokenizeAnnotation uses
PIPE_DELIMITER and the same split logic after calling OcrSanitizer.sanitize, and
update tests to exercise sanitizer rules separately.
- Line 97: The threshold calculation in FuzzyAttributeParser (the line computing
threshold from normalizedKey.length) special-cases length == 6 which is unclear
and brittle; either make the rule monotonic by changing the condition to "≤3 →
65, ≤6 → 75, else → 80" (i.e., replace the length==6 branch with length <= 6)
or, if the carve-out for length==6 is intentional, add a concise inline comment
on that same line referencing a concrete example (e.g., an OCR mis-parse like
"wldth") and why 75 was chosen so future readers can grep for it; update the
code in FuzzyAttributeParser.kt accordingly and keep the variable normalizedKey
as the referenced symbol.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt`:
- Around line 57-60: DimensionCleaner is dropping fractional parts because it
uses NumberCleaner (integer-only) when extracting numericPart from fixedUnit;
update the extraction to preserve decimals by delegating to FloatCleaner (or
using FloatCleaner’s regex) instead of NumberCleaner, then reconstruct the unit
as "${numericPart}dp" (or, if fractional values are not expected, add an
explicit comment in DimensionCleaner explaining the choice and leave
NumberCleaner but document behavior); refer to DimensionCleaner, NumberCleaner,
FloatCleaner, numericPart, fixedUnit, and rawValue when making the change.
- Line 46: The set wrapKeywords in ValueCleanersImpl.kt contains a stale
OCR-like token "wrapcan"; remove "wrapcan" from the set (leaving "wrap" and
"content") or, if you intentionally want to handle a specific OCR artifact,
replace it with a short inline comment explaining the rationale; update the
declaration of wrapKeywords to reflect the removal/comment so the intent is
clear.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt`:
- Around line 284-303: Password inference is currently English-only; update
inferInputTypeFromHint to support common non-English password tokens by
replacing the hardcoded contains checks with a configurable keyword list (e.g.,
LOCAL_PASSWORD_KEYWORDS) and matching against normalizedHint, so
specificAttributes still prefers parsedAttrs[AttributeKey.INPUT_TYPE.xmlName]
but falls back to inferInputTypeFromHint(normalizedHint) which now checks
multiple localized tokens (reference functions inferInputTypeFromHint and
specificAttributes, and keys AttributeKey.HINT.xmlName /
AttributeKey.INPUT_TYPE.xmlName); consider making the keyword list injectable or
a companion object constant so it can be extended without changing logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dd5586b6-f561-4e2b-80bb-b5c1ca15f782

📥 Commits

Reviewing files that changed from the base of the PR and between 27af4e9 and 8fbe6a5.

📒 Files selected for processing (13)
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/FuzzyAttributeParser.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/LayoutGeometryProcessor.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/MarginAnnotationParser.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/WidgetAnnotationMatcher.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/WidgetTagParser.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/WidgetGrammar.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/AttributeModels.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleaner.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/ValueCleanersImpl.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/WidgetFactory.kt
  • cv-image-to-xml/src/test/java/org/appdevforall/codeonthego/computervision/domain/FuzzyAttributeParserTest.kt
💤 Files with no reviewable changes (2)
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/WidgetAnnotationMatcher.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/FuzzyAttributeParser.kt

@hal-eisen-adfa
Copy link
Copy Markdown
Collaborator

Wait, the title of this PR does not match what I expected

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt (2)

13-24: ⚡ Quick win

De-duplicate the identity ValueCleaner.

ValueCleaner { it } is allocated both as the value for ValueType.RAW (Line 23) and as the fallback inside flushAttribute (Line 84). Hoisting it into a single private val (or a named object) avoids the duplication, ensures both call sites stay in sync if the identity behavior ever changes, and saves a small allocation per flushAttribute invocation when a valueType has no registered cleaner.

♻️ Proposed refactor
+    private val identityCleaner = ValueCleaner { it }
+
     private val cleaners = mapOf(
         ValueType.TEXT_CONTENT to TextContentCleaner,
         ValueType.DIMENSION to DimensionCleaner,
         ValueType.SP_DIMENSION to SpDimensionCleaner,
         ValueType.COLOR to ColorCleaner,
         ValueType.ID to IdCleaner,
         ValueType.DRAWABLE to DrawableCleaner,
         ValueType.INTEGER to NumberCleaner,
         ValueType.FLOAT to FloatCleaner,
         ValueType.TEXT_STYLE to TextStyleCleaner,
-        ValueType.RAW to ValueCleaner { it }
+        ValueType.RAW to identityCleaner
     )
@@
-        val cleaner = cleaners[key.valueType] ?: ValueCleaner { it }
+        val cleaner = cleaners[key.valueType] ?: identityCleaner

Also applies to: 81-91

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt`
around lines 13 - 24, The map 'cleaners' currently instantiates an identity
ValueCleaner twice (as ValueType.RAW and again inside flushAttribute fallback);
create a single private val (e.g., identityCleaner or IdentityValueCleaner) and
replace both occurrences so both the 'cleaners' entry for ValueType.RAW and the
fallback in flushAttribute reference that single instance, eliminating
duplication and extra allocations while keeping behavior identical.

112-116: 💤 Low value

Use AndroidWidgetTags.BUTTON instead of hardcoded "Button" string.

Line 113 uses tag == "Button" as a hardcoded literal, but AndroidWidgetTags.BUTTON constant is already defined in the codebase. Import AndroidWidgetTags and replace the hardcoded string to maintain consistency with the project's centralized widget tag constants.

if (key == AttributeKey.BACKGROUND && tag == AndroidWidgetTags.BUTTON) return "app:backgroundTint" to value
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt`
around lines 112 - 116, In resolveXmlAttribute, replace the hardcoded tag
comparison "Button" with the centralized constant AndroidWidgetTags.BUTTON:
update the conditional that checks AttributeKey.BACKGROUND to use
AndroidWidgetTags.BUTTON (ensure AndroidWidgetTags is imported) so the line
inside the resolveXmlAttribute function uses AndroidWidgetTags.BUTTON instead of
the literal string.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt`:
- Line 106: The threshold branch in FuzzyAttributeParser (variable normalizedKey
-> threshold) treats keys of length == 6 specially which is likely accidental;
either (A) if the intent is to target keys up to 6 characters, change the
condition from "== 6" to "<= 6", or (B) if the special-case for exactly 6 chars
is intentional, add a one-line comment above the threshold assignment
documenting why 6 is privileged (with examples of keys or rationale) so future
readers/tests understand the magic numbers.

---

Nitpick comments:
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt`:
- Around line 13-24: The map 'cleaners' currently instantiates an identity
ValueCleaner twice (as ValueType.RAW and again inside flushAttribute fallback);
create a single private val (e.g., identityCleaner or IdentityValueCleaner) and
replace both occurrences so both the 'cleaners' entry for ValueType.RAW and the
fallback in flushAttribute reference that single instance, eliminating
duplication and extra allocations while keeping behavior identical.
- Around line 112-116: In resolveXmlAttribute, replace the hardcoded tag
comparison "Button" with the centralized constant AndroidWidgetTags.BUTTON:
update the conditional that checks AttributeKey.BACKGROUND to use
AndroidWidgetTags.BUTTON (ensure AndroidWidgetTags is imported) so the line
inside the resolveXmlAttribute function uses AndroidWidgetTags.BUTTON instead of
the literal string.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e2a5f006-db5e-4d90-97d0-d000a841a878

📥 Commits

Reviewing files that changed from the base of the PR and between 8fbe6a5 and 04420cc.

📒 Files selected for processing (4)
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/MarginAnnotationParser.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/parser/FuzzyAttributeParser.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/ui/viewmodel/ComputerVisionViewModel.kt
✅ Files skipped from review due to trivial changes (1)
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/ui/viewmodel/ComputerVisionViewModel.kt
🚧 Files skipped from review as they are similar to previous changes (2)
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/xml/AndroidWidget.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/MarginAnnotationParser.kt

@jatezzz jatezzz changed the title ADFA-3900 | Infer password inputType from widget hint ADFA-3900 | Fix password inputType parsing from sketch annotations May 7, 2026
@jatezzz jatezzz force-pushed the fix/ADFA-3900-password-input-type-experimental branch from 207e958 to 167eb3d Compare May 8, 2026 14:47
@jatezzz jatezzz force-pushed the fix/ADFA-3900-password-input-type-experimental branch from 76cf0f7 to 3606e17 Compare May 8, 2026 22:21
@jatezzz jatezzz requested a review from Daniel-ADFA May 11, 2026 13:04
@jatezzz jatezzz force-pushed the fix/ADFA-3900-password-input-type-experimental branch from 3606e17 to cde11fd Compare May 11, 2026 13:38
jatezzz added 3 commits May 11, 2026 12:33
Resolves the issue by defaulting to textPassword when hint indicates a password field.
Preserve explicit margin tags and stop inferring EditText inputType from hint text
@jatezzz jatezzz force-pushed the fix/ADFA-3900-password-input-type-experimental branch from cde11fd to c204d68 Compare May 11, 2026 17:33
@jatezzz jatezzz merged commit 9c865b1 into stage May 11, 2026
2 checks passed
@jatezzz jatezzz deleted the fix/ADFA-3900-password-input-type-experimental branch May 11, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants