Skip to content

Commit a3a4bf4

Browse files
committed
Nebula: Fix User Image message type (#7018)
<!-- ## 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 focuses on updating the image handling in the `types.ts` and related components by modifying the structure of image objects, allowing for optional `image_url` and `b64` properties. ### Detailed summary - In `types.ts`, changed the `image` type to include `image_url: string | null` and `b64: string | null`. - In `ChatBar.tsx`, added `image_url: null` when pushing the image object to `userMessage.content`. - In `Chats.tsx`, updated the condition to check if `msg.b64` is a string and used `msg.image_url ?? ""` for the URL. - In `NebulaImage.tsx`, adjusted the skeleton div to have a minimum height of 300px. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent e8ec54e commit a3a4bf4

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ type SessionContextFilter = {
66
type NebulaUserMessageContentItem =
77
| {
88
type: "image";
9-
image_url: string;
10-
}
11-
| {
12-
type: "image";
13-
b64: string;
9+
image_url: string | null;
10+
b64: string | null;
1411
}
1512
| {
1613
type: "text";

apps/dashboard/src/app/nebula-app/(app)/components/ChatBar.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ export function ChatBar(props: {
8282
if (images.length > 0) {
8383
for (const image of images) {
8484
if (image.b64) {
85-
userMessage.content.push({ type: "image", b64: image.b64 });
85+
userMessage.content.push({
86+
type: "image",
87+
b64: image.b64,
88+
image_url: null,
89+
});
8690
}
8791
}
8892
}

apps/dashboard/src/app/nebula-app/(app)/components/Chats.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ function RenderMessage(props: {
202202
<NebulaImage
203203
type="submitted"
204204
url={
205-
"b64" in msg
205+
typeof msg.b64 === "string"
206206
? msg.b64.startsWith("data:image")
207207
? msg.b64
208208
: `data:image/png;base64,${msg.b64}`
209-
: msg.image_url
209+
: (msg.image_url ?? "")
210210
}
211211
client={props.client}
212212
/>

apps/dashboard/src/app/nebula-app/(app)/components/NebulaImage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ export function NebulaImage(
5555
height={props.type === "response" ? props.height : undefined}
5656
src={src}
5757
className="w-full rounded-lg border hover:border-active-border"
58-
skeleton={<div className="animate-skeleton bg-muted" />}
58+
skeleton={
59+
<div className="min-h-[300px] animate-skeleton bg-muted" />
60+
}
5961
/>
6062
</DialogTrigger>
6163

0 commit comments

Comments
 (0)