-
Notifications
You must be signed in to change notification settings - Fork 46
chat docs: update history.mdx for specific use-cases #3124
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ 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. Comment |
6f882b7 to
fea3179
Compare
…ault param values
fea3179 to
ef8437c
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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).
maratal
left a comment
There was a problem hiding this 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).** | |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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).** | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
Summary by CodeRabbit
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.