Skip to content

fix(profiles): phone profile edit can clear PIN and turn subtitles off - #51

Closed
RXWatcher wants to merge 1 commit into
Silo-Server:mainfrom
RXWatcher:fix/phone-profile-edit-pin-subtitle
Closed

RXWatcher wants to merge 1 commit into
Silo-Server:mainfrom
RXWatcher:fix/phone-profile-edit-pin-subtitle

Conversation

@RXWatcher

@RXWatcher RXWatcher commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

The phone EditProfileViewModel carried the same explicitNulls=false trap that PR #50 fixed on the TV app but never ported to phone. Two edit-flow bugs:

  • Can't clear a PIN. Disabling a PIN sent pin = null, which SiloJson omits from the PUT, so the server kept the old PIN. Now tracks loadedHasPin and sends an explicit "" to clear (server treats "" as clear, null/omitted as unchanged).
  • Can't turn subtitles off. Selecting subtitle mode "Off" mapped to null, likewise omitted, so the previous mode stuck. Now sends the literal "off".

Both are straight ports of TvEditProfileViewModel's already-correct handling (the loadedHasPin → "" PIN mapping and the "off" subtitle mapping). Create and delete flows were already correct on both platforms and are untouched.

Gated on :androidApp:assembleDebug + ./gradlew test (debug + release unit suites) — all green.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed profile updates so PIN changes are saved correctly when enabling, disabling, or leaving a PIN unchanged.
    • Improved subtitle settings so turning subtitles off now applies reliably instead of being treated as an unset value.

The phone EditProfileViewModel had the same explicitNulls=false trap we
fixed on TV this session. Disabling a PIN sent pin=null, which SiloJson
omits, so the server kept the old PIN; selecting subtitles "Off" mapped
to null, likewise omitted, so the prior mode stuck. Port the TV fix:
track loadedHasPin and send an explicit "" to clear a PIN, and send the
literal "off" for subtitle mode. Matches TvEditProfileViewModel.

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

EditProfileViewModel now tracks whether a loaded profile previously had a PIN via a loadedHasPin flag, using it to decide whether to send the entered PIN, an explicit empty string to clear it, or null to leave it unchanged. Subtitle mode "Off" now sends "off" instead of null.

Changes

Profile Update Request Serialization

Layer / File(s) Summary
Track loaded PIN state
androidApp/.../EditProfileViewModel.kt
Adds a loadedHasPin field, set from the profile's hasPin during loadProfile, to distinguish "no PIN existed" from "PIN removal".
Compute save request fields
androidApp/.../EditProfileViewModel.kt
onSubtitleModeSelected sends explicit "off" for the Off mode; onSaveClick computes pinValue using pinEnabled, pin, and loadedHasPin to send the PIN, clear it with "", or omit it with null.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main phone profile edit fix: clearing PINs and turning subtitles off.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/profiles/EditProfileViewModel.kt (1)

148-155: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

The "Off" special-case branch is redundant.

"Off".lowercase().replace(" ", "_") already yields "off", so the explicit branch produces the same wire value as the else branch. The pre-fix bug was mapping "Off" to null; now that it maps to a real value, the conditional can be collapsed. Keeping it is harmless, but it may mislead future readers into thinking "Off" needs distinct handling.

♻️ Optional simplification
-            // "Off" must go over the wire as the explicit "off" value, not null:
-            // explicitNulls=false drops a null subtitle_mode so the server would
-            // keep the previous mode instead of switching subtitles off.
-            it.copy(subtitleMode = if (mode == "Off") "off" else mode.lowercase().replace(" ", "_"))
+            // Normalize to the wire value (e.g. "Off" -> "off"). A real value is
+            // required because explicitNulls=false drops a null subtitle_mode, so
+            // the server would otherwise keep the previous mode.
+            it.copy(subtitleMode = mode.lowercase().replace(" ", "_"))
🤖 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
`@androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/profiles/EditProfileViewModel.kt`
around lines 148 - 155, The special-case handling in
EditProfileViewModel.onSubtitleModeSelected is redundant because the "Off"
option already normalizes to the same wire value as the general branch. Simplify
the subtitleMode assignment by removing the explicit "Off" conditional and using
the shared lowercase/underscore normalization path for all values, while keeping
the explicit non-null wire value behavior intact.
🤖 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.

Nitpick comments:
In
`@androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/profiles/EditProfileViewModel.kt`:
- Around line 148-155: The special-case handling in
EditProfileViewModel.onSubtitleModeSelected is redundant because the "Off"
option already normalizes to the same wire value as the general branch. Simplify
the subtitleMode assignment by removing the explicit "Off" conditional and using
the shared lowercase/underscore normalization path for all values, while keeping
the explicit non-null wire value behavior intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b1282b72-5294-4de3-bb4e-9da323ff6cbc

📥 Commits

Reviewing files that changed from the base of the PR and between 5706de9 and d96f7d6.

📒 Files selected for processing (1)
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/profiles/EditProfileViewModel.kt

@RXWatcher

Copy link
Copy Markdown
Contributor Author

Superseded by #52, which folds this profile PIN/subtitle fix (as commit 06cb58f1) into the consolidated phone + TV QA sweep. Closing in favor of the single PR.

@RXWatcher RXWatcher closed this Jul 9, 2026
@RXWatcher
RXWatcher deleted the fix/phone-profile-edit-pin-subtitle branch July 13, 2026 19:41
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.

1 participant