📧 feat: Mention "@" Command Popover (#2635)

* feat: initial mockup

* wip: activesetting, may use or not use

* wip: mention with useCombobox usage

* feat: connect textarea to new mention popover

* refactor: consolidate icon logic for Landing/convos

* refactor: cleanup URL logic

* refactor(useTextarea): key up handler

* wip: render desired mention options

* refactor: improve mention detection

* feat: modular chat the default option

* WIP: first pass mention selection

* feat: scroll mention items with keypad

* chore(showMentionPopoverFamily): add typing to atomFamily

* feat: removeAtSymbol

* refactor(useListAssistantsQuery): use defaultOrderQuery as default param

* feat: assistants mentioning

* fix conversation switch errors

* filter mention selections based on startup settings and available endpoints

* fix: mentions model spec icon URL

* style: archive icon

* fix: convo renaming behavior on click

* fix(Convo): toggle hover state

* style: EditMenu refactor

* fix: archive chats table

* fix: errorsToString import

* chore: remove comments

* chore: remove comment

* feat: mention descriptions

* refactor: make sure continue hover button is always last, add correct fork button alt text
This commit is contained in:
Danny Avila 2024-05-07 13:13:55 -04:00 committed by GitHub
parent 89b1e33be0
commit b6d6343f54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 1048 additions and 217 deletions

View file

@ -14,11 +14,13 @@ export const getPresetIcon = (preset: TPreset, Icon) => {
type TEndpoints = Array<string | EModelEndpoint>;
export const getPresetTitle = (preset: TPreset) => {
export const getPresetTitle = (preset: TPreset, mention?: boolean) => {
const {
endpoint,
title: presetTitle,
model,
tools,
promptPrefix,
chatGptLabel,
modelLabel,
jailbreak,
@ -51,6 +53,21 @@ export const getPresetTitle = (preset: TPreset) => {
title = presetTitle + ': ';
}
if (mention) {
return `${modelInfo}${label ? ` | ${label}` : ''}${promptPrefix ? ` | ${promptPrefix}` : ''}${
tools
? ` | ${tools
.map((tool: TPlugin | string) => {
if (typeof tool === 'string') {
return tool;
}
return tool.pluginKey;
})
.join(', ')}`
: ''
}`;
}
return `${title}${modelInfo}${label ? ` (${label})` : ''}`.trim();
};

View file

@ -57,3 +57,19 @@ export const trimUndoneRange = (textAreaRef: React.RefObject<HTMLTextAreaElement
textAreaRef.current.value = newValue;
textAreaRef.current.setSelectionRange(selectionStart, selectionStart);
};
/**
* Remove the "@" character from the end of the textarea's text if it's present.
* This function ensures that the "@" is only removed if it's the last character.
*
* @param {HTMLTextAreaElement} textarea - The textarea element where text manipulation will occur.
*/
export function removeAtSymbolIfLast(textarea: HTMLTextAreaElement) {
if (textarea.value.endsWith('@')) {
textarea.value = textarea.value.slice(0, -1);
textarea.setSelectionRange(textarea.value.length, textarea.value.length);
textarea.dispatchEvent(new Event('input', { bubbles: true }));
}
textarea.focus();
}