-
Notifications
You must be signed in to change notification settings - Fork 243
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
feat: stream translation titles in feed and post page #4098
base: feat-realtime-translation
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
218ee51
to
6343527
Compare
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.
Some initial comments, overall logic looks nice. Did not spend time yet to test it out.
@@ -24,6 +24,7 @@ | |||
"date-fns": "^2.25.0", | |||
"date-fns-tz": "1.2.2", | |||
"dompurify": "^2.5.4", | |||
"fetch-event-stream": "^0.1.5", |
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.
You are using this because native EventSource does not allow headers? I would rather use the query param from AI search and native EventSource
, wasteful to add dependencies for this.
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.
Yeah, it's because it doesn't allow headers, think it's a neater solutions than token (don't really like auth tokens in params, even short lived ones 🙈) and language as query param. Package is 730B gzipped, so negligible small imo.
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.
Can shave it down to 608B gzipped
by using events
and not their stream
wrapper which just adds two headers and checks if response is OK before returning events
🤪
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.
If anything, I think we should move AI search over to use this as well. Especially now when we're starting to send smart prompts, we might encounter issues with max length of URLs in browsers.
Also because EventSource
is kinda "deprecated", no browsers is going to remove it, but it's not getting any new features.
So the package is just for parsing the stream, fetch
natively supports streaming.
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.
Wondering can we just use fetch
then?
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.
So the package name is a bit misleading, it's more a parser than fetch. It exposes events
which is the stream parser (608B) then stream
(122B) which just wraps around fetch and returns the events
parsed stream.
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.
Nothing blocking, but do check question.
updatedPost.sharedPost.title = translation.title; | ||
updatedPost.sharedPost.translation = { title: !!translation.title }; | ||
} |
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.
Doesn't this set it wrong in cache?
eg some case the title might not render but we need it for some other field?
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.
No, don't think so
Changes
Events
Did you introduce any new tracking events?
Experiment
Did you introduce any new experiments?
Manual Testing
Caution
Please make sure existing components are not breaking/affected by this PR
AS-925
Preview domain
https://as-925-kvasir-stream.preview.app.daily.dev