Repository navigation
fix(documents): drop fetched state from a previous contract or type - #1155
Conversation
The document action screen kept the fetched document, its field values and the fetched price after the user picked another contract or document type, so Replace or Purchase could submit them with the new selection. A fetch still running when the selection changed also filled in the form when it finished, and its error still raised a banner. Fetches now dispatch through a PendingRequest, and only the outstanding fetch's Documents result or error reaches the form. A contract or document-type change clears every fetched value and abandons the pending fetch. An identity change also abandons the pending fetch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…pped Abandoning a pending fetch dismissed the progress banner even when a broadcast had started since then and owned it. The banner is now taken only while the screen still shows the fetch. Tests now drive the document-type chooser and the identity selector, so dropping either call that abandons the fetch fails a test. They also check that a running broadcast survives a selection change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 46 minutes. View limit details
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Fetch state and selection lifecycle src/ui/contracts_documents/document_action_screen.rs, src/ui/mod.rs |
The screen tracks a pending fetch. Contract, document-type, and identity changes abandon pending fetches and clear selection-dependent data. Network switches reset the screen with the new context. |
Tracked fetch dispatch and broadcast gating src/ui/contracts_documents/document_action_screen.rs |
Delete, Purchase, and Replace fetches use shared tracked dispatch. Fetch controls are disabled during broadcasts, and pending fetches block broadcasts. Tests cover the button and broadcast behavior. |
Fetch completion and validation src/ui/contracts_documents/document_action_screen.rs |
The screen ignores uncorrelated or stale results and suppresses errors from abandoned fetches. Tests cover current and stale results and errors. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix
Possibly related PRs
- dashpay/dash-evo-tool#1117: Changes the same contract and document-type selection path in
DocumentActionScreen.
Suggested reviewers: pauldelucia, lklimek
Merge Risk: 
Minimal · previous review 0eb19
-
No actionable merge-blocking risk remains from the reviewed document-action changes.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 18 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- 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.
Comment @coderabbitai help to get the list of available commands.
|
✅ Final review complete — no blockers (commit 62ea078) · triage: normal · Phase 2 only (no Phase 1 for this repository) |
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 2 only (no Phase 1 for this repository)
The PR correctly correlates document fetches and clears stale selection state, and the CI checks covering the change passed. One blocking concurrency defect remains: a pending fetch can still overwrite an in-flight or completed Delete broadcast, clearing its banner/status and potentially enabling a duplicate action.
🔴 1 blocking
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:
normalbygpt-6.1-sol(effort low) — This is a contained but substantial UI state-management change involving asynchronous request correlation, stale-result suppression, selection invalidation, and regression tests, but it does not modify a critical surface such as funds movement, cryptography, consensus, or storage migrations. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-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/ui/contracts_documents/document_action_screen.rs`:
- [BLOCKING] src/ui/contracts_documents/document_action_screen.rs:1797-1802: Do not let a pending fetch overwrite an in-flight or completed broadcast
The Delete form can dispatch Fetch Owned Documents and still allow Delete because its `can_broadcast()` branch only checks whether `document_id_input` is non-empty; it does not reject `BroadcastStatus::Fetching` or account for an outstanding `pending_fetch`. If Delete starts while that fetch is pending, the fetch result settles here and `display_task_result()` clears the `Broadcasting...` banner and changes the status to `Fetched`. If the Delete result arrives first, a late fetch result changes `Broadcasted` back to `Fetched`. Either ordering loses the broadcast progress/success state and can expose the broadcast button again, allowing a duplicate deletion. Disable broadcast controls while a fetch is pending, clear or abandon the pending fetch when a broadcast starts, and ignore any fetch result once a broadcast owns the form.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Delete, Set Price and Transfer could be sent during a fetch, whose result then cleared the broadcast's progress or replaced its success. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fetch started during a broadcast could clear its progress banner or replace its success when the fetch result arrived. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fetch or broadcast still awaited from the previous network kept the form's fetch or send controls disabled, and its selections stayed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
The request correlation and contract/document-type reset logic is sound, and the previously reported fetch-versus-broadcast overwrite race is fixed. Two blocking races remain: a broadcast can be submitted repeatedly while the first one is still running, and changing the document ID can leave stale fetched data or price eligible for a different document. Test Suite is still in progress and Clippy is queued.
🔴 2 blocking
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); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — This is a substantial but contained UI state-management change involving asynchronous request correlation, result/error gating, selection invalidation, and regression tests, without modifying a critical surface such as funds movement, cryptography, consensus, or storage. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-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/ui/contracts_documents/document_action_screen.rs`:
- [BLOCKING] src/ui/contracts_documents/document_action_screen.rs:1701-1705: Do not allow a second broadcast while one is already running
`can_broadcast()` rejects an outstanding fetch but does not reject `BroadcastStatus::Broadcasting`. After the first click changes the status to `Broadcasting`, the button remains active and the Create, Delete, Set Price, and Transfer branches still satisfy their input checks. A second click can therefore dispatch another paid document transition before the first result arrives. Include the broadcasting state in this guard so every document action is disabled until the in-flight broadcast settles.
- [BLOCKING] src/ui/contracts_documents/document_action_screen.rs:248-251: Invalidate fetched state when the document ID changes or a new fetch begins
`dispatch_fetch()` replaces the pending request and sets the status to `Fetching`, but it leaves `original_doc`, `fetched_price`, and other document-derived state untouched. The document ID input is editable without invalidating that state. For Purchase, changing from document A to document B can leave A's price available for purchasing B; after a failed fetch for B, the status becomes `NotBroadcasted` and the stale price still passes `can_broadcast()`. For Replace, `create_replace_task()` uses `original_doc` rather than the edited document ID, so the form can display B while submitting a replacement for the previously fetched A. Clear document-derived state whenever the ID changes and when a replacement fetch starts, or track the queried ID and require it to match the current input before broadcasting.
…ent shown A document action could be sent again while the first was still being broadcast, paying for it twice. The send button is now disabled and the action refused until the running broadcast settles. Editing the document ID kept the document fetched for the old ID, so Purchase could buy the new ID at the old price and Replace could rewrite the old document while the form showed the new ID. Editing the ID or starting a new fetch now drops the fetched document, its price and the fields filled in from it, and stops waiting on a fetch for the old ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Waiting for bot review — coderabbitai not yet · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
Another task's error or message, such as a background scheduled-vote sweep failure, reset the document action screen to NotBroadcasted while its paid broadcast was still running, re-enabling the send button. The broadcast is now dispatched under its own context (PendingRequest), and only that dispatch's result or error ends Broadcasting and clears its progress banner. The screen no longer changes state in display_message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Waiting for bot review — coderabbitai skipped after its own rate limit · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
The current head correctly correlates document fetches and broadcasts with their originating dispatches, invalidates fetched state when the contract, document type, or fetched document ID changes, and resets network-bound state. The code and supplied CI evidence show no in-scope defects; Clippy and the Test Suite passed, while only the non-code PR Hygiene check remains pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
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); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — This is a substantial but contained UI state-management change involving asynchronous request correlation, result and error gating, selection invalidation, and tests, but it does not modify a critical surface such as funds movement, cryptography, consensus, or storage. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
Ready for review — files with no dedicated owner: lklimek. |
|
Policy satisfied — this can merge. |
TL;DR: Document actions (Replace, Purchase, Delete, Create) no longer keep a document, price, or field values fetched for one contract or document type after you pick another, and a slow fetch from an earlier pick no longer fills in the form.
User story
DOC-006 / DOC-009 (Replace a document; Purchase a document): as a developer, I want the document action form to show and send only what belongs to the contract and document type I have selected, so I never replace or buy the wrong document by mistake.
Scenario
Base flow
Open Contracts → Replace Document (or Purchase Document). Pick contract A and a document type, enter a document ID, and click Fetch (or Fetch Document Price). Then pick contract B or another document type.
Actual behavior
Expected behavior
Detailed discussion
What was done
All changes are in
src/ui/contracts_documents/document_action_screen.rs:dispatch_fetch(), which tracks the request in aPendingRequest(ui/state/pending_request.rs, the same patternViewTokenClaimsScreenuses). Each dispatch gets its ownBackendTaskContext::Dispatchedid, so two identical queries can still be told apart.display_backend_task_resultapplies aDocumentsresult only when it settles the pending fetch; anything else is ignored. Non-fetch results (broadcast outcomes) pass through as before.should_suppress_backend_task_errorhides errors from a dispatched document fetch the screen no longer waits on.display_backend_task_errorends the wait for the current fetch.clear_selection_state()abandons the pending fetch and clearsoriginal_doc,field_inputs,fetched_price,fetched_documents, andno_documents_found. It also resets aFetching/Fetchedstatus. Before this PR, onlyfetched_documentsandno_documents_foundwere cleared.field_inputsis shared by Create and Replace, so Create also starts with empty fields after you pick another document type or contract. Those fields belonged to the old type's schema.Fetching. A broadcast started meanwhile keepsBroadcastingand its "Broadcasting..." banner.Found by thepastaclaw while reviewing #1126. That code predates #1126, so the fix goes in its own PR against
v1.0-dev.Testing
ui::contracts_documents::document_action_screen::tests:a_selection_change_discards_fetched_state: a fetched price, document, fields and owned-documents list are cleared, and Purchase can no longer be sent.an_uncorrelated_fetch_result_is_ignored: aDocumentsresult the screen did not request leaves the form untouched.a_late_fetch_result_for_an_old_selection_is_ignored: fetch, change the selection, fetch again; the first fetch's result is dropped and the second one's price is applied.only_the_current_fetch_error_reaches_the_banner: the abandoned fetch's error is suppressed, and the current fetch's error is shown and ends the wait.a_selection_change_leaves_a_running_broadcast_alone: with a fetch pending and a broadcast running, a selection change keepsBroadcastingand the progress banner.egui_kittest:picking_another_document_type_abandons_the_fetch: open the Doc Type combo, pickpreorderinstead ofdomain; the fetch is abandoned and the fetched document and fields are gone.picking_another_identity_abandons_the_fetch: pick the other identity in the selector; the fetch is abandoned.clear_selection_state()in the chooser, orabandon_pending_fetch()in the identity branch) is removed.kittest contract_screenpass.cargo clippy --all-features --lib --tests -- -D warningsclean;cargo fmt --all.Prior work
ViewTokenClaimsScreenalready correlates document fetches withPendingRequest; this screen now follows the same pattern.🤖 Generated with Claude Code
https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
PR Hygiene ·
62ea078src/ui/contracts_documents/document_action_screen.rs,src/ui/mod.rs) — approved by lklimekWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit