Skip to content

Conversation

@lawrence-forooghian
Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian commented Oct 7, 2025

As in ably/ably-chat-js#657. And accordingly rename Messages.history(withOptions:) to history(withParams:).

Summary by CodeRabbit

  • Refactor

    • Renamed the history query type from QueryOptions to HistoryParams across messaging APIs and updated related method labels (withOptions → withParams / getPreviousMessages → historyBeforeSubscribe). Public behavior, endpoints, and results unchanged; update integrations to use HistoryParams.
  • Tests

    • Updated and renamed tests to align with the new HistoryParams type and the withParams/historyBeforeSubscribe labels.

@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2025

Warning

Rate limit exceeded

@lawrence-forooghian has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 2 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 4e4f985 and 3aedfc2.

📒 Files selected for processing (7)
  • Example/AblyChatExample/Mocks/MockClients.swift (1 hunks)
  • Example/AblyChatExample/Mocks/MockSubscriptionStorage.swift (4 hunks)
  • Sources/AblyChat/ChatAPI.swift (1 hunks)
  • Sources/AblyChat/DefaultMessages.swift (1 hunks)
  • Sources/AblyChat/Messages.swift (5 hunks)
  • Sources/AblyChat/Subscription.swift (2 hunks)
  • Tests/AblyChatTests/DefaultMessagesTests.swift (2 hunks)

Walkthrough

Renamed the history query parameter type from QueryOptions to HistoryParams across public APIs, internal implementations, mocks, and tests. Updated method signatures, initializers, stored closures, and call sites to use HistoryParams; request flow and error handling are unchanged.

Changes

Cohort / File(s) Change Summary
Core API: Messages & Params
Sources/AblyChat/Messages.swift
Replaced QueryOptions with HistoryParams (type rename, moved/renamed nested OrderBy, initializer signature, internal extension, and all public method signatures and stored closures using the new type).
Core: Subscription & Default responses
Sources/AblyChat/Subscription.swift, Sources/AblyChat/DefaultMessages.swift
Updated historyBeforeSubscribe / history method parameter types from QueryOptions to HistoryParams; adjusted internal calls to pass HistoryParams to chatAPI.getMessages.
Core: API client
Sources/AblyChat/ChatAPI.swift
Changed getMessages parameter type from QueryOptions to HistoryParams and continued to use params.asQueryItems() for request construction.
Example mocks
Example/AblyChatExample/Mocks/*, Example/AblyChatExample/Mocks/MockClients.swift
Updated mocks and mock factories to accept HistoryParams instead of QueryOptions for history/previousMessages-related methods and stored properties; implementation returns same mock paginated results.
Mock subscription storage
Example/AblyChatExample/Mocks/MockSubscriptionStorage.swift
Replaced occurrences of QueryOptions with HistoryParams in initializers, stored properties, and helper methods for previous messages handling.
Tests: unit & integration
Tests/AblyChatTests/*, Tests/AblyChatTests/DefaultMessagesTests.swift, Tests/AblyChatTests/IntegrationTests.swift, Tests/AblyChatTests/MessageSubscriptionResponseAsyncSequenceTests.swift
Updated tests to use new method names/signatures (history(withParams:), historyBeforeSubscribe(withParams:)) and HistoryParams constructors; renamed some test types and functions to match renamed types/methods.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Msgs as Messages / DefaultMessages
  participant Sub as SubscriptionResponse
  participant API as ChatAPI
  participant Net as Network

  rect rgb(235,245,255)
    Note right of Msgs: Public history API
    Msgs->>API: getMessages(roomName, params: HistoryParams)
    API->>Net: HTTP GET /rooms/:roomName/messages?{params.asQueryItems()}
    Net-->>API: HTTP response (paginated messages)
    API-->>Msgs: PaginatedResult<Message>
  end

  rect rgb(255,245,235)
    Note right of Sub: Pre-subscribe history
    Sub->>API: getMessages(roomName, params: HistoryParams(with orderBy=newestFirst, fromSerial?))
    API->>Net: HTTP GET /rooms/:roomName/messages?{...}
    Net-->>API: HTTP response
    API-->>Sub: PaginatedResult<Message>
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

Thump-thump, I hopped through code tonight,
Options to Params — tidy and light.
Burrows of history, names all aligned,
Same carrots, same paths, just better defined.
🥕🐇

Pre-merge checks and finishing touches and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.16% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the renaming of the QueryOptions type to HistoryParams, which is the primary change in this PR. It clearly communicates the main change to readers scanning the history. The phrasing is concise, specific, and directly reflects the updated API elements.

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/380/AblyChat October 7, 2025 18:17 Inactive
@lawrence-forooghian lawrence-forooghian force-pushed the rename-QueryOptions-to-HistoryParams branch from 47748d7 to 4e4f985 Compare October 7, 2025 18:28
@github-actions github-actions bot temporarily deployed to staging/pull/380/AblyChat October 7, 2025 18:29 Inactive
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 (6)
Tests/AblyChatTests/DefaultMessagesTests.swift (1)

439-439: Tests updated to new API — LGTM

Calls now use history(withParams:). Consider renaming test names mentioning “QueryOptions” to “HistoryParams” for clarity.

Also applies to: 470-470

Sources/AblyChat/Subscription.swift (1)

57-57: Rename to withParams and HistoryParams — LGTM

Behavior preserved: force newestFirst and set fromSerial before fetching.

Minor: update doc text “Options” → “Params” for consistency with the new naming.

Also applies to: 94-105

Sources/AblyChat/Messages.swift (4)

36-36: Public API now uses HistoryParams — LGTM

Method signature updated; aligns with downstream implementations and tests.

Docs above still refer to “options”; consider updating parameter docs to “params”.


233-233: Introduce HistoryParams — LGTM

Naming aligns with API guidelines. Consider updating the struct comment from “Options” to “Parameters” for consistency.


285-316: Default direction handling: verify or make explicit

Docs say default is newestFirst, but asQueryItems omits “direction” when orderBy is nil, relying on server defaults. To avoid ambiguity, either:

  • Confirm server default is backwards/newestFirst, or
  • Explicitly set “direction=backwards” when orderBy is nil.

Example change:

 func asQueryItems() -> [String: String] {
   var dict: [String: String] = [:]
@@
-  if let orderBy {
-      switch orderBy {
-      case .oldestFirst:
-          dict["direction"] = "forwards"
-      case .newestFirst:
-          dict["direction"] = "backwards"
-      }
-  }
+  switch orderBy {
+  case .some(.oldestFirst):
+      dict["direction"] = "forwards"
+  case .some(.newestFirst):
+      dict["direction"] = "backwards"
+  case .none:
+      // Be explicit to match documented default
+      dict["direction"] = "backwards"
+  }

Alternatively, if you intend to rely on server defaults, update the HistoryParams docs to state that omission defers to server defaults.


233-233: Optional: provide migration shims for smoother adoption

To ease external migration, consider temporarily adding:

  • public typealias QueryOptions = HistoryParams
  • a deprecated wrapper on Messages: history(withOptions:) calling history(withParams:)

Example:

public typealias QueryOptions = HistoryParams

public extension Messages {
    @available(*, deprecated, message: "Use history(withParams:) instead.")
    func history(withOptions options: QueryOptions) async throws(ARTErrorInfo) -> HistoryResult {
        try await history(withParams: options)
    }
}
📜 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 c32a2fa and 4e4f985.

📒 Files selected for processing (7)
  • Example/AblyChatExample/Mocks/MockClients.swift (1 hunks)
  • Example/AblyChatExample/Mocks/MockSubscriptionStorage.swift (4 hunks)
  • Sources/AblyChat/ChatAPI.swift (1 hunks)
  • Sources/AblyChat/DefaultMessages.swift (1 hunks)
  • Sources/AblyChat/Messages.swift (5 hunks)
  • Sources/AblyChat/Subscription.swift (2 hunks)
  • Tests/AblyChatTests/DefaultMessagesTests.swift (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
Sources/AblyChat/DefaultMessages.swift (2)
Example/AblyChatExample/Mocks/MockClients.swift (1)
  • history (157-159)
Sources/AblyChat/ChatAPI.swift (1)
  • getMessages (19-22)
Tests/AblyChatTests/DefaultMessagesTests.swift (2)
Example/AblyChatExample/Mocks/MockClients.swift (1)
  • history (157-159)
Sources/AblyChat/DefaultMessages.swift (1)
  • history (118-124)
Sources/AblyChat/Messages.swift (3)
Example/AblyChatExample/Mocks/MockClients.swift (1)
  • history (157-159)
Sources/AblyChat/DefaultMessages.swift (1)
  • history (118-124)
Tests/AblyChatTests/MessageSubscriptionAsyncSequenceTests.swift (1)
  • mockGetPreviousMessages (49-57)
Sources/AblyChat/Subscription.swift (1)
Example/AblyChatExample/Mocks/MockSubscriptionStorage.swift (1)
  • historyBeforeSubscribe (211-213)
Example/AblyChatExample/Mocks/MockClients.swift (1)
Sources/AblyChat/DefaultMessages.swift (1)
  • history (118-124)
Example/AblyChatExample/Mocks/MockSubscriptionStorage.swift (1)
Sources/AblyChat/Subscription.swift (1)
  • historyBeforeSubscribe (94-109)
⏰ 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: SPM, release configuration (Xcode 26.0)
  • GitHub Check: Xcode, macOS (Xcode 26.0)
  • GitHub Check: Xcode, tvOS (Xcode 26.0)
  • GitHub Check: Xcode, iOS (Xcode 26.0)
  • GitHub Check: SPM (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: Example app, tvOS (Xcode 26.0)
  • GitHub Check: Example app, iOS (Xcode 26.0)
  • GitHub Check: spec-coverage
🔇 Additional comments (6)
Example/AblyChatExample/Mocks/MockSubscriptionStorage.swift (1)

130-130: Consistent rename to HistoryParams — LGTM

Closures, method, and initializer now uniformly use HistoryParams. No behavioral changes introduced.

Also applies to: 155-155, 210-210, 211-211, 221-221

Sources/AblyChat/DefaultMessages.swift (1)

118-118: Method rename wired correctly — LGTM

history(withParams:) forwards params to chatAPI.getMessages as expected.

Also applies to: 120-120

Sources/AblyChat/ChatAPI.swift (1)

19-19: getMessages now accepts HistoryParams — LGTM

Signature aligns with callers; asQueryItems() remains the conversion point.

Example/AblyChatExample/Mocks/MockClients.swift (1)

157-157: Mock API updated to HistoryParams — LGTM

Signature change only; behavior unchanged.

Sources/AblyChat/Messages.swift (2)

277-277: Initializer updated to HistoryParams.OrderBy — LGTM

Type reference updated correctly.


367-367: AsyncSequence hooks migrated to HistoryParams — LGTM

Closures and method now take HistoryParams; matches Subscription and Messages surfaces.

Also applies to: 372-372, 379-379, 394-394

@github-actions github-actions bot temporarily deployed to staging/pull/380/AblyChat October 8, 2025 11:54 Inactive
@lawrence-forooghian
Copy link
Collaborator Author

Oops, this now contains #381 after I merged that too soon. Well, will merge this one once #379 approved.

@lawrence-forooghian lawrence-forooghian force-pushed the rename-QueryOptions-to-HistoryParams branch from a748402 to 4e4f985 Compare October 8, 2025 11:55
@lawrence-forooghian
Copy link
Collaborator Author

Actually, no, will reset this PR and re-open #381.

@github-actions github-actions bot temporarily deployed to staging/pull/380/AblyChat October 8, 2025 11:57 Inactive
As in [1]. And accordingly rename Messages.history(withOptions:) to
history(withParams:).

[1] ably/ably-chat-js#657
@lawrence-forooghian lawrence-forooghian force-pushed the rename-QueryOptions-to-HistoryParams branch from 4e4f985 to 3aedfc2 Compare October 8, 2025 12:19
Base automatically changed from rename-public-api-to-meet-guidelines to main October 8, 2025 15:00
@lawrence-forooghian lawrence-forooghian merged commit 532b287 into main Oct 8, 2025
17 checks passed
@lawrence-forooghian lawrence-forooghian deleted the rename-QueryOptions-to-HistoryParams branch October 8, 2025 15:01
@lawrence-forooghian lawrence-forooghian changed the title Rename QueryOptions to HistoryParams [ECO-5577] Rename QueryOptions to HistoryParams Oct 10, 2025
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.

3 participants