Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ECO-5018] Use wrapper SDK proxy to track Chat SDK usage #211

Merged
merged 5 commits into from
Feb 10, 2025

Conversation

lawrence-forooghian
Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian commented Jan 15, 2025

This demonstrates the use of the new -[ARTRealtime createWrapperSDKProxyWithOptions:] method introduced in ably/ably-cocoa#2014, which implements ADR-117: Tracking wrapper SDK usage, continued, allowing us to track usage of the Chat SDK.

Once I've written a specification for the API introduced in ably-cocoa, I will also add something to the chat spec to describe the behaviour implemented in the current PR.

Summary by CodeRabbit

Summary by CodeRabbit

  • Chores

    • Revised dependency references for enhanced stability and consistent package management.
  • Refactor

    • Streamlined client initialization and protocol implementations to ensure a smoother configuration flow.
    • Optimized versioning and agent information handling for improved performance.
  • Tests

    • Updated testing approaches to match new instantiation patterns, reinforcing reliability while maintaining current functionality.
    • Added new test cases for DefaultChatClient to ensure correct instance behavior.

Copy link

coderabbitai bot commented Jan 15, 2025

Walkthrough

This PR updates dependency references for the ably-cocoa package by revising originHash, revision, and version values in Package.resolved and changing the dependency declaration in Package.swift. It also updates the instantiation methods for the mock realtime client in both example code and tests, introduces a new protocol (SuppliedRealtimeClientProtocol) along with associated proxy creation, adjusts protocol conformance in various source files, and redefines the structure for agent information.

Changes

File(s) Change Summary
AblyChat.xcworkspace/xcshareddata/.../Package.resolved, Package.resolved Updated originHash, revision, and version for the ably-cocoa dependency.
Package.swift Changed dependency declaration for ably-cocoa from semantic versioning (from: "1.2.37") to a newer version (from: "1.2.38").
Example/AblyChatExample/ContentView.swift, Example/AblyChatExample/Mocks/MockRealtime.swift Modified chat client creation by switching from a factory method (MockRealtime.create()) to direct instantiation; removed extra required initializers and the factory method in MockRealtime.
Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift, Sources/AblyChat/ChatClient.swift, Sources/AblyChat/Dependencies.swift, Sources/AblyChat/Room.swift, Sources/AblyChat/Version.swift Updated protocol conformances (e.g., ARTRealtime now conforms to SuppliedRealtimeClientProtocol), introduced SuppliedRealtimeClientProtocol with a createWrapperSDKProxy(with:) method, changed channel options instantiation, and restructured agent info storage from a concatenated string to a key-value mapping.
Tests/AblyChatTests/* Replaced calls to MockRealtime.create() with direct initialization across multiple test files; added new test cases for DefaultChatClient; updated expectations and instantiation for mock realtime clients in chat API, messages, room, and rooms tests; and significantly modified Mocks/MockRealtime.swift to align with new protocol changes.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant DefaultChatClient
    participant RealtimeClient
    participant SDKProxy

    Caller->>DefaultChatClient: init(realtime: any SuppliedRealtimeClientProtocol, clientOptions?)
    DefaultChatClient->>RealtimeClient: createWrapperSDKProxy(with: options)
    RealtimeClient-->>DefaultChatClient: Return proxy client
    DefaultChatClient->>DefaultChatClient: Initialize rooms & connection using proxy
    DefaultChatClient-->>Caller: Instance created
Loading

Assessment against linked issues

Objective (ECO-5018) Addressed Explanation
Define how to send up agent info (ECO-5018)

Possibly related PRs

Suggested reviewers

  • umair-ably
  • maratal

Poem

I'm a rabbit with a carrot so bright,
Hopping through code changes day and night.
Dependencies aligned, protocols redefined,
Tests hop in rhythm, leaving bugs behind.
In this code garden, I nibble with delight! 🥕🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot temporarily deployed to staging/pull/211/AblyChat January 15, 2025 16:33 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/211/AblyChat January 16, 2025 19:39 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/211/AblyChat January 16, 2025 19:52 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/211/AblyChat January 20, 2025 17:34 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/211/AblyChat January 22, 2025 18:37 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/211/AblyChat January 28, 2025 19:26 Inactive
@lawrence-forooghian lawrence-forooghian changed the title [WIP] Use wrapper sdk proxy [WIP] Use wrapper SDK proxy to track Chat DK usage Jan 30, 2025
@lawrence-forooghian lawrence-forooghian changed the title [WIP] Use wrapper SDK proxy to track Chat DK usage [WIP] Use wrapper SDK proxy to track Chat SDK usage Jan 30, 2025
@github-actions github-actions bot temporarily deployed to staging/pull/211/AblyChat January 30, 2025 19:19 Inactive
@github-actions github-actions bot temporarily deployed to staging/pull/211/AblyChat February 5, 2025 13:47 Inactive
@lawrence-forooghian lawrence-forooghian changed the title [WIP] Use wrapper SDK proxy to track Chat SDK usage [ECO-5018] Use wrapper SDK proxy to track Chat SDK usage Feb 5, 2025
@lawrence-forooghian lawrence-forooghian marked this pull request as ready for review February 5, 2025 13:48
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
Sources/AblyChat/Version.swift (1)

7-7: Consider using semantic versioning constants.

While the version string follows semantic versioning format, consider breaking it down into constants for better maintainability:

-internal let version = "0.1.2"
+internal let majorVersion = 0
+internal let minorVersion = 1
+internal let patchVersion = 2
+internal let version = "\(majorVersion).\(minorVersion).\(patchVersion)"
Sources/AblyChat/Dependencies.swift (2)

6-10: Consider adding more documentation and concurrency notes.

You've introduced a new SuppliedRealtimeClientProtocol that extends RealtimeClientProtocol and adds a createWrapperSDKProxy(with:) method. This is a great way to cleanly separate the creation of a proxy client. However, since the protocol is marked Sendable, it might be helpful to add documentation clarifying any concurrency guarantees or usage constraints.


42-54: Refine force casting in channel options copy.

Force casting with // swiftlint:disable:next force_cast can make debugging difficult if copy() ever returns an unexpected type. Consider replacing it with a safe cast or an explicit error pathway if the cast fails.

Here is a suggested fix:

-// swiftlint:disable:next force_cast
-opts.copy() as! ARTRealtimeChannelOptions
+guard let newOpts = opts.copy() as? ARTRealtimeChannelOptions else {
+    fatalError("Failed to copy ARTRealtimeChannelOptions to the expected type.")
+}
+let resolvedOptions: ARTRealtimeChannelOptions = newOpts
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec2a0b8 and b894916.

📒 Files selected for processing (16)
  • AblyChat.xcworkspace/xcshareddata/swiftpm/Package.resolved (1 hunks)
  • Example/AblyChatExample/ContentView.swift (1 hunks)
  • Example/AblyChatExample/Mocks/MockRealtime.swift (0 hunks)
  • Package.resolved (1 hunks)
  • Package.swift (1 hunks)
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift (1 hunks)
  • Sources/AblyChat/ChatClient.swift (2 hunks)
  • Sources/AblyChat/Dependencies.swift (2 hunks)
  • Sources/AblyChat/Room.swift (1 hunks)
  • Sources/AblyChat/Version.swift (1 hunks)
  • Tests/AblyChatTests/ChatAPITests.swift (7 hunks)
  • Tests/AblyChatTests/DefaultChatClientTests.swift (1 hunks)
  • Tests/AblyChatTests/DefaultMessagesTests.swift (6 hunks)
  • Tests/AblyChatTests/DefaultRoomTests.swift (11 hunks)
  • Tests/AblyChatTests/DefaultRoomsTests.swift (10 hunks)
  • Tests/AblyChatTests/Mocks/MockRealtime.swift (3 hunks)
💤 Files with no reviewable changes (1)
  • Example/AblyChatExample/Mocks/MockRealtime.swift
✅ Files skipped from review due to trivial changes (4)
  • Tests/AblyChatTests/DefaultRoomTests.swift
  • Tests/AblyChatTests/DefaultRoomsTests.swift
  • AblyChat.xcworkspace/xcshareddata/swiftpm/Package.resolved
  • Package.resolved
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Xcode, tvOS (Xcode 16)
  • GitHub Check: Xcode, iOS (Xcode 16)
  • GitHub Check: Xcode, macOS (Xcode 16)
🔇 Additional comments (22)
Sources/AblyChat/Version.swift (2)

3-3: Address or update the TODO comment.

The comment indicates this is a temporary implementation copied from chat-js. Since this PR implements ADR-117 for tracking wrapper SDK usage, we should either:

  1. Remove the TODO if the current implementation aligns with ADR-117
  2. Update it to reflect the current implementation status

Would you like me to help track this in a new issue?


9-9: LGTM! The new agent structure aligns with wrapper SDK tracking.

The change from a concatenated string to a dictionary structure is a good improvement that:

  1. Makes the agent information more structured and maintainable
  2. Aligns with the wrapper SDK proxy tracking requirements from ADR-117

Let's verify this matches the implementation in ably-cocoa:

Sources/AblyChat/Dependencies.swift (1)

12-13: Confirm concurrency assumptions.

RealtimeClientProtocol now inherits Sendable, which is beneficial for Swift concurrency. Ensure that all conforming types can be safely passed across concurrency domains without introducing data races.

Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift (4)

3-4: Smooth transition to SuppliedRealtimeClientProtocol.

Designating ARTRealtime as SuppliedRealtimeClientProtocol is a logical approach that keeps the codebase consistent with the newly introduced proxy client concept.


5-5: Straightforward conformance to RealtimeClientProtocol.

Extending ARTWrapperSDKProxyRealtime allows the code to leverage existing real-time client features. No issues spotted here.


8-8: Proxy channels conformance.

Aligning ARTWrapperSDKProxyRealtimeChannels with RealtimeChannelsProtocol maintains consistent usage alongside the primary channel structures.


11-11: Proxy channel conformance looks good.

Registering ARTWrapperSDKProxyRealtimeChannel under RealtimeChannelProtocol is consistent with the approach above and ensures uniform usage of channel APIs.

Tests/AblyChatTests/DefaultChatClientTests.swift (5)

8-11: Clean initialization for a default client.

Switching to a direct MockRealtime(createWrapperSDKProxyReturnValue: .init()) instantiation clarifies test setup. Good improvement.


18-27: Ensures real-time reference integrity.

The new test_realtime() method confirms that the DefaultChatClient retains the original realtime instance rather than replacing it with a proxy. This is valuable coverage.


29-36: Checks wrapper SDK proxy agent creation.

Verifying createWrapperSDKProxyOptionsArgument?.agents ensures correct agent info is passed. Good test for usage tracking requirements.


41-42: Verifying proxy instantiation consistency.

Creating both proxyClient and realtime in tandem effectively tests different code paths for the real-time client setup.


46-46: Rooms ownership verification.

By asserting defaultRooms.testsOnly_realtime is the proxy, you confirm the rooms feature uses the intended wrapped client, aligning with the rest of the abstraction.

Sources/AblyChat/ChatClient.swift (2)

47-47: LGTM! Good use of nonisolated.

The nonisolated keyword is correctly applied to allow access to the realtime property without requiring actor isolation.


63-68: LGTM! Good implementation of the wrapper SDK proxy pattern.

The constructor correctly accepts a SuppliedRealtimeClientProtocol and creates a wrapper SDK proxy for tracking Chat SDK usage, aligning with ADR-117.

Tests/AblyChatTests/Mocks/MockRealtime.swift (2)

6-6: LGTM! Good use of @unchecked Sendable.

The class correctly conforms to SuppliedRealtimeClientProtocol and is marked as @unchecked Sendable since thread safety is manually implemented.


81-91: LGTM! Well-implemented thread-safe proxy creation.

The createWrapperSDKProxy method correctly:

  • Validates the return value
  • Uses mutex for thread-safe options storage
  • Returns the appropriate type
Tests/AblyChatTests/ChatAPITests.swift (1)

11-13: LGTM! Consistent test initialization pattern.

The test initialization has been updated to use the new MockRealtime API consistently across all test cases while maintaining the same test coverage.

Also applies to: 32-34, 58-60, 81-83, 108-110, 130-132, 174-176

Tests/AblyChatTests/DefaultMessagesTests.swift (1)

11-11: LGTM! Consistent test initialization pattern.

The test initialization has been updated to use the new MockRealtime API consistently across all test cases while maintaining the same test coverage.

Also applies to: 29-29, 49-49, 75-75, 109-109, 143-143

Example/AblyChatExample/ContentView.swift (1)

19-19: LGTM!

The change simplifies mock instantiation by using direct initialization instead of a factory method, which aligns with the wrapper SDK proxy implementation.

Sources/AblyChat/Room.swift (1)

318-318: LGTM!

The change appropriately:

  1. Makes the channel options immutable since they're only modified within the loop's scope
  2. Uses ARTRealtimeChannelOptions which aligns with the wrapper SDK proxy implementation
Package.swift (2)

22-23: Consider using a released version instead of a commit reference.

The PR objectives indicate that this change depends on functionality from ably-cocoa#2014 which hasn't been released yet. Using an unreleased commit could be risky:

  1. The referenced commit might change if the PR is rebased
  2. The functionality might change before release
  3. You won't automatically get bug fixes

Consider waiting for the release and then updating to use a version constraint instead:

-            revision: "58bbd149cbd92da6c29fad40b51ccdc3ca71404d"
+            from: "x.y.z"  // Replace with the version that includes ably-cocoa#2014
✅ Verification successful

Error: No shell scripts or web queries found


Switch to a Released Version for Dependency Stability

The current dependency in Package.swift uses an unreleased commit reference for functionality introduced in ably-cocoa#2014. This approach carries the following risks:

  • The commit might change if the PR is rebased.
  • The intended functionality may evolve before a stable release.
  • You won’t automatically benefit from future bug fixes.

Recommendation:

• Update the dependency to use a version constraint (e.g., from: "x.y.z") once the release incorporating ably-cocoa#2014 is available.
• If you must use the commit reference temporarily, document the reasoning and ensure there’s a plan to switch to a released version promptly.


22-23: Verify the referenced commit exists and contains the required functionality.

The dependency is pinned to a specific commit (58bbd149cbd92da6c29fad40b51ccdc3ca71404d) that should contain the new -[ARTRealtime createWrapperSDKProxyWithOptions:] method.

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Verify the commit exists and contains the required functionality

# Check if the commit exists in the repository
gh api repos/ably/ably-cocoa/commits/58bbd149cbd92da6c29fad40b51ccdc3ca71404d --jq '.sha'

# Look for the new method in the codebase at this commit
gh api repos/ably/ably-cocoa/git/trees/58bbd149cbd92da6c29fad40b51ccdc3ca71404d?recursive=1 | \
  jq -r '.tree[].path' | \
  grep -i "ARTRealtime" | \
  xargs -I {} gh api repos/ably/ably-cocoa/contents/{}?ref=58bbd149cbd92da6c29fad40b51ccdc3ca71404d | \
  jq -r '.content' | base64 -d | \
  grep -A 5 "createWrapperSDKProxyWithOptions"

Length of output: 582


I'll run a modified shell script that decodes file contents using Python rather than the missing base64 command. This script will:

  • Confirm the commit exists.
  • Iterate over files in the commit whose paths contain "ARTRealtime".
  • Decode their base64-encoded content with Python.
  • Search for "createWrapperSDKProxyWithOptions" and report if the method is found.

Let's run the following script:

Please re-run this script and share the output so we can verify if the required method is present in the commit.


🏁 Script executed:

#!/bin/bash
# Description: Verify the commit exists and check for the presence of the method "createWrapperSDKProxyWithOptions"
# using Python for the base64 decoding.

# Confirm commit exists
COMMIT=$(gh api repos/ably/ably-cocoa/commits/58bbd149cbd92da6c29fad40b51ccdc3ca71404d --jq '.sha')
echo "Commit found: ${COMMIT}"

# Retrieve tree and filter for files containing "ARTRealtime" in their path,
# then iterate over them.
gh api repos/ably/ably-cocoa/git/trees/58bbd149cbd92da6c29fad40b51ccdc3ca71404d?recursive=1 | \
  jq -r '.tree[].path' | grep -i "ARTRealtime" | while read filepath; do
    echo "Checking file: $filepath"
    # Get the file content and decode with Python
    gh api repos/ably/ably-cocoa/contents/"$filepath"?ref=58bbd149cbd92da6c29fad40b51ccdc3ca71404d --jq '.content' | \
      python3 -c "import sys, base64; print(base64.b64decode(sys.stdin.read().strip()).decode('utf-8'))" > tmp.txt
    if grep -q "createWrapperSDKProxyWithOptions" tmp.txt; then
        echo "Method found in: $filepath"
    else
        echo "Method not found in: $filepath"
    fi
done
rm -f tmp.txt

Length of output: 11311


Commit verification confirmed

The specified commit exists, and the new createWrapperSDKProxyWithOptions method is present in the expected files (e.g., Source/ARTRealtime.m and Source/include/Ably/ARTRealtime+WrapperSDKProxy.h). No issues were found with the dependency pin.

@lawrence-forooghian lawrence-forooghian marked this pull request as draft February 5, 2025 14:02
Copy link
Collaborator

@maratal maratal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

So that we can use the wrapper SDK proxy functionality.
Allows us to get rid of the required initializers and to allow the use
of `init()`.
There's no need for it to be actor-isolated. Not sure why the compiler
allowed it to satisfy the non-async requirement in the ChatClient
protocol, because when I tried to fetch it from an explicit
DefaultChatClient instance, it said I needed to write `await`.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
Tests/AblyChatTests/DefaultChatClientTests.swift (1)

29-36: Add Given/Then section comments for clarity.

While the test logic is correct, adding section comments would improve readability and maintain consistency with other tests.

 @Test
 func createsWrapperSDKProxyRealtimeClientWithAgents() throws {
+    // Given: An instance of DefaultChatClient
     let realtime = MockRealtime(createWrapperSDKProxyReturnValue: .init())
     let options = ClientOptions()
     _ = DefaultChatClient(realtime: realtime, clientOptions: options)

+    // Then: The wrapper SDK proxy is created with correct agent information
     #expect(realtime.createWrapperSDKProxyOptionsArgument?.agents == ["chat-swift": AblyChat.version])
 }
Sources/AblyChat/Dependencies.swift (1)

41-56: Consider safer options handling.

While the implementation works, the force cast could be replaced with a safer alternative.

-            // swiftlint:disable:next force_cast
-            opts.copy() as! ARTRealtimeChannelOptions
+            guard let copiedOpts = opts.copy() as? ARTRealtimeChannelOptions else {
+                // This should never happen as opts is already ARTRealtimeChannelOptions
+                return .init()
+            }
+            copiedOpts
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b894916 and 47752d3.

📒 Files selected for processing (16)
  • AblyChat.xcworkspace/xcshareddata/swiftpm/Package.resolved (1 hunks)
  • Example/AblyChatExample/ContentView.swift (1 hunks)
  • Example/AblyChatExample/Mocks/MockRealtime.swift (0 hunks)
  • Package.resolved (1 hunks)
  • Package.swift (1 hunks)
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift (1 hunks)
  • Sources/AblyChat/ChatClient.swift (2 hunks)
  • Sources/AblyChat/Dependencies.swift (2 hunks)
  • Sources/AblyChat/Room.swift (1 hunks)
  • Sources/AblyChat/Version.swift (1 hunks)
  • Tests/AblyChatTests/ChatAPITests.swift (7 hunks)
  • Tests/AblyChatTests/DefaultChatClientTests.swift (1 hunks)
  • Tests/AblyChatTests/DefaultMessagesTests.swift (6 hunks)
  • Tests/AblyChatTests/DefaultRoomTests.swift (11 hunks)
  • Tests/AblyChatTests/DefaultRoomsTests.swift (10 hunks)
  • Tests/AblyChatTests/Mocks/MockRealtime.swift (3 hunks)
💤 Files with no reviewable changes (1)
  • Example/AblyChatExample/Mocks/MockRealtime.swift
🚧 Files skipped from review as they are similar to previous changes (11)
  • Example/AblyChatExample/ContentView.swift
  • Tests/AblyChatTests/DefaultRoomTests.swift
  • Tests/AblyChatTests/DefaultMessagesTests.swift
  • Sources/AblyChat/Version.swift
  • Sources/AblyChat/AblyCocoaExtensions/Ably+Dependencies.swift
  • Sources/AblyChat/Room.swift
  • AblyChat.xcworkspace/xcshareddata/swiftpm/Package.resolved
  • Tests/AblyChatTests/ChatAPITests.swift
  • Sources/AblyChat/ChatClient.swift
  • Package.swift
  • Tests/AblyChatTests/DefaultRoomsTests.swift
🔇 Additional comments (11)
Package.resolved (2)

2-2: LGTM! Dependency update aligns with PR objectives.

The update to ably-cocoa v1.2.38 and the specific commit containing the wrapper SDK proxy functionality looks correct.

Let's verify the version compatibility and commit contents:

Also applies to: 9-9, 10-10

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Verify the ably-cocoa dependency version and commit contents

# Check if the commit exists and contains the wrapper SDK proxy functionality
curl -s -H "Accept: application/vnd.github.v3+json" \
  "https://api.github.com/repos/ably/ably-cocoa/commits/11f67876d3f2070ac976f639c4cc959d2995e1ca" | \
  jq -r '.commit.message'

# Check the version tag
curl -s -H "Accept: application/vnd.github.v3+json" \
  "https://api.github.com/repos/ably/ably-cocoa/git/refs/tags/1.2.38"

Length of output: 743


Dependency Update Verified for ably-cocoa v1.2.38

The commit message confirms the release (Merge pull request #2027 … Release version 1.2.38) and the tag lookup corroborates that the commit hash matches the updated version. The changes in Package.resolved (originHash, revision, and version bump) align with the intended dependency update and the new wrapper SDK proxy functionality.


2-2: Verify wrapper SDK proxy implementation.

Since this update is specifically for implementing the wrapper SDK proxy tracking feature, let's verify the implementation exists in the referenced commit.

Also applies to: 9-9, 10-10

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Verify the wrapper SDK proxy implementation in the specified commit

# Clone only the specific commit to check for the implementation
git clone --quiet --depth 1 --branch 1.2.38 https://github.com/ably/ably-cocoa.git
cd ably-cocoa

# Search for the wrapper SDK proxy implementation
rg -l "createWrapperSDKProxyWithOptions"

Length of output: 854


Wrapper SDK Proxy Implementation Verified

The implementation is present in the commit. The search for createWrapperSDKProxyWithOptions found its occurrence in:

  • Source/ARTRealtime.m
  • Source/include/Ably/ARTRealtime+WrapperSDKProxy.h

This confirms that the wrapper SDK proxy feature has been implemented as expected.

Tests/AblyChatTests/DefaultChatClientTests.swift (3)

8-11: LGTM! Initialization updated to use wrapper SDK proxy.

The initialization has been correctly updated to use the new wrapper SDK proxy functionality.


18-27: LGTM! Good test coverage for realtime property.

The test effectively verifies that the realtime property returns the original client instance rather than the proxy client.


41-47: LGTM! Test updated to verify proxy client usage.

The test has been correctly updated to verify that DefaultRooms uses the wrapper SDK proxy client.

Sources/AblyChat/Dependencies.swift (2)

6-10: LGTM! Well-designed protocol for wrapper SDK proxy support.

The protocol design effectively supports wrapper SDK proxy creation while maintaining type safety through associated types.


12-14: LGTM! Protocol inheritance updated appropriately.

The protocol now correctly extends ARTRealtimeInstanceMethodsProtocol to support wrapper SDK proxy functionality.

Tests/AblyChatTests/Mocks/MockRealtime.swift (4)

6-16: LGTM! Thread-safe implementation of SuppliedRealtimeClientProtocol.

The implementation correctly handles thread safety for proxy options and properly implements the new protocol.


26-36: LGTM! Initializer updated with backward compatibility.

The initializer has been correctly updated to support wrapper SDK proxy while maintaining backward compatibility.


81-92: LGTM! Thread-safe implementation of createWrapperSDKProxy.

The implementation correctly handles proxy creation with proper thread safety and error handling.


93-99: LGTM! Thread-safe access to proxy options.

The property implementation correctly provides synchronized access to the proxy options.

@lawrence-forooghian lawrence-forooghian merged commit 46c0e1f into main Feb 10, 2025
17 checks passed
@lawrence-forooghian lawrence-forooghian deleted the use-wrapper-sdk-proxy branch February 10, 2025 13:05
lawrence-forooghian added a commit to ably/specification that referenced this pull request Feb 11, 2025
This implements the API agreed in ADR-117 [1], to allow us to track usage of a
"modern wrapper SDK" (the term used in that ADR to refer to a wrapper SDK which
accepts an already-instantiated core SDK client). We will use it to track usage
of the Chat SDK.

The functionality described here has already been partially implemented in
ably-cocoa [2] and is being used by ably-chat-swift [3].

I found it quite hard to write a spec for this, and the language might still be
both too vague and too convoluted. I'm putting this up for review as a first
attempt in order not to end up getting stuck trying to write something perfect.

[1] https://ably.atlassian.net/wiki/spaces/ENG/pages/3413016589/ADR-117+Tracking+wrapper+SDK+usage+continued
[2] ably/ably-cocoa#2014
[3] ably/ably-chat-swift#211
lawrence-forooghian added a commit to ably/specification that referenced this pull request Feb 12, 2025
This specifies the API agreed in ADR-117 [1], to allow us to track usage of a
"modern wrapper SDK" (the term used in that ADR to refer to a wrapper SDK which
accepts an already-instantiated core SDK client). We will use it to track usage
of the Chat SDK.

The functionality described here has already been partially implemented in
ably-cocoa [2] and is being used by ably-chat-swift [3].

I found it quite hard to write a spec for this, and the language might still be
both too vague and too convoluted. I'm putting this up for review as a first
attempt in order not to end up getting stuck trying to write something perfect.

[1] https://ably.atlassian.net/wiki/spaces/ENG/pages/3413016589/ADR-117+Tracking+wrapper+SDK+usage+continued
[2] ably/ably-cocoa#2014
[3] ably/ably-chat-swift#211
lawrence-forooghian added a commit to ably/specification that referenced this pull request Feb 12, 2025
This specifies the API agreed in ADR-117 [1], to allow us to track usage of a
"modern wrapper SDK" (the term used in that ADR to refer to a wrapper SDK which
accepts an already-instantiated core SDK client). We will use it to track usage
of the Chat SDK.

The functionality described here has already been partially implemented in
ably-cocoa [2] and is being used by ably-chat-swift [3].

I found it quite hard to write a spec for this, and the language might still be
both too vague and too convoluted. I'm putting this up for review as a first
attempt in order not to end up getting stuck trying to write something perfect.

[1] https://ably.atlassian.net/wiki/spaces/ENG/pages/3413016589/ADR-117+Tracking+wrapper+SDK+usage+continued
[2] ably/ably-cocoa#2014
[3] ably/ably-chat-swift#211
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants