Repository navigation
#1086 Tap a server on Servers to make it active - #1087
Conversation
Tapping a saved server card on Settings › Servers now switches the active server through the same coordinator switch as the Home server sheet, so Home's title, projects and sessions follow. The trailing ✕ becomes an Edit (pencil) button; Remove already lives on the edit screen, so the list's own remove dialog goes away. Both iOS and Android, with unit tests for the switch rules. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Automated review: 2 finding(s) that 2+ of 3 passes agreed on.
Outside the diff lines:
ios/OpenCode Mobile/OpenCode Mobile/UI/Settings/ServersView.swift:97medium: switchTo guard compares against stale cached activeId, same divergence as Android
1 finding(s) from a single pass, not posted
ios/OpenCode Mobile/OpenCode Mobile/UI/Settings/ServersView.swift:102medium: Switched server briefly shows the previous server health (muse-spark-1.3-contributor)
opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.095
| fun switchTo(profileId: String) { | ||
| val state = _uiState.value | ||
| if (switchJob?.isActive == true) return | ||
| if (profileId == state.activeId || state.profiles.none { it.id == profileId }) return |
There was a problem hiding this comment.
medium: Tap guard uses a cached activeId that coordinator-driven switches elsewhere never update
switchTo ignores a tap when profileId == state.activeId, but _uiState.activeId is only written by reload() inside this ViewModel (refresh on screen open and after setup closes); it is never updated when the active profile changes through the coordinator from elsewhere (e.g. the Home server sheet), and ServersViewModel observes no profile-change events. The guard that decides whether a tap is a no-op therefore evaluates a stale value. Lines added by this PR (100-117) make the stale cached id load-bearing for tap semantics.
Failure scenario: Tablet split layout: Servers detail is open showing Work as Active; the user picks Home in the Home server sheet, so the coordinator's active profile becomes Home while Servers' state still says Work. Tapping the Work card (the one the UI marks Active, but which is not actually active) is silently swallowed by the profileId == state.activeId guard, and tapping the Home card runs switchProfile("home") again on a profile that is already active, tearing down and re-binding the live connection (SSE restart, retarget job cancel) for no change; the list then re-renders as if a switch happened.
Found by 2 of 3 passes.







Summary
ConnectionSessionCoordinator.switchProfilecall the Home server sheet uses, so Home's title, projects and sessions follow. The active card is no longer tappable; taps while a switch runs and taps on an unknown server are ignored. A switch that doesn't apply is logged by profile id.servers.remove_profile,servers.remove_dialog.title) are gone. New string:servers.edit_profile("Edit %@").ServersViewModel.switchTo) and Android (ServersViewModel.switchTo).editicon on both platforms. The prototype also explored an ⓘ icon, but the icon set has none, so this avoids a new design-system icon.Checks
ServersSwitchTest(new, 4 tests),ServersUiStateTest,ServersHealthQuickViewTest: 8/8 pass.assembleDebug+assembleDebugAndroidTestbuild. No ktlint findings in the changed files (the remaining ones are on untouched lines).ServersSwitchTests(new, 3 tests) +ServerHealthViewModelTests: 11/11 pass on an iPhone 17 simulator (iOS 27.2).opencode servev2 instances: tap switches, the health footer moves to the new server, Home's title follows, and the pencil opens Edit with Remove (see the evidence comment).Evidence
Screenshots in the evidence comment.
Issue
Fixes #1086
Risks / Follow-ups
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.