@@ -25,6 +25,7 @@ import {
2525import { useData } from "../context"
2626import { useDiffComponent } from "../context/diff"
2727import { useCodeComponent } from "../context/code"
28+ import { useDialog } from "../context/dialog"
2829import { BasicTool } from "./basic-tool"
2930import { GenericTool } from "./basic-tool"
3031import { Button } from "./button"
@@ -33,6 +34,7 @@ import { Icon } from "./icon"
3334import { Checkbox } from "./checkbox"
3435import { DiffChanges } from "./diff-changes"
3536import { Markdown } from "./markdown"
37+ import { ImagePreview } from "./image-preview"
3638import { getDirectory as _getDirectory , getFilename } from "@opencode-ai/util/path"
3739import { checksum } from "@opencode-ai/util/encode"
3840import { createAutoScroll } from "../hooks"
@@ -264,6 +266,8 @@ export function AssistantMessageDisplay(props: { message: AssistantMessage; part
264266}
265267
266268export function UserMessageDisplay ( props : { message : UserMessage ; parts : PartType [ ] } ) {
269+ const dialog = useDialog ( )
270+
267271 const textPart = createMemo (
268272 ( ) => props . parts ?. find ( ( p ) => p . type === "text" && ! ( p as TextPart ) . synthetic ) as TextPart | undefined ,
269273 )
@@ -286,13 +290,26 @@ export function UserMessageDisplay(props: { message: UserMessage; parts: PartTyp
286290 } ) ,
287291 )
288292
293+ const openImagePreview = ( url : string , alt ?: string ) => {
294+ dialog . show ( ( ) => < ImagePreview src = { url } alt = { alt } /> )
295+ }
296+
289297 return (
290298 < div data-component = "user-message" >
291299 < Show when = { attachments ( ) . length > 0 } >
292300 < div data-slot = "user-message-attachments" >
293301 < For each = { attachments ( ) } >
294302 { ( file ) => (
295- < div data-slot = "user-message-attachment" data-type = { file . mime . startsWith ( "image/" ) ? "image" : "file" } >
303+ < div
304+ data-slot = "user-message-attachment"
305+ data-type = { file . mime . startsWith ( "image/" ) ? "image" : "file" }
306+ data-clickable = { file . mime . startsWith ( "image/" ) && ! ! file . url }
307+ onClick = { ( ) => {
308+ if ( file . mime . startsWith ( "image/" ) && file . url ) {
309+ openImagePreview ( file . url , file . filename )
310+ }
311+ } }
312+ >
296313 < Show
297314 when = { file . mime . startsWith ( "image/" ) && file . url }
298315 fallback = {
0 commit comments