-
Notifications
You must be signed in to change notification settings - Fork 45
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
input lag fix #708
input lag fix #708
Conversation
Deploying chatcraft-org with
|
Latest commit: |
2548100
|
Status: | ✅ Deploy successful! |
Preview URL: | https://904e2aa3.console-overthinker-dev.pages.dev |
Branch Preview URL: | https://taras-input-lag.console-overthinker-dev.pages.dev |
Not super excited to duplicate this fix for mobile..would be nice to unify the logic and just keep rendering separate |
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.
Seems to work, not sure what it loses, if anything.
I wonder if we can further drop state here and compare to values whenever necessary.
@@ -164,27 +161,25 @@ function DesktopPromptForm({ | |||
switch (e.key) { | |||
// Allow the user to cursor-up to repeat last prompt | |||
case "ArrowUp": | |||
if (!isDirty && previousMessage) { | |||
if (isPromptEmpty && previousMessage && inputPromptRef.current) { |
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.
Could you get rid of the isPromptEmpty
state completely and do:
if (inputPromptRef.current?.value === "" && previousMessage) {
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.
here either would work, this is just more consistent cos it does trim in state
@@ -422,7 +418,7 @@ function DesktopPromptForm({ | |||
/> | |||
|
|||
<Flex alignItems="center" gap={2}> | |||
<KeyboardHint isVisible={!!prompt.length && !isLoading} /> | |||
<KeyboardHint isVisible={!isPromptEmpty && !isLoading} /> |
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'm not sure if doing inputPromptRef.current.value !== ""
works here, but it might
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.
doesnt cos you need to trigger a react rerender
if (settings.enterBehaviour === "newline") { | ||
handleMetaEnter(e); | ||
} else if (settings.enterBehaviour === "send") { | ||
if (!e.shiftKey && prompt.length) { | ||
if (!e.shiftKey && !isPromptEmpty) { |
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 here
Stopped keeping prompt in react. @humphd how's this change?