Skip to content

Commit 9ae48af

Browse files
authored
fix(list): 🐛 move cloud icon to model column (#51)
* fix(list): 🐛 move cloud icon to model column * fix(cloud): 🐛 show task failure reason in list
1 parent 63cefd1 commit 9ae48af

4 files changed

Lines changed: 81 additions & 17 deletions

File tree

src/renderer/pages/List.tsx

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -530,29 +530,41 @@ const List: React.FC = () => {
530530
}
531531
})()}
532532
</Tooltip>
533-
{record.provider === -1 && (
534-
<Tooltip title={t('task_type.cloud')}>
535-
<CloudOutlined style={{ color: '#1890ff' }} />
536-
</Tooltip>
537-
)}
538533
</Space>
539534
),
540535
},
541536
{
542537
title: t('columns.model'),
543538
dataIndex: "model_name",
544539
width: 240,
545-
render: (text: string) => (
546-
<Text
540+
render: (text: string, record: Task) => (
541+
<div
547542
style={{
548543
maxWidth: "240px",
549-
overflow: "hidden",
550-
textOverflow: "ellipsis",
551-
whiteSpace: "nowrap",
544+
display: "flex",
545+
alignItems: "center",
546+
gap: "4px",
552547
}}
553548
>
554-
{text}
555-
</Text>
549+
<Text
550+
style={{
551+
maxWidth: record.provider === -1 ? "216px" : "240px",
552+
overflow: "hidden",
553+
textOverflow: "ellipsis",
554+
whiteSpace: "nowrap",
555+
display: "inline-block",
556+
}}
557+
>
558+
{text}
559+
</Text>
560+
{record.provider === -1 && (
561+
<Tooltip title={t('task_type.cloud')}>
562+
<span style={{ display: "inline-flex", alignItems: "center" }}>
563+
<CloudOutlined style={{ color: "#1890ff" }} />
564+
</span>
565+
</Tooltip>
566+
)}
567+
</div>
556568
),
557569
},
558570
{
@@ -571,11 +583,15 @@ const List: React.FC = () => {
571583
title: t('columns.status'),
572584
dataIndex: "status",
573585
width: 100,
574-
render: (status: number, record: Task) => {
586+
render: (status: number, record: Task | CloudTask) => {
575587
const tag = <Tag color={getStatusColor(status)}>{getStatusText(status)}</Tag>;
576-
// Show error tooltip for failed status
577-
if (status === 0 && record.error) {
578-
return <Tooltip title={record.error}>{tag}</Tooltip>;
588+
const failedReason =
589+
record.error ||
590+
('error_message' in record ? record.error_message : undefined) ||
591+
('description' in record ? record.description : undefined);
592+
// Show tooltip for failed/partial-failed tasks if backend provides reason
593+
if ((status === 0 || status === 8) && failedReason) {
594+
return <Tooltip title={failedReason}>{tag}</Tooltip>;
579595
}
580596
return tag;
581597
},

src/renderer/pages/__tests__/List.test.tsx

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ vi.mock('react-i18next', () => ({
3838
'actions.view': 'View',
3939
'actions.cancel': 'Cancel',
4040
'actions.retry': 'Retry',
41-
'actions.delete': 'Delete'
41+
'actions.delete': 'Delete',
42+
'task_type.cloud': 'Cloud Task'
4243
}
4344
return translations[key] || key
4445
},
@@ -412,6 +413,46 @@ describe('List', () => {
412413
})
413414
})
414415

416+
describe('Cloud Task Indicator', () => {
417+
it('should render cloud icon in model column instead of file column', async () => {
418+
vi.mocked(window.api.task.getAll).mockResolvedValue({
419+
success: true,
420+
data: {
421+
list: [
422+
{
423+
id: 'cloud-task-1',
424+
filename: 'very-long-cloud-filename-that-should-not-cover-cloud-icon.pdf',
425+
type: 'pdf',
426+
pages: 3,
427+
model_name: 'Markdown.Fit Pro',
428+
progress: 60,
429+
status: 3,
430+
provider: -1
431+
}
432+
],
433+
total: 1
434+
}
435+
})
436+
437+
render(
438+
<Wrapper>
439+
<List />
440+
</Wrapper>
441+
)
442+
443+
await waitFor(() => {
444+
const row = document.querySelector('.ant-table-tbody tr')
445+
expect(row).toBeInTheDocument()
446+
})
447+
448+
const row = document.querySelector('.ant-table-tbody tr') as HTMLTableRowElement
449+
const cells = row.querySelectorAll('td')
450+
451+
expect(cells[0].querySelector('[aria-label="cloud"]')).toBeNull()
452+
expect(cells[1].querySelector('[aria-label="cloud"]')).toBeInTheDocument()
453+
})
454+
})
455+
415456
describe('Page Count Display', () => {
416457
it('should display page count for multi-page files', async () => {
417458
render(

src/renderer/utils/cloudTaskMapper.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface CloudTask extends Task {
99
isCloud: boolean;
1010
/** Unix timestamp in ms for sorting */
1111
sortTimestamp: number;
12+
description?: string;
13+
error_message?: string;
1214
}
1315

1416
/**
@@ -63,6 +65,9 @@ export function mapCloudTaskToTask(ct: CloudTaskResponse): CloudTask {
6365
status: ct.status,
6466
completed_count: pagesCompleted,
6567
failed_count: ct.pages_failed || 0,
68+
error: ct.error_message || ct.description || null,
69+
description: ct.description,
70+
error_message: ct.error_message,
6671
isCloud: true,
6772
sortTimestamp,
6873
};

src/shared/types/cloud-api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ export interface CloudTaskResponse {
122122
file_name: string;
123123
status: number;
124124
status_name: string;
125+
description?: string;
126+
error_message?: string;
125127
page_count: number;
126128
pages_completed: number;
127129
pages_failed: number;

0 commit comments

Comments
 (0)