LostRuins / lite.koboldai.net

A zero dependency web UI for KoboldAI Horde
GNU Affero General Public License v3.0
74 stars 35 forks source link

"Enter" key does not submit typed message in Pale Moon outside of "Aesthetic Chat UI" #2

Closed NintendoManiac64 closed 1 year ago

NintendoManiac64 commented 1 year ago

This occurs on both Windows 7 SP1 and Linux Mint 20.3, and I tested on Windows using a newly-downloaded copy of Pale Moon Portable (see the attached video).

Simply put, the "Enter" key does not work in Pale Moon for submitting the message that you typed when using the "Aesthetic Chat UI". This issue does not occur in LibreWolf.

More information from https://repo.palemoon.org/MoonchildProductions/UXP/issues/2153

This is likely because of our change in keypress handling as introduced in 74b3ce90d7 that was a response to the bad practice on the web to use onkeypress handlers to attempt to "filter" inputs (instead of using the normal methods available in HTML to do so). We aligned with the behavior in other mainstream browsers in this case even though I considered it webmaster error.

If websites use onkeypress enter to trigger script processing of a message, then that will likely no longer work, and will need a scripting change on the affected websites.

See the following attached video for a demonstration of the issue (do not mind the messages in the video speaking of an issue with scrolling; I didn't realize at the time that the "autoscroll" setting on Kobold is disabled by default):

video.webm

LostRuins commented 1 year ago

Hello @NintendoManiac64 thanks for bringing this to my attention. This is a very poor choice on Pale Moon's part.

Nevertheless, I have deployed a change that changes the trigger event from KeyPress to KeyUp, which should hopefully solve this issue. Could you help me see if that resolves the problem? Thanks.

NintendoManiac64 commented 1 year ago

This is a very poor choice on Pale Moon's part.

I know nothing of code, but I do know that Pale Moon tends to not like playing "follow the leader" in terms of what Chrome does if that clarifies anything.

Nevertheless, I have deployed a change that changes the trigger event from KeyPress to KeyUp, which should hopefully solve this issue. Could you help me see if that resolves the problem? Thanks.

I'm not seeing any change in end-result unless it's not yet active on https://lite.koboldai.net at this time.

(is there a particular reason you are unable to download a portable copy of Pale Moon yourself to try? My video even basically doubles as a demonstration on where and how to download it; heck Pale Moon Portable it even works in Wine 8.x if you don't want to try the native Linux version)

jobbautista9 commented 1 year ago

Hi, it seems further digging by one of Pale Moon's developers reveal that your website is using global window.event. We don't plan to support this in the future as it has never been a part of the standard, and though mainstream browsers like Chrome and Firefox (and do note that Firefox supported this pretty late, starting with version 66) currently support it, the MDN says this is deprecated and recommends doing away with it. Please use the event passed into the handler instead. Not only will this ensure compatibility across all modern browsers, it will also remove potential fragility in your JavaScript. :) It shouldn't take long to fix.

LostRuins commented 1 year ago

Thank you for highlighting this, @jobbautista9 . I have now switched it to the local event handler and it seems to be working fine.

@NintendoManiac64 , can you confirm if this issue is now resolved for you?

NintendoManiac64 commented 1 year ago

Confirmed that it's working now.

That being said, since the issue was initially mis-diagnosed, it might be a good idea to revert commit a214c01 where you switched to KeyUp.

Also, the head Pale Moon dev actually says using KeyDown would make more sense, but I'm not sure how applicable that'd be if we mis-diagnosed the issue in the first place.

EDIT: Okay yeah, the "KeyUp" change really should be reverted because it causes some issues like sending a line-break right before sending a message, which also means that, when you have no message and press enter, it instead has you send an empty message rather than the chat bot just generating another message.

LostRuins commented 1 year ago

@NintendoManiac64 okay, the KeyUp change has been reverted back to original. If everything is fine, I will mark the issue as resolved.

NintendoManiac64 commented 1 year ago

Actually, it seems like the original behavior results in the enter key not even being able to have the chat bot generate another message even in the likes of Firefox. I wonder if the "KeyDown" behavior suggested by the head Pale Moon dev would actually solve that without having the line-break issues that "KeyUp" was causing?

LostRuins commented 1 year ago

Alright @NintendoManiac64 I've switched to KeyDown instead. Can you see if it works better for you?

For my own testing I use the latest versions of Firefox, Opera, Chrome, and all of them seem to work equally fine regardless of which keyup/keydown/keypress event I was handling. So I can't really compare myself.

NintendoManiac64 commented 1 year ago

Hmm, peculiar. KeyDown seems to behave exactly the same as the original behavior...

It would seem that we need to instead figure out some other way to make the enter key work when you have not typed anything in order to make the chat bot generate a new message without it having you send a blank message - perhaps something worthy of opening a separate issue?

As for 'KeyDown', my coding skills are so non-existent that I've no idea whether its better to revert again to the original behavior or to stick with 'KeyDown'.

LostRuins commented 1 year ago

Preventing enter key from triggering when the textbox is empty is intentional - you normally don't want to send a blank reply. Most other chat apps have the same behavior. If you want to send a blank message, you can manually trigger it with the Submit button.

Alright, marking this issue as closed. Do open another one if you encounter further issues. Thanks.

NintendoManiac64 commented 1 year ago

Most other chat apps have the same behavior. If you want to send a blank message, you can manually trigger it with the Submit button.

But in real life, you don't have the ability to "force" the other party to send another message like you do with chat bots.

As it stands, the only way to "force" the chat bot to send another message without taking your hands off of the keyboard is to press the "Tab" key and then the "Enter" but but then, to go back to the message field, you have to press the "Tab" key a bajillion times with defeats the purpose of trying to keep your hands on the keyboard.

(I think I now understand why Thinkpad enthusiasts enjoy their Trackpoint so much)

LostRuins commented 1 year ago

Understood - but people will normally interact with a chat UI in the same way and expect similar results.

I can probably add an exception to permit it for the aesthetic chat UI as it is single lined. I'll make the change, but it may be reverted if others find it a problem

For the default normal UI, this will be very disruptive as people use it to input multi-lined story prompts as well.

NintendoManiac64 commented 1 year ago

Idea - you know how shift+enter inserts a line-break? Well, starting a message with a line-break makes absolutely no sense, so maybe shift+enter, when nothing is typed, can have the chat bot generate another message instead?

(fun fact: the "chat" function on pixiv has shift+enter always function as "send message" so it's not unheard of)

LostRuins commented 1 year ago

Shift-enter sending a message instead would be a super unintuitive behavior. I'll just enable sending empty messages with the enter button, but only in aesthetic chat mode.

NintendoManiac64 commented 1 year ago

I only meant shift+enter only for when there's no typed message at all, and primarily for the non-aesthetic chat mode since I tend to just stay on "edit" mode permanently rather than toggle back-and-forth.

(this does actually mean that I have no problems with aesthetic chat mode other than you can't edit in it)

The idea would be that, if there's anything typed in the message box at all, even a space, then shift+enter does a line-break like normal. Unless the issue is the inconsistent behavior of shift+enter basically doing two different things in such a scenario?

LostRuins commented 1 year ago

still not a good idea in multilined mode. what if the user just wants to send a single newline? it would no longer be possible.

NintendoManiac64 commented 1 year ago

I think you're misunderstanding.

So my logic is to use the current behavior, but with a single exception that, if there's literally nothing typed at all in the message box, then shift+enter has the chat box generate a new message.

The idea is that the user would never begin a message with a linebreak, e.g.:


this is an example of a message that begins with a linebreak
LostRuins commented 1 year ago

my point is, sometimes they actually do, especially when writing stories. maybe less common for chat, but it's perfectly fine to want to add some newlines after the main story or adventure prompt. For example say the AI generated a giant block of text. You want to add a new paragraph after it. How? you start with a newline.

NintendoManiac64 commented 1 year ago

Oh. huh. I did not know that, but I am very much not the author/writer type, so what do I know?

I don't suppose there are any sort of other keyboard shortcuts that are possible?

EDIT: Oh man, if other keyboard shortcuts were possible, then that'd be amazing if the usual "Back", "Redo", "Rety", etc functions could be mapped to keyboard shortcuts as well.

LostRuins commented 1 year ago

I think the current behavior is mostly fine. If you want to send blank messages, now a simple Enter button will do so in chat mode. And for normal mode, this is usually a very uncommon requirement - pressing the submit button manually would be warranted in those cases. If you really only want to use the keyboard, a trick may be to send an empty space and then enable "Trim Whitespaces" in options, which would trim it back to empty anyway.

Just wondering, what's the issue with using tabs or the mouse cursor to select the "Submit" button? Is it somehow inaccessible?

NintendoManiac64 commented 1 year ago

I'll be honest, I wasn't even sure what the "Trim Whitespaces" setting was supposed to do... I'll give that a whirl.

Regarding Tab, it's mainly that going back from "Send" to the message box requires... uh, hang on I need to count... pressing Tab 23 times.

As for using the mouse, well, it's just that I'm a moderately fast typist at 70-80 words per minute.

NintendoManiac64 commented 1 year ago

a trick may be to send an empty space and then enable "Trim Whitespaces" in options, which would trim it back to empty anyway.

I tried this and it causes the "You" to still appear, albeit with no message next to it which was the same thing that was occurring with "KeyUp" if you had just pressed enter without typing anything at all.

Do you know if the end-result from the chat bot is the same compared to if you had instead had the chat bot just generate another message?