Skip to content

Chat getting started react guide #2521

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

Merged
merged 14 commits into from
May 15, 2025
Merged

Conversation

splindsay-92
Copy link
Contributor

@splindsay-92 splindsay-92 commented Apr 10, 2025

Description

CHA-898

Adding a getting started guide for Chat with React and Vite

Issues still to investigate

  • Looks like the formatting on the page for React code blocks is a bit off

Checklist

Copy link

coderabbitai bot commented Apr 10, 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.


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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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 splindsay-92 changed the base branch from main to edu-1851-chat-start-js April 10, 2025 13:23
@splindsay-92 splindsay-92 requested a review from m-hulbert April 10, 2025 13:23
@splindsay-92 splindsay-92 marked this pull request as ready for review April 11, 2025 09:26
@splindsay-92
Copy link
Contributor Author

Hey @m-hulbert, do you have any ideas as to why the react code blocks don't correctly render? I get the following error

You're currently viewing the JavaScript docs. There either isn't a JavaScript code sample for this example, or this feature isn't supported in JavaScript. Switch language to view this example in a different language, or check which SDKs support this feature.

@m-hulbert m-hulbert temporarily deployed to ably-docs-chat-getting--8awdef April 25, 2025 08:01 Inactive
@splindsay-92 splindsay-92 force-pushed the chat/getting-started-react-guide branch 4 times, most recently from bac7e74 to 0298e90 Compare April 30, 2025 11:01
@m-hulbert m-hulbert force-pushed the edu-1851-chat-start-js branch 2 times, most recently from fdc86af to e414332 Compare April 30, 2025 11:25
Base automatically changed from edu-1851-chat-start-js to main April 30, 2025 11:32
@splindsay-92 splindsay-92 force-pushed the chat/getting-started-react-guide branch from d662769 to 427678e Compare April 30, 2025 11:40
@m-hulbert m-hulbert temporarily deployed to ably-docs-chat-getting--ytzsbt April 30, 2025 17:06 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.

This was really great, @splindsay-92 ! Especially as it builds up the UI.

I've made some suggestions and fixes and then there's a couple of other things to discuss:

  • Minor, but we should be consistent with styling on hook names. At the moment we sometimes code style them, and sometimes don't.
  • I think we should have a quick sync on when / when not to include the entire code, as there's a few places where it isn't obvious what to add and what to replace.
  • Edit and history currently don't work when following it verbatim so let's catch up on those quickly too.

* Setting up typing indicators to see which clients are typing
* Displaying online status of clients in the room
* Subscribing to and sending reactions
* Retrieving historical messages to provide context for new joiners
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we reorder these where history has moved and add a point for closing?

Copy link
Contributor

Choose a reason for hiding this comment

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

RE: closing - do you think it's worth still having a step and mentioning how React handles it when unmounting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will move the points around :) As for closing, are we talking about the Realtime pubsub component or the chat component? Chat components will release channels, but they do not close any realtime connections. Should we have a specific section on detaching too?

* You can also send a reaction to the room via the Ably CLI by running the following command:

```[sh]
ably rooms reactions send my-first-room 👍
Copy link
Contributor

Choose a reason for hiding this comment

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

This no longer works without providing a messageId in addition to the emoji which seems wrong to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats strange, this isn't a chat change though, I will have to take a look at the CLI and fix it up :)

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 checked this over, it seems to work find for me 🤷 Happy to take a look with you whenever you're free though!

@splindsay-92 splindsay-92 force-pushed the chat/getting-started-react-guide branch 2 times, most recently from e539b09 to 4df3782 Compare May 8, 2025 16:41
Copy link
Contributor

@GregHolmes GregHolmes 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 run through the text and the code. The only other comment is that tailwind doesn't seem to load properly?
Screenshot 2025-05-09 at 15 21 10

import {
AllFeaturesEnabled,
MessageEvent,
Message,
Copy link
Contributor

Choose a reason for hiding this comment

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

This may be me, but I run npm run dev. Load it in my browser and get the error:

Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/@ably_chat.js?v=605f498d' does not provide an export named 'Message'

This error also happens for React and MessageEvent. Once these are commented out from the import, all works fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you confirm what version of the chat-sdk you are using? It should be 0.6.0, and these imports are all exported there

@GregHolmes
Copy link
Contributor

I've run through the text and the code. The only other comment is that tailwind doesn't seem to load properly? Screenshot 2025-05-09 at 15 21 10

Ignore the styling complaint. 👀

@splindsay-92 splindsay-92 force-pushed the chat/getting-started-react-guide branch from 4df3782 to 0b5e042 Compare May 12, 2025 09:57
@splindsay-92 splindsay-92 requested a review from GregHolmes May 12, 2025 10:33
@splindsay-92 splindsay-92 force-pushed the chat/getting-started-react-guide branch from ac99b6a to 067fe3c Compare May 15, 2025 13:05
The guide includes instructions on installation, authentication, and room creation, along with practical examples for messaging and typing indicators.
- Trimmed down the installation section.
- Moved all imports to a dedicated section at the start of the guide for reuse.
- Lots more test changes and corrections.
@splindsay-92 splindsay-92 force-pushed the chat/getting-started-react-guide branch from 067fe3c to 4bfa827 Compare May 15, 2025 13:36
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.

Upgraded to 0.7 and all works fine for me.

Awesome work 🚀

@splindsay-92 splindsay-92 merged commit 16de4fa into main May 15, 2025
6 checks passed
@splindsay-92 splindsay-92 deleted the chat/getting-started-react-guide branch May 15, 2025 13:46
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