Skip to content

Commit 2297915

Browse files
committed
[NEB-210] Nebula: Add image upload (#6995)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR introduces image upload functionality within the chat application, enhancing user interaction by allowing users to send images along with text messages. It also includes updates to various components to support this feature. ### Detailed summary - Added `allowImageUpload` prop to multiple components. - Introduced `ImageUploadButton` for image selection. - Modified `ChatBar` to handle image uploads and message composition. - Updated `FloatingChatContentLoggedIn`, `ChatPageContent`, and `EmptyStateChatPageContent` to accommodate new props. - Enhanced `NebulaImage` for displaying uploaded images. - Implemented image preview and removal functionality in `ChatBar`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 585ba2f commit 2297915

File tree

12 files changed

+484
-170
lines changed

12 files changed

+484
-170
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"use client";
2+
3+
import { Button } from "@/components/ui/button";
4+
import type React from "react";
5+
import { useRef } from "react";
6+
7+
interface ImageUploadProps {
8+
value: File | undefined;
9+
onChange?: (files: File[]) => void;
10+
children?: React.ReactNode;
11+
variant?: React.ComponentProps<typeof Button>["variant"];
12+
className?: string;
13+
multiple?: boolean;
14+
}
15+
16+
export function ImageUploadButton(props: ImageUploadProps) {
17+
const fileInputRef = useRef<HTMLInputElement>(null);
18+
19+
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
20+
const files = Array.from(e.target.files || []);
21+
props.onChange?.(files);
22+
};
23+
24+
return (
25+
<div>
26+
<Button
27+
variant={props.variant}
28+
onClick={() => fileInputRef.current?.click()}
29+
className={props.className}
30+
>
31+
{props.children}
32+
</Button>
33+
<input
34+
ref={fileInputRef}
35+
type="file"
36+
multiple={props.multiple}
37+
accept="image/*"
38+
onChange={handleFileChange}
39+
className="hidden"
40+
aria-label="Upload image"
41+
/>
42+
</div>
43+
);
44+
}

apps/dashboard/src/app/nebula-app/(app)/api/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ type NebulaUserMessageContentItem =
88
type: "image";
99
image_url: string;
1010
}
11+
| {
12+
type: "image";
13+
b64: string;
14+
}
1115
| {
1216
type: "text";
1317
text: string;

0 commit comments

Comments
 (0)