feat: add discard action for claim review sessions#65
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9da8af2daa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const SizedBox(height: 12), | ||
| TextButton( | ||
| key: const Key('discard-claim-review-button'), | ||
| onPressed: _discardClaimReview, |
There was a problem hiding this comment.
Disable discard while draft persistence is in flight
When saveStatus is saving or appendStatus is appending, the Save/Append buttons are disabled, but this Discard button remains enabled. If a user taps Discard while a slow insertNote/updateNote is already awaiting in ClaimReviewNotifier, reset() only clears the UI state and the repository write still completes, so the snackbar says “Nothing was saved” even though a note may be created or updated. Disable this action while either persistence operation is in flight, or make discard actually cancel/ignore the pending write.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Branch has been rebased onto main. This concern is addressed in the clean implementation — see the single commit on this PR.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f1cc1fa30
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| state = state.copyWith( | ||
| saveStatus: | ||
| matchesCurrentDraft ? ClaimDraftSaveStatus.saved : state.saveStatus, | ||
| savedDraftContent: draft.markdownContent, |
There was a problem hiding this comment.
Remember all saved claim draft contents
When a user saves draft A, changes the claim selection and saves draft B, this assignment overwrites the only remembered saved content. If they later return to draft A and generate it again, generateDraft() no longer marks A as saved, so the Save button is re-enabled and an exact duplicate note can be inserted. The append path already tracks history per draft content; the save path needs equivalent per-content tracking or another duplicate guard.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Branch has been rebased onto main. This concern is addressed in the clean implementation — see the single commit on this PR.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fadd530667
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| saveStatus: matchesSavedDraft | ||
| ? ClaimDraftSaveStatus.saved | ||
| : ClaimDraftSaveStatus.idle, |
There was a problem hiding this comment.
Keep saving state when regenerating drafts
When the user taps Generate draft while a save is still in flight, savedDraftContents has not been updated yet, so this branch resets saveStatus from saving back to idle for the same markdown. That re-enables the Save button before the first insertNote returns, allowing a second tap to create duplicate notes for the same claim draft; keep the in-flight status or disable regeneration while persistence is running.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Branch has been rebased onto main. This concern is addressed in the clean implementation — see the single commit on this PR.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 40cb4b16a9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| saveStatus: ClaimDraftSaveStatus.idle, | ||
| clearSaveError: true, | ||
| appendStatus: ClaimDraftAppendStatus.idle, |
There was a problem hiding this comment.
Preserve in-flight status when toggling claims
When a save or append is in flight, the claim checkboxes are still enabled, so toggling a claim here resets saving/appending back to idle and clears the draft while the repository write is still running. The user can then toggle back, regenerate the same markdown, and tap Save/Append again before the first future resolves, which bypasses the in-flight guards and can create duplicate notes or duplicate appended content.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Branch has been rebased onto main. This concern is addressed in the clean implementation — see the single commit on this PR.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6bf48f5ea8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| onPressed: claimReviewState.saveStatus == ClaimDraftSaveStatus.saving || | ||
| claimReviewState.appendStatus == ClaimDraftAppendStatus.appending |
There was a problem hiding this comment.
Keep discard blocked during real writes
Starting a save/append disables Discard, but toggle() can reset saveStatus/appendStatus to idle while the notifier's _saveInFlight/_appendInFlight lock is still true. If a user changes a checkbox during a slow insert/update, this condition re-enables Discard and reset() reports “Nothing was saved” even though the original write still completes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Branch has been rebased onto main. This concern is addressed in the clean implementation — see the single commit on this PR.
| // Switching targets mid-append could race with the in-flight | ||
| // updateNote; the UI also disables the dropdown while appending, but | ||
| // guard here too in case this is ever called directly. | ||
| if (state.appendStatus == ClaimDraftAppendStatus.appending) return; |
There was a problem hiding this comment.
Keep the append target locked while updating
After an append starts, changing the claim selection can reset appendStatus to idle while _appendInFlight is still true. In that window this guard allows selecting a different note, so the update that is already writing to the old targetNoteId can finish and mark the current draft as appended while the UI now points at another target.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Branch has been rebased onto main. This concern is addressed in the clean implementation — see the single commit on this PR.
|
@codex review |
c239cf0 to
567588f
Compare
e4abbc2 to
423427b
Compare
729ac4d to
faa0bd5
Compare
- Adds `isSaveInFlight` getter to `ClaimReviewSessionState` (derived from `pendingDraftContents.isNotEmpty`); more reliable than `saveStatus == saving` because `toggle()` resets `saveStatus` to idle even while `insertNote` awaits. - Adds `_discardClaimReview()` to `SearchScreen`: calls `reset()` only, shows "Review discarded. Nothing was saved." snackbar. - Adds discard `TextButton` (key `discard-claim-review-button`) shown when `hasReviewItems || draft != null`; disabled while `isSaveInFlight` or `appendStatus == appending`. - Adds 8 widget tests covering: clears groups, clears draft, clears selection, does not delete saved notes, save-in-flight disables button, toggle-then-pending still disables button, button hidden when nothing to discard. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40ac19b to
8e884ca
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Add discard action for claim review sessions
Noticed the claim review panel had no way out on its own - the existing Discard button only ever reset the older note-draft flow, so if you'd generated a claim draft (or just had review results sitting there) with nothing in the old flow, there was nothing to click. Wired a dedicated Discard button that shows up whenever there's something to discard (review results or a generated draft) and calls the reset() the provider already had, which wipes groups/selection/draft/save/append status back to a clean slate. It never touches the repository, so anything already saved or appended stays exactly as it is - discard is UI-only. New test file
search_screen_claim_review_discard_test.dart, went from 469 passing to 475,flutter analyzeis clean.