Skip to content

A full-featured download manager.

fix(downloads): improve inspector feedback and error layout

Dr_rOot79917441c93a
diff --git a/src/renderer/routes/downloads/inspector/overview-tab.test.tsx b/src/renderer/routes/downloads/inspector/overview-tab.test.tsx
index 1f304f7e..be26c49a 100644
--- a/src/renderer/routes/downloads/inspector/overview-tab.test.tsx
+++ b/src/renderer/routes/downloads/inspector/overview-tab.test.tsx
@@ -160,9 +160,19 @@ describe('OverviewTab', () => {
errorCode: DownloadErrorCode.NetworkError,
errorMessage: 'ECONNREFUSED 127.0.0.1:9999',
})
- expect(
- screen.getByText('ECONNREFUSED 127.0.0.1:9999')
- ).toBeInTheDocument()
+ const technicalDetail = screen.getByText('ECONNREFUSED 127.0.0.1:9999')
+ const alertDescription = technicalDetail.closest(
+ '[data-slot="alert-description"]'
+ )
+
+ expect(technicalDetail).toBeInTheDocument()
+ expect(alertDescription).toHaveClass('min-w-0')
+ expect(alertDescription).toContainElement(
+ screen.getByText('Check your network connection, then retry')
+ )
+ expect(alertDescription?.parentElement).toContainElement(
+ screen.getByText('Network connection failed')
+ )
})
it('hides retry for a Mux-kind error task (not rebuildable)', () => {
diff --git a/src/renderer/routes/downloads/inspector/overview-tab.tsx b/src/renderer/routes/downloads/inspector/overview-tab.tsx
index 33318f43..b293a693 100644
--- a/src/renderer/routes/downloads/inspector/overview-tab.tsx
+++ b/src/renderer/routes/downloads/inspector/overview-tab.tsx
@@ -80,11 +80,15 @@ function ErrorPanel({ task }: { task: DownloadTask }) {
<Alert variant="destructive" className="items-start">
<AlertCircleIcon />
<AlertTitle>{failure.reason}</AlertTitle>
- {failure.hint && <AlertDescription>{failure.hint}</AlertDescription>}
- {failure.technicalDetail && (
- <pre className="mt-1 whitespace-pre-wrap break-all text-xs text-muted-foreground">
- {failure.technicalDetail}
- </pre>
+ {(failure.hint || failure.technicalDetail) && (
+ <AlertDescription className="min-w-0">
+ {failure.hint && <span className="block">{failure.hint}</span>}
+ {failure.technicalDetail && (
+ <pre className="mt-1 whitespace-pre-wrap break-words text-xs text-muted-foreground">
+ {failure.technicalDetail}
+ </pre>
+ )}
+ </AlertDescription>
)}
{showRetry && (
<AlertAction>
diff --git a/src/renderer/routes/downloads/inspector/task-inspector-action-bar.test.tsx b/src/renderer/routes/downloads/inspector/task-inspector-action-bar.test.tsx
index c5c4c6b1..9984230c 100644
--- a/src/renderer/routes/downloads/inspector/task-inspector-action-bar.test.tsx
+++ b/src/renderer/routes/downloads/inspector/task-inspector-action-bar.test.tsx
@@ -272,12 +272,16 @@ describe('TaskInspectorActionBar', () => {
onClose={vi.fn()}
/>
)
- fireEvent.click(screen.getByRole('button', { name: /Copy URL/ }))
+ const copyButton = screen.getByRole('button', { name: /Copy URL/ })
+ expect(copyButton.querySelector('.lucide-copy')).not.toBeNull()
+
+ fireEvent.click(copyButton)
await waitFor(() =>
expect(navigator.clipboard.writeText).toHaveBeenCalledWith(
'https://example.com/file.zip'
)
)
+ expect(copyButton.querySelector('.lucide-check')).not.toBeNull()
})
it('BT task with infoHash copies a magnet URI carrying name + trackers', async () => {
@@ -370,5 +374,31 @@ describe('TaskInspectorActionBar', () => {
)
)
})
+
+ it('keeps the idle icon and reports an error when task details cannot load', async () => {
+ vi.mocked(transport.invoke).mockRejectedValueOnce(
+ new Error('detail unavailable')
+ )
+ render(
+ <TaskInspectorActionBar
+ selected={[
+ makeTask({
+ type: TaskType.Bt,
+ infoHash: 'abc123',
+ uris: [],
+ }),
+ ]}
+ onClose={vi.fn()}
+ />
+ )
+
+ const copyButton = screen.getByRole('button', { name: /Copy URL/ })
+ fireEvent.click(copyButton)
+
+ await waitFor(() => expect(toastAddMock).toHaveBeenCalledTimes(1))
+ expect(navigator.clipboard.writeText).not.toHaveBeenCalled()
+ expect(copyButton.querySelector('.lucide-copy')).not.toBeNull()
+ expect(copyButton.querySelector('.lucide-check')).toBeNull()
+ })
})
})
diff --git a/src/renderer/routes/downloads/inspector/task-inspector-action-bar.tsx b/src/renderer/routes/downloads/inspector/task-inspector-action-bar.tsx
index a38c7a3d..306e46bb 100644
--- a/src/renderer/routes/downloads/inspector/task-inspector-action-bar.tsx
+++ b/src/renderer/routes/downloads/inspector/task-inspector-action-bar.tsx
@@ -1,3 +1,4 @@
+import { CopyButton } from '@renderer/components/desktop-kit/copy-button'
import { Button } from '@renderer/components/ui/button'
import { toast } from '@renderer/components/ui/toast'
import { useModifierKeys } from '@renderer/hooks/use-modifier-keys'
@@ -13,7 +14,6 @@ import { isTorrentLike } from '@shared/types/task-actions'
import {
ChevronDown,
FolderOpen,
- Link as LinkIcon,
ListChecks,
Pause,
Play,
@@ -36,7 +36,7 @@ export interface TaskInspectorActionBarProps {
/**
* Click-time copy with an explicit failure path: a failed detail fetch must
* abort the copy and tell the user, never silently write a tracker-less
- * magnet and report success.
+ * magnet and report success. Re-throw so CopyButton keeps its idle state.
*/
async function copyTaskUrl(
task: DownloadTask,
@@ -45,9 +45,9 @@ async function copyTaskUrl(
let url: string
try {
url = await getCopyUrl(task)
- } catch {
+ } catch (error) {
onFailure()
- return
+ throw error
}
await navigator.clipboard.writeText(url)
}
@@ -139,7 +139,7 @@ function FinalizingActionBar({
{t('panel.downloads.action.openFolder')}
</Button>
)}
- <Button
+ <CopyButton
size="xs"
variant="outline"
onClick={() =>
@@ -151,9 +151,8 @@ function FinalizingActionBar({
)
}
>
- <LinkIcon />
{t('panel.downloads.action.copyUrl')}
- </Button>
+ </CopyButton>
<Button
size="xs"
variant="outline"
@@ -304,7 +303,7 @@ export function TaskInspectorActionBar({
</Button>
)}
{single && (
- <Button
+ <CopyButton
size="xs"
variant="outline"
onClick={() =>
@@ -316,9 +315,8 @@ export function TaskInspectorActionBar({
)
}
>
- <LinkIcon />
{t('panel.downloads.action.copyUrl')}
- </Button>
+ </CopyButton>
)}
<CountedButton