Skip to content

Conversation

@sacOO7
Copy link
Contributor

@sacOO7 sacOO7 commented Jan 20, 2026

Summary by CodeRabbit

Documentation

  • Clarified chat history retrieval parameters with documented defaults and behavior specifications
  • Added detailed guidance on message ordering options and their effects on retrieval and display
  • Explained differences between standard history retrieval and retrieval methods before subscribing
  • Enhanced code examples across multiple supported programming languages

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

Walkthrough

This pull request updates documentation for message history retrieval functionality, adding explicit parameter defaults (start, end, orderBy, limit) and a new section explaining message ordering behavior (newestFirst vs oldestFirst) to clarify API semantics and reduce implementation confusion.

Changes

Cohort / File(s) Summary
Documentation: Message History API Clarification
src/pages/docs/chat/rooms/history.mdx
Added parameter defaults for history and historyBeforeSubscribe methods; introduced "Understanding message ordering" section with newestFirst/oldestFirst comparison table; added clarifying aside that orderBy unavailable for historyBeforeSubscribe; revised code examples across JS, Swift, Kotlin, Jetpack, React to reflect updated semantics

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Defaults now clear, from first to last,
No more confusion from the past!
Messages ordered, newest first,
This rabbit's thirst for clarity—quenched! 📚✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: updating the history.mdx documentation to include specific use-cases, defaults, and ordering guidance for chat history retrieval.
Linked Issues check ✅ Passed All coding objectives from FTF-489 are met: added explicit use-case section, defined default parameter values for history methods, clarified ordering behavior, and provided concrete guidance to prevent LLM hallucinations.
Out of Scope Changes check ✅ Passed All changes are directly in scope—only the history.mdx documentation file was modified to address the linked issue requirements without introducing unrelated alterations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

@sacOO7 sacOO7 marked this pull request as ready for review January 20, 2026 12:54
@sacOO7 sacOO7 added the review-app Create a Heroku review app label Jan 20, 2026
@sacOO7 sacOO7 requested a review from GregHolmes January 20, 2026 12:56
@ably-ci ably-ci temporarily deployed to ably-docs-update-chat-h-rckj2m January 20, 2026 12:56 Inactive
@sacOO7 sacOO7 requested a review from m-hulbert January 20, 2026 12:56
@sacOO7 sacOO7 changed the title chat docs: update history.mdx for chat specific use-case chat docs: update history.mdx for specific use-cases Jan 20, 2026
@sacOO7 sacOO7 requested review from AndyTWF and maratal January 20, 2026 13:16
@sacOO7 sacOO7 force-pushed the update/chat-history-doc branch from 6f882b7 to fea3179 Compare January 23, 2026 10:39
@ably-ci ably-ci temporarily deployed to ably-docs-update-chat-h-rckj2m January 23, 2026 10:39 Inactive
@sacOO7 sacOO7 requested a review from splindsay-92 January 23, 2026 10:39
@sacOO7
Copy link
Contributor Author

sacOO7 commented Jan 23, 2026

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🤖 Fix all issues with AI agents
In `@src/pages/docs/chat/rooms/history.mdx`:
- Line 114: The Swift typedoc link contains an extra closing parenthesis; edit
the line referencing historyBeforeSubscribe(withParams:) and remove the trailing
")" from the URL in the If lang="swift" link so the URL matches the intended
typedoc link exactly (keep the displayed label
[`historyBeforeSubscribe(withParams:)`] and only correct the href).
- Line 111: Remove the incorrect inline link on the function name so
`historyBeforeSubscribe()` is plain text and add a separate, clearly worded link
to the ordering guidance (the "understanding-message-ordering" anchor) in the
surrounding sentence; specifically, edit the paragraph that currently contains
[`historyBeforeSubscribe()`](`#understanding-message-ordering`) to render
historyBeforeSubscribe() without a link and include a second sentence or clause
linking to the ordering guidance (e.g., "See the ordering guidance in the
understanding-message-ordering section") so the function name and the ordering
documentation are distinct.

## Retrieve messages sent prior to subscribing <a id="subscribe"/>

Users can also retrieve historical messages that were sent to a room before the point that they registered a listener by [subscribing](/docs/chat/rooms/messages#subscribe). The order of messages returned is from most recent, to oldest. This is useful for providing conversational context when a user first joins a room, or when they subsequently rejoin it later on. It also ensures that the message history they see is continuous, without any overlap of messages being returned between their subscription and their history call.
Retrieve historical messages sent before subscribing using [`historyBeforeSubscribe()`](#understanding-message-ordering). Messages are returned in `newestFirst` order. This is useful for providing conversational context when a user joins or rejoins a room, ensuring continuous message history without overlap.
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix the historyBeforeSubscribe() link target.

The function name currently links to the ordering section, which is confusing. Consider removing the link on the function name and linking the ordering guidance separately.

🔧 Proposed fix
-Retrieve historical messages sent before subscribing using [`historyBeforeSubscribe()`](`#understanding-message-ordering`). Messages are returned in `newestFirst` order. This is useful for providing conversational context when a user joins or rejoins a room, ensuring continuous message history without overlap.
+Retrieve historical messages sent before subscribing using `historyBeforeSubscribe()`. Messages are returned in `newestFirst` order. For ordering details, see [Understanding message ordering](`#understanding-message-ordering`). This is useful for providing conversational context when a user joins or rejoins a room, ensuring continuous message history without overlap.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Retrieve historical messages sent before subscribing using [`historyBeforeSubscribe()`](#understanding-message-ordering). Messages are returned in `newestFirst` order. This is useful for providing conversational context when a user joins or rejoins a room, ensuring continuous message history without overlap.
Retrieve historical messages sent before subscribing using `historyBeforeSubscribe()`. Messages are returned in `newestFirst` order. For ordering details, see [Understanding message ordering](`#understanding-message-ordering`). This is useful for providing conversational context when a user joins or rejoins a room, ensuring continuous message history without overlap.
🤖 Prompt for AI Agents
In `@src/pages/docs/chat/rooms/history.mdx` at line 111, Remove the incorrect
inline link on the function name so `historyBeforeSubscribe()` is plain text and
add a separate, clearly worded link to the ordering guidance (the
"understanding-message-ordering" anchor) in the surrounding sentence;
specifically, edit the paragraph that currently contains
[`historyBeforeSubscribe()`](`#understanding-message-ordering`) to render
historyBeforeSubscribe() without a link and include a second sentence or clause
linking to the ordering guidance (e.g., "See the ordering guidance in the
understanding-message-ordering section") so the function name and the ordering
documentation are distinct.

Retrieve historical messages sent before subscribing using [`historyBeforeSubscribe()`](#understanding-message-ordering). Messages are returned in `newestFirst` order. This is useful for providing conversational context when a user joins or rejoins a room, ensuring continuous message history without overlap.

<If lang="javascript,swift,kotlin">
Use the <If lang="javascript">[`historyBeforeSubscribe()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.MessageSubscriptionResponse.html#historyBeforeSubscribe)</If><If lang="swift">[`historyBeforeSubscribe(withParams:)`](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/messagesubscriptionresponse/historybeforesubscribe%28withparams%3A%29))</If><If lang="kotlin">[`historyBeforeSubscribe()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat/com.ably.chat/-messages-subscription/history-before-subscribe.html)</If> function returned as part of a [message subscription](/docs/chat/rooms/messages#subscribe) response to only retrieve messages that were received before the listener was subscribed to the room. This returns a paginated response, which can be queried further to retrieve the next set of messages.
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix the Swift typedoc link URL.

There’s an extra closing parenthesis at the end of the Swift link, which likely breaks the URL.

🔧 Proposed fix
-Use the <If lang="javascript">[`historyBeforeSubscribe()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.MessageSubscriptionResponse.html#historyBeforeSubscribe)</If><If lang="swift">[`historyBeforeSubscribe(withParams:)`](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/messagesubscriptionresponse/historybeforesubscribe%28withparams%3A%29))</If><If lang="kotlin">[`historyBeforeSubscribe()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat/com.ably.chat/-messages-subscription/history-before-subscribe.html)</If> function returned as part of a [message subscription](/docs/chat/rooms/messages#subscribe) response to only retrieve messages that were received before the listener was subscribed to the room. This returns a paginated response, which can be queried further to retrieve the next set of messages.
+Use the <If lang="javascript">[`historyBeforeSubscribe()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.MessageSubscriptionResponse.html#historyBeforeSubscribe)</If><If lang="swift">[`historyBeforeSubscribe(withParams:)`](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/messagesubscriptionresponse/historybeforesubscribe%28withparams%3A%29)</If><If lang="kotlin">[`historyBeforeSubscribe()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat/com.ably.chat/-messages-subscription/history-before-subscribe.html)</If> function returned as part of a [message subscription](/docs/chat/rooms/messages#subscribe) response to only retrieve messages that were received before the listener was subscribed to the room. This returns a paginated response, which can be queried further to retrieve the next set of messages.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Use the <If lang="javascript">[`historyBeforeSubscribe()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.MessageSubscriptionResponse.html#historyBeforeSubscribe)</If><If lang="swift">[`historyBeforeSubscribe(withParams:)`](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/messagesubscriptionresponse/historybeforesubscribe%28withparams%3A%29))</If><If lang="kotlin">[`historyBeforeSubscribe()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat/com.ably.chat/-messages-subscription/history-before-subscribe.html)</If> function returned as part of a [message subscription](/docs/chat/rooms/messages#subscribe) response to only retrieve messages that were received before the listener was subscribed to the room. This returns a paginated response, which can be queried further to retrieve the next set of messages.
Use the <If lang="javascript">[`historyBeforeSubscribe()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.MessageSubscriptionResponse.html#historyBeforeSubscribe)</If><If lang="swift">[`historyBeforeSubscribe(withParams:)`](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/messagesubscriptionresponse/historybeforesubscribe%28withparams%3A%29)</If><If lang="kotlin">[`historyBeforeSubscribe()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat/com.ably.chat/-messages-subscription/history-before-subscribe.html)</If> function returned as part of a [message subscription](/docs/chat/rooms/messages#subscribe) response to only retrieve messages that were received before the listener was subscribed to the room. This returns a paginated response, which can be queried further to retrieve the next set of messages.
🤖 Prompt for AI Agents
In `@src/pages/docs/chat/rooms/history.mdx` at line 114, The Swift typedoc link
contains an extra closing parenthesis; edit the line referencing
historyBeforeSubscribe(withParams:) and remove the trailing ")" from the URL in
the If lang="swift" link so the URL matches the intended typedoc link exactly
(keep the displayed label [`historyBeforeSubscribe(withParams:)`] and only
correct the href).

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.

Small suggestions

| end | Latest time to retrieve messages from, as a unix timestamp in milliseconds. Messages with a timestamp less than this value will be returned. |
| orderBy | The order in which to retrieve messages from; either `oldestFirst` or `newestFirst`. |
| limit | Maximum number of messages to be retrieved per page, up to 1,000. |
| start | Earliest time to retrieve messages from, as a unix timestamp in milliseconds. Messages with a timestamp equal to, or greater than, this value will be returned. **Defaults to no lower bound (earliest available message).** |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just "Defaults to earliest available message".

| `newestFirst` (default) | Most recent messages | `[newest, ..., oldest]` | Standard chat UIs |
| `oldestFirst` | Oldest messages from room start | `[oldest, ..., newest]` | Archives, exports, admin tools |

**For typical chat applications:** Use `newestFirst` (default) to get recent messages, then reverse the result for chronological display.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would add "... for chronological display (newest at the bottom of the UI)." or something. Or remove this remark at all.

| start | Earliest time to retrieve messages from, as a unix timestamp in milliseconds. Messages with a timestamp equal to, or greater than, this value will be returned. |
| end | Latest time to retrieve messages from, as a unix timestamp in milliseconds. Messages with a timestamp less than this value will be returned. |
| limit | Maximum number of messages to be retrieved per page, up to 1,000. |
| start | Earliest time to retrieve messages from, as a unix timestamp in milliseconds. Messages with a timestamp equal to, or greater than, this value will be returned. **Defaults to no lower bound (earliest available message).** |
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-app Create a Heroku review app

Development

Successfully merging this pull request may close these issues.

4 participants