From b9eb86541c3b82f6c401cecd2dadece3cb2d855e Mon Sep 17 00:00:00 2001 From: Narasimha-sc <166327228+Narasimha-sc@users.noreply.github.com> Date: Thu, 6 Aug 2026 16:12:26 +0000 Subject: [PATCH] ios: don't capture a mutable local in a @Sendable closure MainActor.run's body is @Sendable, and the switched flag added in the previous commit was a var captured by it - which strict concurrency diagnoses. Assigning a let on both branches of the do/catch is definitely initialised and safe to capture anywhere, with no behaviour change. --- .../Chat/ComposeMessage/ContextProfilePickerView.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/ios/Shared/Views/Chat/ComposeMessage/ContextProfilePickerView.swift b/apps/ios/Shared/Views/Chat/ComposeMessage/ContextProfilePickerView.swift index 5da33af018..c46790c74d 100644 --- a/apps/ios/Shared/Views/Chat/ComposeMessage/ContextProfilePickerView.swift +++ b/apps/ios/Shared/Views/Chat/ComposeMessage/ContextProfilePickerView.swift @@ -281,12 +281,16 @@ struct ContextProfilePickerView: View { // resync to what the host actually did and report it. The failure is the // switch, not the creation, so it is not rethrown into the form's "error // creating profile" handler. - var switched = false + // let, not var: MainActor.run's body is @Sendable, and capturing a mutable + // local in one is diagnosed under strict concurrency. Assigned on both + // branches, so it is definitely initialised. + let switched: Bool do { try await changeActiveUserAsync_(newUser.userId, viewPwd: nil) switched = true } catch { logger.error("changeActiveUserAsync_ error: \(responseError(error))") + switched = false } await MainActor.run { // Only when the switch actually happened: the prepared chat then belongs