Skip to content

refactor(ui): move transaction details to SwiftUI (MO-1154) - #1490

Open
ross-dash wants to merge 2 commits into
fix/remaining-nav-bar-buttonsfrom
refactor/tx-details-swiftui
Open

ross-dash wants to merge 2 commits into
fix/remaining-nav-bar-buttonsfrom
refactor/tx-details-swiftui

Conversation

@ross-dash

@ross-dash ross-dash commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

First part of MO-1154: the transaction details screen moves to SwiftUI. Stacked on #1478 (it changes the same screen's bar); retarget to develop once that merges.

  • TxDetailViewModel (new) takes the logic out of the controller: building the sections, rebuilding when recovery inputs change, the tax category toggle, retrying a stuck asset lock and removing an unconfirmed transaction — same texts, alerts and logging. HUDs and UIAlertController become published alert / toast / progress state.
  • TxDetailScreen (new) renders the header, cards, contact row, block explorer picker, raw transaction sheet, contact profile, alerts, toasts and the progress overlay. Amounts with the Dash symbol are drawn by a UILabel (SwiftUI Text can't draw an NSTextAttachment).
  • TXDetailViewController is a thin host. Its ObjC name, init(model:), contactReturn, onAccessibilityEscape and SuccessTxDetailViewController stay, so Home, contacts, Receive and the payment success screen are untouched.
  • Deleted: TxDetailCells.swift and 4 cell XIBs.
  • TxDetailRecoveryRowsTests counts rebuilds through the view model instead of a table snapshot.

Difference from before: the fiat amount uses the adaptive secondary text color instead of a fixed gray (0.33) that was hard to read in dark mode.

Screenshots

image image

Test plan

  • dashwallet-dashpay builds
  • TxDetailRecoveryRowsTests + TXDetailAccessibilityEscapeTests (16 tests) pass
  • Received-from-contact and sent details match the old layout
  • Tax category toggles and back
  • Copy Raw Transaction shows the toast; View Transaction opens the sheet
  • Block explorer picker opens Insight in Safari
  • Contact row opens the profile; inside the profile it goes back to it
  • scripts/a11y_audit.py --check passes
  • Success screen after a payment (SuccessTxDetailViewController)
  • Receive receipt (close button as root of a nav stack)
  • Retry stuck asset lock / remove unconfirmed transaction
  • CI unit tests

🤖 Generated with Claude Code

TxDetailViewModel takes the row building and actions from the controller
(recovery rows, tax category, stuck asset lock retry, removing an
unconfirmed transaction) and exposes alerts, toasts and progress as state.
TxDetailScreen renders them with DashUIKit. TXDetailViewController stays a
plain UIViewController for Objective-C and SuccessTxDetailViewController,
hosting the screen. The table cells and their XIBs are deleted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 07d5052b-b5b9-415a-a648-d5521ccf1a14

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@thepastaclaw

thepastaclaw commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

⛔ Final review complete — 2 blocking finding(s) (commit 2d785aa) · triage: normal

…etails

The symbol is a bitmap tinted when the amount string is built, so it could
carry the other theme's colour (almost white in light mode). The label now
re-tints it with the text colour resolved for the current theme, and again
when the theme changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

Changes requested: 2 blockers

  • Closing the Home details sheet during removal can hide required wallet recovery instructions — DashWallet/Sources/UI/Tx/Details/TxDetailViewModel.swift:338-364 (new)
    Impact: A user who closes or swipes down the Home sheet during removal can miss that the transaction was deleted and that they must restart the wallet and manually rescan.
  • Rendering the transaction header can run a synchronous wallet metadata query — DashWallet/Sources/UI/Tx/Details/TxDetailScreen.swift:304-320 (new)
    Impact: Opening a detail whose metadata is not already loaded can make the header render wait on SQLite, and unrelated row updates can make a loaded contact avatar flash back to initials.

PR #1490 moves transaction details to SwiftUI, with a new view model for row construction and recovery actions and a thin UIKit host for existing entry points. Simulator tests, test-target membership, workflow lint, and the accessibility audit passed on the exact reviewed head; the automated review check is pending. The PR’s test plan does not record runtime checks for Receive receipts, payment success, or transaction recovery.

🔴 2 blocking | 🟡 2 suggestion(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The SwiftUI migration substantially changes presentation, navigation, and recovery UI state, but delegates asset-lock retries and unconfirmed-transaction removal to the existing services without changing their wallet logic.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `DashWallet/Sources/UI/Tx/Details/TxDetailViewModel.swift`:
- [BLOCKING] DashWallet/Sources/UI/Tx/Details/TxDetailViewModel.swift:338-364: Closing the Home details sheet during removal can hide required wallet recovery instructions
  Impact: A user who closes or swipes down the Home sheet during removal can miss that the transaction was deleted and that they must restart the wallet and manually rescan.
  If the runtime fails to restart, the user can be left without the two steps needed to recover. After the user confirms removal, the task keeps running independently of the detail, while `progressOverlay` covers only `TxDetailScreen`. Home’s enclosing `TransactionDetailsSheet` still allows Close and swipe dismissal. The remover saves the deletion before attempting the reload, but `.runtimeStopped` is delivered only as an alert on the weakly held detail view model; after dismissal, there is no visible recipient, and restarting alone does not replay the skipped rescan. Have the outer sheet prevent dismissal until the outcome is acknowledged, or deliver actionable outcomes through the surviving parent. Cover dismissal during removal followed by `.runtimeStopped` in a regression check.

In `DashWallet/Sources/UI/Tx/Details/TxDetailScreen.swift`:
- [SUGGESTION] DashWallet/Sources/UI/Tx/Details/TxDetailScreen.swift:100-111: Selecting a block explorer can close the picker without opening Safari
  Impact: If the picker is still dismissing when the 400 ms timer fires, the user can end up back in transaction details with no browser or error.
  The browser request can be lost because the timer is not tied to the dismissal transition. The selection handler clears `showsExplorerPicker`, `BlockExplorerSelectionView` also calls its environment’s `dismiss()`, and `openInBrowser` makes a single UIKit presentation attempt when the timer fires. The previous controller presented Safari from the actual dismissal completion. Give one layer ownership of dismissal, store the selected URL, and consume it in the sheet’s `onDismiss` while the detail is still active. Closing the picker without a selection should leave nothing to open.
- [BLOCKING] DashWallet/Sources/UI/Tx/Details/TxDetailScreen.swift:304-320: Rendering the transaction header can run a synchronous wallet metadata query
  Impact: Opening a detail whose metadata is not already loaded can make the header render wait on SQLite, and unrelated row updates can make a loaded contact avatar flash back to initials.
  The new SwiftUI header reads live wallet data instead of rendering view-model state. `model.fiatAmount` reaches the lazy `Transaction.userInfo`, which calls `TransactionMetadataDAOImpl.get(by:)` and queries SQLite synchronously on a cache miss. The earlier tax-category lookup does not initialize that lazy property or cache a missing row. The header also recomputes the live DASH amount and gets a new identity on every `revision`, so even a tax toggle or fee refresh discards the avatar’s `AsyncImage` state. Publish a header snapshot alongside the rows, keep the header identity stable, and leave font and attachment sizing in the view.
- [SUGGESTION] DashWallet/Sources/UI/Tx/Details/TxDetailScreen.swift:261-269: Repeated copy feedback can disappear early, and unavailable actions show a success icon
  Impact: Users who repeat an action can lose its feedback before reading it, while failed copy or contact actions display a success icon.
  A replacement message can disappear as soon as it appears. When the string changes, SwiftUI cancels the previous `.task(id:)`, but `try?` swallows the cancellation and the old task still clears the shared slot. Repeating the same string does not restart the timer at all. Missing raw bytes and missing contacts also write to the same slot, which always renders `.success`. Reuse the view model’s per-event `Toast` identity with `.copied` for a successful copy and an informational or error style for unavailable data. Return on cancellation and clear only the event the timer was started for.

Comment on lines +338 to +364
private func removeUnconfirmed() {
guard !isBusy else { return }
isBusy = true
let txidWire = model.transaction.txHashData
progressMessage = NSLocalizedString("Removing transaction…", comment: "Remove never-accepted transaction: progress")
Task { [weak self] in
defer {
self?.isBusy = false
self?.progressMessage = nil
}
do {
let outcome = try await UnconfirmedTransactionRemover().remove(txidWire: txidWire)
switch outcome {
case .rescanArmed:
// The row this screen describes no longer exists.
self?.onClose(Toast(style: .success, message: NSLocalizedString("Transaction removed", comment: "Remove never-accepted transaction: success")))
case .rescanUnavailable:
// Never claim the rescan safety net ran when it didn't.
self?.onClose(Toast(style: .info, message: NSLocalizedString("Transaction removed — rescan couldn't start, run Rescan Filters in Core Sync Status", comment: "Remove never-accepted transaction: removed but the recovery rescan did not arm")))
case .runtimeStopped:
// Both steps are named, because restarting the runtime does
// not replay this removal's rescan; the screen closes only
// once the user has read it.
self?.alert = Alert(
title: NSLocalizedString("Transaction removed, but the wallet stopped", comment: "Remove never-accepted transaction: removed but the runtime reload left the wallet stopped"),
message: NSLocalizedString("The transaction was deleted from this device. Reloading the wallet didn't finish, so the wallet is stopped and the rescan that double-checks the blockchain never ran.\n\nRestart the wallet — reopen the app, or tap Sync Now in Sync Info — and then run Rescan Filters in Core Sync Status. Restarting alone does not repeat the rescan.", comment: "Remove never-accepted transaction: both recovery steps after a failed runtime reload"),
onDismiss: { [weak self] in self?.onClose(nil) })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Blocking: Closing the Home details sheet during removal can hide required wallet recovery instructions
Impact: A user who closes or swipes down the Home sheet during removal can miss that the transaction was deleted and that they must restart the wallet and manually rescan.

If the runtime fails to restart, the user can be left without the two steps needed to recover. After the user confirms removal, the task keeps running independently of the detail, while progressOverlay covers only TxDetailScreen. Home’s enclosing TransactionDetailsSheet still allows Close and swipe dismissal. The remover saves the deletion before attempting the reload, but .runtimeStopped is delivered only as an alert on the weakly held detail view model; after dismissal, there is no visible recipient, and restarting alone does not replay the skipped rescan. Have the outer sheet prevent dismissal until the outcome is acknowledged, or deliver actionable outcomes through the surviving parent. Cover dismissal during removal followed by .runtimeStopped in a regression check.

source: gpt-6.2-sol (phase2-reviewer: general)

Comment on lines +100 to +111
.sheet(isPresented: $showsExplorerPicker) {
DashUIKit.BottomSheet(
title: NSLocalizedString("Select block explorer", comment: "Block explorer picker"),
showBackButton: .constant(false)
) {
BlockExplorerSelectionView { explorer in
showsExplorerPicker = false
if let url = viewModel.model.getExplorerURL(explorer: explorer) {
// After the picker has gone: nothing presents over a
// sheet that is still dismissing.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) { openURL(url) }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: Selecting a block explorer can close the picker without opening Safari
Impact: If the picker is still dismissing when the 400 ms timer fires, the user can end up back in transaction details with no browser or error.

The browser request can be lost because the timer is not tied to the dismissal transition. The selection handler clears showsExplorerPicker, BlockExplorerSelectionView also calls its environment’s dismiss(), and openInBrowser makes a single UIKit presentation attempt when the timer fires. The previous controller presented Safari from the actual dismissal completion. Give one layer ownership of dismissal, store the selected URL, and consume it in the sheet’s onDismiss while the detail is still active. Closing the picker without a selection should leave nothing to open.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-sol (phase2-reviewer: general)

Comment on lines +304 to +320
private struct TxDetailHeader: View {
let model: TxDetailModel

var body: some View {
HStack(spacing: 10) {
VStack(alignment: .leading, spacing: 2) {
Text(model.title)
.font(Font(UIFont.dw_font(forTextStyle: .subheadline)).weight(.medium))
.foregroundColor(Color(uiColor: .dw_label()))

AttributedLabel(
text: model.dashAmountString(
with: UIFont.preferredFont(forTextStyle: .largeTitle).withWeight(UIFont.Weight.medium.rawValue)))

Text(model.fiatAmount)
.font(Font(UIFont.dw_font(forTextStyle: .footnote)))
.foregroundColor(Color(uiColor: .dw_secondaryText()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Blocking: Rendering the transaction header can run a synchronous wallet metadata query
Impact: Opening a detail whose metadata is not already loaded can make the header render wait on SQLite, and unrelated row updates can make a loaded contact avatar flash back to initials.

The new SwiftUI header reads live wallet data instead of rendering view-model state. model.fiatAmount reaches the lazy Transaction.userInfo, which calls TransactionMetadataDAOImpl.get(by:) and queries SQLite synchronously on a cache miss. The earlier tax-category lookup does not initialize that lazy property or cache a missing row. The header also recomputes the live DASH amount and gets a new identity on every revision, so even a tax toggle or fee refresh discards the avatar’s AsyncImage state. Publish a header snapshot alongside the rows, keep the header identity stable, and leave font and attachment sizing in the view.

source: gpt-6.2-sol (phase2-reviewer: general)

Comment on lines +261 to +269
} else if let copiedMessage {
DashUIKit.Toast(style: .success, message: copiedMessage)
.padding(.horizontal, 20)
.padding(.bottom, 16)
.transition(.opacity)
.task(id: copiedMessage) {
try? await Task.sleep(nanoseconds: 2_000_000_000)
withAnimation { self.copiedMessage = nil }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: Repeated copy feedback can disappear early, and unavailable actions show a success icon
Impact: Users who repeat an action can lose its feedback before reading it, while failed copy or contact actions display a success icon.

A replacement message can disappear as soon as it appears. When the string changes, SwiftUI cancels the previous .task(id:), but try? swallows the cancellation and the old task still clears the shared slot. Repeating the same string does not restart the timer at all. Missing raw bytes and missing contacts also write to the same slot, which always renders .success. Reuse the view model’s per-event Toast identity with .copied for a successful copy and an informational or error style for unavailable data. Return on cancellation and clear only the event the timer was started for.

source: gpt-6.2-sol (phase2-reviewer: general)

@ross-dash
ross-dash requested a review from romchornyi November 25, 2026 22:43

This branch has not been deployed

No deployments
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.

2 participants