Skip to content
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

Add chat API support #278

Merged
merged 8 commits into from
Oct 14, 2024
Merged

Add chat API support #278

merged 8 commits into from
Oct 14, 2024

Conversation

lukasIO
Copy link
Contributor

@lukasIO lukasIO commented Sep 25, 2024

Copy link

changeset-bot bot commented Sep 25, 2024

🦋 Changeset detected

Latest commit: 3183086

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@livekit/rtc-node Patch
@livekit/rtc-node-darwin-arm64 Patch
@livekit/rtc-node-darwin-x64 Patch
@livekit/rtc-node-linux-arm64-gnu Patch
@livekit/rtc-node-linux-x64-gnu Patch
@livekit/rtc-node-win32-x64-msvc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@lukasIO lukasIO marked this pull request as ready for review September 25, 2024 13:37
@lukasIO lukasIO requested review from bcherry and nbsp September 25, 2024 16:25
@@ -185,6 +190,60 @@ export class LocalParticipant extends Participant {
});
}

async sendChatMessage(
text: string,
destinationIdentities?: Array<string>,
Copy link
Contributor

Choose a reason for hiding this comment

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

does this default to all? Worth adding docstrings

async editChatMessage(
editText: string,
originalMessage: ChatMessage,
destinationIdentities?: Array<string>,
Copy link
Contributor

Choose a reason for hiding this comment

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

seems kinda weird that you can give different values here than to the original. this might also cause participants who join a call after an initial message is sent but before an edit to receive the edit and maybe have strange behavior? not sure if there's an easy way to solve though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, had the same feeling and opted to omit destinationIdentites on client-sdk-js altogether for now because of that

Copy link
Member

@nbsp nbsp left a comment

Choose a reason for hiding this comment

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

lg, seconding ben's comments plus this one

Comment on lines +4 to +10
export interface ChatMessage {
id: string;
timestamp: number;
message: string;
editTimestamp?: number;
generated?: boolean;
}
Copy link
Member

Choose a reason for hiding this comment

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

as far as i understand this is the same as the proto interface but with bigints swapped out for numbers? there's already a bunch of conversions happening in code and i wonder if this cuts down on enough of them to warrant this utility type or whether it's okay to just use the proto one

Copy link
Contributor Author

@lukasIO lukasIO Oct 13, 2024

Choose a reason for hiding this comment

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

are you concerned about performance reasons of the conversions or maintenance burden?
reasons for me to keep them separate:

  • we might be adding stuff in the proto that we don't necessarily want to expose to the user facing API in the same form
  • it's a bit of a pain to work with bigints in JS and we're just shifting the conversion burden to userland if we don't do the conversion ourselves

Copy link
Member

Choose a reason for hiding this comment

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

mix of maintenance burden + consistency with other things, this is i think the first time we do this conversion to a special type, and it's a weak point if the proto ever changes — this adds a second source of truth that isn't dependent on the other and is mostly redundant

i agree that doing the bigint juggling ourselves is the right choice, though. just a bit weird how this is the first time we've had to do this

Copy link
Contributor Author

@lukasIO lukasIO Oct 14, 2024

Choose a reason for hiding this comment

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

just a bit weird how this is the first time we've had to do this

FWIW in the client js sdk we do this for almost every proto type.
One downside of using the proto interfaces is that it is a complete protobuf class with conversion methods to/from JSON

@lukasIO lukasIO requested a review from davidzhao October 13, 2024 12:40
@nbsp
Copy link
Member

nbsp commented Oct 14, 2024

also add a changeset

@lukasIO lukasIO merged commit b0ff41a into main Oct 14, 2024
3 of 11 checks passed
@lukasIO lukasIO deleted the lukas/chat-api branch October 14, 2024 12:10
@github-actions github-actions bot mentioned this pull request Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants