feat(chat): show sent images as thumbnails with a full-screen viewer
Operator-attached images render as rounded thumbnails above the user bubble and open a zoomable Material/Cupertino viewer. Inline data: URIs decode locally; file:// attachment-store URIs load through the new chat_attachment_image websocket request, which serves only regular image files directly inside the private attachment store (os.Root, <= 4 MiB, sniffed raster types). Missing files show an 'Image no longer available' placeholder; other files keep the file row.
This commit is contained in:
@@ -80,6 +80,12 @@ const (
|
||||
// session. ChatShellOutput reads a bounded page from one such shell.
|
||||
ChatShells = "chat_shells"
|
||||
ChatShellOutput = "chat_shell_output"
|
||||
// ChatAttachmentImage reads back one image the operator attached earlier,
|
||||
// so a transcript can draw it after a reload. The request body is
|
||||
// ChatAttachmentImageRequest (the history part's file:// URI) and the reply
|
||||
// carries ChatAttachmentImageContent. Only regular image files inside the
|
||||
// server's private chat attachment store are served.
|
||||
ChatAttachmentImage = "chat_attachment_image"
|
||||
// ChatEvent and ChatPermission are the server-pushed frames; they are the
|
||||
// only types the server sends without a matching request.
|
||||
ChatEvent = "chat_event"
|
||||
@@ -361,6 +367,21 @@ type ChatAttachment struct {
|
||||
Upload string `json:"upload,omitempty"`
|
||||
}
|
||||
|
||||
// ChatAttachmentImageRequest names one stored attachment by the file:// URI a
|
||||
// history file part carries.
|
||||
type ChatAttachmentImageRequest struct {
|
||||
URI string `json:"uri"`
|
||||
}
|
||||
|
||||
// ChatAttachmentImageContent is the chat_attachment_image reply: the file's
|
||||
// bytes as standard base64 and the image MIME type sniffed from those bytes.
|
||||
type ChatAttachmentImageContent struct {
|
||||
URI string `json:"uri"`
|
||||
Mime string `json:"mime"`
|
||||
Size int64 `json:"size"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
// ChatMessage is one stored turn returned by chat_messages. A user turn is a
|
||||
// single text part; an assistant turn holds the text, reasoning and tool parts
|
||||
// the phone renders. Parts corresponds to the OpenCode content array.
|
||||
|
||||
@@ -229,6 +229,10 @@ type Message struct {
|
||||
ChatShellOutputQuery *ChatShellOutputQuery `json:"chat_shell_output_query,omitempty"`
|
||||
ChatShells []ChatShell `json:"chat_shells,omitempty"`
|
||||
ChatShellOutput *ChatShellOutputPage `json:"chat_shell_output,omitempty"`
|
||||
// ChatAttachmentImageRequest is the chat_attachment_image body and
|
||||
// ChatAttachmentImage its reply.
|
||||
ChatAttachmentImageRequest *ChatAttachmentImageRequest `json:"chat_attachment_image_request,omitempty"`
|
||||
ChatAttachmentImage *ChatAttachmentImageContent `json:"chat_attachment_image,omitempty"`
|
||||
// RunEvent is the server-pushed run state delta (see runevents.go) and
|
||||
// RunIDs the optional subscribe scope, so a client asks for the runs it
|
||||
// displays. Both are optional so older peers ignore them.
|
||||
|
||||
Reference in New Issue
Block a user