Skip to content

Commit 1c26bbe

Browse files
authored
Merge pull request #128 from HyunggyuJang/sydney/tone-adjustment
Make tone adjustment available after conversation started if sydney
2 parents 52d57f6 + 6f03730 commit 1c26bbe

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
export default function AdjustButton({ onClick }) {
3+
const clickHandler = (e) => {
4+
e.preventDefault();
5+
onClick();
6+
};
7+
return (
8+
<button
9+
onClick={clickHandler}
10+
className="group absolute bottom-11 md:bottom-0 -right-11 flex h-[100%] w-[50px] items-center justify-center bg-transparent p-1 text-gray-500"
11+
>
12+
<div className="m-1 mr-0 rounded-md p-2 pt-[10px] pb-[10px] group-hover:bg-gray-100 group-disabled:hover:bg-transparent dark:group-hover:bg-gray-900 dark:group-hover:text-gray-400 dark:group-disabled:hover:bg-transparent">
13+
<svg
14+
xmlns="http://www.w3.org/2000/svg"
15+
fill="none"
16+
viewBox="0 0 24 24"
17+
height="1em"
18+
width="1em"
19+
strokeWidth="2"
20+
stroke="currentColor"
21+
className="mr-1 h-4 w-4">
22+
<path
23+
strokeLinecap="round"
24+
strokeLinejoin="round"
25+
d="M10.5 6h9.75M10.5 6a1.5 1.5 0 11-3 0m3 0a1.5 1.5 0 10-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-9.75 0h9.75" />
26+
</svg>
27+
</div>
28+
</button>
29+
);
30+
}

client/src/components/Main/BingStyles.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ function BingStyles(props, ref) {
99
const { model } = useSelector((state) => state.submit);
1010
const { conversationId } = useSelector((state) => state.convo);
1111
const { messages } = useSelector((state) => state.messages);
12-
12+
1313
const isBing = model === 'bingai' || model === 'sydney';
1414
useEffect(() => {
15-
if (isBing && !conversationId) {
15+
if (model === 'bingai' && !conversationId || model === 'sydney') {
1616
dispatch(setConversation({ toneStyle: value }));
1717
}
18-
}, [isBing, conversationId, model, value, dispatch]);
18+
}, [conversationId, model, value, dispatch]);
1919

20-
const show = isBing && (!conversationId || messages?.length === 0);
20+
const show = isBing && ((!conversationId || messages?.length === 0) || props.show);
2121
const defaultClasses = 'p-2 rounded-md font-normal bg-white/[.60] dark:bg-gray-700 text-black';
2222
const defaultSelected = defaultClasses + 'font-medium data-[state=active]:text-white';
2323

client/src/components/Main/TextChat.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useRef } from 'react';
1+
import React, { useEffect, useRef, useState } from 'react';
22
import { useSelector, useDispatch } from 'react-redux';
33
import { SSE } from '~/utils/sse';
44
import SubmitButton from './SubmitButton';
@@ -15,14 +15,16 @@ import { setMessages } from '~/store/messageSlice';
1515
import { setSubmitState, toggleCursor } from '~/store/submitSlice';
1616
import { setText } from '~/store/textSlice';
1717
import { useMessageHandler } from '../../utils/handleSubmit';
18+
import AdjustToneButton from './AdjustToneButton';
1819

1920
export default function TextChat({ messages }) {
2021
const inputRef = useRef(null);
2122
const bingStylesRef = useRef(null);
23+
const [showBingToneSetting, setShowBingToneSetting] = useState(false);
2224
const isComposing = useRef(false);
2325
const dispatch = useDispatch();
2426
const convo = useSelector(state => state.convo);
25-
const { isSubmitting, stopStream, submission, disabled } = useSelector(state => state.submit);
27+
const { isSubmitting, stopStream, submission, disabled, model } = useSelector(state => state.submit);
2628
const { text } = useSelector(state => state.text);
2729
const { latestMessage } = convo;
2830
const { ask, regenerate, stopGenerating } = useMessageHandler();
@@ -372,13 +374,17 @@ export default function TextChat({ messages }) {
372374
return '';
373375
};
374376

377+
const handleBingToneSetting = () => {
378+
setShowBingToneSetting((show) => !show)
379+
}
380+
375381
return (
376382
<>
377383
<div className="input-panel md:bg-vert-light-gradient dark:md:bg-vert-dark-gradient fixed bottom-0 left-0 w-full border-t bg-white py-2 dark:border-white/20 dark:bg-gray-800 md:absolute md:border-t-0 md:border-transparent md:bg-transparent md:dark:border-transparent md:dark:bg-transparent">
378384
<form className="stretch mx-2 flex flex-row gap-3 last:mb-2 md:pt-2 md:last:mb-6 lg:mx-auto lg:max-w-3xl lg:pt-6">
379385
<div className="relative flex h-full flex-1 md:flex-col">
380386
<span className="order-last ml-1 flex justify-center gap-0 md:order-none md:m-auto md:mb-2 md:w-full md:gap-2">
381-
<BingStyles ref={bingStylesRef}/>
387+
<BingStyles ref={bingStylesRef} show={showBingToneSetting}/>
382388
{isSubmitting && !isSearchView ? (
383389
<button
384390
onClick={handleStopGenerating}
@@ -427,6 +433,9 @@ export default function TextChat({ messages }) {
427433
submitMessage={submitMessage}
428434
disabled={disabled || isNotAppendable}
429435
/>
436+
{messages?.length && model === 'sydney' ?
437+
<AdjustToneButton onClick={handleBingToneSetting} /> :
438+
null}
430439
</div>
431440
</div>
432441
</form>

0 commit comments

Comments
 (0)