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

WI regex keys #2200

Merged
merged 28 commits into from
May 16, 2024
Merged

WI regex keys #2200

merged 28 commits into from
May 16, 2024

Conversation

Wolfsblvt
Copy link
Contributor

WI keys will now support regexes. (both keys and secondary keys)

  • Regex uses javascript syntax, same as Regex extension. Flags are allowed and encouraged
  • Key control switched to select2
  • input show dropdown of all already chosen keys of this book
  • special display of regex keys and regex syntax highlighting

image

Detailed list of all other changes:

  • Custom tokenizer for regex parsing, allowing comma in regex
  • Keep mobile-compatibility by switching to textarea
  • select2 utility method to pre-fill options
  • New inline display mode of select2 multi to save space
  • moved select2 styling to its own file
  • Cache all keys for the loaded lorebook
  • Key selection dropdown shows all keys and how often they are used already

- Switch key/secondarykey controls to select2 input
- Custom tokenizer for regex parsing, allowing comma in regex
- Keep mobile-compatibility by switching to textarea
- select2 utility method to pre-fill options
- New inline display mode of select2 multi to save space
- WI custom style for regex keys
- moved select2 styling to its own file
- Cache all keys for the loaded lorebook
- Key selection dropdown shows all keys and how often they are used already
- More templating changes
@LenAnderson
Copy link
Contributor

Does select2 allow editing of the keys? Or only delete and re-add?

@Wolfsblvt
Copy link
Contributor Author

Only delete and re-add.
It's basically the "tagging" feature that they fleshed out.

I could try and implement some kind of edit functionality, but is that worth it?

@LenAnderson
Copy link
Contributor

LenAnderson commented May 9, 2024

That's gonna be pain, especially with regex keys.
It's one very poor UX behavior that I really hate about most implementations of these fancy combo boxes. Very few implementations seem to care enough to make it actually usable and not just look pretty.
Even a click to prompt modal would be better than delete and re-add if select2 is built too strongly against editing entries.

Edit: what I'm saying is: yes, definitely worth the effort.

@Wolfsblvt
Copy link
Contributor Author

select2 is basically an extended dropdown selection box with search and all. So yeah, there is no built-in edit functionality.

I see your point. And it shouldn't be too hard to implement. Left-click an entry opens it in edit-mode where you can edit the text of it again.
I think that's easy enough to implement. A bit work, but possible. I'll add it to my list and work on it soon. Question is - is that request important enough so that this PR should wait before its implemented, or can this be added without it to staging and the imminent next big ST release, before I come around implementing it?

@LenAnderson
Copy link
Contributor

LenAnderson commented May 9, 2024

I wouldn't call it a showstopper. ST isn't exactly known for great UX in the first place.
But I know I'm going to hate dealing with WI keys until it's fixed.
Maybe make select2 optional, since the plain textarea is still there for mobile anyways.

- Allow click on WI keys to edit
- Removes them from the key list, allowing direct text editing
- Refactor select2 click subscribe some more, fixing a few issues
@Wolfsblvt
Copy link
Contributor Author

Request done.

edit_wi_keys

@valden80
Copy link
Contributor

valden80 commented May 10, 2024

@Wolfsblvt
PLEASE! Make this optional! It's the main thing why I'm switched from the Kobold AI when they start implementig new UI (UI2) to the ST.
IT's ABSOLUTELY horrible UI for anyone who prefer keyboard and want minimal mouse usage. Simple plain text string for keywords is 10 times better experience for me. Please, don't broke something that already works!!!

P.S. I'm proposed about regexp keys long time ago, but if only I know that they will come with this...

@github-actions github-actions bot added the 🚫 Merge Conflicts [PR] Submitted code needs rebasing label May 10, 2024
@Wolfsblvt
Copy link
Contributor Author

The "don't make nice UI" people appear. Not unexpected.

The plain textbox still exists for mobile anyway. I can easily make this a toggle.

@Wolfsblvt Wolfsblvt marked this pull request as draft May 11, 2024 05:58
@valden80
Copy link
Contributor

@Wolfsblvt
Between "nice looking" and "easy to use" - I prefer second. Please, try to test it yourself in something close to real situation (real for user who actively use WI).
For example: just try to enter 5+ WI entries in row with ~10 primary and secondary keys for each. I bet - you will be tired and annoyed with "nice" interface very quickly if you need to switch between keyboard and mouse to add/edit for every keyword...

@Wolfsblvt
Copy link
Contributor Author

Typing for 10+ world entries is pretty easy, because the input hasn‘t changed at all. You can use Enter instead of comma, that‘s the only difference. Fixing mistakes until you have finished the key by typing Enter/Comma is easy too. Going back to a key with keyboard no. Editing past entries is okay too, but I can see how having to change keys regularly for whatever reason would be kind of annoying.

This PR is on hold. The UI portion will be likely scrapped completely and just the Regex matching stays. We have another big thing planned for which I am really excited.

- Implemented switch between fancy and plaintext input controls
- Fixed splitting keys into regexes index issue
- Fixed focus falsely adding text as key
@Wolfsblvt Wolfsblvt marked this pull request as ready for review May 14, 2024 02:51
@Wolfsblvt
Copy link
Contributor Author

Wolfsblvt commented May 14, 2024

Added an inline switcher of fancy/plaintext input modes. It'll reload the WI window and changes the input types back to the textarea, or the new select control. Saved in user settings.

image
image

Also did a few more hotfixes I ran into.

Even though I want to revamp the stuff like I said above, I think actually adding Regex key matching sooner than later makes sense. Would be sad to hold back the actual matching functionality if that one is completely done already.
If you think this is too risky, or I should still scrap the whole new UI control stuff, I can rework it again. I just couldn't bring it over me to just delete everything :/

This PR also makes the existing select2 inputs in WI (world selector at the top, character filter) slimmer and a bit nicer. So yeah.

@Wolfsblvt
Copy link
Contributor Author

@deffcolony seems like the repo bot is broken. There are no merge conflicts anymore but it didn't remove the tag.
maybe because when I pushed the commits it was still in Draft mode, so the checks didn't ran?

@github-actions github-actions bot added 🚫 Merge Conflicts [PR] Submitted code needs rebasing and removed 🚫 Merge Conflicts [PR] Submitted code needs rebasing labels May 14, 2024
@github-actions github-actions bot removed the 🚫 Merge Conflicts [PR] Submitted code needs rebasing label May 15, 2024
Copy link
Member

@Cohee1207 Cohee1207 left a comment

Choose a reason for hiding this comment

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

Now all we need is docs for it all.

@Cohee1207 Cohee1207 merged commit 719202b into SillyTavern:staging May 16, 2024
@Wolfsblvt
Copy link
Contributor Author

I'll make docs this weekend, for all the new WI stuff.

@Wolfsblvt Wolfsblvt deleted the wi-regex-keys branch May 16, 2024 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants