Skip to content

feat: remove slider from manage UTXO custom amount flow#691

Open
Vineet1101 wants to merge 2 commits intobitcoinppl:masterfrom
Vineet1101:feature/remove-utxo-slider
Open

feat: remove slider from manage UTXO custom amount flow#691
Vineet1101 wants to merge 2 commits intobitcoinppl:masterfrom
Vineet1101:feature/remove-utxo-slider

Conversation

@Vineet1101
Copy link
Copy Markdown

@Vineet1101 Vineet1101 commented Apr 19, 2026

Summary

Testing

Platform Coverage

  • Tested on iOS device
  • Tested on Android device
  • Tested on iOS simulator
  • Tested on Android simulator
  • Not tested

Checklist

Fixes #457

Summary by CodeRabbit

  • UI Changes

    • Removed the slider control from the send flow; amount entry is now via the text field only.
    • Updated on-screen instructions to guide users to the text field for custom amounts.
  • Behavior

    • Amount now consistently syncs with external updates regardless of focus.
    • Slider-specific update behavior and accessibility metadata removed.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 19, 2026

📝 Walkthrough

Walkthrough

Removed the slider-based input mechanism and associated state management from the UTXO custom amount sheet view. The amount input is now driven exclusively by a text field, with simplified dispatch logic triggered only by text field changes and focus loss events.

Changes

Cohort / File(s) Summary
UTXO Amount Input Simplification
ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift
Removed slider UI component, related state (previousAmount, isEditing, pinState, smartSnapBinding, minSend, step), and snap logic. Amount synchronization now always updates on external manager.amount changes without isEditing guard. Dispatch behavior simplified to trigger only via text field interaction and focus-loss handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I hopped through UI, slider tucked away,
The text field now leads the bright new day.
Numbers align with a simple, clear beat,
No snaps, no pins—just typing, neat.
Hooray for clarity, small and spry!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete. The Summary section is empty and does not explain what changed or why, and the Testing section lacks detail on testing performed. Add a Summary explaining the slider removal and its UX benefits, and provide details on testing (even if testing was intentionally deferred). Address reviewer feedback about demonstrating the custom amount sheet functionality.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: removal of the slider from the UTXO custom amount flow.
Linked Issues check ✅ Passed The code changes fully satisfy the requirement in issue #457 by removing the slider and simplifying the custom amount input UI to make the text field discoverable.
Out of Scope Changes check ✅ Passed All changes are directly related to removing slider-based flow logic and associated state, staying within the scope of issue #457.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 19, 2026

Greptile Summary

This PR simplifies the manage-UTXO custom amount flow by replacing the Slider (and its elaborate smart-snap / dust-avoidance logic) with a plain TextField. The user instruction label is updated accordingly, and the now-unused isEditing / pinState / previousAmount state and related onChange handlers are removed cleanly.

Confidence Score: 5/5

Safe to merge; only P2 dead-code cleanup remains.

All findings are P2 style issues (unused softMaxSend and satToDouble helpers). The core logic change is straightforward — slider and its state removed, text field already dispatches amounts correctly, focus-loss reset is preserved.

No files require special attention beyond the minor dead-code cleanup in SendFlowUtxoCustomAmountSheetView.swift.

Important Files Changed

Filename Overview
ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift Slider and its complex snapping logic removed, replaced by plain text-field entry; two helpers (softMaxSend, satToDouble) are now dead code and should be cleaned up.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User opens UTXO custom amount sheet] --> B[TextField shown with current amount]
    B --> C{User taps TextField?}
    C -- Yes --> D[isFocused = true]
    D --> E[User types amount]
    E --> F[displayAmountBinding.set fires]
    F --> G[enteringAmount updated]
    G --> H[manager.dispatch notifyCoinControlEnteredAmountChanged]
    C -- No --> I[Amount stays at customAmount]
    D --> J{User dismisses keyboard?}
    J -- Yes --> K[isFocused = false]
    K --> L[onChange isFocused: reset customAmount from manager.amount]
    H --> M{manager.amount changes?}
    M -- Yes --> N[onChange manager.amount: update customAmount]
    N --> O[Display refreshed via displayAmount]
Loading

Comments Outside Diff (2)

  1. ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift, line 44-47 (link)

    P2 Unused softMaxSend and satToDouble after slider removal

    With smartSnapBinding and the Slider removed, both softMaxSend (line 44) and satToDouble (line 78) are now dead code — neither is referenced anywhere else in the view. softMaxSend in particular encodes the dust-avoidance boundary logic, so leaving it around may mislead future contributors into thinking there is still an active guard against selecting amounts between softMaxSend and maxSend via the text field.

  2. ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift, line 78-80 (link)

    P2 satToDouble is now unreachable

    satToDouble was only called from the removed minSend and step properties (which fed the Slider). With the slider gone, this helper is never invoked and can be deleted alongside softMaxSend.

Reviews (1): Last reviewed commit: "Merge branch 'master' into feature/remov..." | Re-trigger Greptile

@pradhyum6144
Copy link
Copy Markdown
Collaborator

Hey @Vineet1101 lgtm. A couple of things before this can move forward:

The Summary section is empty could you add a brief description of what was wrong with the slider (referencing #457) and why a text field alone is the better UX?
The PR is only checked against iOS simulator. Could you test on a real iOS device and share a short screen recording showing the custom amount sheet working end-to-end (entering an amount, confirming the coin control flow still works correctly)?

Thanks!

@praveenperera
Copy link
Copy Markdown
Contributor

@Vineet1101 what about android? should be done together

@praveenperera praveenperera force-pushed the feature/remove-utxo-slider branch from 3510c66 to e79828f Compare April 20, 2026 17:22
@praveenperera
Copy link
Copy Markdown
Contributor

also please make sure CI is passing before requesting review again thank you

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift (1)

174-179: ⚠️ Potential issue | 🟠 Major

Dispatch the final amount when the field loses focus.

After removing the slider/editing-end path, the backend may never receive .notifyCoinControlEnteredAmountChanged(..., false) when the user taps away without changing text again. That can leave focus-loss validation/commit logic untriggered.

🐛 Proposed fix
 .onChange(of: isFocused, initial: false) { old, new in
     // lost focus
     if old == true, new == false {
+        if let enteringAmount {
+            manager.dispatch(.notifyCoinControlEnteredAmountChanged(enteringAmount, false))
+            self.enteringAmount = nil
+        }
         self.customAmount = manager.amount.map(amountToDouble) ?? maxSend
     }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift`
around lines 174 - 179, When the text field loses focus the code resets
self.customAmount but does not dispatch the final entered amount to the backend,
so add a call to manager.notifyCoinControlEnteredAmountChanged(...) (or the
project's equivalent) inside the isFocused onChange branch where old == true and
new == false; compute the final amount the same way you set self.customAmount
(use manager.amount.map(amountToDouble) ?? maxSend or the resolved Double) and
call notifyCoinControlEnteredAmountChanged(finalAmount, false) so the backend
receives the final committed value; update the block in
SendFlowUtxoCustomAmountSheetView where customAmount, manager, amountToDouble,
maxSend are used.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift`:
- Around line 174-179: When the text field loses focus the code resets
self.customAmount but does not dispatch the final entered amount to the backend,
so add a call to manager.notifyCoinControlEnteredAmountChanged(...) (or the
project's equivalent) inside the isFocused onChange branch where old == true and
new == false; compute the final amount the same way you set self.customAmount
(use manager.amount.map(amountToDouble) ?? maxSend or the resolved Double) and
call notifyCoinControlEnteredAmountChanged(finalAmount, false) so the backend
receives the final committed value; update the block in
SendFlowUtxoCustomAmountSheetView where customAmount, manager, amountToDouble,
maxSend are used.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 08c12828-6ae0-48b6-ae41-3fda2f04d038

📥 Commits

Reviewing files that changed from the base of the PR and between 7bb4a5a and e79828f.

📒 Files selected for processing (1)
  • ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift

@praveenperera praveenperera force-pushed the feature/remove-utxo-slider branch from e79828f to 72b9345 Compare April 20, 2026 18:11
@praveenperera praveenperera force-pushed the feature/remove-utxo-slider branch from 72b9345 to 49a740d Compare April 21, 2026 17:58
@praveenperera
Copy link
Copy Markdown
Contributor

@Vineet1101 get ci passing

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift (2)

28-32: ⚠️ Potential issue | 🟡 Minor

Remove unused divider computed property — leftover from slider UI removal.

The divider property (lines 28–32) is defined but never referenced. The inline Divider() on line 124 is separate. This dead code can be removed along with the surrounding blank lines.

Suggested cleanup
-
-
-    private var divider: some View {
-        Divider()
-            .padding(.vertical, 28)
-            .foregroundStyle(.red)
-    }
-
-
-
     private var maxSend: Double {

Additionally, the softMaxSend computed property (lines 44–47) also appears unused after slider removal.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift`
around lines 28 - 32, Remove the dead computed properties `divider` and
`softMaxSend` from the SendFlowUtxoCustomAmountSheetView type: delete the
`private var divider: some View { Divider() ... }` block and the `private var
softMaxSend: Decimal { ... }` block (and any adjacent blank lines), then run a
build to ensure nothing references them; if any references remain, replace them
with the inline `Divider()` or the appropriate value logic where used.

162-179: ⚠️ Potential issue | 🟡 Minor

Clarify dust-UTXO safeguard enforcement: softMaxSend is calculated but not used for input validation.

The softMaxSend property is defined at line 44 but never used to constrain the TextField or validate enteringAmount before dispatch. Unlike the Android equivalent (which coerces input against softMaxSend), the iOS view sends raw user input directly to Rust via notifyCoinControlEnteredAmountChanged without client-side validation. The dust-UTXO guardrail is enforced downstream on the Rust side through maxSendMinusFeesAndSmallUtxo() (which calls the actual dust-check logic in cove-bdk/src/util.rs:72), so amounts that would create dust UTXOs should still be rejected during coin selection.

Confirm on a real device that:

  1. Typing remains smooth and the input field doesn't rewrite mid-edit as the onChange handlers fire
  2. Fee/total fields don't visibly thrash during rapid keystroke input
  3. The Rust-side validation correctly rejects amounts in the dust range when the transaction is confirmed
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift`
around lines 162 - 179, The view computes softMaxSend but never applies it
before notifying Rust; fix by clamping user-entered amounts to softMaxSend
before dispatching to notifyCoinControlEnteredAmountChanged (and/or when
committing on focus loss) instead of altering the live TextField while typing.
Locate references to softMaxSend, notifyCoinControlEnteredAmountChanged,
manager.amount, customAmount, isFocused and amountToDouble: on focus-loss
handler (the .onChange for isFocused) and in the confirm/send action that calls
notifyCoinControlEnteredAmountChanged, coerce the value with min(customAmount,
softMaxSend) (convert units using amountToDouble / selectedUnit or
manager.amount helpers) and then send the clamped value; keep the per-keystroke
handlers unchanged to avoid mid-edit rewrites so typing remains smooth.
🧹 Nitpick comments (1)
ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift (1)

44-47: softMaxSend appears unused after slider removal — remove dead code.

The doc comment explicitly describes a slider-selection constraint ("the next biggest amount below maxSend that can be selected"), and the property is no longer referenced anywhere in the file now that the slider is gone. Leaving it (and the dependency on maxSendMinusFeesAndSmallUtxo) increases surface area and may also be tripping the CI warnings/lints @praveenperera flagged.

♻️ Proposed cleanup
-    /// softMaxSend is the next biggest amount below maxSend that can be selected
-    /// any amount between softMaxSend and maxSend can NOT be selected, because that would create a dust UTXO
-    private var softMaxSend: Double {
-        let amount = manager.rust.maxSendMinusFeesAndSmallUtxo() ?? minSendAmount
-        return amountToDouble(amount)
-    }
-
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift`
around lines 44 - 47, Remove the now-unused softMaxSend computed property and
its internal call to manager.rust.maxSendMinusFeesAndSmallUtxo() (and any
reliance on amountToDouble/minSendAmount only used by that property) from
SendFlowUtxoCustomAmountSheetView, since the slider was removed and softMaxSend
is no longer referenced; delete the softMaxSend declaration and any imports or
unused helpers that exist solely to support it to eliminate dead code and
related lint/CI warnings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift`:
- Around line 28-32: Remove the dead computed properties `divider` and
`softMaxSend` from the SendFlowUtxoCustomAmountSheetView type: delete the
`private var divider: some View { Divider() ... }` block and the `private var
softMaxSend: Decimal { ... }` block (and any adjacent blank lines), then run a
build to ensure nothing references them; if any references remain, replace them
with the inline `Divider()` or the appropriate value logic where used.
- Around line 162-179: The view computes softMaxSend but never applies it before
notifying Rust; fix by clamping user-entered amounts to softMaxSend before
dispatching to notifyCoinControlEnteredAmountChanged (and/or when committing on
focus loss) instead of altering the live TextField while typing. Locate
references to softMaxSend, notifyCoinControlEnteredAmountChanged,
manager.amount, customAmount, isFocused and amountToDouble: on focus-loss
handler (the .onChange for isFocused) and in the confirm/send action that calls
notifyCoinControlEnteredAmountChanged, coerce the value with min(customAmount,
softMaxSend) (convert units using amountToDouble / selectedUnit or
manager.amount helpers) and then send the clamped value; keep the per-keystroke
handlers unchanged to avoid mid-edit rewrites so typing remains smooth.

---

Nitpick comments:
In `@ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift`:
- Around line 44-47: Remove the now-unused softMaxSend computed property and its
internal call to manager.rust.maxSendMinusFeesAndSmallUtxo() (and any reliance
on amountToDouble/minSendAmount only used by that property) from
SendFlowUtxoCustomAmountSheetView, since the slider was removed and softMaxSend
is no longer referenced; delete the softMaxSend declaration and any imports or
unused helpers that exist solely to support it to eliminate dead code and
related lint/CI warnings.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d841c0dc-167b-4621-b6b2-4f157b40db7c

📥 Commits

Reviewing files that changed from the base of the PR and between e79828f and 15de688.

📒 Files selected for processing (1)
  • ios/Cove/Flows/SendFlow/Common/SendFlowUtxoCustomAmountSheetView.swift

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.

Remove slider on Manage UTXO flow

3 participants