Skip to content

feat: add discard action for claim review sessions#65

Merged
enlorik merged 1 commit into
mainfrom
feature/claim-review-discard-reset
Jul 20, 2026
Merged

feat: add discard action for claim review sessions#65
enlorik merged 1 commit into
mainfrom
feature/claim-review-discard-reset

Conversation

@enlorik

@enlorik enlorik commented Jul 9, 2026

Copy link
Copy Markdown
Owner

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 analyze is clean.

@enlorik

enlorik commented Jul 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread lib/screens/search_screen.dart Outdated
const SizedBox(height: 12),
TextButton(
key: const Key('discard-claim-review-button'),
onPressed: _discardClaimReview,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Branch has been rebased onto main. This concern is addressed in the clean implementation — see the single commit on this PR.

@enlorik

enlorik commented Jul 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Branch has been rebased onto main. This concern is addressed in the clean implementation — see the single commit on this PR.

@enlorik

enlorik commented Jul 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +180 to +182
saveStatus: matchesSavedDraft
? ClaimDraftSaveStatus.saved
: ClaimDraftSaveStatus.idle,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Branch has been rebased onto main. This concern is addressed in the clean implementation — see the single commit on this PR.

@enlorik

enlorik commented Jul 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +119 to +121
saveStatus: ClaimDraftSaveStatus.idle,
clearSaveError: true,
appendStatus: ClaimDraftAppendStatus.idle,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Branch has been rebased onto main. This concern is addressed in the clean implementation — see the single commit on this PR.

@enlorik

enlorik commented Jul 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread lib/screens/search_screen.dart Outdated
Comment on lines +429 to +430
onPressed: claimReviewState.saveStatus == ClaimDraftSaveStatus.saving ||
claimReviewState.appendStatus == ClaimDraftAppendStatus.appending

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Branch has been rebased onto main. This concern is addressed in the clean implementation — see the single commit on this PR.

@enlorik

enlorik commented Jul 9, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@enlorik
enlorik changed the base branch from main to feature/claim-draft-append-to-note July 9, 2026 13:36
@enlorik
enlorik force-pushed the feature/claim-draft-append-to-note branch from c239cf0 to 567588f Compare July 9, 2026 13:38
@enlorik
enlorik force-pushed the feature/claim-review-discard-reset branch from e4abbc2 to 423427b Compare July 9, 2026 13:38
@enlorik
enlorik force-pushed the feature/claim-draft-append-to-note branch from 729ac4d to faa0bd5 Compare July 19, 2026 23:36
- 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>
@enlorik
enlorik force-pushed the feature/claim-review-discard-reset branch from 40ac19b to 8e884ca Compare July 20, 2026 17:30
@enlorik
enlorik changed the base branch from feature/claim-draft-append-to-note to main July 20, 2026 17:31
@enlorik

enlorik commented Jul 20, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 8e884cafa8

ℹ️ 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".

@enlorik
enlorik marked this pull request as ready for review July 20, 2026 18:28
@enlorik
enlorik merged commit 5e658b2 into main Jul 20, 2026
1 check passed
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.

1 participant