fix(InterfaceManagementViewModel): default add-dialog AutoInterface to wifi_only#904
Draft
torlando-agent[bot] wants to merge 1 commit into
Draft
Conversation
…o wifi_only InterfaceConfigState.networkRestriction was a non-null String defaulting to NetworkRestriction.ANY.value, regardless of the active interface type. The per-type fallback in configStateToInterfaceConfig only fires when NetworkRestriction.fromValue returns null, so "any" parsed cleanly and the AutoInterface row was persisted with networkRestriction=ANY instead of the intended WIFI_ONLY (894 design intent: UDP multicast on cellular is noise). Switch the field to nullable with sentinel-as-null. Save resolves null to the per-type default (AutoInterface -> WIFI_ONLY, others -> ANY); editing existing rows still seeds a non-null string from the entity, so user-picked values survive round-trips. Dialog renders via a new effectiveNetworkRestriction computed property so the segmented selector highlights the per-type default when the user hasn't picked anything. Tests: tight-assertion repro for the showAddDialog->save path (AutoInterface saves as WIFI_ONLY); paired test confirming explicit "Any" selection still persists ANY so the sentinel doesn't swallow user choices. Closes #899 Co-Authored-By: Claude claude-opus-4-7 <noreply@anthropic.com>
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Implements the approved plan for #899.
Summary
When the user taps the FAB to add a new interface and saves without touching the network restriction selector, the persisted
InterfaceConfig.AutoInterfaceended up withnetworkRestriction = ANYinstead ofWIFI_ONLY. The 894 design intent ("AutoInterface defaults to Wi-Fi only — UDP multicast on cellular is meaningless and noisy") and the data class default (AutoInterface.networkRestriction = NetworkRestriction.WIFI_ONLY) were bypassed becauseInterfaceConfigStatedefaulted its string field toNetworkRestriction.ANY.valueregardless oftype, so the per-type fallback inconfigStateToInterfaceConfignever fired.The seeded "Auto Discovery" row and the v1→v2 JSON-omission path both correctly inherit
WIFI_ONLY. Only theshowAddDialog()→ save-without-touching-selector path was broken.Switches
InterfaceConfigState.networkRestrictionto a nullableString?with sentinel-as-null. Save resolves null to the per-type default (AutoInterface → WIFI_ONLY, others → ANY); editing existing rows still seeds a non-null string from the entity, so user-picked values survive round-trips. The dialog renders via a neweffectiveNetworkRestrictioncomputed property so the segmented selector highlights the per-type default when the user hasn't picked anything.Changes
app/src/main/java/network/columba/app/viewmodel/InterfaceManagementViewModel.kt—InterfaceConfigState.networkRestriction: String? = null; neweffectiveNetworkRestrictioncomputed property mirroring the per-type fallback inconfigStateToInterfaceConfig;configStateToInterfaceConfigreads viastate.networkRestriction?.let { NetworkRestriction.fromValue(it) } ?: defaultRestriction.app/src/main/java/network/columba/app/ui/components/InterfaceConfigDialog.kt—NetworkRestrictionSelectoris fedconfigState.effectiveNetworkRestrictionso a freshly-opened AutoInterface dialog renders "Wi-Fi only" highlighted.app/src/test/java/network/columba/app/viewmodel/InterfaceManagementViewModelStatusEventTest.kt— adds the tight-assertion repro test for the showAddDialog→save path (AutoInterface saves as WIFI_ONLY) plus a paired test confirming explicit "Any" selection still persists ANY so the sentinel doesn't swallow user choices.Test plan
./gradlew :app:testNoSentryDebugUnitTest --tests "network.columba.app.viewmodel.InterfaceManagementViewModelStatusEventTest"— 29 PASSED, including the two new tests./gradlew :app:testNoSentryDebugUnitTest— full app unit suite green./gradlew ktlintCheck detekt cpdCheck --continue— BUILD SUCCESSFUL./gradlew :app:assembleNoSentryDebug— debug APK builds cleanImplementer notes
Wizards (
TcpClientWizardViewModel,RNodeWizardViewModel) carry their ownnetworkRestriction: Stringstate independent ofInterfaceConfigState; the change here does not touch them, and per the plan they were not buggy (their per-type default isANY, which matches the wizard string default).The plan flagged a "hotspot" pattern around 894-derived plumbing — long-term, dropping the string-typed
networkRestrictiononInterfaceConfigStatein favor of aNetworkRestriction?would be cleaner. Out of scope here.🤖 Generated with Claude Code