fix: single-tap save proxy + suspend getString + preserve cancellation#578
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughProxy host validation now consistently selects between "required" and "invalid" messages; proxy Test/Save handlers hide the software keyboard and clear focus before calling the VM; the Test button is enabled when not testing. Separately, app update flows now rethrow CancellationException to allow normal coroutine cancellation. ChangesProxy Validation & Keyboard UX
App Updates Cancellation Handling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Greptile Summary
Confidence Score: 5/5Safe to merge — all changes are targeted bug fixes with no new logic errors introduced. Only pre-existing P2 finding (dead Network.kt still contains the dead Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant IME as Android IME
participant Network as Network.kt (Composable)
participant FocusManager
participant KeyboardController
participant TweaksVM as TweaksViewModel
User->>Network: Tap Save / Test button
Network->>KeyboardController: hide() — flush composition buffer
Network->>FocusManager: clearFocus()
Network->>TweaksVM: OnProxySave / OnProxyTest action
alt host blank or invalid
TweaksVM->>TweaksVM: "capture isBlank = form.host.isBlank()"
TweaksVM->>TweaksVM: viewModelScope.launch
TweaksVM->>TweaksVM: getString(proxy_host_required / proxy_host_invalid)
TweaksVM-->>Network: _events.send(OnProxySaveError / OnProxyTestError)
else port invalid
TweaksVM->>TweaksVM: viewModelScope.launch
TweaksVM->>TweaksVM: getString(invalid_proxy_port)
TweaksVM-->>Network: _events.send(error event)
else form valid
TweaksVM->>TweaksVM: build ProxyConfig
TweaksVM->>TweaksVM: viewModelScope.launch → save / test
TweaksVM-->>Network: _events.send(OnProxySaved / test outcome)
end
Reviews (2): Last reviewed commit: "fix(apps): preserve coroutine cancellati..." | Re-trigger Greptile |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksViewModel.kt (1)
639-647: ⚡ Quick winCentralize the proxy-host error resource selection.
The blank-vs-invalid branch is now duplicated in both save and test validation paths. That logic already drifted once; keeping it in one helper will make the next validation tweak much safer.
♻️ Small extraction
+private fun proxyHostErrorRes(host: String) = + if (host.isBlank()) { + Res.string.proxy_host_required + } else { + Res.string.proxy_host_invalid + } ... - val isBlank = form.host.isBlank() viewModelScope.launch { - val msg = - if (isBlank) { - getString(Res.string.proxy_host_required) - } else { - getString(Res.string.proxy_host_invalid) - } + val msg = getString(proxyHostErrorRes(form.host)) _events.send(TweaksEvent.OnProxySaveError(msg)) } ... - val isBlank = form.host.isBlank() viewModelScope.launch { - val msg = - if (isBlank) { - getString(Res.string.proxy_host_required) - } else { - getString(Res.string.proxy_host_invalid) - } + val msg = getString(proxyHostErrorRes(form.host)) _events.send(TweaksEvent.OnProxyTestError(msg)) }Also applies to: 1026-1034
🤖 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 `@feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksViewModel.kt` around lines 639 - 647, Extract the blank-vs-invalid selection into a single helper on TweaksViewModel (e.g., proxyHostErrorMessage(host: String): String) that checks form.host.isBlank() and returns getString(Res.string.proxy_host_required) or getString(Res.string.proxy_host_invalid); then replace the duplicated branches that build msg (the block that sends _events.send(TweaksEvent.OnProxySaveError(msg)) and the similar code at the other occurrence) to call this helper so both save and test validation use the same logic.
🤖 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
`@feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksViewModel.kt`:
- Around line 639-647: Extract the blank-vs-invalid selection into a single
helper on TweaksViewModel (e.g., proxyHostErrorMessage(host: String): String)
that checks form.host.isBlank() and returns
getString(Res.string.proxy_host_required) or
getString(Res.string.proxy_host_invalid); then replace the duplicated branches
that build msg (the block that sends
_events.send(TweaksEvent.OnProxySaveError(msg)) and the similar code at the
other occurrence) to call this helper so both save and test validation use the
same logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 37e08d7c-c423-4ec2-b7b4-93a61d2ec2fc
📒 Files selected for processing (2)
feature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/TweaksViewModel.ktfeature/tweaks/presentation/src/commonMain/kotlin/zed/rainxch/tweaks/presentation/components/sections/Network.kt
Two fixes (one a follow-up to merged #576, one a supersede of open #577):
1. Save proxy required two taps. Root cause: the
enabled = isFormValid && !form.isTestInProgressgate raced with the IME-composition-commit step on Android keyboards (Gboard / SwiftKey hold last-typed chars in a composition buffer until focus actually transfers). First tap landed on a momentarily-disabled button. Removed the validity gate — VM still validates and surfaces a clear error event. Also addedLocalSoftwareKeyboardController.hide()alongsidefocusManager.clearFocus()so any pending composition commits synchronously before the action dispatches.2. Suspend
getStringin non-coroutine scope (same fix as #577). Main is currently broken because #576 merged without a compile pass —getString(Res.string.proxy_host_*)was called outside the surroundingviewModelScope.launch. Moved the calls inside; passisBlankboolean across the boundary. Also missing import forproxy_host_invalidadded.Verified with
./gradlew :feature:tweaks:presentation:compileDebugKotlinAndroid :feature:tweaks:presentation:compileKotlinJvm :composeApp:compileDebugKotlinAndroid— all green.If this lands first, #577 should be closed as redundant (its fix is duplicated here).
Summary by CodeRabbit