Fix inline bot rule mode conversion#63
Closed
BraveSail wants to merge 1 commit into
Closed
Conversation
Reviewer's GuideAdjusts inline URL auto inline bot rule handling so host metadata is correctly preserved and normalized when converting between simple and advanced modes, and when parsing persisted rules, preventing host-only rules from degrading into bare regex text. Sequence diagram for inline bot rule mode conversion with host preservationsequenceDiagram
actor User
participant Activity as NekoExperimentalSettingsActivity
participant Row as FixUrlAutoInlineBotRuleRow
participant Helper as InlineBotRulesHelper
User->>Activity: toggle advancedMode
activate Activity
Activity->>Activity: updateFixUrlAutoInlineBotRulesDialogMode(context, hintTextView, ruleRows, advancedMode, convertValues)
loop for each rule row
Activity->>Row: get value from ruleEditText
alt advancedMode is true
Activity->>Helper: normalizeSimpleHostInput(value)
Helper-->>Activity: normalizedHost
Activity->>Helper: buildHostPattern(normalizedHost)
Helper-->>Activity: advancedPattern
Activity->>Row: set host = normalizedHost
Activity->>Row: ruleEditText.setText(advancedPattern)
else simple mode
Activity->>Helper: extractHostFromPattern(value)
Helper-->>Activity: hostCandidate
Activity->>Helper: getHostForRule(value, Row.host)
Helper-->>Activity: hostFromMetadata
Activity->>Helper: normalizeSimpleHostInput(value)
Helper-->>Activity: fallbackHost
Activity->>Row: set host = chosenHost
Activity->>Row: ruleEditText.setText(chosenHost)
end
end
Activity-->>User: dialog updated with converted patterns and preserved hosts
deactivate Activity
Class diagram for updated inline bot rule handlingclassDiagram
class NekoExperimentalSettingsActivity {
- ArrayList FixUrlAutoInlineBotRuleRow ruleRows
+ void showFixUrlAutoInlineBotRulesDialog()
+ boolean updateFixUrlAutoInlineBotRulesDialogMode(Context context, TextView hintTextView, ArrayList ruleRows, boolean advancedMode, boolean convertValues)
+ void addFixUrlAutoInlineBotRuleRow(ArrayList ruleRows, LinearLayout rowsContainer, String rule, String username, String host)
+ void setupFixUrlAutoInlineBotRuleEditText(EditTextBoldCursor editText, String rule)
}
class FixUrlAutoInlineBotRuleRow {
+ EditTextBoldCursor ruleEditText
+ EditTextBoldCursor usernameEditText
+ String host
+ FixUrlAutoInlineBotRuleRow(EditTextBoldCursor ruleEditText, EditTextBoldCursor usernameEditText, String host)
}
class InlineBotRulesHelper {
+ static ArrayList parseInlineBotRules(String list, boolean legacy)
+ static InlineBotRule extractInlineBotRule(JSONObject object)
+ static String extractHostFromPattern(String pattern)
+ static String buildHostPattern(String host)
+ static String normalizeSimpleHostInput(String hostInput)
+ static String normalizeHostInput(String hostInput)
+ static String getHostForRule(String pattern, String existingHost)
+ static void addInlineBotRule(ArrayList rules, InlineBotRule rule)
}
class InlineBotRule {
+ String username
+ String pattern
+ String host
+ boolean enabled
+ InlineBotRule(String username, String pattern, String host, boolean enabled)
}
NekoExperimentalSettingsActivity ..> FixUrlAutoInlineBotRuleRow : uses
NekoExperimentalSettingsActivity ..> InlineBotRulesHelper : calls
NekoExperimentalSettingsActivity ..> InlineBotRule : constructs
FixUrlAutoInlineBotRuleRow o-- EditTextBoldCursor : composition
InlineBotRulesHelper ..> InlineBotRule : creates
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Several code paths assume
row.hostis non-null (e.g.,!row.host.isEmpty()and passing it togetHostForRule), so either ensureFixUrlAutoInlineBotRuleRow.hostis always initialized to a non-null value or add null-safety checks to avoid potentialNullPointerExceptions. - In
updateFixUrlAutoInlineBotRulesDialogMode, the host normalization/conversion logic is fairly intricate; consider extracting the simple→advanced and advanced→simple host conversion into small helper methods to make the control flow easier to follow and reduce duplication.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Several code paths assume `row.host` is non-null (e.g., `!row.host.isEmpty()` and passing it to `getHostForRule`), so either ensure `FixUrlAutoInlineBotRuleRow.host` is always initialized to a non-null value or add null-safety checks to avoid potential `NullPointerException`s.
- In `updateFixUrlAutoInlineBotRulesDialogMode`, the host normalization/conversion logic is fairly intricate; consider extracting the simple→advanced and advanced→simple host conversion into small helper methods to make the control flow easier to follow and reduce duplication.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Preserve host metadata when switching between simple and advanced rule modes. Recover host-backed rules that were persisted with a bare host as the pattern.
ccf2105 to
51bd91d
Compare
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.
Follow-up to #62.
This preserves host metadata when switching URL inline bot rules between simple and advanced modes, so host-only simple rules do not get stuck as bare regex text. It also recovers host-backed rules that were already persisted with a bare host as the pattern.
Validation:
Summary by Sourcery
Preserve and normalize host metadata for URL auto inline bot rules when converting between simple and advanced modes and when parsing persisted rules.
Bug Fixes:
Enhancements: