Skip to content

Fix Home delete-failure alert cleared on confirmation dismissal#1131

Open
acorretti wants to merge 1 commit into
r3dbars:mainfrom
acorretti:fix/home-alert-binding-clears-pending-failure
Open

Fix Home delete-failure alert cleared on confirmation dismissal#1131
acorretti wants to merge 1 commit into
r3dbars:mainfrom
acorretti:fix/home-alert-binding-clears-pending-failure

Conversation

@acorretti

Copy link
Copy Markdown
Contributor

Why

Follow-up to #1126, which consolidated the three stacked Home .alert(item:) into one shared rootAlertBinding. codex-review flagged (and it shipped in the merge): the binding clears all three alert states whenever SwiftUI writes nil on dismissal. When a confirm action fails synchronously it sets homeDeleteFailure inside the confirm closure, then SwiftUI dismisses the confirmation by writing nil, which wipes the just-set failure before it can present. So a failed delete silently shows no error.

Affected paths:

  • Dictation delete throws → presentHomeDeleteFailure(...) in the confirm closure
  • Failed-meeting delete returns false → same

(The meeting-delete path fails asynchronously, after the alert is gone, which is why it wasn't caught at merge time.)

Product Impact

  • Affects: meetings, dictation
  • Lane: meeting reliability
  • Why this matters: a delete that fails (locked file, permissions, etc.) gave the user no feedback at all. The "Could not delete…" alert was created and then immediately wiped by the confirmation's own dismissal.

What changed

  • Dismiss only the active alert, not all three. Routing goes through a new Foundation-pure HomeRootAlertPolicy.activeSlot; the confirmation outranks the failure, so dismissal clears the confirmation and a freshly-set failure survives to present next.
  • Defer presentHomeActionFailure to the next runloop turn so a failure raised inside a confirm action lands after the confirmation finishes dismissing (SwiftUI won't present a second alert mid-dismissal).
  • Add HomeRootAlertPolicyTests covering the priority/dismissal, including the exact regression case (confirmation + failure both set → confirmation dismissed first, failure survives), plus a source-contract guard that the binding clears only the dismissed alert.

How I checked it

  • scripts/dev/agent-preflight.sh
  • Selected checks from .agents/test-matrix.yml (Sources/UI/** + root Tests/*.swift map to build + fast tests)
  • bash build.sh --no-open
  • bash run-tests.sh (5413/5413)
  • Performance budget passed (build.sh --no-open bundle gate: "Performance budget OK")
  • bash run-integration-smoke.sh (N/A, no Sources/Meeting/ or Sources/TranscriptedCore/ changes)
  • swift test (N/A, no Package.swift / core seam changes)
  • Manual check: normal delete path verified (confirm deletes, cancel dismisses). The failure path is hard to trigger by hand, so it's locked down by HomeRootAlertPolicyTests instead.

Risk Review

  • Privacy / local-first behavior reviewed (no off-device payload or analytics shape changes)
  • Storage path or migration impact reviewed (deletion path unchanged; this only touches alert presentation/dismissal)
  • Public-facing copy stays concrete and matches current product scope (alert copy unchanged)
  • Release/update impact reviewed (none)
  • Agent PRs link the issue/workpad and stay draft until human review (N/A, human-overseen PR)
  • UI changes include sanitized .agent-review/visuals/ evidence (not attached; behavioral fix to alert sequencing with no visual change, and the live Home list shows private titles. Can add a cropped capture of the failure alert if wanted.)
  • No private transcripts, audio, tokens, personal paths, or customer data are included

Notes

The consolidated rootAlertBinding cleared all three Home alert states when
SwiftUI wrote nil on dismissal. When a confirm action fails synchronously
(dictation delete throws, failed-meeting delete returns false) it sets
homeDeleteFailure inside the confirm closure, then SwiftUI dismisses the
confirmation by writing nil, which wiped the just-set failure before it
could present.

- Dismiss only the active alert, routed through a new Foundation-pure
  HomeRootAlertPolicy.activeSlot. The confirmation outranks the failure, so
  dismissal clears the confirmation and the failure survives to present.
- Defer presentHomeActionFailure so a failure raised inside a confirm action
  lands after the confirmation finishes dismissing; SwiftUI will not present a
  second alert mid-dismissal.
- Add HomeRootAlertPolicyTests for the priority/dismissal behavior and a
  source-contract guard that the binding clears only the dismissed alert.

Follow-up to r3dbars#1126 / codex-review.
@acorretti

Copy link
Copy Markdown
Contributor Author

@r3dbars I was working on this follow-up to #1126 when I saw you went ahead and merged it.
I'm creating this PR with the fix instead.

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