Skip to content

Close saved-payment-method confirmation interactors when they leave composition - #13774

Draft
jaynewstrom-stripe wants to merge 1 commit into
masterfrom
jaynewstrom/dispose-saved-payment-confirm-interactors
Draft

Close saved-payment-method confirmation interactors when they leave composition#13774
jaynewstrom-stripe wants to merge 1 commit into
masterfrom
jaynewstrom/dispose-saved-payment-confirm-interactors

Conversation

@jaynewstrom-stripe

@jaynewstrom-stripe jaynewstrom-stripe commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

SavedPaymentMethodConfirmInteractor now exposes close(), which cancels its internal selection-collecting job. PaymentSheetScreen.SavedPaymentMethodConfirm implements Closeable and delegates to it. In the embedded form, FormScreenContent now remembers the interactor keyed on the selection being confirmed and closes it via DisposableEffect when it leaves composition or the selection changes.

Motivation

DefaultSavedPaymentMethodConfirmInteractor launched a coroutineScope.launch { selection.collectLatest { updateSelection(it) } } job in init with no way to stop it — every time the saved-payment confirmation screen/composable was shown, that collector leaked for the life of the underlying scope. This adds an explicit disposal hook and wires it up at both places the interactor is created: the standalone PaymentSheetScreen.SavedPaymentMethodConfirm screen and the embedded FormActivityUI's FormScreenContent composable.

Testing

  • Added tests

  • Modified tests

  • Manually verified

  • Added a DefaultSavedPaymentMethodConfirmInteractorTest case verifying that after close(), selection updates stop being delivered. Wired a CleanupTestRule so every interactor built by the test helper gets closed during test cleanup.

  • Added FormScreenContentTest covering the remember/DisposableEffect semantics in the embedded form: the interactor is reused across unrelated recompositions of the same selection, closed exactly once when the confirmation is dismissed, and recreated (with the old one closed) when the selection changes.

  • Added a PaymentSheetScreen test verifying SavedPaymentMethodConfirm.close() delegates to the interactor's close().

  • FakeSavedPaymentMethodConfirmInteractor got a no-op close() to satisfy the interface.

Screenshots

N/A — no visual changes.

@jaynewstrom-stripe
jaynewstrom-stripe force-pushed the jaynewstrom/dispose-saved-payment-confirm-interactors branch from 59fa20e to 7235b26 Compare August 5, 2026 20:40
@jaynewstrom-stripe
jaynewstrom-stripe force-pushed the jaynewstrom/dispose-saved-payment-confirm-interactors branch 2 times, most recently from 21d1401 to 2cb9f9a Compare August 5, 2026 22:00
@jaynewstrom-stripe
jaynewstrom-stripe force-pushed the jaynewstrom/dispose-saved-payment-confirm-interactors branch from 2cb9f9a to 8a70e12 Compare August 5, 2026 23:12
Base automatically changed from jaynewstrom/scope-vertical-pm-list-interactors to master August 6, 2026 15:14
@jaynewstrom-stripe
jaynewstrom-stripe force-pushed the jaynewstrom/dispose-saved-payment-confirm-interactors branch 3 times, most recently from 36f5282 to fe6391c Compare August 6, 2026 22:55
Committed-By-Agent: codex
Co-authored-by: codex <noreply@openai.com>
@jaynewstrom-stripe
jaynewstrom-stripe force-pushed the jaynewstrom/dispose-saved-payment-confirm-interactors branch from fe6391c to d67caef Compare August 6, 2026 23:09
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