Skip to content

#1086 Tap a server on Servers to make it active - #1087

Merged
ivanfenenko merged 1 commit into
mainfrom
feature/1086-servers-tap-to-switch
Nov 18, 2026
Merged

ivanfenenko merged 1 commit into
mainfrom
feature/1086-servers-tap-to-switch

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Tap a server to make it active. On Settings › Servers, tapping a saved server card switches the active server through the same ConnectionSessionCoordinator.switchProfile call 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.
  • ✕ → Edit (pencil). The trailing button now opens the server's edit screen. Remove already lives there with its confirm dialog, so the list's own remove dialog, its Screen Model state and its now-unused strings (servers.remove_profile, servers.remove_dialog.title) are gone. New string: servers.edit_profile ("Edit %@").
  • Same behaviour on iOS (ServersViewModel.switchTo) and Android (ServersViewModel.switchTo).
  • Uses the existing edit icon on both platforms. The prototype also explored an ⓘ icon, but the icon set has none, so this avoids a new design-system icon.

Checks

  • Android: ServersSwitchTest (new, 4 tests), ServersUiStateTest, ServersHealthQuickViewTest: 8/8 pass. assembleDebug + assembleDebugAndroidTest build. No ktlint findings in the changed files (the remaining ones are on untouched lines).
  • iOS: ServersSwitchTests (new, 3 tests) + ServerHealthViewModelTests: 11/11 pass on an iPhone 17 simulator (iOS 27.2).
  • Real apps against two local opencode serve v2 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

  • Checked against v2 servers only. The switch path is protocol-agnostic (same coordinator call as the Home sheet), but v1 wasn't exercised on device.
  • The switch doesn't probe the server, same as the Home sheet: an unreachable server becomes active and its health footer shows the connection state.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

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]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

iOS (iPhone 17 sim, light) and Android (Pixel 9a emulator, dark), both against two local opencode serve v2 instances with demo sessions; no real data.

Step iOS Android
Before: second server active, pencil on every card ios before android before
Tap the other card: it becomes Active, health footer moves to it ios after tap android after tap
Back on Home: title follows the new server ios home android home
Pencil opens Edit, where Remove (trash) lives android edit

Android Home shows "No projects yet" because the freshly seeded v2 profile has no added project, unrelated to this change.

@github-actions github-actions 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.

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:97 medium: 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:102 medium: 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@ivanfenenko
ivanfenenko added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 032dca9 Nov 18, 2026
@ivanfenenko
ivanfenenko deleted the feature/1086-servers-tap-to-switch branch November 18, 2026 11:29
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.

Servers: tap a server to make it active

1 participant