diff --git a/app/components/mask.tsx b/app/components/mask.tsx index 106418e82..964a3cc35 100644 --- a/app/components/mask.tsx +++ b/app/components/mask.tsx @@ -106,6 +106,59 @@ export function MaskConfig(props: { ); } +function ContextPromptItem(props: { + prompt: Message; + update: (prompt: Message) => void; + remove: () => void; +}) { + const [focusingInput, setFocusingInput] = useState(false); + + return ( + <div className={chatStyle["context-prompt-row"]}> + {!focusingInput && ( + <select + value={props.prompt.role} + className={chatStyle["context-role"]} + onChange={(e) => + props.update({ + ...props.prompt, + role: e.target.value as any, + }) + } + > + {ROLES.map((r) => ( + <option key={r} value={r}> + {r} + </option> + ))} + </select> + )} + <Input + value={props.prompt.content} + type="text" + className={chatStyle["context-content"]} + rows={focusingInput ? 5 : 1} + onFocus={() => setFocusingInput(true)} + onBlur={() => setFocusingInput(false)} + onInput={(e) => + props.update({ + ...props.prompt, + content: e.currentTarget.value as any, + }) + } + /> + {!focusingInput && ( + <IconButton + icon={<DeleteIcon />} + className={chatStyle["context-delete-button"]} + onClick={() => props.remove()} + bordered + /> + )} + </div> + ); +} + export function ContextPrompts(props: { context: Message[]; updateContext: (updater: (context: Message[]) => void) => void; @@ -128,42 +181,12 @@ export function ContextPrompts(props: { <> <div className={chatStyle["context-prompt"]} style={{ marginBottom: 20 }}> {context.map((c, i) => ( - <div className={chatStyle["context-prompt-row"]} key={i}> - <select - value={c.role} - className={chatStyle["context-role"]} - onChange={(e) => - updateContextPrompt(i, { - ...c, - role: e.target.value as any, - }) - } - > - {ROLES.map((r) => ( - <option key={r} value={r}> - {r} - </option> - ))} - </select> - <Input - value={c.content} - type="text" - className={chatStyle["context-content"]} - rows={1} - onInput={(e) => - updateContextPrompt(i, { - ...c, - content: e.currentTarget.value as any, - }) - } - /> - <IconButton - icon={<DeleteIcon />} - className={chatStyle["context-delete-button"]} - onClick={() => removeContextPrompt(i)} - bordered - /> - </div> + <ContextPromptItem + key={i} + prompt={c} + update={(prompt) => updateContextPrompt(i, prompt)} + remove={() => removeContextPrompt(i)} + /> ))} <div className={chatStyle["context-prompt-row"]}> diff --git a/app/components/model-config.tsx b/app/components/model-config.tsx index 32c2f5c0d..fe9319e0f 100644 --- a/app/components/model-config.tsx +++ b/app/components/model-config.tsx @@ -1,4 +1,3 @@ -import styles from "./settings.module.scss"; import { ALL_MODELS, ModalConfigValidator, ModelConfig } from "../store"; import Locale from "../locales"; diff --git a/app/components/ui-lib.module.scss b/app/components/ui-lib.module.scss index 465fc0de4..ce512dab4 100644 --- a/app/components/ui-lib.module.scss +++ b/app/components/ui-lib.module.scss @@ -124,6 +124,18 @@ } } +@media screen and (max-width: 600px) { + .modal-container { + width: 100vw; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + + .modal-content { + max-height: 50vh; + } + } +} + .show { opacity: 1; transition: all ease 0.3s; @@ -191,13 +203,3 @@ resize: none; min-width: 50px; } - -@media only screen and (max-width: 600px) { - .modal-container { - width: 90vw; - - .modal-content { - max-height: 50vh; - } - } -} diff --git a/app/store/chat.ts b/app/store/chat.ts index 5abd81298..0d66580dc 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -33,7 +33,7 @@ export function createMessage(override: Partial<Message>): Message { }; } -export const ROLES: Message["role"][] = ["system", "user", "assistant"]; +export const ROLES: Message["role"][] = ["user", "system", "assistant"]; export interface ChatStat { tokenCount: number; diff --git a/app/styles/globals.scss b/app/styles/globals.scss index f849516a0..1ae908be5 100644 --- a/app/styles/globals.scss +++ b/app/styles/globals.scss @@ -248,6 +248,10 @@ div.math { display: flex; align-items: center; justify-content: center; + + @media screen and (max-width: 600px) { + align-items: flex-end; + } } .link {