Skip to content

Commit 4476129

Browse files
committed
change all icons to heroicons
1 parent 7d59402 commit 4476129

File tree

6 files changed

+117
-50
lines changed

6 files changed

+117
-50
lines changed

tools/server/webui/src/components/ChatInputExtraContextItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function ChatInputExtraContextItem({
5757
</div>
5858

5959
<div className="text-xs pr-4">
60-
<b>{item.name}</b>
60+
<b>{item.name ?? 'Extra content'}</b>
6161
</div>
6262
</>
6363
)}
@@ -69,7 +69,7 @@ export default function ChatInputExtraContextItem({
6969
<dialog className="modal modal-open">
7070
<div className="modal-box">
7171
<div className="flex justify-between items-center mb-4">
72-
<b>{showingItem.name}</b>
72+
<b>{showingItem.name ?? 'Extra content'}</b>
7373
<button className="btn btn-ghost btn-sm">
7474
<XMarkIcon className="h-5 w-5" onClick={() => setShow(-1)} />
7575
</button>

tools/server/webui/src/components/ChatMessage.tsx

Lines changed: 63 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ import { useAppContext } from '../utils/app.context';
33
import { Message, PendingMessage } from '../utils/types';
44
import { classNames } from '../utils/misc';
55
import MarkdownDisplay, { CopyButton } from './MarkdownDisplay';
6-
import { ChevronLeftIcon, ChevronRightIcon } from '@heroicons/react/24/outline';
6+
import {
7+
ArrowPathIcon,
8+
ChevronLeftIcon,
9+
ChevronRightIcon,
10+
PencilSquareIcon,
11+
} from '@heroicons/react/24/outline';
712
import ChatInputExtraContextItem from './ChatInputExtraContextItem';
13+
import { BtnWithTooltips } from '../utils/common';
814

915
interface SplitMessage {
1016
content: PendingMessage['content'];
@@ -138,31 +144,11 @@ export default function ChatMessage({
138144
{/* render message as markdown */}
139145
<div dir="auto">
140146
{thought && (
141-
<details
142-
className="collapse bg-base-200 collapse-arrow mb-4"
143-
open={isThinking && config.showThoughtInProgress}
144-
>
145-
<summary className="collapse-title">
146-
{isPending && isThinking ? (
147-
<span>
148-
<span
149-
v-if="isGenerating"
150-
className="loading loading-spinner loading-md mr-2"
151-
style={{ verticalAlign: 'middle' }}
152-
></span>
153-
<b>Thinking</b>
154-
</span>
155-
) : (
156-
<b>Thought Process</b>
157-
)}
158-
</summary>
159-
<div className="collapse-content">
160-
<MarkdownDisplay
161-
content={thought}
162-
isGenerating={isPending}
163-
/>
164-
</div>
165-
</details>
147+
<ThoughtProcess
148+
isThinking={!!isThinking && !!isPending}
149+
content={thought}
150+
open={config.showThoughtInProgress}
151+
/>
166152
)}
167153

168154
<MarkdownDisplay
@@ -236,38 +222,80 @@ export default function ChatMessage({
236222
)}
237223
{/* user message */}
238224
{msg.role === 'user' && (
239-
<button
240-
className="badge btn-mini show-on-hover"
225+
<BtnWithTooltips
226+
className="btn-mini show-on-hover w-8 h-8"
241227
onClick={() => setEditingContent(msg.content)}
242228
disabled={msg.content === null}
229+
tooltipsContent="Edit message"
243230
>
244-
✍️ Edit
245-
</button>
231+
<PencilSquareIcon className="h-4 w-4" />
232+
</BtnWithTooltips>
246233
)}
247234
{/* assistant message */}
248235
{msg.role === 'assistant' && (
249236
<>
250237
{!isPending && (
251-
<button
252-
className="badge btn-mini show-on-hover mr-2"
238+
<BtnWithTooltips
239+
className="btn-mini show-on-hover w-8 h-8"
253240
onClick={() => {
254241
if (msg.content !== null) {
255242
onRegenerateMessage(msg as Message);
256243
}
257244
}}
258245
disabled={msg.content === null}
246+
tooltipsContent="Regenerate response"
259247
>
260-
🔄 Regenerate
261-
</button>
248+
<ArrowPathIcon className="h-4 w-4" />
249+
</BtnWithTooltips>
262250
)}
263251
</>
264252
)}
265253
<CopyButton
266-
className="badge btn-mini show-on-hover mr-2"
254+
className="btn-mini show-on-hover w-8 h-8"
267255
content={msg.content}
268256
/>
269257
</div>
270258
)}
271259
</div>
272260
);
273261
}
262+
263+
function ThoughtProcess({
264+
isThinking,
265+
content,
266+
open,
267+
}: {
268+
isThinking: boolean;
269+
content: string;
270+
open: boolean;
271+
}) {
272+
return (
273+
<div
274+
tabIndex={0}
275+
className={classNames({
276+
'collapse bg-none': true,
277+
'collapse-open': open,
278+
})}
279+
>
280+
<input type="checkbox" />
281+
<div className="collapse-title px-0">
282+
{isThinking ? (
283+
<span>
284+
<span
285+
className="loading loading-spinner loading-md mr-2"
286+
style={{ verticalAlign: 'middle' }}
287+
></span>
288+
<b>Thinking</b>
289+
</span>
290+
) : (
291+
<b>Thought Process</b>
292+
)}
293+
</div>
294+
<div className="collapse-content text-base-content/70 text-sm p-1">
295+
<div className="border-l-2 border-base-content/20 pl-4 mb-4">
296+
<MarkdownDisplay content={content} />
297+
</div>
298+
</div>
299+
</div>
300+
);
301+
}

tools/server/webui/src/components/ChatScreen.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ export default function ChatScreen() {
262262
onRegenerateMessage={handleRegenerateMessage}
263263
onEditMessage={handleEditMessage}
264264
onChangeSibling={setCurrNodeId}
265+
isPending={msg.isPending}
265266
/>
266267
))}
267268
</div>
@@ -321,10 +322,12 @@ function ChatInput({
321322
className="flex flex-col rounded-xl border-1 border-base-content/30 p-3 w-full"
322323
{...getRootProps()}
323324
>
324-
<ChatInputExtraContextItem
325-
items={extraContext.items}
326-
removeItem={extraContext.removeItem}
327-
/>
325+
{!isGenerating && (
326+
<ChatInputExtraContextItem
327+
items={extraContext.items}
328+
removeItem={extraContext.removeItem}
329+
/>
330+
)}
328331

329332
<div className="flex flex-row w-full">
330333
<textarea

tools/server/webui/src/components/MarkdownDisplay.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { ElementContent, Root } from 'hast';
1111
import { visit } from 'unist-util-visit';
1212
import { useAppContext } from '../utils/app.context';
1313
import { CanvasType } from '../utils/types';
14+
import { BtnWithTooltips } from '../utils/common';
15+
import { DocumentDuplicateIcon, PlayIcon } from '@heroicons/react/24/outline';
1416

1517
export default function MarkdownDisplay({
1618
content,
@@ -81,10 +83,13 @@ const CodeBlockButtons: React.ElementType<
8183
'display-none': !node?.position,
8284
})}
8385
>
84-
<CopyButton className="badge btn-mini" content={copiedContent} />
86+
<CopyButton
87+
className="badge btn-mini btn-soft shadow-sm"
88+
content={copiedContent}
89+
/>
8590
{canRunCode && (
8691
<RunPyCodeButton
87-
className="badge btn-mini ml-2"
92+
className="badge btn-mini shadow-sm ml-2"
8893
content={copiedContent}
8994
/>
9095
)}
@@ -101,16 +106,17 @@ export const CopyButton = ({
101106
}) => {
102107
const [copied, setCopied] = useState(false);
103108
return (
104-
<button
109+
<BtnWithTooltips
105110
className={className}
106111
onClick={() => {
107112
copyStr(content);
108113
setCopied(true);
109114
}}
110115
onMouseLeave={() => setCopied(false)}
116+
tooltipsContent={copied ? 'Copied!' : 'Copy'}
111117
>
112-
{copied ? 'Copied!' : '📋 Copy'}
113-
</button>
118+
<DocumentDuplicateIcon className="h-4 w-4" />
119+
</BtnWithTooltips>
114120
);
115121
};
116122

@@ -124,17 +130,18 @@ export const RunPyCodeButton = ({
124130
const { setCanvasData } = useAppContext();
125131
return (
126132
<>
127-
<button
133+
<BtnWithTooltips
128134
className={className}
129135
onClick={() =>
130136
setCanvasData({
131137
type: CanvasType.PY_INTERPRETER,
132138
content,
133139
})
134140
}
141+
tooltipsContent="Run code"
135142
>
136-
▶️ Run
137-
</button>
143+
<PlayIcon className="h-4 w-4" />
144+
</BtnWithTooltips>
138145
</>
139146
);
140147
};

tools/server/webui/src/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ html {
3535
@apply md:opacity-0 md:group-hover:opacity-100;
3636
}
3737
.btn-mini {
38-
@apply cursor-pointer hover:shadow-md;
38+
@apply cursor-pointer;
3939
}
4040
.chat-screen {
4141
max-width: 900px;

tools/server/webui/src/utils/common.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,32 @@ export const OpenInNewTab = ({
3636
{children}
3737
</a>
3838
);
39+
40+
export function BtnWithTooltips({
41+
className,
42+
onClick,
43+
onMouseLeave,
44+
children,
45+
tooltipsContent,
46+
disabled,
47+
}: {
48+
className?: string;
49+
onClick: () => void;
50+
onMouseLeave?: () => void;
51+
children: React.ReactNode;
52+
tooltipsContent: string;
53+
disabled?: boolean;
54+
}) {
55+
return (
56+
<div className="tooltip tooltip-bottom" data-tip={tooltipsContent}>
57+
<button
58+
className={`${className ?? ''} flex items-center justify-center`}
59+
onClick={onClick}
60+
disabled={disabled}
61+
onMouseLeave={onMouseLeave}
62+
>
63+
{children}
64+
</button>
65+
</div>
66+
);
67+
}

0 commit comments

Comments
 (0)