1015 Commits

Author SHA1 Message Date
Matthew Hodgson d8a2ac75a8 Fix CurrentValuePublisher.map dropping updates when the mapped publisher is chained inline (#5870)
* Fix CurrentValuePublisher.map dropping updates when the mapped publisher is chained inline

The eager implementation bridged through a second CurrentValueSubject fed by
a sink whose AnyCancellable was stored on the returned struct. Combine
consumes publisher structs when building a subscription, so chaining the
mapped publisher inline (e.g. `publisher.map { … }.removeDuplicates(…)
.sink { … }`, as RoomScreenViewModel and RoomDetailsScreenViewModel do for
knock requests) dropped the only copy holding that cancellable: the feeding
sink was cancelled and subscribers only ever received the initial value.

In practice this meant a room admin viewing a knockable room never saw the
"wants to join" banner (or a live "Requests to join" badge) for a knock
arriving while the room was open — it only appeared when the knock predated
opening the room. Caught by a live cross-client knocking test; the
double-execution of the transform at subscription time (eager transform +
current-value replay) was the giveaway.

Make map lazy instead: keep the transformed AnyPublisher and a value
provider, so subscribers attach straight through to the source subject (which
replays its current value itself) and no keep-alive is needed. Adds a
regression test chaining a mapped publisher inline.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* swiftformat

* better docs

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Mauro Romito <mauro.romito@element.io>
2026-07-14 15:02:56 +02:00
Mauro Romito b730815842 disable creation and enabling of e2ee if remote preference for disabling it is true 2026-07-13 15:51:13 +02:00
Mauro e2c573b1eb Use deferFulfillment in flow coordinator tests (#5861)
* use deferFulfillment in coordinator tests

* pr suggestions
2026-07-13 11:52:22 +02:00
Mauro 6bd8423675 Media Preview content scanning (#5851)
* implemented checkSourceSafetyIfNeeded in the timeline media preview

* added a subtitle to the spinner when scanning and an animated drag gesture for the error and loading states

* pr suggestions

* pr suggestions part 2
2026-07-09 18:46:14 +02:00
Mauro ee89f8846f Fix for the media browser showing also images and videos in file mode (#5853)
* fix for the bug that makes the images appear in the file list of the media browser

* pr suggestions
2026-07-09 15:51:46 +02:00
Mauro 0a77ba6c90 Swift format enforce isEmpty rule (#5843)
* swift format enforce isEmpty rule

* revert scheme

* use trailing closure
2026-07-06 15:39:16 +02:00
Stefan Ceriu b8e6421551 Fix various project warnings 2026-07-03 19:30:28 +03:00
Stefan Ceriu 02d9ed1f0e Address search PR review comments
- Drop the redundant searchService coordinator/view model parameter; derive it from the client proxy.
- Rename the globalSearch avatar size to search.
- Lift the query observation streams out of their tasks.
- Restore the appeared and updateVisibleRange comments.
- Use CompoundIcon defaults and a scaledFrame for media previews.
- Simplify the result mapping with compactMap(makeResult) and drop unsupported events by returning nil.
- Move the preview helpers beneath the previews.
2026-07-03 13:39:45 +03:00
Stefan Ceriu 4fbfc87551 Add a Messages tab to global search
Split global search into Rooms and Messages tabs. The Messages tab lists
matching events with the room's name and avatar, a sender-prefixed preview,
rich media (image/video/audio/file) previews, and a loading indicator, then
paginates as you scroll. Queries are debounced and the previous one is
superseded so late results can't clobber a newer search.
2026-07-03 13:39:45 +03:00
Mauro 5ea4b46604 Content Scanner Service (#5826)
* implemented the content scanner service with caching and a way to use in the state store context

* fix swiftformat comment enforcing

* pr suggestions
2026-07-02 17:12:39 +02:00
Doug 3ef66cdd05 Rename UserProfileProxy to UserProfile. It's a pure struct and proxies nothing.
Also remove the redundant `userID` property given `id` already exists (for Identifiable conformance).
2026-07-02 13:09:34 +01:00
Doug 123661537a Make LinkNewDeviceScreen fall back to the App Lock PIN code when there's no passcode. (#5794)
* Fall back to the AppLock PIN code when there's no passcode.

* Add extra tests on the LinkNewDeviceFlowCoordinator.

* Misc tweaks for clarification.

* Regenerate snapshots.
2026-07-01 10:13:18 +01:00
Mauro 2d486ece33 Use iOS 26 Observation for Unit and Preview tests. (#5797)
* use observation in unit and preview tests instead of the async stream

* use a parsing approach that is independent of the sourcery annotation

* Fix observation deferred fulfillments not receiving the initial value

Observation's observe only emits transitions, not the value present at subscription time. Drop the leading initial value from the affected transitionValues sequences and assert it directly with #expect instead.

* improved docs
2026-06-30 14:01:08 +02:00
Stefan Ceriu bcee62f198 Fix new swiftformat errors 2026-06-30 11:18:45 +03:00
Doug f05fd41c36 Replace the UserPreference property wrapper with the new macro version. 2026-06-29 10:34:32 +01:00
Doug c53e0c1466 Add a new BuildExtensions package that contains a UserPreference macro.
The build extensions package can be used for both macros and plugins.
2026-06-29 10:34:32 +01:00
Doug f3da459d16 Ensure that the current user is the device owner before linking a new device. (#5773) 2026-06-26 16:24:18 +01:00
Stefan Ceriu 0bd32d24fd Switch to a custom HomeserverReachability instead of different publishers 2026-06-24 20:49:49 +03:00
Mauro c93d6e3265 Unit Tests migration to swift 6.2 (#5781) 2026-06-24 12:39:35 +02:00
Stefan Ceriu c5653c2208 Allow returning from global search with the escape key
cmd+k jumps to the search tab but left users with no way back. Pressing
escape in the search field now returns to the tab they came from (never
into search itself).

Escape is handled at the search field's pressesBegan, alongside the
existing arrow-key navigation, since the focused UIKit field swallows
SwiftUI keyboard shortcuts.
2026-06-22 16:54:30 +03:00
svetoslav-sportinno 30e4e6339d Add max selections support for polls (#5726) 2026-06-22 13:39:12 +02:00
Mauro Romito 3aedd0ccff swiftformat now enforces newlines for ifs 2026-06-19 15:28:27 +02:00
Stefan Ceriu 7f1b6086ae Search tab (#5754)
* Add a developer flag for the search tab
Introduces a globalSearchEnabled user preference (off by default) with a toggle in Developer Options, used to gate the new search experience.

* Support search role tabs in the tab coordinator
Migrates the NavigationTabCoordinator to SwiftUI's value-based Tab API and adds an isSearch option so a tab can adopt the iOS 26 .search role, which detaches it into the trailing search button in the tab bar.

* Moves room search to a new screen
Adds a new screen that filters the alternate room summary provider as you type, shows an empty state, and lists matching rooms with their matrix identifier. Supports hardware keyboard selection (arrow keys to move through results, return to open) by reaching into the system search field.

* Present search in a dedicated tab
Adds the search tab to the chats flow on iOS 26 when the flag is enabled, rendered as the detached .search role button. The Cmd+K shortcut now selects this tab, and the home screen's inline search is hidden while the tab is available.

* Remove the old global search screen
The dedicated search tab replaces the Cmd+K floating window, so the GlobalSearchScreen, its window plumbing in the WindowManager, and its presentation in the chats flow are all removed.
2026-06-19 13:50:17 +03:00
Mauro a520d94760 Swift 6 Migration (#5733)
* Enable Swift 6.2 with default main actor isolation for the app target

Turn on SWIFT_VERSION 6.2, SWIFT_APPROACHABLE_CONCURRENCY and SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor for the ElementX target, matching the NSE and Share Extension (which already use 6.2 without the main actor default).

# Conflicts:
#	ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

* Update the code generation templates for Swift 6

Emit nonisolated/@unchecked Sendable mocks and nonisolated string enums, and mark async mock methods @concurrent so they keep suspending like the real implementations (otherwise intermediate states are unobservable in tests). Includes the regenerated mocks and strings.

# Conflicts:
#	ElementX/Sources/Mocks/Generated/GeneratedMocks.swift

* Make the data layer and services nonisolated and Sendable

Annotate the value-type models, Rust SDK proxy wrappers, timeline item graph, settings, logging and NSE-shared types as nonisolated, and conform the service protocols to Sendable so their existentials can cross isolation boundaries. These types run off the main actor and no longer inherit the target's default main actor isolation.

* Adopt the new isolation across call sites, mocks and signatures

Update call sites, closure signatures and mock configuration helpers to match the nonisolated/Sendable data layer, including the main actor isolated mock inits and the @Sendable filter on recentlyVisitedRooms.

^ Conflicts:
^	ElementX/Sources/Services/SecureBackup/SecureBackupController.swift

* Remove redundant @MainActor annotations

With the app target defaulting to main actor isolation, the explicit @MainActor on view models, coordinators, views and their protocols is no longer required.

* Fix concurrency hotspots surfaced by the migration

Resolve the room summary main-thread deadlock by moving diff processing onto AsyncStreams, add the SDKListener.onMainActor FIFO bridge for SDK callbacks, hop KVO/timer/UIKit callbacks to the main actor via assumeIsolated, add isolated deinits, and apply the few justified nonisolated(unsafe) escapes for queue-confined Apple APIs.

* Fix the unit tests for Swift 6 concurrency

Hop the waitForConfirmation body onto the caller's actor (Swift Testing runs confirmation closures off-actor), and adjust the affected suites and async signatures.

* offload diffs on concurrent threads instead of main actor

* make room info protocols sendable

* use a task group for fetching data so that everything runs concurrently in the TextRoomTimelineView when getting the preview.

* use the generic onMainActor implementation, which already makes a stream and send the continuation on the main actor.

* small pr comments issues being addressed

* update enterprise

* Update StaticCode to 1.1.0 and specify the required Swift isolation.

* fix ElementCallServiceTests

* update enterprise

* re-generate mocks

* update enterprise

* enterprise new code conformed to swift 6

---------

Co-authored-by: Doug <douglase@element.io>
2026-06-18 17:55:31 +02:00
Daniel Anderson 434b3aab83 Report a phantom call to CallKit on PushKit early-return paths
iOS kills the app if a VoIP push isn't followed by reportNewIncomingCall, so
report an immediately ended call on every early-return path, named after the
room. A duplicate of an ongoing call is reported as answered elsewhere and an
expired push as a missed call that can be tapped to call back.

Signed-off-by: Daniel Anderson <daniel.anderson@toptal.com>
2026-06-16 12:11:37 +03:00
Mauro da5360c8e8 Hide user dot and track own user marker in Live Location mode. (#5707)
* added a new tracking mode for following a marker and the logic for switching such tracking mode

* implemented the follow marker tracking mode

* improved and added new tests
2026-06-05 13:51:57 +02:00
Stefan Ceriu 56d5f72f01 Rename RoomTimelineItemFixtures to just TimelineFixtures 2026-06-04 09:14:58 +03:00
Stefan Ceriu 9615e184ad Switch to using proper SDK Mocks everywhere. 2026-06-04 09:14:58 +03:00
Stefan Ceriu a6cad41b12 Remove all underlyingFoo mock property usage (unnecessary) 2026-06-03 08:57:04 +03:00
Stefan Ceriu 6ad1654d97 Convert the old MockTimelineController to the generated TimelineControllerMock 2026-06-03 08:57:04 +03:00
Daniel Anderson 4c8becc99e Clear incoming-call state on every path that ends a ringing call
Four end paths each cleaned up partially.

Signed-off-by: Daniel Anderson <daniel.anderson@toptal.com>
2026-06-02 15:43:20 +03:00
Aaron Thornburgh dc7454d161 Updates to File Info Bottom Sheet (#5667)
* Updates to File Info Bottom Sheet

Removing buttons, changing labels, adding a title

* Update the underlying actions rather than fixing it at the screen-level.

* Fix the media details sheet height now there's a navigation title.

* Record preview snapshots

---------

Co-authored-by: Doug <douglase@element.io>
Co-authored-by: Element CI <ci@element.io>
2026-06-01 14:00:55 +01:00
Stefan Ceriu 423bd8073f Move more MockTimelineController configuration to the constructor 2026-05-29 17:48:00 +03:00
Stefan Ceriu f040964d3f Allow the user to forward the same message to multiple rooms at once
This will send the item to the rooms in order they were chosen and only deep link
into the target room if single, otherwise it will just dismiss the forwarding screen
after sending.
2026-05-29 14:27:42 +03:00
Mauro 7093d966b4 Set map tiler URL from well known if available (#5633) 2026-05-28 15:24:58 +02:00
Doug fa67713726 Run SwiftFormat. 2026-05-27 17:11:42 +01:00
Quentin Gliech 2082e71888 Recognise dragged iOS screenshots as images instead of raw data
When dragging the floating screenshot preview into a room, iOS hands us
a provider whose `suggestedName` is e.g. `Screenshot 2026-05-22 at
14.49.40`. `NSString.pathExtension` returns `"40"`, so the previous
`!pathExtension.isEmpty` check treated the timestamp's trailing segment
as a real extension. The file got written without `.jpg`/`.png`, and the
`MediaUploadingPreprocessor` then fell back to `application/octet-stream`
which is why screenshots showed up as a "data" tile.
2026-05-25 11:01:28 +03:00
Doug 08d02001bf Tidy up mock creation. (#5627)
* Use our standard XYZMock(.init()) pattern everywhere instead of XYZMock.default.

* Remove the configuration parameter label on mock convenience inits.

* Update the enterprise submodule.
2026-05-22 17:34:35 +01:00
Stefan Ceriu 77c5aba326 Forward current composer text to the new poll form to serve as the question/topic 2026-05-22 16:46:42 +03:00
Stefan Ceriu ac20ff0fc3 Forward current composer text to the media upload preview screen as captions 2026-05-22 16:46:42 +03:00
Michael 22d14ff8e4 AppSettings are Mockable (#5589)
* create DependenciesProtocol and replace ServiceLocator registration with it

replace mocking calls for ServiceLocator to Dependencies

replace ServiceLocator with instance level calls

replace ServiceLocator configs with TestDependencies config in Tests

replace servicelocator usage in analytics service

replace remaining ServiceLocator calls in unit tests

that depended on the UnitTestAppCoordinator configuration with per suite dependencies instances

fix swiftlint warning

remove remaining references to ServiceLocator

make dependencies properties consistent in tests

delete Dependencies and DependenciesProtocol

fix whitespace modifications

updates from PR feedback

a pass over converting AppSettings and AnalyticsService test instance properties to per test instantiation

fix a missed PR feedback

Sync up after rebase

create DependenciesProtocol and replace ServiceLocator registration with it

replace mocking calls for ServiceLocator to Dependencies

replace ServiceLocator with instance level calls

replace ServiceLocator configs with TestDependencies config in Tests

replace servicelocator usage in analytics service

replace remaining ServiceLocator calls in unit tests

that depended on the UnitTestAppCoordinator configuration with per suite dependencies instances

fix swiftlint warning

remove remaining references to ServiceLocator

make dependencies properties consistent in tests

delete Dependencies and DependenciesProtocol

* AppSettings is instance level mockable now

* replace mocked and preview usages of reset + AppSettings global init with

AppSettings(store: UserDefaultsMock())

* AppSettings.UserDefaultsKeys is now a RawRep struct, making it extensible

* update tests with new AppSettings so it builds

* update remaining AppSettings test/mock inits

* AppSettings.UserDefaultsKey conformed to ExpressibleByStringLiteral

* addressed issues found in first pass ai review

* update AppSettings instantiations after rebase

* fix accessibility tests coordinator after rebase

* Rename to VolatileUserDefaults

* AppSettings init uses mandatory parameter

* Revert UserDefaultsKey to enum

* Add TrackedUserDefaults to be able to reset the defaults object

* Added volatile static func to AppSettings

* Use .volatile() static func instead of full init

* review fixups

* Resolve build issues after rebase

* updated enterprise module

* remove the static reset settings call from the preview tests

---------

Co-authored-by: Mauro Romito <mauro.romito@element.io>
2026-05-22 15:14:08 +02:00
Michael dfebb4719c Compiler Warning Reductions (#5609)
* Reduce warnings in AttributedStringBuilderTests

(cherry picked from commit e1f32b2b1df147c93207e01df5c8fec4046b0f48)

* Fixed Sentry warning

(cherry picked from commit e45c3002b2331a6f2d363de61a12377316078602)

* JoinRule and AllowRule conform to Sendable

(cherry picked from commit 27c67c27b944df11adc17bdd405e442e8c50b0d6)

* AudioConverterProtocol conform to Sendable

(cherry picked from commit 352bdab15db424c632538eb3140858eae9fdfb15)

* TimelineControllerProtocol conform to Sendable

(cherry picked from commit 07a927745624db4bab3cf68842027e12177be70b)

* Resolved some AI review notes

(cherry picked from commit 8d3ac820754a6126785e639a98c8c1fcf86ef77f)

# Conflicts:
#	ElementX/Sources/Other/SendableConformance/SendableBox.swift
#	ElementX/Sources/Other/SendableConformance/WeakSendableBox.swift
2026-05-22 10:56:30 +02:00
Danny eae464ecd7 Timeline: add a Jump to Unread button and a new-message badge on the scroll-to-bottom button. (#5506)
* Timeline: add a Jump to Unread button and a new-message badge on the scroll-to-bottom button.

* Rename scrollToFirstUnread to scrollToReadMarker for consistency with isReadMarkerVisible.

* Cache readMarkerUniqueID and unreadMessageCount as stored properties on TimelineState.

* TimelineViewModel: rename newTimelineItems and drop redundant ordering comment.

* Use Compound chevron icons in TimelineScrollButton.

* Fix TimelineScrollButton layout at large dynamic type sizes.

* Add a trailingAccessory slot to topBanners and use it to dodge banners with the jump-to-read-marker button.

* Put jump-to-read-marker behind a developer-options feature flag.

* Fine-tune TimelineScrollButton sizing and badge colour.

* Remove TimelineScrollButton chevron offset that was compensating for SF Symbol centering.

* Drop the new-messages count, replace with a presence dot.

* Move both timeline scroll buttons to bottom-right and revert topBanners trailingAccessory slot.

* Position TimelineScrollButton badge above for up direction and below for down direction.

* Add long-press mark-as-read pill to the timeline scroll buttons

* Read isSwitchingTimelines from state in updateHasNewMessagesAtBottom.

* Use assertionFailure when scrollToReadMarker is called with no read marker.

* Add TimelineScrollButton preview snapshots.

* (fix) design and various self-review issues

* (fix) suppress scroll button tap after long-press

* (feat) fall back to RoomInfo.fullyReadEventID for jump-to-unread

* (fix) hide jump-to-unread immediately after mark-as-read

* (fix) align with newer matrix-rust-sdk surface

* Bump the RustSDK to v26.05.20

---------

Signed-off-by: Daniel Anderson <daniel.anderson@toptal.com>
Co-authored-by: Stefan Ceriu <stefan.ceriu@gmail.com>
2026-05-21 15:03:32 +03:00
Stefan Ceriu ab82068740 Make the AnalyticsServiceMock default a variable as well, for consistency. 2026-05-21 12:37:52 +03:00
Michael dd0de4d7b0 Custom Notification Tones (#5527)
* added foundation for custom notifications

* feat: add localizations for tone names

also, if available, include the pro sound in the element x sound list

* use a static file location to store the notification tone

and update the file at that location when selected

* if there's a problem previewing or setting the alert tone, toast the user with the error

* rename tone directory

* create NotificationToneManager to handle tone business logic

* conform to project formatting

* assign custom sound to actual notifications

* dry up notification generation in the nse

* add compilation condition for including notification alert tone and remove from share extension

* swift format had some opinions

* flatten the notification tone ui, removing system/elementx designations

* fix stored file url breaking due to sandbox path changes

* tone manager can import custom tones and provide a list of imported tones

* ui support for custom tones

* can delete custom imported tones

* sort the custom tones

* add additional preset sounds

* can choose caf files for custom sounds and fix location persistence issues

* store sound locations with relative links

this is a better solution than storing bookmarks since bookmark resolution can be variable and differ from freshly derived urls

* add docs for new notification features

* run tone conversion in background

* resolved several ai found issues

* added protocol and mocks for notification tone manager

* added tests for notification settings screen vm interactions with the tone manager

* add tests for notification tone manager

* rename element tone names per feedback

* move custom tone option to the top of the notification tone list

* rename Tone to Sound for consistency with Android

* remove additional bundled tones

* restore accidentally deleted Element Default sound file

* system alert tones are filtered by what's available on the system prior to finalizing the collection

* Add a couple more caf file conversion log statements

* Simplify the notification sound conversion logic

* Update notification sound strings in sync with Android

* update xcodeproj after rebase

* remove conditional compilation and include NotificationAlertSound in share extension

* Use AudioPlayer instead of custom tone previewer and remove the previewer

* rename NotificationTone

* Consolidate and move errors to top of NotificationToneManager

* tone manager no longer depends on userinterfacecontroller

* Move static Tone properties to NotificationToneManager

* resolve view model initializer feedback

* update xcodeproj

* fatalerror when tone manager cannot init

* Remove banner icon on alert tone error

* fixup review feedback

* Moved URL handling to NotificationToneManager
2026-05-20 15:40:34 +03:00
Michael 5a07c98afc Make AnalyticsService mockable via `AnalyticsServiceProtocol (#5599)
* Create AnalyticsServiceProtocol and conform AnalyticsService

* Replace AnalyticsService properties and arguments with AnalyticsServiceProtocol

* Inline AnalyticsServiceMock replacing old mock

* handle more complex AnalyticsServiceMock callsites

* move documentation from AnalyticsService to AnalyticsServiceProtocol
2026-05-20 08:23:58 +03:00
Mauro 6c0aaa7a58 Invite the DM recipient to a new room (#5588)
* handle the details to invite users flow.

* implemented the room creation in the invite screen, and its dismissal + navigaton to the newly created room

* updated preview and unit tests

* pr suggestions
2026-05-18 10:08:07 +02:00
Michael ff5dcb040d Replace the ServiceLocator with direct dependency injection (#5548)
Removes the ServiceLocator singleton and instead directly injects the dependencies it was holding for more control over instantiation of the various component subtrees and better visibility over how they're being used.
2026-05-14 09:45:49 +03:00
Mauro Romito 07fc022a65 prevent replies to LLS timeline items, and live location sharing in threads 2026-05-12 17:26:02 +02:00
Mauro Romito deac31e48d remove code related to the previous bidi usage implementation of whitespaces for the timestamp label 2026-05-12 14:46:18 +02:00