Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(assistant-ui): add rich mime-type icons and fix scroll direction access

Steven Enamakel4e3fcf640098
diff --git a/app/src/components/assistant-ui/file.tsx b/app/src/components/assistant-ui/file.tsx
index a5907668eb..ca042437dd 100644
--- a/app/src/components/assistant-ui/file.tsx
+++ b/app/src/components/assistant-ui/file.tsx
@@ -56,6 +56,22 @@ function getMimeTypeIcon(mimeType: string): FC<{ className?: string }> {
return FileIcon;
}
+function renderMimeTypeIcon(mimeType: string | undefined) {
+ const type = mimeType?.toLowerCase();
+
+ if (type?.startsWith('image/')) return <ImageIcon className="size-5" />;
+ if (type === 'application/pdf' || type === 'application/json' || type?.startsWith('text/')) {
+ return type === 'application/json' ? (
+ <BracesIcon className="size-5" />
+ ) : (
+ <FileTextIcon className="size-5" />
+ );
+ }
+ if (type?.startsWith('audio/')) return <MusicIcon className="size-5" />;
+ if (type?.startsWith('video/')) return <VideoIcon className="size-5" />;
+ return <FileIcon className="size-5" />;
+}
+
export type FileDataKind = 'data-uri' | 'url' | 'base64' | 'id';
function getFileDataKind(data: string, sourceType?: 'url' | 'id'): FileDataKind {
@@ -101,14 +117,12 @@ function FileRoot({ className, variant, size, children, ...props }: FileRootProp
type FileIconDisplayProps = React.ComponentProps<'span'> & { mimeType?: string };
function FileIconDisplay({ mimeType, className, children, ...props }: FileIconDisplayProps) {
- const IconComponent = mimeType ? getMimeTypeIcon(mimeType) : FileIcon;
-
return (
<span
data-slot="file-icon"
className={cn('text-muted-foreground shrink-0', className)}
{...props}>
- {children ?? <IconComponent className="size-5" />}
+ {children ?? renderMimeTypeIcon(mimeType)}
</span>
);
}
diff --git a/app/src/components/assistant-ui/follow-up-suggestions.tsx b/app/src/components/assistant-ui/follow-up-suggestions.tsx
index ccdb0b2bc4..3746a11059 100644
--- a/app/src/components/assistant-ui/follow-up-suggestions.tsx
+++ b/app/src/components/assistant-ui/follow-up-suggestions.tsx
@@ -16,7 +16,7 @@ const FollowupSuggestionsRow: FC = () => {
// scrollLeft runs 0..-max in RTL; normalize to hidden width per physical edge.
const fromStart = Math.abs(el.scrollLeft);
// getComputedStyle forces a style recalc per scroll event; direction is stable, read it once.
- const rtl = (rtlRef.current ??= getComputedStyle(el).direction === 'rtl');
+ const rtl = (rtlRef.current ??= window.getComputedStyle(el).direction === 'rtl');
const [left, right] = rtl
? [maxScroll - fromStart, fromStart]
: [fromStart, maxScroll - fromStart];