Skip to content

Report FluidRideauViewController dismissal once - #198

Merged
muukii merged 2 commits into
mainfrom
takumatt/fix-rideau-double-dismiss
Nov 17, 2026
Merged

muukii merged 2 commits into
mainfrom
takumatt/fix-rideau-double-dismiss

Conversation

@takumatt

@takumatt takumatt commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

A backdrop tap on a FluidRideauViewController in a FluidStackController reported onWillDismiss and onDidDismiss twice. Callers that run work in onDidDismiss, such as advancing a list or resuming a continuation, ran that work twice.

Cause

The tap reported the dismissal itself and then popped the sheet with the .rideau removing transition, which moves the sheet to .hidden. When that move finishes, Rideau calls the move completion first and then reports .hidden to didMoveTo:

  1. The move completion finishes the removal: the sheet leaves the stack, fluidStackContext becomes nil, and the tap's pop completion reports onDidDismiss.
  2. The didMoveTo(.hidden) handler then reports onWillDismiss again. isInFluidStackController is now false, so it takes the modal branch and calls dismiss(animated:completion:) on a sheet that is not presented. UIKit still runs that completion, which reports onDidDismiss again.

A fluidPop() from outside the sheet passes no completion, so it was reported only by step 2: once, after the sheet had left. That path also stays correct when the removal overlaps another transition. A second fluidPop() or a cascade removal still ends with one report after the sheet leaves, and a re-push that keeps the sheet never reaches .hidden, so nothing is reported.

Change

The didMoveTo(.hidden) handler is now the only reporter, and it reports explicitly instead of relying on the dismiss(animated:completion:) call:

  • A swipe arrives while the sheet is still presented. The handler reports onWillDismiss, removes the sheet, and reports onDidDismiss when the removal completes. This is unchanged.
  • A removing transition, such as a backdrop tap or fluidPop(), arrives after the removal has finished. The handler reports onWillDismiss and onDidDismiss right away.
  • A backdrop tap only starts the pop or the modal dismissal.
  • The modal transitioning delegate no longer reports onWillDismiss, which a modal swipe reported twice.

The removing transition and the modal dismiss transition keep their existing code.

Dismissal Before After
Backdrop tap, in a stack onWillDismiss ×2, onDidDismiss ×2 Once each, after the removal
Swipe, in a stack Once each Once each
fluidPop() from outside Once each, after the removal Unchanged
Second fluidPop() during a removal Once each from outside; ×2 after a tap Once each
Cascade removal during a removal Once each from outside; ×2 after a tap Once each
Re-push during a removal None from outside; once after a tap, with the sheet still shown None
Removal of a parent (cascade) without a sheet removal Not reported Not reported
Swipe, modal onWillDismiss ×2 Once each

onWillDismiss for a backdrop tap now comes when the sheet has left, as it already did for fluidPop(), instead of at the tap.

Validation

  • Built in an app workspace that consumes this package through a local path; the iOS Simulator Debug build passed.
  • iOS Simulator (iPhone 18 Pro), with a sheet pushed with fluidPush(_:target:) whose caller advances a list in onDidDismiss:
    • Backdrop tap: onDidDismiss was reported once and the list advanced by one item. Before this change, the same steps reported it twice.
    • Swipe down: reported once and the list advanced by one item.
    • A button in the sheet that pops its parent with cascade removal: onDidDismiss was not reported, as before.
  • git diff --check origin/main passed.

Not checked at runtime: overlapping removals, re-push during a removal, fluidPop() from outside the sheet, and modal presentation. Those rows of the table follow from the code. FluidStackRideauSupport has no unit tests.

🤖 Generated with Claude Code

A backdrop tap on a sheet in FluidStackController reported
onWillDismiss and onDidDismiss twice. The tap pops the sheet with the
Rideau removing transition. Rideau runs the move completion first,
which removes the sheet and calls the pop completion, and only then
reports `.hidden` to didMoveTo. The sheet is out of the stack by then,
so the didMoveTo handler took the modal branch and called
dismiss(animated:completion:), whose completion reported onDidDismiss
again. A fluidPop() from outside the sheet received onDidDismiss only
through that same branch.

Each dismissal now has a single reporter. The Rideau removing
transition reports onWillDismiss when it starts and onDidDismiss when
it finishes, unless the removal is cancelled; this covers backdrop taps
and fluidPop(). The modal dismiss transition reports onDidDismiss when
it completes. The didMoveTo handler starts a dismissal only while the
sheet is still presented, which is the swipe case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T07:04:19.704938Z 7e10a69 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 654a4c2a1f

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

Reporting from the removing transition reported onDidDismiss on
`.interrupted`, which fires twice when a second fluidPop() replaces a
running removal, and before a re-push keeps the sheet. A removal that
starts from fluidPop() already behaved correctly before: the handler
reported once after Rideau finished the move and the sheet had left.

Keep that behavior and make it explicit. The didMoveTo(.hidden) handler
is the only reporter. A swipe arrives while the sheet is presented, so
the handler removes it first; a removing transition arrives after the
removal, so the handler only reports, instead of calling
dismiss(animated:completion:) on a sheet that is not presented. A
backdrop tap no longer reports by itself, and the modal transitioning
delegate no longer reports onWillDismiss a second time. The removing
and modal dismiss transitions are back to their previous code.

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

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 7e10a6972d

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

@muukii
muukii merged commit 2aacc2f into main Nov 17, 2026
0 of 4 checks passed
@muukii
muukii deleted the takumatt/fix-rideau-double-dismiss branch November 17, 2026 08:43
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.

2 participants