fix: hide queue attachment action for messages without attachments
Derive attachment presence from saved queue inputs and only show the preview action when attachments exist. Cover queue metadata and button visibility with regression tests. Release note: Queued messages without attachments no longer show the View attachments button.
This commit is contained in:
@@ -4618,6 +4618,22 @@ describe('AssistantDatabase', () => {
|
||||
}
|
||||
])
|
||||
|
||||
for (const [payload, hasAttachments] of [
|
||||
[{ prompt: 'text' }, false],
|
||||
[{ input: { attachments: [] } }, false],
|
||||
[{ input: { attachments: [{ id: 'attachment' }] } }, true],
|
||||
[{ attachments: [{ id: 'attachment' }] }, true]
|
||||
] as const) {
|
||||
const queued = initial.enqueueConversationUserInput({
|
||||
conversationId,
|
||||
label: 'Attachment visibility',
|
||||
payloadJson: JSON.stringify(payload)
|
||||
})
|
||||
expect(queued.hasAttachments).toBe(hasAttachments)
|
||||
expect(initial.listConversationQueueItems(conversationId)[0]?.hasAttachments).toBe(hasAttachments)
|
||||
initial.cancelConversationQueueItem(queued.id)
|
||||
}
|
||||
|
||||
const first = initial.enqueueConversationUserInput({
|
||||
conversationId,
|
||||
label: '第一条消息',
|
||||
|
||||
@@ -782,7 +782,18 @@ function toSchedule(row: ScheduleWithTaskRow): AssistantSchedule {
|
||||
function toConversationQueueItem(
|
||||
row: ConversationQueueRow
|
||||
): ConversationQueueItem {
|
||||
let hasAttachments = false
|
||||
if (row.source === 'user' && row.payload_json) {
|
||||
try {
|
||||
const payload = JSON.parse(row.payload_json)
|
||||
const input = payload?.input ?? payload
|
||||
hasAttachments = Array.isArray(input?.attachments) && input.attachments.length > 0
|
||||
} catch {
|
||||
// Invalid queued payloads are reported when previewed or dispatched.
|
||||
}
|
||||
}
|
||||
return {
|
||||
hasAttachments,
|
||||
id: row.id,
|
||||
conversationId: row.conversation_id,
|
||||
source: row.source,
|
||||
|
||||
Reference in New Issue
Block a user