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:
@@ -311,6 +311,7 @@ function sameConversationQueueItems(
|
||||
item.id === candidate.id &&
|
||||
item.conversationId === candidate.conversationId &&
|
||||
item.source === candidate.source &&
|
||||
item.hasAttachments === candidate.hasAttachments &&
|
||||
item.label === candidate.label &&
|
||||
item.createdAt === candidate.createdAt &&
|
||||
item.scheduleRunId === candidate.scheduleRunId &&
|
||||
|
||||
@@ -81,6 +81,19 @@ describe('ConversationInputQueue', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it.each([undefined, false, true])('shows attachment preview only for attached inputs (%s)', (hasAttachments) => {
|
||||
render(
|
||||
<ConversationInputQueue
|
||||
items={[{ ...items[1]!, hasAttachments }]}
|
||||
onError={vi.fn()}
|
||||
onInterruptAndRun={vi.fn()}
|
||||
onRemove={vi.fn()}
|
||||
running={false}
|
||||
/>
|
||||
)
|
||||
expect(screen.queryByTitle('查看附件') !== null).toBe(hasAttachments === true)
|
||||
})
|
||||
|
||||
it('uses run-now wording while idle and reports action errors', async () => {
|
||||
const onError = vi.fn()
|
||||
render(
|
||||
|
||||
@@ -93,7 +93,7 @@ export const ConversationInputQueue = memo(
|
||||
{item.error && <small className="knowledge-inline-error" role="alert">{item.error}</small>}
|
||||
</span>
|
||||
<span className="conversation-input-queue__actions">
|
||||
{item.source === 'user' && <button type="button" aria-label={`查看入队附件:${item.label}`} title="查看附件" onClick={() => setViewing(item.id)}><Paperclip aria-hidden="true" size={13} /><span>查看附件</span></button>}
|
||||
{item.source === 'user' && item.hasAttachments && <button type="button" aria-label={`查看入队附件:${item.label}`} title="查看附件" onClick={() => setViewing(item.id)}><Paperclip aria-hidden="true" size={13} /><span>查看附件</span></button>}
|
||||
{onRestore && item.source === 'user' && <button type="button" disabled={pendingAction !== undefined} aria-label={`恢复到草稿:${item.label}`} title="恢复到草稿" onClick={() => void runAction(item.id, 'restore', () => onRestore(item.id))}><Undo2 aria-hidden="true" size={13} /><span>恢复到草稿</span></button>}
|
||||
<button
|
||||
aria-label={t(
|
||||
|
||||
Reference in New Issue
Block a user