feat(composer): carry reference image names and submit on Enter
Propagate an optional imageName through the agent content pipeline (frontend types → API → domain → prompt building) so reference images render with their name instead of a bare "image" label. Also switch PromptComposer to submit on plain Enter (Shift+Enter for newline, IME-safe) and add a submitDisabled guard wired from the canvas and home composers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -369,6 +369,7 @@ type AgentContent {
|
||||
Text string `json:"text,optional"`
|
||||
TextSource string `json:"textSource,optional"`
|
||||
ImageUrl string `json:"imageUrl,optional"`
|
||||
ImageName string `json:"imageName,optional"`
|
||||
ImageWidth int64 `json:"imageWidth,optional"`
|
||||
ImageHeight int64 `json:"imageHeight,optional"`
|
||||
}
|
||||
|
||||
@@ -4510,7 +4510,13 @@ func promptFromAgentMessages(messages []design.AgentChatMessage) string {
|
||||
if builder.Len() > 0 {
|
||||
builder.WriteString("\n")
|
||||
}
|
||||
builder.WriteString("Reference image: ")
|
||||
builder.WriteString("Reference image")
|
||||
if imageName := strings.TrimSpace(content.ImageName); imageName != "" {
|
||||
builder.WriteString(" (")
|
||||
builder.WriteString(compactReferenceImageName(imageName))
|
||||
builder.WriteString(")")
|
||||
}
|
||||
builder.WriteString(": ")
|
||||
builder.WriteString(imageURL)
|
||||
}
|
||||
}
|
||||
@@ -4519,6 +4525,10 @@ func promptFromAgentMessages(messages []design.AgentChatMessage) string {
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
func compactReferenceImageName(value string) string {
|
||||
return strings.Join(strings.Fields(value), " ")
|
||||
}
|
||||
|
||||
func hasUserPromptTextInAgentMessages(messages []design.AgentChatMessage) bool {
|
||||
for _, message := range messages {
|
||||
if strings.TrimSpace(message.Role) != "" && strings.ToLower(strings.TrimSpace(message.Role)) != "user" {
|
||||
|
||||
@@ -18,6 +18,7 @@ type AgentContent struct {
|
||||
Text string
|
||||
TextSource string
|
||||
ImageURL string
|
||||
ImageName string
|
||||
ImageWidth int64
|
||||
ImageHeight int64
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ type socketContent struct {
|
||||
Text string `json:"text"`
|
||||
TextSource string `json:"text_source"`
|
||||
ImageURL string `json:"image_url"`
|
||||
ImageName string `json:"image_name"`
|
||||
ImageWidth int64 `json:"image_width"`
|
||||
ImageHeight int64 `json:"image_height"`
|
||||
}
|
||||
@@ -155,6 +156,7 @@ func (data socketStartData) toDomainChat(projectID string) design.AgentChatReque
|
||||
Text: content.Text,
|
||||
TextSource: content.TextSource,
|
||||
ImageURL: content.ImageURL,
|
||||
ImageName: content.ImageName,
|
||||
ImageWidth: content.ImageWidth,
|
||||
ImageHeight: content.ImageHeight,
|
||||
})
|
||||
|
||||
@@ -519,6 +519,7 @@ func toDomainAgentChat(req *types.AgentChatRequest) design.AgentChatRequest {
|
||||
Text: content.Text,
|
||||
TextSource: content.TextSource,
|
||||
ImageURL: content.ImageUrl,
|
||||
ImageName: content.ImageName,
|
||||
ImageWidth: content.ImageWidth,
|
||||
ImageHeight: content.ImageHeight,
|
||||
})
|
||||
|
||||
@@ -49,6 +49,7 @@ type AgentContent struct {
|
||||
Text string `json:"text,optional"`
|
||||
TextSource string `json:"textSource,optional"`
|
||||
ImageUrl string `json:"imageUrl,optional"`
|
||||
ImageName string `json:"imageName,optional"`
|
||||
ImageWidth int64 `json:"imageWidth,optional"`
|
||||
ImageHeight int64 `json:"imageHeight,optional"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user