Skip to content

Chat: A how to guide for replies #2712

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

splindsay-92
Copy link
Contributor

@splindsay-92 splindsay-92 commented Jul 11, 2025

Context

Chat currently doesn't have native support for things like replies and quotes, so we need a short guide to give users an idea as to how they might implement a solution with the Chat SDK in the mean time.

As a temporary fix, I've added typescript to the langs list, I've had to override the langs for the replies page in the nav bar though, so it displays nothing. This is because the selection bar doesn't seem to support typescript yet - thats fine for my doc as there is only one language for the whole doc. Also, nowhere else uses typescript tag, so it shouldn't break other docs.

CHA-1016

Description

This PR adds a guide that covers a basic replies setup, using the Chat SDK, and sending message reply metadata in the metadata field of a chat message.

Copy link

coderabbitai bot commented Jul 11, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chat/how-to-replies

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

CodeRabbit Configuration File (.coderabbit.yaml)

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

Documentation and Community

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

@splindsay-92
Copy link
Contributor Author

@jamiehenson tagged you in relation to my temporary fix to add typescript support to the docs.

@splindsay-92 splindsay-92 force-pushed the chat/how-to-replies branch from 11415a5 to fb3b799 Compare July 11, 2025 17:11
{
name: 'Replies',
link: '/docs/guides/chat/replies',
languages: [],
Copy link
Member

@jamiehenson jamiehenson Jul 15, 2025

Choose a reason for hiding this comment

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

An unintended use for this, but this'll do the job for suppressing the language selector. Two thoughts from here:

  • (more for @m-hulbert) we already have a condition where if there is no language content detected on the page (i.e. here), then it won't show the language selector. Is there something in changing that so we only show it if there are two or more languages? Even with one language, there's nothing to switch. It would mean we hide it on this new page as normal without an override as it only has TS.
  • either way, if we would like to support TS as a language, then we need to add it with a version number to the language version data and language info (for the label), guessing it would be the same version as the JS lib but not for me to say.

TLDR, this override works but a better path forward would be to either not show the language selector for single language pages, or add TS to the language data so we get the selector working with TS

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about removing it if there's only 1 language. I think we should remove the ability to click the dropdown, but I personally think it makes sense to keep it for consistency (though I'll check to get a UX perspective).

Copy link
Contributor

@vladvelici vladvelici left a comment

Choose a reason for hiding this comment

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

Reads well. Left a few comments.

@splindsay-92 splindsay-92 requested a review from vladvelici July 17, 2025 16:40
@splindsay-92 splindsay-92 added the review-app Create a Heroku review app label Jul 18, 2025
@ably-ci ably-ci temporarily deployed to ably-docs-chat-how-to-r-wfmhik July 18, 2025 08:31 Inactive
Copy link
Contributor

@m-hulbert m-hulbert left a comment

Choose a reason for hiding this comment

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

I've just dropped some high-level comments for now on how I think we should position these types of features.

@@ -129,6 +129,11 @@ export default {
name: 'Livestream chat',
link: '/docs/guides/chat/build-livestream',
},
{
name: 'Replies',
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest referencing quotes here as well for completeness and scanning purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

meta_keywords: "ably chat, message replies, message quotes, chat replies, chat quotes, javascript chat replies, typescript chat replies, chat metadata, ably chat metadata, realtime chat replies"
---

This guide will show you how you could implement a simple solution for things like replies and quotes in your Ably Chat application.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm going to make the same comment as I did for file uploads in that I think it's immaterial to an end-user that there isn't a dedicated API for handling this. I think this should just sit in the existing 'feature' docs and it isn't necessary to call it out as a guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to rooms and no longer call out here that it's a guide.


This guide will show you how you could implement a simple solution for things like replies and quotes in your Ably Chat application.
While the two features have different applications, they share the same fundamental principle of referencing other messages in the chat.
As such, we will cover only replies in this guide, but the same principles can be applied to quotes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid first person "we" please 🙂


While cross-room replies are possible, this guide will focus on providing replies within the same room for simplicity.

## Understanding the current limitations <a id="limitations"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is starting out on a negative upfront. I don't think we need to be apologetic or mention there isn't a dedicated API. It's possible to do them and people just want to get to the how.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reworded things a bit now as you recommended :)


By storing the serial and creation time of a message you want to quote in the metadata of a new message, you can create a reference between messages that your application can interpret and display accordingly.

## Implementing replies using message metadata <a id="implementing-replies"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd keep this active voice, so 'Implement replies using message metadata'.


When displaying a reply message, you might want to show a preview of the original message, the name of the original sender, or a visual indication that it's a reply.

## Finding quoted messages that aren't in local state <a id="finding-quoted-messages"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

We state at the top that we're only covering replies, but then we start referencing quotes here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could change this to Finding parent messages that have been replied to...?

2. Include that information in the metadata when sending the reply.
3. Process incoming messages to check for reply metadata.

### Step 1: Store information about the message being replied to <a id="store-information"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should move away from making this step-based and just discuss the process as we normally would for another feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reworked the headings and wordings a but, but are you suggesting it needs a wider refactor for the overall flow too?


Ably Chat doesn't provide built-in UI components or reply functionality **yet**, so you'll need to implement these aspects yourself using the metadata approach described in this guide. The steps outlined in the previous sections provide the foundation for building a complete reply system in your application.

## Limitations and considerations <a id="limitations-and-considerations"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the second section covering limitations 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Corrected that, thanks! :D

@ably-ci ably-ci temporarily deployed to ably-docs-chat-how-to-r-wfmhik July 18, 2025 12:35 Inactive
@splindsay-92 splindsay-92 requested a review from m-hulbert July 18, 2025 12:41
@splindsay-92 splindsay-92 force-pushed the chat/how-to-replies branch from f7110e3 to 0570485 Compare July 22, 2025 11:49
@ably-ci ably-ci temporarily deployed to ably-docs-chat-how-to-r-wfmhik July 22, 2025 11:49 Inactive
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.

5 participants