Skip to content

Commit f9b316c

Browse files
authored
feat: Chat UI improvements (#210)
1 parent fbd57f6 commit f9b316c

File tree

4 files changed

+69
-55
lines changed

4 files changed

+69
-55
lines changed

apps/array/src/renderer/features/sessions/components/ChatBubble.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function ChatBubble({ variant, children }: ChatBubbleProps) {
1111

1212
return (
1313
<Box
14-
className={`mr-auto max-w-[95%] py-1 xl:max-w-[60%] [&>*:last-child]:mb-0 ${isUser ? "mt-4 rounded-xl rounded-bl-sm bg-gray-2 px-3 py-2" : ""}
14+
className={`mr-auto max-w-[95%] py-1 xl:max-w-[60%] [&>*:last-child]:mb-0 ${isUser ? "mt-4 rounded-xl rounded-bl-sm bg-accent-4 px-3 py-2" : ""}
1515
`}
1616
>
1717
{children}

apps/array/src/renderer/features/sessions/components/MessageEditor.tsx

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ export const MessageEditor = forwardRef<
430430
onClick={handleContainerClick}
431431
style={{ cursor: "text" }}
432432
>
433-
<Box className="max-h-[200px] flex-1 overflow-y-auto font-mono text-sm">
433+
<Box className="max-h-[200px] min-h-[30px] flex-1 overflow-y-auto font-mono text-sm">
434434
<EditorContent editor={editor} />
435435
</Box>
436436
<Flex justify="between" align="center">
@@ -448,32 +448,48 @@ export const MessageEditor = forwardRef<
448448
color="gray"
449449
onClick={() => fileInputRef.current?.click()}
450450
disabled={disabled}
451+
title="Attach file"
452+
style={{ marginLeft: "0px" }}
451453
>
452-
<Paperclip size={14} />
454+
<Paperclip size={14} weight="bold" />
453455
</IconButton>
454456
</Tooltip>
455-
{isLoading && onCancel ? (
456-
<IconButton
457-
size="1"
458-
variant="soft"
459-
color="red"
460-
onClick={onCancel}
461-
title="Stop"
462-
>
463-
<Stop size={14} weight="fill" />
464-
</IconButton>
465-
) : (
466-
<IconButton
467-
size="1"
468-
variant="solid"
469-
color="orange"
470-
onClick={handleSubmit}
471-
disabled={disabled || isEmpty}
472-
title="Send (Enter)"
473-
>
474-
<ArrowUp size={14} weight="bold" />
475-
</IconButton>
476-
)}
457+
<Flex gap="4" align="center">
458+
{isLoading && onCancel ? (
459+
<Tooltip content="Stop">
460+
<IconButton
461+
size="1"
462+
variant="soft"
463+
color="red"
464+
onClick={onCancel}
465+
title="Stop"
466+
>
467+
<Stop size={14} weight="fill" />
468+
</IconButton>
469+
</Tooltip>
470+
) : (
471+
<Tooltip
472+
content={
473+
disabled || isEmpty ? "Enter a message" : "Send message"
474+
}
475+
>
476+
<IconButton
477+
size="1"
478+
variant="solid"
479+
onClick={handleSubmit}
480+
disabled={disabled || isEmpty}
481+
loading={isLoading}
482+
style={{
483+
backgroundColor:
484+
disabled || isEmpty ? "var(--accent-a4)" : undefined,
485+
color: disabled || isEmpty ? "var(--accent-8)" : undefined,
486+
}}
487+
>
488+
<ArrowUp size={14} weight="bold" />
489+
</IconButton>
490+
</Tooltip>
491+
)}
492+
</Flex>
477493
</Flex>
478494
</Flex>
479495
);

apps/array/src/renderer/features/sessions/components/SessionView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ export function SessionView({
475475
const shouldCollapse = turn.isComplete && collapsibleMessages.length > 0;
476476

477477
return (
478-
<Box className="flex flex-col gap-2">
478+
<Box className="flex flex-col gap-4">
479479
<UserMessage content={turn.userMessage.content} />
480480
{shouldCollapse ? (
481481
<>
@@ -588,7 +588,7 @@ export function SessionView({
588588
renderItem={renderTurn}
589589
autoScrollToBottom
590590
className="flex-1 p-4"
591-
gap={8}
591+
gap={24}
592592
footer={
593593
<>
594594
{isPromptPending && (

apps/array/src/renderer/features/sessions/components/VirtualizedList.tsx

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ export function VirtualizedList<T>({
9999
});
100100
}, [autoScrollToBottom, items]);
101101

102-
if (items.length === 0) {
103-
return null;
104-
}
105-
106102
const virtualItems = virtualizer.getVirtualItems();
107103

108104
return (
@@ -111,30 +107,32 @@ export function VirtualizedList<T>({
111107
className={className}
112108
style={{ height: "100%", overflow: "auto" }}
113109
>
114-
<div
115-
style={{
116-
height: virtualizer.getTotalSize(),
117-
width: "100%",
118-
position: "relative",
119-
}}
120-
>
121-
{virtualItems.map((virtualRow) => (
122-
<div
123-
key={virtualRow.key}
124-
ref={virtualizer.measureElement}
125-
data-index={virtualRow.index}
126-
style={{
127-
position: "absolute",
128-
top: 0,
129-
left: 0,
130-
width: "100%",
131-
transform: `translateY(${virtualRow.start}px)`,
132-
}}
133-
>
134-
{renderItem(items[virtualRow.index], virtualRow.index)}
135-
</div>
136-
))}
137-
</div>
110+
{items.length > 0 && (
111+
<div
112+
style={{
113+
height: virtualizer.getTotalSize(),
114+
width: "100%",
115+
position: "relative",
116+
}}
117+
>
118+
{virtualItems.map((virtualRow) => (
119+
<div
120+
key={virtualRow.key}
121+
ref={virtualizer.measureElement}
122+
data-index={virtualRow.index}
123+
style={{
124+
position: "absolute",
125+
top: 0,
126+
left: 0,
127+
width: "100%",
128+
transform: `translateY(${virtualRow.start}px)`,
129+
}}
130+
>
131+
{renderItem(items[virtualRow.index], virtualRow.index)}
132+
</div>
133+
))}
134+
</div>
135+
)}
138136
{footer}
139137
</div>
140138
);

0 commit comments

Comments
 (0)