Skip to content

[ECO-5587, ECO-5589] Add missing documentation for public API#462

Open
maratal wants to merge 5 commits intomainfrom
377-388-docstrings
Open

[ECO-5587, ECO-5589] Add missing documentation for public API#462
maratal wants to merge 5 commits intomainfrom
377-388-docstrings

Conversation

@maratal
Copy link
Copy Markdown
Collaborator

@maratal maratal commented Oct 26, 2025

Closes #377, #388

Summary by CodeRabbit

  • New Features

    • AsyncSequence-based subscribe variants for messages, presence, typing, occupancy, and reactions.
    • New message update APIs to apply reaction summaries and incoming message events.
    • Client-specific reaction query and status-subscription off() for cleanup.
    • Several explicit public initializers for event and member types.
  • Documentation

    • Extensive public API documentation added and clarified across the SDK.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 26, 2025

Walkthrough

This PR primarily adds missing documentation across public APIs, replaces SwiftLint missing_docs disables with doc comments, and introduces several small public API additions: message update helpers, AsyncSequence-based subscribe overloads (Messages, Presence, Typing, MessageReactions, Presence), and a few explicit public initializers.

Changes

Cohort / File(s) Summary
Enums & literal docs
Sources/AblyChat/BufferingPolicy.swift, Sources/AblyChat/JSONValue.swift, Sources/AblyChat/Headers.swift, Sources/AblyChat/Events.swift
Added Swift doc comments for enum cases and literal initializers; removed inline SwiftLint missing_docs pragmas. No behavior or signature changes.
Core client & connection docs
Sources/AblyChat/ChatClient.swift, Sources/AblyChat/Connection.swift
Expanded documentation for protocol associated types, properties, initializers, and connection status/error docs. No signature changes.
Message logic & reactions
Sources/AblyChat/Message.swift, Sources/AblyChat/MessageReaction.swift, Sources/AblyChat/MessageReactions.swift, Sources/AblyChat/RoomReaction.swift
Added two Message extension methods: with(_ summaryEvent: MessageReactionSummaryEvent) throws -> Self and with(_ messageEvent: ChatMessageEvent) throws -> Self with validation and reaction-copy semantics; many doc improvements for reactions and reaction-related types. RoomReaction.name doc updated.
Async subscribe additions (Messages/Presence/Typing/Reactions/Presence)
Sources/AblyChat/Messages.swift, Sources/AblyChat/Presence.swift, Sources/AblyChat/Typing.swift, Sources/AblyChat/MessageReactions.swift
Added AsyncSequence-based subscribe overloads accepting BufferingPolicy and default unbounded wrappers for messages, presence, typing, and reactions. Sequences ensure unsubscription on termination.
Subscription & AsyncSequence docs
Sources/AblyChat/Subscription.swift, Sources/AblyChat/SubscriptionAsyncSequence.swift
Added StatusSubscription.off(); enriched MessageSubscriptionResponse docs and historyBeforeSubscribe explanation; documented SubscriptionAsyncSequence mock init and iterator.
Presence & Occupancy initializers
Sources/AblyChat/Occupancy.swift, Sources/AblyChat/Presence.swift
Added public init(type: OccupancyEventType, occupancy: OccupancyData) and public init(...) for PresenceMember; added Presence.subscribe(bufferingPolicy:) + convenience subscribe(); expanded docs.
Room & Rooms docs + options
Sources/AblyChat/Room.swift, Sources/AblyChat/Rooms.swift, Sources/AblyChat/RoomOptions.swift, Sources/AblyChat/RoomReactions.swift
Extensive documentation additions for Room/Rooms and option inits; added init(type: RoomReactionEventType = .reaction, reaction: RoomReaction) to RoomReactionEvent.
Logging, PaginatedResult & utilities
Sources/AblyChat/Logging.swift, Sources/AblyChat/PaginatedResult.swift
Replaced missing_docs suppressions with doc comments for LogHandler/LogLevel and PaginatedResult members.
Misc. docs & small API additions
Sources/AblyChat/Headers.swift, Sources/AblyChat/Subscription.swift, Sources/AblyChat/SubscriptionAsyncSequence.swift
Additional doc blocks and small API surface tweaks (e.g., StatusSubscription.off()); no breaking signature changes beyond listed initializers/methods.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller
    participant Presence as Presence
    participant Seq as SubscriptionAsyncSequence
    Note over Caller,Presence: New API: subscribe(bufferingPolicy:)
    Caller->>Presence: subscribe(bufferingPolicy: policy)
    Presence->>Seq: create sequence bound to callback + policy
    Seq-->>Caller: SubscriptionAsyncSequence<PresenceEvent>
    alt sequence terminates
        Seq->>Presence: unsubscribe on termination
    end
Loading
sequenceDiagram
    participant Updater as Updater
    participant Msg as Message
    participant Event as ChatMessageEvent
    Note over Updater,Msg: Message.with(_ messageEvent:)
    Updater->>Msg: with(messageEvent)
    alt event.type == .created
        Msg-->>Updater: throw ErrorInfo (created event rejected)
    else id mismatch
        Msg-->>Updater: throw ErrorInfo (identity mismatch)
    else event.serial <= msg.serial
        Msg-->>Updater: return original (no-op)
    else newer event
        Msg->>Msg: copy reactions, apply update fields
        Msg-->>Updater: return updated message
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Mostly documentation changes; several new public APIs and non-trivial message-update logic.
  • Pay special attention to:
    • Sources/AblyChat/Message.swift — validation, serial/version comparisons, reaction deep-copy semantics, and thrown errors.
    • Sources/AblyChat/Messages.swift, Sources/AblyChat/Presence.swift, Sources/AblyChat/Typing.swift, Sources/AblyChat/MessageReactions.swift — AsyncSequence wiring, bufferingPolicy handling, and unsubscribe-on-termination behavior.
    • Sources/AblyChat/Occupancy.swift, Sources/AblyChat/RoomReactions.swift — new explicit initializers and default parameter behavior.

Poem

🐰
I hopped through docs both near and far,
Replaced the lint with words that spar,
Subscribes now buffer, messages mend,
Init paths opened, little hops blend,
A tidy hop — the API's a star. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: adding missing documentation for the public API across multiple files. It is specific, directly related to the changeset, and concise.
Linked Issues check ✅ Passed The PR successfully addresses both linked issues: (1) removes SwiftLint missing_docs disablers and adds documentation across all public API entities [#377, ECO-5587], and (2) updates documentation to align with JavaScript implementation ECO-5589.
Out of Scope Changes check ✅ Passed Minor scope expansion detected: new public APIs added (methods, initializers, typealias) beyond documentation-only changes, but these appear intentional and support the documentation objectives. All changes directly support the core documentation goals.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 377-388-docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot temporarily deployed to staging/pull/462/AblyChat October 26, 2025 22:28 Inactive
Copy link
Copy Markdown

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Sources/AblyChat/Connection.swift (1)

152-154: Fix time unit: TimeInterval is seconds, not milliseconds.
The doc states “milliseconds” but retryIn: TimeInterval? is in seconds. Update wording or change the type if milliseconds are intended.

Apply this diff to fix the doc:

-    /**
-     * The time in milliseconds that the client will wait before attempting to reconnect.
-     */
+    /**
+     * The time in seconds (TimeInterval) that the client will wait before attempting to reconnect.
+     */
🧹 Nitpick comments (1)
Sources/AblyChat/JSONValue.swift (1)

103-142: Solid initializer docs; optional note on numeric precision.
Docs look good. Optionally add that number stores IEEE‑754 Double, which may round large integers.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8ed5e8b and 81cd251.

📒 Files selected for processing (21)
  • Sources/AblyChat/BufferingPolicy.swift (1 hunks)
  • Sources/AblyChat/ChatClient.swift (5 hunks)
  • Sources/AblyChat/Connection.swift (1 hunks)
  • Sources/AblyChat/Events.swift (3 hunks)
  • Sources/AblyChat/Headers.swift (2 hunks)
  • Sources/AblyChat/JSONValue.swift (2 hunks)
  • Sources/AblyChat/Logging.swift (2 hunks)
  • Sources/AblyChat/Message.swift (1 hunks)
  • Sources/AblyChat/MessageReaction.swift (2 hunks)
  • Sources/AblyChat/MessageReactions.swift (1 hunks)
  • Sources/AblyChat/Messages.swift (11 hunks)
  • Sources/AblyChat/Occupancy.swift (2 hunks)
  • Sources/AblyChat/PaginatedResult.swift (1 hunks)
  • Sources/AblyChat/Presence.swift (6 hunks)
  • Sources/AblyChat/Room.swift (2 hunks)
  • Sources/AblyChat/RoomOptions.swift (5 hunks)
  • Sources/AblyChat/RoomReactions.swift (2 hunks)
  • Sources/AblyChat/Rooms.swift (2 hunks)
  • Sources/AblyChat/Subscription.swift (1 hunks)
  • Sources/AblyChat/SubscriptionAsyncSequence.swift (3 hunks)
  • Sources/AblyChat/Typing.swift (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.swift

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.swift: Use protocol-based design; expose SDK functionality via protocols and prefer associated types with opaque return types (some Protocol) instead of existentials (any Protocol)
Isolate all mutable state to the main actor; mark stateful objects with @mainactor
Public API must use typed throws with ErrorInfo; use InternalError internally and convert at the public API boundary
For public structs emitted by the API, provide an explicit public memberwise initializer
When using AsyncSequence operators in @mainactor contexts, mark operator closures as @sendable
Task, CheckedContinuation, and AsyncThrowingStream do not support typed errors; use Result and call .get() to surface typed errors
Do not use Dictionary.mapValues for typed throws; use ablyChat_mapValuesWithTypedThrow instead
When the compiler struggles with typed throws, explicitly declare the error type on do blocks (e.g., do throws(InternalError))
Specify error types in closures using the throws(ErrorType) syntax (e.g., try items.map { jsonValue throws(InternalError) in ... })
Mark any test-only APIs with testsOnly_ prefix and wrap them in #if DEBUG

Files:

  • Sources/AblyChat/RoomOptions.swift
  • Sources/AblyChat/JSONValue.swift
  • Sources/AblyChat/Events.swift
  • Sources/AblyChat/Message.swift
  • Sources/AblyChat/RoomReactions.swift
  • Sources/AblyChat/Messages.swift
  • Sources/AblyChat/Room.swift
  • Sources/AblyChat/MessageReaction.swift
  • Sources/AblyChat/Headers.swift
  • Sources/AblyChat/PaginatedResult.swift
  • Sources/AblyChat/Typing.swift
  • Sources/AblyChat/Rooms.swift
  • Sources/AblyChat/Occupancy.swift
  • Sources/AblyChat/BufferingPolicy.swift
  • Sources/AblyChat/Presence.swift
  • Sources/AblyChat/Connection.swift
  • Sources/AblyChat/Logging.swift
  • Sources/AblyChat/SubscriptionAsyncSequence.swift
  • Sources/AblyChat/Subscription.swift
  • Sources/AblyChat/ChatClient.swift
  • Sources/AblyChat/MessageReactions.swift
🧬 Code graph analysis (5)
Sources/AblyChat/Messages.swift (4)
Sources/AblyChat/Subscription.swift (1)
  • historyBeforeSubscribe (94-104)
Example/AblyChatExample/Mocks/MockSubscriptionStorage.swift (1)
  • historyBeforeSubscribe (211-213)
Sources/AblyChat/PaginatedResult.swift (1)
  • next (61-66)
Sources/AblyChat/SubscriptionAsyncSequence.swift (3)
  • next (44-46)
  • next (125-136)
  • next (146-148)
Sources/AblyChat/Room.swift (5)
Sources/AblyChat/AblyCocoaExtensions/InternalAblyCocoaTypes.swift (1)
  • attach (425-439)
Tests/AblyChatTests/Mocks/MockRoom.swift (1)
  • attach (47-49)
Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift (1)
  • attach (94-102)
Sources/AblyChat/RoomLifecycleManager.swift (2)
  • performAttachOperation (370-372)
  • performAttachOperation (374-376)
Tests/AblyChatTests/Mocks/MockRoomLifecycleManager.swift (1)
  • performAttachOperation (25-31)
Sources/AblyChat/PaginatedResult.swift (4)
Sources/AblyChat/AblyCocoaExtensions/InternalAblyCocoaTypes.swift (2)
  • next (209-225)
  • first (227-243)
Tests/AblyChatTests/Mocks/MockHTTPPaginatedResponse.swift (2)
  • next (26-28)
  • first (30-32)
Example/AblyChatExample/Mocks/Misc.swift (2)
  • next (34-34)
  • first (36-36)
Tests/AblyChatTests/MessageSubscriptionResponseAsyncSequenceTests.swift (2)
  • next (14-14)
  • first (16-16)
Sources/AblyChat/Typing.swift (2)
Sources/AblyChat/DefaultTyping.swift (1)
  • keystroke (117-132)
Example/AblyChatExample/Mocks/MockClients.swift (1)
  • keystroke (419-427)
Sources/AblyChat/SubscriptionAsyncSequence.swift (1)
Sources/AblyChat/Messages.swift (1)
  • next (491-493)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Xcode, tvOS (Xcode 26.0)
  • GitHub Check: Example app, tvOS (Xcode 26.0)
  • GitHub Check: Example app, iOS (Xcode 26.0)
  • GitHub Check: Xcode, release configuration, iOS (Xcode 26.0)
  • GitHub Check: Xcode, release configuration, macOS (Xcode 26.0)
  • GitHub Check: Xcode, release configuration, tvOS (Xcode 26.0)
  • GitHub Check: Example app, macOS (Xcode 26.0)
  • GitHub Check: Xcode, iOS (Xcode 26.0)
  • GitHub Check: Xcode, macOS (Xcode 26.0)
  • GitHub Check: SPM, release configuration (Xcode 26.0)
  • GitHub Check: SPM (Xcode 26.0)
  • GitHub Check: check-documentation
🔇 Additional comments (53)
Sources/AblyChat/Subscription.swift (1)

37-38: LGTM: Doc for HistoryResult associated type is clear and accurate.
No action needed.

Sources/AblyChat/Connection.swift (1)

8-9: LGTM: StatusSubscription associated type docs.
Reads well and aligns with the protocol.

Sources/AblyChat/JSONValue.swift (1)

32-43: LGTM: Enum case documentation is clear and consistent.
No changes needed.

Sources/AblyChat/MessageReaction.swift (2)

140-147: LGTM: ClientIDList initializer docs.
Clear purpose and mock-usage note. No changes needed.


181-190: LGTM: ClientIDCounts initializer docs.
Consistent and helpful. No changes needed.

Sources/AblyChat/Events.swift (3)

11-18: LGTM: ChatMessageAction case docs.
Concise and accurate.


88-91: LGTM: TypingEventType case docs.
Clear semantics.


105-106: LGTM: TypingSetEventType documentation.
Looks good.

Sources/AblyChat/Logging.swift (1)

3-5: LGTM! Clear and concise documentation.

The documentation added for LogHandler and LogLevel cases is well-written and provides appropriate context for users of the public API.

Also applies to: 39-48

Sources/AblyChat/PaginatedResult.swift (1)

3-30: LGTM! Comprehensive protocol documentation.

The documentation clearly describes the PaginatedResult protocol and all its members, making the pagination API easy to understand and use.

Sources/AblyChat/RoomReactions.swift (2)

10-10: LGTM! Documentation additions are clear.

The documentation for the associatedtype and event-related types appropriately describes their purpose in the public API.

Also applies to: 112-116, 118-123


128-131: Public initializer added per coding guidelines.

The explicit public memberwise initializer follows the coding guideline for public structs. The default value for type makes sense since RoomReactionEventType currently only has one case (.reaction).

Sources/AblyChat/SubscriptionAsyncSequence.swift (2)

62-67: LGTM! Improved mock initializer documentation.

The concise documentation clearly explains the purpose of the mock initializer and appropriately warns that passing a throwing AsyncSequence is a programmer error.


119-119: LGTM! Standard AsyncSequence documentation.

The documentation for AsyncIterator and its methods follows Swift conventions and clearly describes their behavior.

Also applies to: 145-146, 151-151

Sources/AblyChat/Headers.swift (1)

5-12: LGTM! Clear documentation for HeadersValue.

The documentation for enum cases and literal conformance initializers appropriately describes their purpose and usage.

Also applies to: 54-55, 61-62, 68-69, 75-76

Sources/AblyChat/BufferingPolicy.swift (1)

6-11: LGTM! Clear BufferingPolicy documentation.

The documentation concisely describes each buffering strategy, making it easy for users to choose the appropriate policy.

Sources/AblyChat/MessageReactions.swift (1)

10-10: LGTM! Consistent associatedtype documentation.

The documentation for the Subscription associatedtype follows the same pattern used in other protocols throughout the PR.

Sources/AblyChat/RoomOptions.swift (1)

27-35: LGTM! Comprehensive initializer documentation.

The documentation for all option struct initializers is well-structured and consistent, clearly describing the purpose and parameters of each initializer.

Also applies to: 57-62, 92-98, 121-126, 145-150

Sources/AblyChat/Messages.swift (10)

11-16: LGTM! Clear documentation for associated types.

The documentation concisely describes each associated type's purpose, improving API discoverability.


118-118: LGTM! Extension documentation added.

The documentation clearly describes the extension's purpose.


197-209: LGTM! Comprehensive initializer documentation.

The documentation clearly describes all parameters and follows the coding guideline for explicit public memberwise initializers.


239-250: LGTM! Initializer documentation added.

The documentation is clear and follows Swift documentation conventions.


256-263: LGTM! Enum case documentation added.

Clear and concise descriptions for both enum cases.


300-314: LGTM! Comprehensive initializer documentation.

The documentation clearly describes all parameters.


346-358: LGTM! Initializer documentation added.

Clear documentation for all parameters.


403-408: LGTM! Enum case documentation added.

Clear descriptions for all event types.


411-416: LGTM! Struct and property documentation added.

Clear and concise documentation.


443-444: LGTM! AsyncSequence documentation comprehensive.

All components of the AsyncSequence implementation are clearly documented, including the mock initializer for testing.

Also applies to: 460-463, 477-478, 482-483, 490-491, 496-497

Sources/AblyChat/Typing.swift (5)

11-11: LGTM! Associated type documentation added.

Clear description of the subscription type.


33-46: LGTM! Comprehensive behavioral documentation.

The expanded documentation clearly explains throttling, serialization guarantees, and no-op behavior for intermediate calls. This provides essential information for developers using the API.


50-62: LGTM! Consistent and comprehensive documentation.

The documentation mirrors the keystroke() method's structure and clearly explains the serialization guarantees and behavior, ensuring consistency across the API.


99-114: LGTM! Struct and property documentation added.

Clear descriptions for all properties in TypingSetEvent.


126-131: LGTM! Nested struct documentation added.

Clear descriptions for the Change struct properties.

Sources/AblyChat/Rooms.swift (2)

8-11: LGTM! Associated type documentation added.

Clear descriptions for both associated types.


57-60: LGTM! Extension and convenience method documented.

Clear descriptions for both the extension and the convenience method.

Sources/AblyChat/ChatClient.swift (5)

3-15: LGTM! Protocol and associated type documentation added.

The documentation clearly explains the protocol's purpose for testing/mocking and describes all associated types.


75-113: LGTM! Property documentation comprehensive.

All properties are clearly documented with consistent formatting.


118-125: LGTM! Enhanced initializer documentation.

The Important note about clientId requirement is valuable information for developers.


154-162: LGTM! Property documentation with important usage note.

The Important note about token-based authentication is valuable for developers.


186-192: LGTM! Initializer documentation added.

Clear parameter documentation for ChatClientOptions.

Sources/AblyChat/Message.swift (3)

212-212: LGTM! Extension documentation added.

Clear description of the extension's purpose.


214-233: LGTM! New public API method with proper validation.

The method correctly:

  • Uses typed throws with ErrorInfo (per coding guidelines)
  • Validates message serial matches event serial before applying changes
  • Follows immutable pattern by returning a new instance
  • Provides clear documentation

235-267: LGTM! New public API method with comprehensive validation.

The method correctly:

  • Uses typed throws with ErrorInfo (per coding guidelines)
  • Rejects created events (which cannot be applied to existing messages)
  • Validates message serial matches
  • Uses lexicographic comparison per spec (CHA-M10e)
  • Returns unchanged message if event is older (optimization)
  • Preserves reactions when creating updated message
Sources/AblyChat/Room.swift (2)

8-23: LGTM! Comprehensive associated type documentation.

All seven associated types are clearly documented.


376-377: LGTM! Method documentation references added.

The "See" references to protocol methods are a good practice for implementation documentation.

Also applies to: 381-382

Sources/AblyChat/Occupancy.swift (3)

11-11: LGTM! Associated type documentation added.

Clear description of the subscription type.


101-104: LGTM! Enum and case documentation added.

Clear descriptions for the occupancy event type.


107-120: LGTM! Explicit public initializer added per coding guidelines.

The explicit memberwise initializer follows the coding guideline for public structs and is properly documented for testing/mocking purposes.

Sources/AblyChat/Presence.swift (5)

3-3: LGTM! Typealias and associated type documentation added.

Clear descriptions for both types.

Also applies to: 14-14


114-146: LGTM! New AsyncSequence convenience methods follow established patterns.

The new subscribe methods:

  • Follow the same pattern as Messages.swift
  • Properly create and manage SubscriptionAsyncSequence
  • Include termination handlers for cleanup
  • Are comprehensively documented with important usage notes

149-153: LGTM! Enhanced struct documentation with important behavioral details.

The documentation clearly explains the uniqueness semantics of presence members and the multi-device scenario, which is valuable for developers.


185-188: LGTM! Property documentation added.

Clear description of the updatedAt property.


281-293: LGTM! Comprehensive initializer documentation.

Clear parameter documentation for all PresenceParams initializer parameters.

@github-actions github-actions bot temporarily deployed to staging/pull/462/AblyChat October 26, 2025 22:33 Inactive
@maratal maratal changed the title [ECO-5587] Add missing documentation for public API [ECO-5587, ECO-5589] Add missing documentation for public API Oct 27, 2025
case deleted
}

/// Event emitted by message subscriptions, containing the type and the message.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

shouldn't this be in the previous commit given that it's an update?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

now copied from js

@lawrence-forooghian
Copy link
Copy Markdown
Collaborator

@maratal please can you:

  • incorporate 648d306 into whichever commit introduced the linter failures
  • for the commits that mention some docstrings taken from JS, mention which JS commit they're taken from?

@lawrence-forooghian
Copy link
Copy Markdown
Collaborator

lawrence-forooghian commented Nov 6, 2025

Am I correct in understanding that the changes of 56f8777 contain all the JS changes between JS commit 69ea478 (which is mentioned in 3d9c0a9) and the JS version that you based these new docstrings on? If so, I'm surprised there isn't more.

@github-actions github-actions bot temporarily deployed to staging/pull/462/AblyChat November 10, 2025 01:53 Inactive
Copy link
Copy Markdown

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Sources/AblyChat/Messages.swift (1)

357-360: Fix return doc to reference async sequence type.

The return description links to MessageSubscription, but this API actually returns MessageSubscriptionResponseAsyncSequence. Using the wrong symbol breaks doc linking and misleads readers—please update the doc to reference the concrete return type.

Apply this diff to fix the docstring:

-     * - Returns: A ``MessageSubscription`` that can be used to iterate through new messages.
+     * - Returns: A ``MessageSubscriptionResponseAsyncSequence`` that can be used to iterate through new messages.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 648d306 and 43f405b.

📒 Files selected for processing (22)
  • Sources/AblyChat/BufferingPolicy.swift (1 hunks)
  • Sources/AblyChat/ChatClient.swift (5 hunks)
  • Sources/AblyChat/Connection.swift (1 hunks)
  • Sources/AblyChat/Events.swift (3 hunks)
  • Sources/AblyChat/Headers.swift (2 hunks)
  • Sources/AblyChat/JSONValue.swift (2 hunks)
  • Sources/AblyChat/Logging.swift (2 hunks)
  • Sources/AblyChat/Message.swift (6 hunks)
  • Sources/AblyChat/MessageReaction.swift (4 hunks)
  • Sources/AblyChat/MessageReactions.swift (3 hunks)
  • Sources/AblyChat/Messages.swift (9 hunks)
  • Sources/AblyChat/Occupancy.swift (2 hunks)
  • Sources/AblyChat/PaginatedResult.swift (1 hunks)
  • Sources/AblyChat/Presence.swift (7 hunks)
  • Sources/AblyChat/Room.swift (2 hunks)
  • Sources/AblyChat/RoomOptions.swift (5 hunks)
  • Sources/AblyChat/RoomReaction.swift (2 hunks)
  • Sources/AblyChat/RoomReactions.swift (3 hunks)
  • Sources/AblyChat/Rooms.swift (2 hunks)
  • Sources/AblyChat/Subscription.swift (2 hunks)
  • Sources/AblyChat/SubscriptionAsyncSequence.swift (3 hunks)
  • Sources/AblyChat/Typing.swift (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • Sources/AblyChat/RoomReaction.swift
🚧 Files skipped from review as they are similar to previous changes (7)
  • Sources/AblyChat/BufferingPolicy.swift
  • Sources/AblyChat/RoomOptions.swift
  • Sources/AblyChat/MessageReaction.swift
  • Sources/AblyChat/PaginatedResult.swift
  • Sources/AblyChat/ChatClient.swift
  • Sources/AblyChat/Rooms.swift
  • Sources/AblyChat/RoomReactions.swift
🧰 Additional context used
📓 Path-based instructions (1)
**/*.swift

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.swift: Use protocol-based design; expose SDK functionality via protocols and prefer associated types with opaque return types (some Protocol) instead of existentials (any Protocol)
Isolate all mutable state to the main actor; mark stateful objects with @mainactor
Public API must use typed throws with ErrorInfo; use InternalError internally and convert at the public API boundary
For public structs emitted by the API, provide an explicit public memberwise initializer
When using AsyncSequence operators in @mainactor contexts, mark operator closures as @sendable
Task, CheckedContinuation, and AsyncThrowingStream do not support typed errors; use Result and call .get() to surface typed errors
Do not use Dictionary.mapValues for typed throws; use ablyChat_mapValuesWithTypedThrow instead
When the compiler struggles with typed throws, explicitly declare the error type on do blocks (e.g., do throws(InternalError))
Specify error types in closures using the throws(ErrorType) syntax (e.g., try items.map { jsonValue throws(InternalError) in ... })
Mark any test-only APIs with testsOnly_ prefix and wrap them in #if DEBUG

Files:

  • Sources/AblyChat/SubscriptionAsyncSequence.swift
  • Sources/AblyChat/Events.swift
  • Sources/AblyChat/JSONValue.swift
  • Sources/AblyChat/Connection.swift
  • Sources/AblyChat/Presence.swift
  • Sources/AblyChat/Headers.swift
  • Sources/AblyChat/Occupancy.swift
  • Sources/AblyChat/Subscription.swift
  • Sources/AblyChat/Typing.swift
  • Sources/AblyChat/Messages.swift
  • Sources/AblyChat/Message.swift
  • Sources/AblyChat/Room.swift
  • Sources/AblyChat/MessageReactions.swift
  • Sources/AblyChat/Logging.swift
🧬 Code graph analysis (7)
Sources/AblyChat/SubscriptionAsyncSequence.swift (1)
Sources/AblyChat/Messages.swift (1)
  • next (749-751)
Sources/AblyChat/Presence.swift (3)
Sources/AblyChat/AblyCocoaExtensions/InternalAblyCocoaTypes.swift (6)
  • get (299-315)
  • get (317-333)
  • get (521-524)
  • enter (351-365)
  • update (367-381)
  • leave (335-349)
Sources/AblyChat/DefaultPresence.swift (12)
  • get (18-37)
  • get (39-58)
  • isUserPresent (61-81)
  • enter (83-85)
  • enter (87-89)
  • enter (92-109)
  • update (111-113)
  • update (115-117)
  • update (120-137)
  • leave (139-141)
  • leave (143-145)
  • leave (148-165)
Example/AblyChatExample/Mocks/MockClients.swift (16)
  • get (29-36)
  • get (223-238)
  • get (471-481)
  • get (483-493)
  • get (600-602)
  • isUserPresent (495-497)
  • enter (499-501)
  • enter (503-505)
  • enter (507-521)
  • update (187-205)
  • update (523-525)
  • update (527-529)
  • update (531-545)
  • leave (547-549)
  • leave (551-553)
  • leave (555-569)
Sources/AblyChat/Occupancy.swift (2)
Sources/AblyChat/DefaultOccupancy.swift (2)
  • subscribe (20-58)
  • get (61-64)
Example/AblyChatExample/Mocks/MockClients.swift (11)
  • subscribe (133-162)
  • subscribe (307-331)
  • subscribe (366-383)
  • subscribe (397-413)
  • subscribe (571-573)
  • subscribe (587-598)
  • get (29-36)
  • get (223-238)
  • get (471-481)
  • get (483-493)
  • get (600-602)
Sources/AblyChat/Typing.swift (2)
Sources/AblyChat/DefaultTyping.swift (2)
  • subscribe (35-109)
  • keystroke (117-132)
Example/AblyChatExample/Mocks/MockClients.swift (7)
  • subscribe (133-162)
  • subscribe (307-331)
  • subscribe (366-383)
  • subscribe (397-413)
  • subscribe (571-573)
  • subscribe (587-598)
  • keystroke (419-427)
Sources/AblyChat/Messages.swift (3)
Sources/AblyChat/DefaultMessages.swift (6)
  • subscribe (37-115)
  • history (118-120)
  • send (122-124)
  • update (126-128)
  • delete (130-132)
  • get (135-137)
Sources/AblyChat/Subscription.swift (1)
  • historyBeforeSubscribe (182-192)
Sources/AblyChat/SubscriptionAsyncSequence.swift (3)
  • next (44-46)
  • next (130-141)
  • next (151-153)
Sources/AblyChat/Room.swift (3)
Tests/AblyChatTests/Mocks/MockRoom.swift (4)
  • onStatusChange (71-74)
  • onDiscontinuity (76-79)
  • attach (47-49)
  • detach (51-53)
Sources/AblyChat/RoomLifecycleManager.swift (3)
  • onDiscontinuity (222-225)
  • performAttachOperation (370-372)
  • performAttachOperation (374-376)
Sources/AblyChat/AblyCocoaExtensions/InternalAblyCocoaTypes.swift (2)
  • attach (425-439)
  • detach (441-455)
Sources/AblyChat/MessageReactions.swift (2)
Sources/AblyChat/DefaultMessageReactions.swift (4)
  • send (20-34)
  • delete (37-50)
  • subscribe (53-91)
  • subscribeRaw (94-140)
Example/AblyChatExample/Mocks/MockClients.swift (12)
  • send (168-185)
  • send (275-292)
  • send (353-364)
  • delete (207-221)
  • delete (294-305)
  • subscribe (133-162)
  • subscribe (307-331)
  • subscribe (366-383)
  • subscribe (397-413)
  • subscribe (571-573)
  • subscribe (587-598)
  • subscribeRaw (333-335)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Example app, macOS (Xcode 26.0)
  • GitHub Check: Xcode, iOS (Xcode 26.0)
  • GitHub Check: Xcode, release configuration, tvOS (Xcode 26.0)
  • GitHub Check: Xcode, release configuration, macOS (Xcode 26.0)
  • GitHub Check: Example app, tvOS (Xcode 26.0)
  • GitHub Check: Xcode, macOS (Xcode 26.0)
  • GitHub Check: Xcode, tvOS (Xcode 26.0)
  • GitHub Check: Example app, iOS (Xcode 26.0)
  • GitHub Check: Xcode, release configuration, iOS (Xcode 26.0)
  • GitHub Check: SPM, release configuration (Xcode 26.0)
  • GitHub Check: SPM (Xcode 26.0)
🔇 Additional comments (20)
Sources/AblyChat/Events.swift (4)

11-20: LGTM! Documentation is clear and consistent.

The documentation for messageUpdate and messageDelete follows the same pattern as the existing messageCreate case, maintaining consistency across the enum.


80-90: LGTM! Good practice to document internal enums.

While these are internal enums and not strictly required by the PR objectives, documenting them improves code maintainability and helps other developers understand their purpose.


92-104: LGTM! Public API documentation is clear.

The documentation for TypingEventType and its cases clearly describes when each event is triggered, fulfilling the PR objective of documenting the public API.


116-123: LGTM! Public API documentation is clear.

The documentation for TypingSetEventType and its setChanged case clearly describes the event's purpose, maintaining consistency with the documentation style used elsewhere in the file.

Sources/AblyChat/Typing.swift (6)

171-201: LGTM! AsyncSequence subscription pattern is consistent.

The implementation follows the standard pattern for providing AsyncSequence-based subscriptions, with proper termination handling to ensure unsubscribe is called when the sequence ends.


14-63: Excellent documentation with practical example.

The documentation clearly explains the behavior, requirements (room attachment), and provides a comprehensive usage example.


65-97: Clear and helpful documentation.

The documentation effectively explains the property's purpose and provides a practical usage example.


99-133: Comprehensive documentation with important behavioral notes.

The documentation clearly explains throttling, serialization, and state requirements, with a practical example.


135-168: Clear documentation for stop method.

The documentation effectively explains serialization behavior and state requirements with a practical example.


203-253: Well-documented event structures with proper public initializers.

The TypingSetEvent and nested Change struct are well-documented, and the public memberwise initializers are correctly provided as per coding guidelines.

Sources/AblyChat/Message.swift (5)

214-237: LGTM! Correct validation and reaction replacement.

The method properly validates that the summary event matches the message serial before applying the reactions, with appropriate error handling.


239-271: LGTM! Correct event application logic with proper validation.

The method correctly:

  • Rejects created events
  • Validates message identity
  • Returns the original for older/equal events (avoiding unnecessary copies)
  • Applies newer events while preserving reactions

15-15: Clear and accurate documentation.

The updated documentation correctly describes the type's purpose.


103-103: Improved comment clarity.

The updated comment accurately describes the copy method's behavior.


130-157: Well-documented MessageVersion structure.

The documentation clearly explains the purpose of MessageVersion and its fields, with accurate descriptions for deletion/update scenarios.

Sources/AblyChat/MessageReactions.swift (5)

309-368: LGTM! Consistent AsyncSequence subscription pattern.

The implementation follows the established pattern for both summary and raw event subscriptions, with proper termination handling.


370-397: Well-documented parameters with clear field ordering.

The field reordering (name before type) improves readability, and the explicit public initializer ensures API stability.


13-290: Excellent comprehensive documentation with practical examples.

The documentation for send, delete, subscribe, subscribeRaw, and clientReactions methods is thorough, clear, and includes helpful usage examples that demonstrate different scenarios.


292-306: Clear documentation for remaining clientReactions example.

The rest of the clientReactions documentation is well-written and helpful.


399-419: Well-documented deletion parameters.

The DeleteMessageReactionParams struct is clearly documented with accurate field descriptions.

Comment thread Sources/AblyChat/MessageReactions.swift Outdated
Comment thread Sources/AblyChat/Presence.swift Outdated
@maratal
Copy link
Copy Markdown
Collaborator Author

maratal commented Nov 10, 2025

Am I correct in understanding that the changes of 56f8777 contain all the JS changes between JS commit 69ea478 (which is mentioned in 3d9c0a9) and the JS version that you based these new docstrings on? If so, I'm surprised there isn't more.

No, I've picked the wrong commit, now it's from JS commit 9898d674

Copy link
Copy Markdown

@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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 43f405b and ff9b164.

📒 Files selected for processing (2)
  • Sources/AblyChat/MessageReactions.swift (3 hunks)
  • Sources/AblyChat/Presence.swift (7 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.swift

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.swift: Use protocol-based design; expose SDK functionality via protocols and prefer associated types with opaque return types (some Protocol) instead of existentials (any Protocol)
Isolate all mutable state to the main actor; mark stateful objects with @mainactor
Public API must use typed throws with ErrorInfo; use InternalError internally and convert at the public API boundary
For public structs emitted by the API, provide an explicit public memberwise initializer
When using AsyncSequence operators in @mainactor contexts, mark operator closures as @sendable
Task, CheckedContinuation, and AsyncThrowingStream do not support typed errors; use Result and call .get() to surface typed errors
Do not use Dictionary.mapValues for typed throws; use ablyChat_mapValuesWithTypedThrow instead
When the compiler struggles with typed throws, explicitly declare the error type on do blocks (e.g., do throws(InternalError))
Specify error types in closures using the throws(ErrorType) syntax (e.g., try items.map { jsonValue throws(InternalError) in ... })
Mark any test-only APIs with testsOnly_ prefix and wrap them in #if DEBUG

Files:

  • Sources/AblyChat/MessageReactions.swift
  • Sources/AblyChat/Presence.swift
🧬 Code graph analysis (2)
Sources/AblyChat/MessageReactions.swift (2)
Sources/AblyChat/DefaultMessageReactions.swift (4)
  • send (20-34)
  • delete (37-50)
  • subscribe (53-91)
  • subscribeRaw (94-140)
Example/AblyChatExample/Mocks/MockClients.swift (12)
  • send (168-185)
  • send (275-292)
  • send (353-364)
  • delete (207-221)
  • delete (294-305)
  • subscribe (133-162)
  • subscribe (307-331)
  • subscribe (366-383)
  • subscribe (397-413)
  • subscribe (571-573)
  • subscribe (587-598)
  • subscribeRaw (333-335)
Sources/AblyChat/Presence.swift (4)
Sources/AblyChat/AblyCocoaExtensions/InternalAblyCocoaTypes.swift (6)
  • get (299-315)
  • get (317-333)
  • get (521-524)
  • enter (351-365)
  • update (367-381)
  • leave (335-349)
Sources/AblyChat/DefaultPresence.swift (12)
  • get (18-37)
  • get (39-58)
  • isUserPresent (61-81)
  • enter (83-85)
  • enter (87-89)
  • enter (92-109)
  • update (111-113)
  • update (115-117)
  • update (120-137)
  • leave (139-141)
  • leave (143-145)
  • leave (148-165)
Tests/AblyChatTests/Mocks/MockRealtimePresence.swift (5)
  • get (19-25)
  • get (27-33)
  • enter (42-47)
  • update (49-54)
  • leave (35-40)
Example/AblyChatExample/Mocks/MockClients.swift (16)
  • get (29-36)
  • get (223-238)
  • get (471-481)
  • get (483-493)
  • get (600-602)
  • isUserPresent (495-497)
  • enter (499-501)
  • enter (503-505)
  • enter (507-521)
  • update (187-205)
  • update (523-525)
  • update (527-529)
  • update (531-545)
  • leave (547-549)
  • leave (551-553)
  • leave (555-569)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Example app, tvOS (Xcode 26.0)
  • GitHub Check: Example app, iOS (Xcode 26.0)
  • GitHub Check: Example app, macOS (Xcode 26.0)
  • GitHub Check: Xcode, tvOS (Xcode 26.0)
  • GitHub Check: SPM, release configuration (Xcode 26.0)
  • GitHub Check: SPM (Xcode 26.0)
  • GitHub Check: Xcode, iOS (Xcode 26.0)
  • GitHub Check: Xcode, release configuration, tvOS (Xcode 26.0)
  • GitHub Check: Xcode, release configuration, iOS (Xcode 26.0)
  • GitHub Check: Xcode, macOS (Xcode 26.0)
  • GitHub Check: Xcode, release configuration, macOS (Xcode 26.0)
🔇 Additional comments (16)
Sources/AblyChat/MessageReactions.swift (8)

3-11: LGTM! Protocol declaration follows guidelines.

The protocol correctly uses @MainActor for isolation, follows protocol-based design, and has clear documentation.


13-72: Excellent documentation with comprehensive examples.

The documentation clearly explains the behavior and provides three practical examples covering different reaction types. Error handling is properly documented.


74-137: Well-documented deletion behavior with clear examples.

The documentation correctly explains the type-specific deletion behavior and provides helpful examples for each scenario. Error handling is comprehensive.


139-190: Thorough documentation of subscription behavior.

The documentation provides important notes about clipping and rate limiting, along with a comprehensive example showing how to handle different reaction types.


192-248: Clear documentation for raw reaction events.

The documentation appropriately warns about the high-volume nature of raw events and clearly documents the configuration requirement. The example is well-structured.


309-368: AsyncSequence extensions follow best practices.

The implementation correctly uses termination handlers for cleanup and properly specifies @MainActor context. The pattern is consistent across both methods.


370-397: Well-structured parameter struct with clear documentation.

The parameter ordering (name, type, count) is logical, and the documentation clearly explains the purpose and constraints of each field.


399-419: Clear documentation for deletion parameters.

The documentation correctly explains that name is required for all reaction types except .unique, which aligns with the implementation.

Sources/AblyChat/Presence.swift (8)

3-6: LGTM - Clear typealias documentation

The documentation clearly explains that PresenceData is for object literal data in presence.


19-67: LGTM - Comprehensive documentation with helpful examples

The documentation for the get methods is thorough, includes proper error handling guidance, and provides clear usage examples.


69-107: LGTM - Well-documented presence check method

Good documentation that explains when to use this method over get() and provides a clear usage example.


110-241: LGTM - Excellent documentation for presence operations

The documentation for enter, update, and leave is comprehensive and includes important behavioral notes:

  • Multiple enter calls emit update events (correct Ably behavior)
  • Update uses PUT-like semantics (entire data replaced)
  • Leave is a no-op if user not present

All examples demonstrate proper error handling patterns.


243-290: LGTM - Complete subscription documentation

The documentation properly describes the non-throwing subscription method with clear requirements and a comprehensive example showing all presence event types.


317-349: LGTM - Proper AsyncSequence implementation

The AsyncSequence-based subscription methods correctly follow the pattern established in Messages and Typing. The implementation properly bridges the callback-based subscription and ensures cleanup via the termination handler.


352-394: LGTM - Proper public API additions

The public initializer for PresenceMember correctly follows the coding guideline for public structs. The documentation clarifications about uniqueness and the updatedAt timestamp are helpful.


486-493: LGTM - Clear initializer documentation

The documentation clearly describes each parameter of the PresenceParams initializer, including the default value for waitForSync.

Comment thread Sources/AblyChat/MessageReactions.swift
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.

Add missing documentation for public API

2 participants