Skip to content

refactor(app): separate task routing, domain state, and shutdown responsibilities - #1100

Merged
lklimek merged 82 commits into
v1.0-devfrom
refactor/app-responsibilities
Oct 28, 2026
Merged

lklimek merged 82 commits into
v1.0-devfrom
refactor/app-responsibilities

Conversation

@lklimek

@lklimek lklimek commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: Keep background results attached to the correct screen and refresh cached data without resetting forms, while separating application coordination from screen-specific behavior.

User story

As a user, I want background work to finish without changing an unrelated form, so I can continue working while data refreshes.

Scenario

Base flow

Start a token purchase, close its form, and open another purchase form. Separately, run a document query while balances refresh in the background.

Actual behavior

The earlier purchase can complete the new form. A background balance refresh can reset the document query.

Expected behavior

Each operation updates its original screen if it remains open and the network has not changed since it started. Background refreshes update relevant cached data without resetting unrelated forms or pending queries.

Detailed discussion

What was done

  • Unify single and batch dispatch with per-request ownership and terminal outcomes for panics, aborted sequential items, stopped workers, and shutdown admission failures.
  • Move the shared task event protocol into backend_task; scope cache notifications by network and domain.
  • Move result acceptance and feedback rules into their owning UI domains; retain generic result delivery in app/result_delivery.rs.
  • Encapsulate DPNS timers, guards, and recovery state in app/dpns_background.rs; co-locate reconciler policy and tests.
  • Share shutdown setup and teardown through app/shutdown.rs, retaining secret clearing and timeout behavior.
  • Record the network each request was dispatched on. A result that arrives after a switch to another network reaches none of the new network's screens. The root screen that sent it stops waiting, and banners still report the outcome. This also covers the Token Creator: a registration sent before a switch can neither complete nor fail a registration started on the new network. A late failure is reported only by a banner, as for a closed form.
  • Contact details (feat(identity): show contact details and a private note in the hub's Contacts tab #1096) use the same dispatch:
    • AppAction::BackendTasksWithContexts runs a screen's batch under the contexts the screen chose and records that screen as the owner. The Contacts tab's contact-list and request-list loads are both the hub's own dispatches.
    • A contact details write that stops without an outcome (panic, stopped worker or shutdown) reports DashPayContactInfoActionFailed with its owner and contact, so the hub can release that write.
    • The hub's writes are owned dispatches, so their results and errors reach the hub even while it is hidden, with no hub-specific routing in AppState. Another screen's successful write reaches a hidden hub as an observed result, so the hub retires its older confirmed note and reloads.

Testing

  • cargo fmt --all -- --check is clean.
  • cargo clippy --all-features --all-targets -- -D warnings: passed.
  • cargo test --all-features --lib -- app:: request_routing task_dispatch contacts:: hub_screen: 180 passed. cargo test --all-features --lib -- app:: request_routing task_dispatch tokens_screen: 133 passed.
  • cargo test --all-features --test kittest -- identity_hub request_routing:: identity_home: 115 passed, including feat(identity): show contact details and a private note in the hub's Contacts tab #1096's contact details tests.
  • The full UI test binary (511 tests) was last run on an earlier head. One existing assertion there expected a network switch to forget request owners; it now checks the new behaviour.
  • Regression tests that fail without their fix:
    • token_balance_refresh_settles_on_its_dispatched_result and failed_restore_from_previous_version_frees_its_button cover task contexts wrapped by the unified dispatch, which My Tokens and Settings had not matched.
    • a_result_sent_before_a_network_switch_stays_off_the_new_network covers a late document page after a network switch.
    • a_registration_result_from_the_previous_network_leaves_the_token_creator_alone covers a late registration success and a late failure while the Token Creator registers on the new network. Both cases fail when previous-network results go to the visible screen.
    • a_foreign_same_contact_save_behind_another_screen_retires_the_hubs_note covers another screen's write reaching a hidden hub through AppState.
    • hydration_dispatches_both_loads_in_one_action checks that both Contacts tab loads are the hub's own dispatches.
  • contact_info_failures_keep_the_dispatched_owner_and_contact checks that a contact details write that stops without an outcome still names its owner and contact: a panic, a skipped batch item, a stopped or cancelled worker, and shutdown.
  • Isolated det-cli smoke checks passed on an earlier head: network-info, tools, tool-describe name=network_info, core-wallets-list.
  • No live GUI or fund-moving tests. CI runs the full workspace validation; this is a draft, so workflows are dispatched manually.

Prior work

Builds on #1091 (merged). Merged with v1.0-dev at ff59f84, including #1099, #1096 and #1119. #1099's batched contact reads and #1096's contact details writes go through the unified per-request dispatch.

🤖 Co-authored by Claudius the Magnificent AI Agent

🤖 Generated with Claude Code

https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q

PR Hygiene · f8b40ff

  • Bots — coderabbitai skipped by lklimek · thepastaclaw skipped by lklimek
  • Self-review — posted; again after any push
  • Build green
  • Approvals — you own every area touched; none needed

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

lklimek and others added 30 commits October 12, 2026 12:26
Show published avatars, compact username controls, responsive Home cards, and Profile navigation. Reuse the wallet send form with fixed identity parties and owned-wallet withdrawal destinations.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Codex GPT-6 <noreply@openai.com>
Keep contacts at the top of the right column beside quick actions. Place
left-aligned username cards with setup and payment history, using A05
column proportions and stacked cards in narrow windows.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Codex GPT-6 <noreply@openai.com>
Preserve the development-branch update alongside the Home layout fix.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Codex GPT-6 <noreply@openai.com>
SDK responses include recipient addresses. Only update balances for
Platform addresses registered to the selected wallet, preventing unrelated
wallets from offering foreign funds for identity top-ups or transfers.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Codex GPT-6 <noreply@openai.com>
…idle

The offline profile-cache test intentionally leaves the avatar request
pending. Render bounded frames while checking the pending fetch and
preserving assertions for cached, saved, and absent profile data.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Codex GPT-6 <noreply@openai.com>
Conflict in src/ui/identity/settings.rs: both sides added methods to
SettingsTab at the same place. Kept both (focus_section from this branch,
usernames_card_mut and accepts_legacy_recovery_result from #1076) and this
branch's doc comment on render.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
IDH-004 still described a `Set up your social profile` checklist entry
with its own skip affordance. Home renders an optional `Set a display
name` step, and the only dismiss control, `Hide this for now`, hides the
whole checklist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
…owns

The only Move to wallet test ran against a context without wallets and
asserted that an external address is refused, so it would also pass if the
ownership check refused every address.

Register a wallet, take one of its receiving addresses, and drive the
production validation and confirmation: the dispatched withdrawal must carry
the bound identity, that address and the entered amount. An external address
is still refused, and the owned address is refused once its wallet is removed.
Nothing is broadcast.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
Every frame of an identity-bound send form restored the binding, which
allocated a new box and cloned the identity twice for Send and Move to
wallet, and looked up the username again for Top up, even when nothing had
changed.

The check `validated_send_route` already made is now a shared predicate, and
the per-frame call restores only when that predicate fails. Construction,
reset and refresh still restore unconditionally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
Home tracked which request its payment preview answered, but not which
identity the rows belonged to. The selected identity can change without the
hub hearing of it, for example when another screen's identity selector is
used and that screen is closed without a refresh. Home then showed the new
identity above the previous identity's payments, and the load guard kept the
new identity's history from being requested.

Home state now records its owner and reconciles it before rendering: content
of another identity is dropped and its pending request forgotten, so a late
answer is discarded and the new history loads. A refresh for the same
identity keeps the preview on screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
…llet

Move to wallet opens the shared send form, whose Max for an identity sender
always kept back the fee of a transfer between identities. A withdrawal to a
Core address costs far more, so Max offered an amount the network refused,
and the form only compared the amount with the balance.

The reserve now follows the destination: a Core address keeps back the
withdrawal estimate, every other destination keeps what it kept before. Max
and send validation read the same value, and a withdrawal that would leave
too little for the fee is refused before the confirmation, naming the highest
amount that works.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
…s app

Send from Identity Home dispatched its transfers without a signing key. The
backend passed that on, and the SDK then takes the identity's first TRANSFER
key, including a disabled one, without asking whether the local signer holds
it. An identity with an earlier disabled key, or one imported with only a
later key, could not send.

Transfers to an identity and to Platform addresses now resolve the key before
any network call: an active TRANSFER key the signer can use, lowest id first.
An explicitly requested key that is unusable is refused rather than replaced,
and a missing key is reported as its own error. The send form resolves the
same key, passes it along, and refuses before the confirmation when there is
none. This also covers the MCP transfer tools, which dispatch without a key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
…registration

The fixture wired the wallet backend before registering its wallet, which
starts a background registration next to the awaited one, and then polled
for the addresses. Registering the wallet first leaves the awaited calls as
the only registration, so the owned address is available as soon as they
return and the wait is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
Home and the Contacts tab share one ContactsState, and the hub reset it only
for identity changes it made itself. Selecting another identity on a screen
opened from the hub (Add contact, then Cancel) left the previous identity's
contacts and requests on screen under the new identity, with the load slot
still claimed, so the new identity's lists never loaded and Accept paired the
new identity with the old identity's request.

ContactsState now records the identity its lists belong to. Home and the
Contacts tab bind it before reading or loading: on a change the lists are
dropped and the load re-armed. Paid-action guards are keyed by request and
survive the change, so a request both identities can see stays guarded while
its action is still running.

The Home payments test no longer depends on which frame its load goes out
in: the contact load now takes the first frame after such a change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…latform address

The shared send form reserved the identity-to-identity transfer fee for a
Platform address destination, while the task it dispatches estimates the
larger transfer-to-addresses fee, and it accepted any amount up to the full
balance. The transfer screen it replaced used the transfer-to-addresses
estimate for Max, the fee shown and an amount-plus-fee check.

Max, the fee preview and the confirmation text now read one reserve that
uses the existing transfer-to-addresses estimate for this route, and an
amount that leaves less than that fee in the identity is refused before the
confirmation, with the highest amount that works.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… took

The hub replaces the tab's action with the header's when both produce one
in the same frame. A tab that returned its contact or payment-history load
on that frame had already claimed the load's one dispatch slot, so the load
never ran, and cancelling the screen the header opened returns to the hub
without refreshing it.

Home and the Contacts tab now take a `may_load` flag. The hub clears it on a
frame where the header returned an action, so the slot stays free and the
load goes out on the next frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er screen

Home asks for its payment history once per arrival and accepts only the
answer to that request. An answer that arrived while Send or Top up covered
the hub went to the covering screen, which ignores it; Cancel returns
without refreshing, so the preview stayed empty or stale until an explicit
refresh.

The app now forwards a payment history result to the hidden hub as it does
for profile results. The hub still records only the answer to its own
request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The existing tests call the key resolver directly, so they would still pass
if a transfer task stopped calling it. This one dispatches both transfer
tasks through `run_identity_task` against a mock SDK, with no usable key and
with an explicitly requested unusable one, and expects the dedicated error:
a task that got past the resolver would fail on the mock instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the list

The preview took six entries from a vector of every matching contact, built
again on each frame. `ContactsState` now offers the matches as an iterator,
which the preview bounds before reading; the Contacts tab keeps the
collected list where it needs the count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hub asks for its contacts and contact requests once per arrival, and
Home now shows them. Answers that arrived while Send or Top up covered the
hub went to the covering screen, which ignores them; Cancel returns without
refreshing, so Home's contact preview stayed empty until an explicit
refresh.

The app now forwards both results to the hidden hub, next to the payment
history. The hub keeps dropping lists loaded for an identity other than the
one it shows, which the new test covers with a result for another identity.
The payment history test shares the new helper that covers the hub with the
Send screen and cancels back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in #1077, #1078 and #1079. No conflicts: docs/user-stories.md and
src/ui/identity/settings.rs merged automatically.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012YneRVSNLhVnGiedWDr3fw
Home's Top up now opens the shared send form, which numbered a wallet-funded
top-up by the count of stored top-ups. A stored history can have gaps, so
with entries 0 and 2 the form chose 2 and the finished top-up replaced that
entry in the identity's stored history; every later one did the same. The
screen it replaced used the highest stored index plus one.

`QualifiedIdentity::next_top_up_index` is now the one place that chooses the
index: one past the highest stored, or the lowest free one when the highest
possible index is taken, so it can neither overflow nor reuse an entry. The
shared send form and the older top-up screen both use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The identity top-up tool numbered a top-up by the count of stored top-ups,
so a history with a gap had an entry replaced, as in the shared send form.
It now uses `QualifiedIdentity::next_top_up_index`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…decided

A hub frame merges actions from the top bar, the sidebar, the header, the
tab, the breadcrumb and a confirmation dialog, and the last non-empty one
wins. The tabs returned their data loads from rendering, claiming the load's
one dispatch slot on the spot. A load could then replace a sidebar or top
bar click made on the same frame, and a breadcrumb entry applied after the
tab could replace a load whose slot was already claimed, so it never ran.
The earlier header-only flag covered one of those sources.

Home and the Contacts tab no longer load while rendering. The hub asks the
rendered tab for its due load at the end of the frame, only when nothing
produced an action, and nothing after that point replaces an action. So a
click anywhere keeps its frame and a claimed load is always the action
returned. The load binds the lists to the selected identity first, so an
identity chosen in the breadcrumb is loaded once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on this device

The transfer key resolver took any stored key entry for a usable key. An
entry that only refers to a wallet needs that wallet on this device: without
it an earlier such key was chosen over a later key whose material is here,
and an identity with only such a key reached the confirmation, to fail when
the transfer was signed.

The resolver now asks whether the private half can be obtained. The rule is
the one username registration already uses; it moves to `QualifiedIdentity`
so both read it from one place. A locked wallet still counts, as the app asks
for its password when it signs. `can_sign_with` is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The app hands every failure to the visible screen as a message without a
task context, and Wallet Send took any of them for the failure of its own
send: it left the waiting state and showed the filled form again while the
payment was still running, so the user could confirm it a second time. Home
starts loads of its own right before Send or Top up opens, which makes such
a failure likely.

A confirmed send now goes out under a dispatch context of its own and the
screen remembers it. While it waits, only a failure carrying that context
ends the wait; other failures are still reported by the banner. The send no
longer joins a task batch, which cannot carry a context: an asset-lock
maximum lookup due in the same frame is asked for on the next one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… form runs

Home's Top up opens the shared send form, which remembered a running top-up
only on the screen. Leaving the waiting form by its breadcrumb destroyed that
record, so a reopened form offered the same identity another top-up while the
first still ran: funds would leave twice, and both could be recorded under
one index.

The form now records its top-ups in the registry Add Funds keeps outside any
screen, and refuses a top-up of an identity that has one in flight. The app
releases the entry on that top-up's own result, as it does for Add Funds, and
hands the result to the form that waits on it. Either screen holds back while
the other's top-up runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Wallet Send tests entered the waiting state through a hook that took a
hand-made context, which no dispatch ever produced. They now go through
`dispatch_send`, the path a confirmed send takes, so the screen waits on a
dispatch of its own and the tests keep holding when the screen relies on it.
The unused hook is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…acy encrypted format

Early versions kept a private key in a per-key encrypted format. This version
stores such an entry but cannot open it, with or without a password, yet the
transfer key resolver counted it as usable: an earlier such key was chosen
over a later key that can sign, and an identity with only such a key reached
the confirmation, to fail when the transfer was signed.

The shared rule now says such a key cannot be obtained. A key in the vault and
a key also held in a readable way stay eligible. Username registration keeps
reporting such a key as ready, as before: it needs a status and guidance of
its own first, and the note saying so moves to where that decision is made.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lklimek and others added 3 commits October 27, 2026 17:42
BackendTaskPanicked keeps the payload out of the error, whose Debug reaches
the banner's details panel. The process-wide panic hook in logging.rs still
logs it, as it does for every panic. The doc now says so, and asks that
panic messages never contain secrets, instead of implying that the payload
is never retained anywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
After a network switch, end_previous_network_request ends the previous
network's contest refresh with NetworkSwitchedBeforeResult. The voting
panel's display_backend_task_error matched any contest-refresh context,
so that ending also stopped the panel's own refresh on the new network:
the progress banner was dismissed and Refresh came back while the new
refresh was still running.

The panel now sends its refresh through a PendingRequest, and a failure
ends the panel's refresh only when the panel owns that context. Switching
networks, or the refresh's own "contests refreshed" result, clears the
slot. The refresh start moves into start_contest_refresh, which the
Refresh path and a testing seam share.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
… network's refresh

The regression test for a previous network's contest refresh ending
checked only the panel's refresh status. The bug it guards against also
dismissed the progress banner, and a regression that kept the status but
dropped the banner would have passed. The test now asserts that the banner
survives the old refresh's end and goes away with the new refresh's own
failure. A mutation that clears the banner on any contest-refresh failure
fails the new assertion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
@Claudius-Maginificent

Copy link
Copy Markdown
Collaborator

Re: Keep scheduled-vote errors off the new network after a switch (src/app.rs:2639-2653). Fixed in edbc547. Good catch.

  • take_result_route now reads the network straight out of the undispatched ScheduledVoteSweep { network } context (BackendTaskContext::scheduled_vote_sweep_network). When that network isn't the active one, it returns ResultRoute::PreviousNetwork(None); the variant now holds Option<ScreenOwner>, and None means a task the app started itself.
  • The sweep error arm no longer calls visible_screen_mut() directly. display_backend_task_error, display_task_error and display_message all go through result_screen_mut(route), which gives no screen for PreviousNetwork. sweep_failed still releases that network's scheduler guard, and the banner still reports the failure. The ScheduledVoteSweepCompleted arm already delivers via deliver_result(route), so the fix covers it too, and record_vote_result still clears the guard unconditionally.
  • Regression test: a_scheduled_vote_sweep_from_the_previous_network_stays_off_the_new_network (tests/kittest/request_routing.rs). The Token Creator, in view on the new network, keeps its registration progress banner through both a late sweep failure and a late sweep completion, and only the failure raises a banner. Before the fix, the failure case failed: the visible screen's display_message(Error) cleared the banner.

The other undispatched voting task, DpnsBackgroundRefresh { network }, needs no route change: none of its terminal results reach a screen. The final success is BackendTaskSuccessResult::None (src/backend_task/contested_names/mod.rs:248-251), which hits the no-op None => {} arm. The error has its own arm, which only logs and records the refresh completion (src/app.rs:2627-2635). The mid-task RefreshedDpnsContests it sends carries no context (TaskResult::unattributed_success), so it is the same documented limitation as the Progress thread on src/backend_task/events.rs. It is fixed in #1156, stacked on #1100. While tracing it, I found that the old network's final refresh result also cleared the new network's refresh in the voting panel. That is fixed here in 6d2cefd: the panel now tracks its own dispatch.

🤖 Co-authored by Claudius the Magnificent AI Agent

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw requested changes — dismiss the review or push a fix. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@Claudius-Maginificent

Copy link
Copy Markdown
Collaborator

Re: Prevent previous-network settings results from mutating the active chooser (src/app.rs:2417-2452). Declining this one. These three results aren't stale on the new network, and holding them back would break the chooser.

  • UpdatedBackupRetention: the policy is app-wide. It's read and written under DetScope::Global (src/context/settings_db.rs:234-246), so the policy a save on the old network applied is the same policy in force on the new one. The chooser has to hear about it. By the time the success arrives, end_previous_network_request (src/app/result_delivery.rs:162) has already given the chooser NetworkSwitchedBeforeResult, which runs save_failed() → revert() and puts the form back on the previously saved policy. Dropping the success would leave the form showing the old policy while the new one is persisted.
  • NetworkDatabaseCleared / PreviousVersionRestored: here the chooser only sets db_clear_in_progress / legacy_restore_in_progress to false (src/ui/network_chooser_screen.rs:1782-1806). end_previous_network_request has already done that for the same dispatch, and before it arrives, the old request's flag keeps the button disabled, so no new request on the new network can be running and get clobbered. The refresh() call is the ScreenLike default no-op (src/ui/mod.rs:873). The chooser has no override. A database clear can't overlap a switch: the network selector is disabled while one runs (src/ui/network_chooser_screen.rs:217). A legacy restore can overlap one, but end_previous_network_request clears its flag for the old dispatch, so the late result changes nothing.
  • Error path (chooser_owned): display_backend_task_error drops the same flags, and save_failed() is correct for a global save that really failed. The global banner still reports the outcome, as you suggested.

The chooser is the one root screen that isn't scoped to a network. It shows and manages every network, so these settings results really are its business on any network.

🤖 Co-authored by Claudius the Magnificent AI Agent

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Oct 27, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

The refactor improves dispatch ownership and network-aware routing for ordinary task results, but network-specific wallet events still arrive without origin metadata and can mutate the active network after a switch. DPNS intermediate events and progress events also discard dispatch ownership, allowing stale or unrelated updates to reach the visible screen. The panic boundary redacts task errors but does not prevent the existing panic hook from logging the original payload; Test Suite and Clippy were still running.

🔴 1 blocking | 🟡 3 suggestion(s)

2 finding(s) not shown inline (the lines are not part of this PR's diff)

🔴 Blocking: Scope wallet-backend events to their originating network
src/app.rs:2541-2545

EventBridge instances belong to individual network contexts, but PlatformAddressSyncPushed is emitted as an unattributed result and this handler applies it to active_context unconditionally. The old network contexts remain alive after a switch, so a late address-sync event from the previous network can overwrite the active network's address balance and nonce data for matching wallet seeds. The same missing origin boundary affects the nearby PlatformReadyDiscoverIdentities and DashPayIncomingDetected handlers: late events can queue discovery or start contact-payment detection through the new active context. Because these results use BackendTaskContext::Unknown, the request-owner map cannot filter them. Preserve the originating network on wallet-backend events or reject events whose origin does not match the active context before applying these side effects.

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

🟡 Suggestion: Propagate dispatch context through DPNS refresh side events
src/backend_task/contested_names/query_dpns_contested_resources.rs:392-397

The DPNS refresh sends RefreshedDpnsContests with TaskResult::unattributed_success, and child-query failures likewise use unattributed errors. These messages therefore carry BackendTaskContext::Unknown; take_result_route treats them as visible-screen work rather than applying the originating dispatch's network and owner filtering. A late refresh from a previous network can reach the active voting panel, where ContestsRefreshed unconditionally reloads data, clears the progress banner, and settles the current refresh state. A stale child error can also be delivered to whichever form is visible. Propagate the dispatch context through these intermediate events or return the completion through the outer task result. Follow-up PR #1156 tracks this context propagation, but the current head still has the race.

source: gpt-6.1-sol (phase2-reviewer: general, rust-quality)

2 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.1-sol (effort low) — This is a large, intricate refactor spanning application task dispatch, routing, shutdown, background coordination, and many UI domains, but it does not change consensus, funds movement, cryptography, key handling, peer-facing deserialization, or storage migrations.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/app.rs`:
- [BLOCKING] src/app.rs:2541-2545: Scope wallet-backend events to their originating network
  `EventBridge` instances belong to individual network contexts, but `PlatformAddressSyncPushed` is emitted as an unattributed result and this handler applies it to `active_context` unconditionally. The old network contexts remain alive after a switch, so a late address-sync event from the previous network can overwrite the active network's address balance and nonce data for matching wallet seeds. The same missing origin boundary affects the nearby `PlatformReadyDiscoverIdentities` and `DashPayIncomingDetected` handlers: late events can queue discovery or start contact-payment detection through the new active context. Because these results use `BackendTaskContext::Unknown`, the request-owner map cannot filter them. Preserve the originating network on wallet-backend events or reject events whose origin does not match the active context before applying these side effects.

In `src/backend_task/contested_names/query_dpns_contested_resources.rs`:
- [SUGGESTION] src/backend_task/contested_names/query_dpns_contested_resources.rs:392-397: Propagate dispatch context through DPNS refresh side events
  The DPNS refresh sends `RefreshedDpnsContests` with `TaskResult::unattributed_success`, and child-query failures likewise use unattributed errors. These messages therefore carry `BackendTaskContext::Unknown`; `take_result_route` treats them as visible-screen work rather than applying the originating dispatch's network and owner filtering. A late refresh from a previous network can reach the active voting panel, where `ContestsRefreshed` unconditionally reloads data, clears the progress banner, and settles the current refresh state. A stale child error can also be delivered to whichever form is visible. Propagate the dispatch context through these intermediate events or return the completion through the outer task result. Follow-up PR #1156 tracks this context propagation, but the current head still has the race.

In `src/app/task_dispatch.rs`:
- [SUGGESTION] src/app/task_dispatch.rs:45-49: Avoid leaking panic payloads through the panic hook
  (existing thread: https://github.com/dashpay/dash-evo-tool/pull/1100#discussion_r4382199799)
  `catch_unwind()` removes the panic payload from `TaskError::BackendTaskPanicked`, but the process-wide hook runs before the catch boundary receives it. `src/logging.rs:124-145` formats the original payload into the log and then invokes the default hook, so a panic payload containing a credential, key material, or other sensitive value can still be written to application logs despite the redacted task error. Establish a safe panic-reporting policy or audit and constrain backend panic payloads so sensitive state cannot reach the hook.

In `src/backend_task/events.rs`:
- [SUGGESTION] src/backend_task/events.rs:52-56: Attribute progress events to their dispatch owner
  (existing thread: https://github.com/dashpay/dash-evo-tool/pull/1100#discussion_r4365373689)
  `unattributed_success` assigns `BackendTaskContext::Unknown`, and identity discovery still uses it for every `Progress` event. `take_result_route` consequently sends these updates to the visible screen instead of the screen that initiated discovery. If the initiating form is covered or closed while another screen is visible, progress can update the wrong screen or clear unrelated progress state. Carry the originating dispatch context through progress events or add a dedicated owner-aware progress result.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Oct 27, 2026
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai skipped after its own rate limit · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. labels Oct 28, 2026

@lklimek lklimek left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

/self-reviewed

@lklimek
lklimek dismissed thepastaclaw’s stale review October 28, 2026 11:55

All items will be handled in follow-up PRs.

@lklimek

lklimek commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

/skip-bots

@github-actions

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@github-actions github-actions Bot removed the waiting-bots Waiting for the review bots to report on this head label Oct 28, 2026
@lklimek
lklimek enabled auto-merge (squash) October 28, 2026 11:57
@lklimek
lklimek merged commit ad15180 into v1.0-dev Oct 28, 2026
13 checks passed
@lklimek
lklimek deleted the refactor/app-responsibilities branch October 28, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-review-skipped A required review bot did not report; it was skipped by the window or by a person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants