Skip to content

armgit / plexo

Public Imported from GitHub
0

Speed up downloads by combining multiple network connections in parallel

Download actions and context menu (#95)

Prashant Tiwarid9fc7888bcd7
diff --git a/e2e/downloadActions.spec.ts b/e2e/downloadActions.spec.ts
new file mode 100644
index 0000000..85dde75
--- /dev/null
+++ b/e2e/downloadActions.spec.ts
@@ -0,0 +1,225 @@
+import { expect, test } from '@playwright/test'
+import type { DownloadState, FinishedDownload } from '../src/shared/types'
+import {
+ availableActions,
+ failureAction,
+ headerActions,
+ manageAction,
+ manageActions,
+ rowAction,
+ splitToolbar,
+ type ActionId,
+ type DownloadItem
+} from '../src/renderer/src/utils/downloadActions'
+
+function download(
+ patch: Partial<DownloadState> & { status: DownloadState['status'] }
+): DownloadItem {
+ return {
+ id: 'a',
+ kind: 'http',
+ url: 'https://example.com/f.bin',
+ fileName: 'f.bin',
+ bytesDownloaded: 100,
+ totalBytes: 1000,
+ ...patch
+ } as unknown as DownloadItem
+}
+
+function finished(patch: Partial<FinishedDownload> = {}): DownloadItem {
+ return {
+ ...(download({ status: 'completed' }) as object),
+ unitsWritten: 4,
+ ...patch
+ } as unknown as DownloadItem
+}
+
+const ids = (items: DownloadItem[]): ActionId[] =>
+ availableActions(items).flatMap((group) => group.map((action) => action.id))
+
+test.describe('what each state offers', () => {
+ test('downloading and queued', () => {
+ for (const status of ['downloading', 'queued'] as const)
+ expect(ids([download({ status })])).toEqual(['pause', 'reveal', 'copy', 'cancel'])
+ })
+
+ test('paused', () => {
+ expect(ids([download({ status: 'paused' })])).toEqual(['resume', 'reveal', 'copy', 'cancel'])
+ })
+
+ test('failed with saved data can be retried', () => {
+ expect(ids([download({ status: 'error', error: 'reset' })])).toEqual([
+ 'retry',
+ 'copy',
+ 'remove'
+ ])
+ })
+
+ test('failed with a refused link can be fixed', () => {
+ const item = download({
+ status: 'error',
+ error: 'Server answered with status 403 for range request'
+ })
+ expect(failureAction(item as DownloadState)).toBe('fix')
+ expect(ids([item])).toEqual(['fix', 'copy', 'remove'])
+ })
+
+ test('failed with nothing to resume starts over', () => {
+ expect(ids([download({ status: 'error', error: 'reset', resumable: false })])).toEqual([
+ 'again',
+ 'copy',
+ 'remove'
+ ])
+ expect(ids([download({ status: 'error', error: 'reset', bytesDownloaded: 0 })])).toEqual([
+ 'again',
+ 'copy',
+ 'remove'
+ ])
+ })
+
+ test('completed', () => {
+ expect(ids([download({ status: 'completed' })])).toEqual([
+ 'open',
+ 'reveal',
+ 'copy',
+ 'remove',
+ 'trash'
+ ])
+ expect(ids([finished()])).toEqual(['open', 'reveal', 'copy', 'remove', 'trash'])
+ })
+
+ test('completed but moved: nothing that needs the file', () => {
+ expect(ids([finished({ missing: true })])).toEqual(['copy', 'remove'])
+ })
+
+ test('a torrent from a .torrent file has no link to copy', () => {
+ const torrent = download({ status: 'paused', kind: 'torrent', url: '/tmp/a.torrent' })
+ expect(ids([torrent])).toEqual(['resume', 'reveal', 'cancel'])
+ })
+})
+
+test.describe('several selected', () => {
+ test('an action acts on just the ones it is valid for', () => {
+ const items = [
+ download({ id: 'a', status: 'downloading' }),
+ download({ id: 'b', status: 'paused' }),
+ download({ id: 'c', status: 'queued' }),
+ finished({ id: 'd' })
+ ]
+ const found = Object.fromEntries(
+ availableActions(items)
+ .flat()
+ .map((action) => [action.id, action.targets.map((target) => target.id)])
+ )
+ expect(found.pause).toEqual(['a', 'c'])
+ expect(found.resume).toEqual(['b'])
+ expect(found.cancel).toEqual(['a', 'b', 'c'])
+ expect(found.remove).toEqual(['d'])
+ })
+
+ test('single-download actions are not offered for several', () => {
+ const items = [finished({ id: 'a' }), finished({ id: 'b' })]
+ expect(ids(items)).toEqual(['copy', 'remove', 'trash'])
+ const failed = [
+ download({
+ id: 'a',
+ status: 'error',
+ error: 'Server answered with status 403 for range request'
+ }),
+ download({
+ id: 'b',
+ status: 'error',
+ error: 'Server answered with status 403 for range request'
+ })
+ ]
+ expect(ids(failed)).toEqual(['copy', 'remove'])
+ })
+})
+
+test.describe('the places that show them agree', () => {
+ test('a row button, a screen header and the menu start from the same list', () => {
+ const states = [
+ download({ status: 'downloading' }),
+ download({ status: 'paused' }),
+ download({ status: 'error', error: 'reset' }),
+ download({ status: 'error', error: 'Server answered with status 403 for range request' }),
+ download({ status: 'error', error: 'reset', resumable: false }),
+ finished()
+ ]
+ for (const item of states) {
+ const menu = ids([item])
+ const row = rowAction(item)
+ if (row) expect(menu).toContain(row)
+ for (const id of headerActions(item)) expect(menu).toContain(id)
+ const manage = manageAction(item)
+ if (manage) expect(menu).toContain(manage)
+ // The first thing a menu offers is what its row button does.
+ if (row) expect(menu[0]).toBe(row)
+ }
+ })
+
+ test('a finished download can be removed or have its file trashed, from its own screen too', () => {
+ expect(manageActions(finished())).toEqual(['remove', 'trash'])
+ expect(manageActions(finished({ missing: true }))).toEqual(['remove'])
+ expect(manageActions(download({ status: 'paused' }))).toEqual(['cancel'])
+ expect(manageActions(download({ status: 'error', error: 'x' }))).toEqual(['remove'])
+ })
+
+ test('a download that is going can be cancelled, one that is over can be removed', () => {
+ expect(manageAction(download({ status: 'paused' }))).toBe('cancel')
+ expect(manageAction(download({ status: 'error', error: 'x' }))).toBe('remove')
+ expect(manageAction(finished())).toBe('remove')
+ })
+})
+
+test.describe('the selection toolbar', () => {
+ const shown = (items: DownloadItem[]): { buttons: ActionId[]; more: ActionId[] } => {
+ const { buttons, more } = splitToolbar(availableActions(items))
+ return { buttons: buttons.map((a) => a.id), more: more.flat().map((a) => a.id) }
+ }
+
+ test('two buttons for every state, the rest behind More', () => {
+ expect(shown([download({ status: 'downloading' })])).toEqual({
+ buttons: ['pause', 'cancel'],
+ more: ['reveal', 'copy']
+ })
+ expect(shown([download({ status: 'paused' })])).toEqual({
+ buttons: ['resume', 'cancel'],
+ more: ['reveal', 'copy']
+ })
+ expect(shown([download({ status: 'error', error: 'reset' })])).toEqual({
+ buttons: ['retry', 'remove'],
+ more: ['copy']
+ })
+ expect(
+ shown([download({ status: 'error', error: 'reset', resumable: false })]).buttons
+ ).toEqual(['again', 'remove'])
+ expect(
+ shown([
+ download({ status: 'error', error: 'Server answered with status 403 for range request' })
+ ]).buttons
+ ).toEqual(['fix', 'remove'])
+ expect(shown([finished()])).toEqual({
+ buttons: ['open', 'reveal'],
+ more: ['copy', 'remove', 'trash']
+ })
+ })
+
+ test('several finished: remove and trash', () => {
+ expect(shown([finished({ id: 'a' }), finished({ id: 'b' })])).toEqual({
+ buttons: ['remove', 'trash'],
+ more: ['copy']
+ })
+ })
+
+ test('a mixed selection still gets two, and nothing is lost', () => {
+ const items = [
+ download({ id: 'a', status: 'downloading' }),
+ download({ id: 'b', status: 'paused' }),
+ finished({ id: 'c' })
+ ]
+ const { buttons, more } = shown(items)
+ expect(buttons).toHaveLength(2)
+ expect([...buttons, ...more].sort()).toEqual([...ids(items)].sort())
+ })
+})
diff --git a/e2e/selection.spec.ts b/e2e/selection.spec.ts
index e5fdb15..6bdcace 100644
--- a/e2e/selection.spec.ts
+++ b/e2e/selection.spec.ts
@@ -1,10 +1,21 @@
import { existsSync } from 'node:fs'
import { mkdir, readFile, writeFile } from 'node:fs/promises'
-import { basename, join } from 'node:path'
+import { basename, dirname, join } from 'node:path'
+import type { Page } from '@playwright/test'
import { BLOCK, expect, test, treeSha } from './fixtures'
import { seededBytes } from './origin'
import { named, Swarm, torrentFileOnDisk } from './torrentSwarm'
+/** The selection toolbar keeps the next step as buttons; the rest is behind More actions. */
+async function openMore(page: Page): Promise<void> {
+ await page.getByRole('button', { name: 'More actions', exact: true }).click()
+}
+
+async function chooseMore(page: Page, name: string | RegExp): Promise<void> {
+ await openMore(page)
+ await page.getByRole('menuitem', { name }).click()
+}
+
async function stubTrash(plexo: import('./fixtures').PlexoApp, destination: string): Promise<void> {
await mkdir(destination)
await plexo.evaluateMain(({ shell }, dest) => {
@@ -54,23 +65,42 @@ test('mixed selection applies actions only to eligible downloads and keeps finis
expect(afterSelection?.y).toBe(beforeSelection?.y)
await expect(page.getByRole('button', { name: 'Resume (1)', exact: true })).toBeVisible()
await expect(page.getByRole('button', { name: /^Retry/ })).toHaveCount(0)
- await expect(page.getByRole('button', { name: 'Fix link', exact: true })).toBeVisible()
await expect(
- page.getByRole('button', { name: 'Cancel downloads… (2)', exact: true })
+ page.getByRole('button', { name: 'Fix link expired.bin', exact: true })
).toBeVisible()
- await plexo.page.getByRole('button', { name: 'Remove from list (1)', exact: true }).click()
+ // Whatever is selected, the toolbar holds its two fixed buttons, the next steps and More.
+ await expect(toolbar.getByRole('button')).toHaveText([
+ '',
+ 'Select all',
+ 'Resume (1)',
+ 'Cancel downloads (1)',
+ ''
+ ])
+ await openMore(page)
+ await expect(
+ page.getByRole('menuitem', { name: 'Remove 2 from list', exact: true })
+ ).toBeVisible()
+ await page.keyboard.press('Escape')
+ // A finished and a failed download leave the list together, after asking.
+ await chooseMore(page, 'Remove 2 from list')
+ const removal = page.getByRole('alertdialog')
+ await expect(removal.getByText(/lose the part they already downloaded/)).toBeVisible()
+ await removal.getByRole('button', { name: 'Cancel', exact: true }).click()
+ await expect(toolbar.getByText('3 selected', { exact: true })).toBeVisible()
+ await chooseMore(page, 'Remove 2 from list')
+ await page.getByRole('alertdialog').getByRole('button', { name: 'Remove', exact: true }).click()
await expect(page.getByRole('button', { name: 'Open finished.bin', exact: true })).toBeHidden()
expect(existsSync(finished.destinationPath)).toBe(true)
- await expect(toolbar.getByText('2 selected', { exact: true })).toBeVisible()
- await page.getByRole('button', { name: 'Cancel downloads… (2)', exact: true }).click()
+ await expect(toolbar.getByText('1 selected', { exact: true })).toBeVisible()
+ await page.getByRole('button', { name: 'Cancel downloads (1)', exact: true }).click()
const confirmation = page.getByRole('alertdialog')
- await expect(confirmation.getByText(/deletes their downloaded data/)).toBeVisible()
- await confirmation.getByRole('button', { name: 'Cancel', exact: true }).click()
- await expect(toolbar.getByText('2 selected', { exact: true })).toBeVisible()
- await page.getByRole('button', { name: 'Cancel downloads… (2)', exact: true }).click()
+ await expect(confirmation.getByText(/part already downloaded will be deleted/)).toBeVisible()
+ await confirmation.getByRole('button', { name: 'Keep', exact: true }).click()
+ await expect(toolbar.getByText('1 selected', { exact: true })).toBeVisible()
+ await page.getByRole('button', { name: 'Cancel downloads (1)', exact: true }).click()
await page
.getByRole('alertdialog')
- .getByRole('button', { name: 'Cancel downloads', exact: true })
+ .getByRole('button', { name: 'Cancel download', exact: true })
.click()
await expect(page.getByText('No downloads yet', { exact: true })).toBeVisible()
expect(existsSync(finished.destinationPath)).toBe(true)
@@ -90,12 +120,44 @@ test('missing finished files can leave the list but are excluded from file remov
await plexo.page
.getByRole('checkbox', { name: `Select ${complete.fileName}`, exact: true })
.check()
- await expect(plexo.page.getByRole('button', { name: /^Move files/ })).toHaveCount(0)
+ await expect(plexo.page.getByRole('button', { name: /^Move/ })).toHaveCount(0)
await plexo.page.getByRole('button', { name: 'Remove from list (1)', exact: true }).click()
+ await plexo.page
+ .getByRole('alertdialog')
+ .getByRole('button', { name: 'Remove', exact: true })
+ .click()
await expect(plexo.page.getByText('No downloads yet', { exact: true })).toBeVisible()
await rename(`${complete.destinationPath}.moved`, complete.destinationPath)
})
+test('showing a file that has moved says so in a dialog, not on the page', async ({
+ plexo,
+ serve
+}) => {
+ const origin = await serve({ size: BLOCK })
+ await plexo.start(origin.url(), origin.sha256)
+ const complete = await plexo.waitForStatus('completed')
+ const { rename } = await import('node:fs/promises')
+ const page = plexo.page
+ // The window hasn't been told yet, so the menu still offers it.
+ await rename(complete.destinationPath, `${complete.destinationPath}.moved`)
+ try {
+ await page.getByRole('button', { name: `Open ${complete.fileName}`, exact: true }).click({
+ button: 'right'
+ })
+ await page.getByRole('menuitem', { name: /^Show in/ }).click()
+ const dialog = page.getByRole('alertdialog')
+ await expect(dialog.getByText('Couldn’t show file', { exact: true })).toBeVisible()
+ await expect(dialog.getByText('That file is no longer where it was saved.')).toBeVisible()
+ await dialog.getByRole('button', { name: 'OK', exact: true }).click()
+ await expect(dialog).toBeHidden()
+ // Nothing is left behind on the list itself.
+ await expect(page.getByRole('alert')).toHaveCount(0)
+ } finally {
+ await rename(`${complete.destinationPath}.moved`, complete.destinationPath)
+ }
+})
+
test('trashing finished torrent files preserves unrelated files in the torrent folder', async ({
plexo,
dirs
@@ -121,12 +183,10 @@ test('trashing finished torrent files preserves unrelated files in the torrent f
.getByRole('checkbox', { name: `Select ${completed.fileName}`, exact: true })
.check()
const trashName = process.platform === 'win32' ? 'Recycle Bin' : 'Trash'
- await plexo.page
- .getByRole('button', { name: `Move files to ${trashName}… (1)`, exact: true })
- .click()
+ await chooseMore(plexo.page, `Move file to ${trashName}`)
await plexo.page
.getByRole('alertdialog')
- .getByRole('button', { name: `Move files to ${trashName}`, exact: true })
+ .getByRole('button', { name: 'Delete file', exact: true })
.click()
await expect(plexo.page.getByText('No downloads yet', { exact: true })).toBeVisible()
expect(await readFile(join(completed.destinationPath, 'personal.txt'), 'utf8')).toBe('keep me')
@@ -171,3 +231,40 @@ test('cancelling an unfinished torrent preserves unrelated files in its folder',
await swarm.stop()
}
})
+
+test('a removal that fails for one download still removes the rest, and asks again about only that one', async ({
+ plexo,
+ serve,
+ dirs
+}) => {
+ const first = await serve({ size: BLOCK })
+ await plexo.start(first.url(), first.sha256, { fileName: 'goes.bin' })
+ await plexo.waitForStatus('completed')
+ const second = await serve({ size: BLOCK })
+ await plexo.start(second.url(), second.sha256, { fileName: 'stays.bin' })
+ await expect
+ .poll(async () => (await plexo.all()).filter((d) => d.status === 'completed').length)
+ .toBe(2)
+ const trashed = join(dirname(dirs.dest), 'test-trash')
+ await mkdir(trashed)
+ await plexo.evaluateMain(({ shell }, dest) => {
+ shell.trashItem = async (path: string): Promise<void> => {
+ const { rename } = process.getBuiltinModule('node:fs/promises')
+ const { basename, join } = process.getBuiltinModule('node:path')
+ if (basename(path) === 'stays.bin') throw new Error('Trash is not available')
+ await rename(path, join(dest, basename(path)))
+ }
+ }, trashed)
+
+ const page = plexo.page
+ await page.getByRole('checkbox', { name: 'Select goes.bin', exact: true }).check()
+ await page.getByRole('checkbox', { name: 'Select stays.bin', exact: true }).check()
+ await page.getByRole('button', { name: /^Move to (Trash|Recycle Bin) \(2\)$/ }).click()
+ const dialog = page.getByRole('alertdialog')
+ await dialog.getByRole('button', { name: 'Delete files', exact: true }).click()
+
+ await expect(dialog.getByRole('alert')).toContainText('1 of 2 couldn’t be removed')
+ await expect(dialog.getByRole('heading', { name: 'Delete file?' })).toBeVisible()
+ await expect(page.getByRole('checkbox', { name: 'Select goes.bin' })).toHaveCount(0)
+ expect(existsSync(join(trashed, 'goes.bin'))).toBe(true)
+})
diff --git a/e2e/ui.spec.ts b/e2e/ui.spec.ts
index c32fcdb..4b981e9 100644
--- a/e2e/ui.spec.ts
+++ b/e2e/ui.spec.ts
@@ -24,6 +24,27 @@ async function stubNativeUi(
}, destination)
}
+test('Show in Finder on a download in progress shows its staging file', async ({
+ plexo,
+ serve,
+ dirs
+}) => {
+ const origin = await serve({ size: SIZE })
+ await stubNativeUi(plexo, dirs.dest)
+ const reached = origin.hold(6 * BLOCK)
+ const id = await plexo.start(origin.url(), origin.sha256)
+ await reached
+ const { destinationPath } = (await plexo.api.listDownloads()).find(
+ (entry) => entry.state.id === id
+ )!.state
+ // The final file isn't there yet: what's on disk is `<name>.plexo`.
+ expect(await plexo.api.revealDownload(id)).toBe(true)
+ expect(
+ await plexo.evaluateMain(() => (globalThis as Record<string, unknown>).__revealed, null)
+ ).toEqual([`${destinationPath}.plexo`])
+ origin.release()
+})
+
test.describe('a torrent through the UI', () => {
// This journey inspects a peer row, not network reassignment. Keep one network stable;
// routing across networks and globally unique peer IDs are checked by torrent specs/invariants.
@@ -42,7 +63,7 @@ test.describe('a torrent through the UI', () => {
const page = plexo.page
const link = await plexo.newDownload()
- await page.getByRole('button', { name: 'Change…' }).click()
+ await page.getByRole('button', { name: 'Change' }).click()
await link.fill(await torrentFileOnDisk(torrent))
await page.getByRole('checkbox', { name: /b\.bin/ }).click()
await plexo.expectNextDownload(
@@ -172,7 +193,7 @@ test.describe('UI journeys @smoke', () => {
const page = plexo.page
const link = await plexo.newDownload()
- await page.getByRole('button', { name: 'Change…' }).click()
+ await page.getByRole('button', { name: 'Change' }).click()
await link.fill(origin.url())
const start = page.getByRole('button', { name: 'Download' })
await expect(start).toBeEnabled()
@@ -220,13 +241,13 @@ test.describe('UI journeys @smoke', () => {
await stubNativeUi(plexo, dirs.dest)
const page = plexo.page
let link = await plexo.newDownload()
- await page.getByRole('button', { name: 'Change…' }).click()
+ await page.getByRole('button', { name: 'Change' }).click()
await link.fill(origin.url())
const reached = origin.hold(6 * BLOCK)
await page.getByRole('button', { name: 'Download' }).click()
await reached
- await page.getByRole('button', { name: 'Cancel download…' }).click()
+ await page.getByRole('button', { name: 'Cancel download' }).click()
await page.getByRole('button', { name: 'Cancel download', exact: true }).click()
origin.release()
// Gone, with what it had downloaded.
@@ -283,7 +304,7 @@ test.describe('settings @smoke', () => {
await stubNativeUi(plexo, dirs.dest)
await plexo.newDownload()
- await page().getByRole('button', { name: 'Change…' }).click()
+ await page().getByRole('button', { name: 'Change' }).click()
const destinationRow = (): Locator =>
page().getByText('Save to', { exact: true }).locator('..')
const chosenDestination = await destinationRow().innerText()
diff --git a/src/main/download/downloadManager.ts b/src/main/download/downloadManager.ts
index 7819a6c..b27b52a 100644
--- a/src/main/download/downloadManager.ts
+++ b/src/main/download/downloadManager.ts
@@ -1448,16 +1448,34 @@ export class DownloadManager {
this.historyChanged()
}
- /** Shows a download's file in its folder: by the download's own path, never one the window
+ /** Shows a download's file in its folder (while it's downloading, its `.plexo` staging file):
+ * by the download's own path, never one the window
* names, and only once it's checked to be there — the window's view of that can be old (the
* file moved or deleted since). When it isn't, the window is told to look again, and the
* history it gets marks it missing. */
async reveal(id: string): Promise<boolean> {
+ const runtime = this.runtimes.get(id)
+ const download = runtime?.state ?? (await findInHistory(id))
+ // Until it's published, what's on disk is its staging file (an HTTP download's
+ // `<name>.plexo`), not the path it will end up at.
+ const unfinished = runtime && runtime.state.status !== 'completed'
+ for (const path of [unfinished ? runtime.file.path : undefined, download?.destinationPath]) {
+ if (path && (await pathExists(path).catch(() => false))) {
+ shell.showItemInFolder(path)
+ return true
+ }
+ }
+ this.historyChanged()
+ return false
+ }
+
+ /** Opens a finished download with the app the OS picks for it; a torrent's folder opens in the
+ * file manager. Like reveal, it checks the path first and false means it's no longer there. */
+ async open(id: string): Promise<boolean> {
const download = this.runtimes.get(id)?.state ?? (await findInHistory(id))
const path = download?.destinationPath
if (path && (await pathExists(path).catch(() => false))) {
- shell.showItemInFolder(path)
- return true
+ return (await shell.openPath(path)) === ''
}
this.historyChanged()
return false
diff --git a/src/main/ipc/handlers.ts b/src/main/ipc/handlers.ts
index b0c2299..e9fef0a 100644
--- a/src/main/ipc/handlers.ts
+++ b/src/main/ipc/handlers.ts
@@ -197,6 +197,8 @@ export function registerIpcHandlers(getWindow: () => BrowserWindow | null): Down
handle('revealDownload', async (_event, id) => manager.reveal(id))
+ handle('openDownload', async (_event, id) => manager.open(id))
+
// The browser's sign-in is attached here, so it never passes through the window.
handle('startDownload', async (_event, request, linkId) => {
const browser = linkId === undefined ? undefined : pendingLink(linkId)?.browser
diff --git a/src/preload/index.ts b/src/preload/index.ts
index a647389..c1d6307 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -34,6 +34,7 @@ const plexoApi = {
pathForFile: (file: File) => webUtils.getPathForFile(file),
readClipboardText: () => invoke('readClipboardText'),
revealDownload: (id: string) => invoke('revealDownload', id),
+ openDownload: (id: string) => invoke('openDownload', id),
startDownload: (request: IpcContract['startDownload']['args'][0], linkId?: string) =>
invoke('startDownload', request, linkId),
listDownloads: () => invoke('listDownloads'),
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index f5fe968..78a7a85 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -1,5 +1,6 @@
import type { DownloadState, FinishedDownload } from '@shared/types'
import { useEffect } from 'react'
+import { DownloadActionsProvider } from './components/DownloadActionsProvider'
import { NetworkBindingDialog } from './components/NetworkBindingDialog'
import { NewDownloadDialog } from './components/NewDownloadDialog'
import { StatusBar } from './components/StatusBar'
@@ -63,16 +64,18 @@ function App(): React.JSX.Element {
return (
<TooltipProvider>
- <div className="flex h-full flex-col">
- <TitleBar />
- <div className="min-h-0 flex-1">
- {shown && !cancelled ? renderDownload(shown) : <DownloadsScreen />}
+ <DownloadActionsProvider>
+ <div className="flex h-full flex-col">
+ <TitleBar />
+ <div className="min-h-0 flex-1">
+ {shown && !cancelled ? renderDownload(shown) : <DownloadsScreen />}
+ </div>
+ <StatusBar />
+ <NewDownloadDialog />
+ <UpdateDialog />
+ <NetworkBindingDialog />
</div>
- <StatusBar />
- <NewDownloadDialog />
- <UpdateDialog />
- <NetworkBindingDialog />
- </div>
+ </DownloadActionsProvider>
</TooltipProvider>
)
}
diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css
index 276e223..7348b39 100644
--- a/src/renderer/src/assets/main.css
+++ b/src/renderer/src/assets/main.css
@@ -239,6 +239,14 @@
font: inherit;
}
+ /* A desktop app: controls keep the arrow, as native ones do; no pointing hand anywhere. */
+ a,
+ button,
+ [role='button'],
+ [role='menuitem'] {
+ cursor: default;
+ }
+
/* No core Tailwind utility for scrollbar pseudo-elements. */
::-webkit-scrollbar {
width: 10px;
diff --git a/src/renderer/src/components/ActionErrorDialog.tsx b/src/renderer/src/components/ActionErrorDialog.tsx
new file mode 100644
index 0000000..cfff5e4
--- /dev/null
+++ b/src/renderer/src/components/ActionErrorDialog.tsx
@@ -0,0 +1,34 @@
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle
+} from './ui/alert-dialog'
+
+/** Says what went wrong with something the user just asked for — a file that's moved, a download
+ * that wouldn't start — in the same kind of dialog the app asks its questions in, wherever the
+ * action came from. Open while `failure` is set. */
+export function ActionErrorDialog({
+ failure,
+ onClose
+}: {
+ failure: { title: string; message: string } | null
+ onClose: () => void
+}): React.JSX.Element {
+ return (
+ <AlertDialog open={failure !== null} onOpenChange={(open) => !open && onClose()}>
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>{failure?.title}</AlertDialogTitle>
+ <AlertDialogDescription>{failure?.message}</AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogAction>OK</AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+ )
+}
diff --git a/src/renderer/src/components/BlockGrid.tsx b/src/renderer/src/components/BlockGrid.tsx
index 36432bb..88c0725 100644
--- a/src/renderer/src/components/BlockGrid.tsx
+++ b/src/renderer/src/components/BlockGrid.tsx
@@ -313,7 +313,7 @@ export function BlockGrid({
onClick={goToActive}
aria-label={`Show the ${unit.toLowerCase()}s in progress`}
className={cn(
- 'absolute right-4 z-10 flex size-6 cursor-pointer items-center justify-center rounded-full border-[0.5px] border-[var(--border-strong)] bg-card text-[var(--text-secondary)] shadow-[0_2px_8px_rgba(0,0,0,0.18)] hover:text-foreground dark:shadow-[0_2px_8px_rgba(0,0,0,0.55)] focus-visible:outline-2 focus-visible:outline-ring',
+ 'absolute right-4 z-10 flex size-6 cursor-default items-center justify-center rounded-full border-[0.5px] border-[var(--border-strong)] bg-card text-[var(--text-secondary)] shadow-[0_2px_8px_rgba(0,0,0,0.18)] hover:text-foreground dark:shadow-[0_2px_8px_rgba(0,0,0,0.55)] focus-visible:outline-2 focus-visible:outline-ring',
nearestActive < firstInView ? '-top-1' : '-bottom-1'
)}
>
diff --git a/src/renderer/src/components/CyclableChip.tsx b/src/renderer/src/components/CyclableChip.tsx
index a3eb49e..07545b5 100644
--- a/src/renderer/src/components/CyclableChip.tsx
+++ b/src/renderer/src/components/CyclableChip.tsx
@@ -31,8 +31,7 @@ export function CyclableChip({
style={{
background: bg,
borderColor: border,
- color,
- cursor: cyclable ? 'pointer' : 'default'
+ color
}}
>
<span>{label}</span>
diff --git a/src/renderer/src/components/DetailHeader.tsx b/src/renderer/src/components/DetailHeader.tsx
index d720723..98131ba 100644
--- a/src/renderer/src/components/DetailHeader.tsx
+++ b/src/renderer/src/components/DetailHeader.tsx
@@ -1,33 +1,57 @@
-import type { DownloadState, FinishedDownload } from '@shared/types'
import { ChevronLeft } from 'lucide-react'
import { useState } from 'react'
import { useAppStore } from '../store/useAppStore'
import {
- AlertDialog,
- AlertDialogAction,
- AlertDialogCancel,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogTitle,
- AlertDialogTrigger
-} from './ui/alert-dialog'
-import { Button, buttonVariants } from './ui/button'
-import { describeError } from '../utils/format'
-import { Checkbox } from './ui/checkbox'
+ headerActions,
+ isFinished,
+ manageActions,
+ type ActionId,
+ type DownloadItem
+} from '../utils/downloadActions'
+import { useDownloadActions, useDownloadActionsState } from './downloadActionsContext'
+import { ACTION_META } from './downloadActionMeta'
+import { Button } from './ui/button'
/** The top of a download's own screen, laid out as the list's header is: the way back to the
- * list on the left; Remove… and what the download can do next (`children`, the main action
- * last) on the right. */
-export function DetailHeader({
- download,
- children
-}: {
- download: DownloadState | FinishedDownload
- children?: React.ReactNode
-}): React.JSX.Element {
+ * list on the left; on the right the ways out (Cancel while it's unfinished; Remove, and Move to
+ * Trash, after) and what the download can do next. They're what its row and its menu offer, from the same list. */
+export function DetailHeader({ download }: { download: DownloadItem }): React.JSX.Element {
const setView = useAppStore((store) => store.setView)
+ const { perform } = useDownloadActions()
+ const { busy } = useDownloadActionsState()
+ const manage = manageActions(download)
+ const next = headerActions(download)
+
+ // Resuming round-trips through the main process to re-verify the download before its status
+ // flips (an ETag re-check over the network for a real download). With no feedback in between,
+ // a slow check reads as the button not having registered the click: it says so until the
+ // download's state moves on.
+ const state = isFinished(download) ? 'finished' : `${download.status}|${download.error ?? ''}`
+ const [working, setWorking] = useState<{ id: ActionId; state: string } | null>(null)
+
+ const run = (id: ActionId): void => {
+ if (id === 'pause' || id === 'resume' || id === 'retry') setWorking({ id, state })
+ void perform(id, [download]).then((done) => done || setWorking(null))
+ }
+
+ const button = (
+ id: ActionId,
+ variant: 'default' | 'secondary' | 'destructive'
+ ): React.ReactNode => {
+ const meta = ACTION_META[id]
+ const isWorking = working?.id === id && working.state === state
+ return (
+ <Button
+ key={id}
+ type="button"
+ variant={variant}
+ disabled={isWorking || (busy && manage.includes(id))}
+ onClick={() => run(id)}
+ >
+ {isWorking && meta.working ? meta.working : meta.label}
+ </Button>
+ )
+ }
return (
<div className="flex h-12 shrink-0 items-center gap-2 border-b-[0.5px] border-border px-5">
@@ -40,104 +64,11 @@ export function DetailHeader({
Downloads
</button>
<div className="flex-1" />
- <RemoveButton download={download} />
- {children}
+ {manage.map((id) => button(id, ACTION_META[id].destructive ? 'destructive' : 'secondary'))}
+ {next.map((id, index) =>
+ // The last is the main one; Pause is never the main one, it's the way to stop.
+ button(id, index === next.length - 1 && id !== 'pause' ? 'default' : 'secondary')
+ )}
</div>
)
}
-
-/** Remove…, asked first. An unfinished download loses what it has; a finished one leaves the
- * list, and its file goes to the Trash only if asked — from where it can still be put back. */
-function RemoveButton({
- download
-}: {
- download: DownloadState | FinishedDownload
-}): React.JSX.Element {
- const setView = useAppStore((store) => store.setView)
- const [trashFile, setTrashFile] = useState(false)
- const [busy, setBusy] = useState(false)
- const [error, setError] = useState<string | null>(null)
- const finished = 'unitsWritten' in download || download.status === 'completed'
- const missing = 'missing' in download && download.missing === true
- const trashName = window.plexo.platform === 'win32' ? 'Recycle Bin' : 'Trash'
-
- return (
- <AlertDialog
- onOpenChange={() => {
- setTrashFile(false)
- setError(null)
- }}
- >
- <AlertDialogTrigger
- render={
- <Button type="button" variant={finished ? 'secondary' : 'destructive'}>
- {finished ? 'Remove from list…' : 'Cancel download…'}
- </Button>
- }
- />
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle>
- {finished ? 'Remove from list' : 'Cancel download'}: {download.fileName}?
- </AlertDialogTitle>
- <AlertDialogDescription>
- {finished
- ? 'This removes the download from your list. Its files stay on your computer.'
- : 'This stops the download and deletes its downloaded data.'}
- </AlertDialogDescription>
- </AlertDialogHeader>
- {finished &&
- !missing &&
- (download.kind !== 'torrent' ||
- !download.folder ||
- !('unitsWritten' in download) ||
- !!download.downloadedFiles?.length) && (
- <label className="flex items-center gap-2.5 text-[13px]">
- <Checkbox checked={trashFile} onCheckedChange={setTrashFile} />
- Also move downloaded files to the {trashName}. Unrelated files stay in place.
- </label>
- )}
- <AlertDialogFooter>
- {error && (
- <p role="alert" className="text-[13px] text-destructive">
- {error}
- </p>
- )}
- <AlertDialogCancel disabled={busy}>Cancel</AlertDialogCancel>
- <AlertDialogAction
- className={buttonVariants({
- variant: finished && !trashFile ? 'default' : 'destructive',
- size: 'sm'
- })}
- disabled={busy}
- onClick={(event) => {
- event.preventDefault()
- setBusy(true)
- void window.plexo
- .removeDownload(download.id, { trashFile })
- .then(() => {
- useAppStore.setState((store) => {
- const downloads = { ...store.downloads }
- delete downloads[download.id]
- return {
- downloads,
- history: store.history.filter((item) => item.id !== download.id)
- }
- })
- setView({ name: 'list' })
- })
- .catch((cause) => setError(describeError(cause)))
- .finally(() => setBusy(false))
- }}
- >
- {trashFile
- ? `Move files to ${trashName}`
- : finished
- ? 'Remove from list'
- : 'Cancel download'}
- </AlertDialogAction>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
- )
-}
diff --git a/src/renderer/src/components/DownloadActionsProvider.tsx b/src/renderer/src/components/DownloadActionsProvider.tsx
new file mode 100644
index 0000000..1ceae0c
--- /dev/null
+++ b/src/renderer/src/components/DownloadActionsProvider.tsx
@@ -0,0 +1,170 @@
+import type { DownloadState } from '@shared/types'
+import { useCallback, useMemo, useState } from 'react'
+import { useAppStore } from '../store/useAppStore'
+import { describeError } from '../utils/format'
+import type { ActionId, DownloadItem } from '../utils/downloadActions'
+import { ActionErrorDialog } from './ActionErrorDialog'
+import { ACTION_META } from './downloadActionMeta'
+import { ActionsContext, StateContext } from './downloadActionsContext'
+import { FixLinkDialog } from './FixLinkDialog'
+import { RemoveDialog, type RemoveMode } from './RemoveDialog'
+
+/** What can be done to a download, done: from its row, its menu, the selection toolbar and its
+ * own screen alike. It owns the two questions an action can lead to (fix the link, confirm a
+ * removal), so they look and behave the same wherever they're asked from. */
+export function DownloadActionsProvider({
+ children
+}: {
+ children: React.ReactNode
+}): React.JSX.Element {
+ const setView = useAppStore((store) => store.setView)
+ const openNewDownload = useAppStore((store) => store.openNewDownload)
+ const [confirmation, setConfirmation] = useState<{
+ mode: RemoveMode
+ items: DownloadItem[]
+ clearAll: boolean
+ } | null>(null)
+ const [fixing, setFixing] = useState<DownloadState | null>(null)
+ const [busy, setBusy] = useState(false)
+ const [failure, setFailure] = useState<{ title: string; message: string } | null>(null)
+ const [dialogError, setDialogError] = useState<string | null>(null)
+
+ const perform = useCallback(
+ async (id: ActionId, targets: DownloadItem[]): Promise<boolean> => {
+ // Said in a dialog, whichever screen it came from.
+ const fail = (cause: unknown): false => {
+ setFailure({ title: ACTION_META[id].failure, message: describeError(cause) })
+ return false
+ }
+ switch (id) {
+ case 'pause':
+ case 'resume':
+ case 'retry': {
+ const results = await Promise.allSettled(
+ targets.map((item) =>
+ id === 'pause'
+ ? window.plexo.pauseDownload(item.id)
+ : window.plexo.resumeDownload(item.id)
+ )
+ )
+ const failed = results.find((result) => result.status === 'rejected')
+ return failed ? fail(failed.reason) : true
+ }
+ case 'fix':
+ setFixing(targets[0] as DownloadState)
+ return true
+ case 'again': {
+ // Nothing of it can be kept: it goes, and its link waits in New download to start over.
+ // Only once it's really gone, so the new one can't collide with what's left of it.
+ const [item] = targets
+ try {
+ await window.plexo.removeDownload(item.id)
+ } catch (cause) {
+ return fail(cause)
+ }
+ useAppStore.getState().forgetDownload(item.id)
+ setView({ name: 'list' })
+ openNewDownload(item.url)
+ return true
+ }
+ case 'open':
+ case 'reveal': {
+ try {
+ const [item] = targets
+ const found =
+ id === 'open'
+ ? await window.plexo.openDownload(item.id)
+ : await window.plexo.revealDownload(item.id)
+ return found || fail('That file is no longer where it was saved.')
+ } catch (cause) {
+ return fail(cause)
+ }
+ }
+ case 'copy':
+ return navigator.clipboard
+ .writeText(targets.map((item) => item.url).join('\n'))
+ .then(() => true)
+ .catch(fail)
+ case 'cancel':
+ case 'remove':
+ case 'trash':
+ setDialogError(null)
+ setConfirmation({
+ mode: id === 'cancel' ? 'cancel' : id === 'trash' ? 'trash' : 'remove',
+ items: targets,
+ clearAll: false
+ })
+ return true
+ }
+ },
+ [setView, openNewDownload]
+ )
+
+ const askClearFinished = useCallback((): void => {
+ setDialogError(null)
+ setConfirmation({ mode: 'remove', items: useAppStore.getState().history, clearAll: true })
+ }, [])
+
+ const confirmRemoval = async (): Promise<void> => {
+ if (!confirmation || busy) return
+ const { mode, items, clearAll } = confirmation
+ setBusy(true)
+ setDialogError(null)
+ try {
+ // One failing doesn't hold back the rest: each that goes is dropped from the window and
+ // from the question, so what's left asked about is exactly what still needs doing.
+ const gone = new Set<string>()
+ let firstFailure: unknown
+ if (clearAll) {
+ await window.plexo.clearHistory()
+ } else {
+ for (const item of items) {
+ try {
+ await window.plexo.removeDownload(item.id, { trashFile: mode === 'trash' })
+ useAppStore.getState().forgetDownload(item.id)
+ gone.add(item.id)
+ } catch (cause) {
+ firstFailure ??= cause
+ }
+ }
+ }
+ // Showing one that's gone: back to the list.
+ const view = useAppStore.getState().view
+ if (view.name === 'download' && (clearAll || gone.has(view.id))) setView({ name: 'list' })
+ const left = items.filter((item) => !gone.has(item.id))
+ if (!clearAll && left.length > 0) {
+ setConfirmation({ mode, items: left, clearAll })
+ setDialogError(
+ `${left.length} of ${items.length} couldn’t be removed: ${describeError(firstFailure)}`
+ )
+ } else setConfirmation(null)
+ } catch (cause) {
+ setDialogError(describeError(cause))
+ } finally {
+ setBusy(false)
+ }
+ }
+
+ const actions = useMemo(() => ({ perform, askClearFinished }), [perform, askClearFinished])
+ const state = useMemo(() => ({ busy }), [busy])
+
+ return (
+ <ActionsContext.Provider value={actions}>
+ <StateContext.Provider value={state}>
+ {children}
+ <RemoveDialog
+ open={confirmation !== null}
+ onOpenChange={(open) => !open && !busy && setConfirmation(null)}
+ mode={confirmation?.mode ?? 'remove'}
+ items={confirmation?.items ?? []}
+ clearAll={confirmation?.clearAll}
+ busy={busy}
+ error={dialogError}
+ onConfirm={() => void confirmRemoval()}
+ />
+ <FixLinkDialog download={fixing} onClose={() => setFixing(null)} />
+ <ActionErrorDialog failure={failure} onClose={() => setFailure(null)} />
+ </StateContext.Provider>
+ </ActionsContext.Provider>
+ )
+}
diff --git a/src/renderer/src/components/DownloadContextMenu.tsx b/src/renderer/src/components/DownloadContextMenu.tsx
new file mode 100644
index 0000000..df02379
--- /dev/null
+++ b/src/renderer/src/components/DownloadContextMenu.tsx
@@ -0,0 +1,57 @@
+import { Fragment } from 'react'
+import { availableActions, type DownloadItem } from '../utils/downloadActions'
+import { useDownloadActions } from './downloadActionsContext'
+import { ACTION_META, menuLabel } from './downloadActionMeta'
+import {
+ ContextMenu,
+ ContextMenuContent,
+ ContextMenuItem,
+ ContextMenuSeparator,
+ ContextMenuTrigger
+} from './ui/context-menu'
+
+/** Right-click menu for a download row: everything that can be done to it, from the same list
+ * as its row button, the toolbar and its own screen. Right-clicking inside the selection acts
+ * on everything selected; outside it, on just that row, which is left unselected (selecting
+ * would swap the header into the selection toolbar). */
+export function DownloadContextMenu({
+ item,
+ selected,
+ chosen,
+ children
+}: {
+ item: DownloadItem
+ selected: boolean
+ chosen: DownloadItem[]
+ children: React.ReactNode
+}): React.JSX.Element {
+ const { perform } = useDownloadActions()
+ const groups = availableActions(selected ? chosen : [item])
+ return (
+ <ContextMenu>
+ <ContextMenuTrigger>{children}</ContextMenuTrigger>
+ <ContextMenuContent className="min-w-52">
+ {groups.map((group, index) => (
+ <Fragment key={group[0].id}>
+ {index > 0 && <ContextMenuSeparator />}
+ {group.map(({ id, targets }, position) => {
+ const meta = ACTION_META[id]
+ return (
+ <ContextMenuItem
+ key={id}
+ variant={meta.destructive ? 'destructive' : 'default'}
+ // The first is what the row's own button does.
+ className={index === 0 && position === 0 ? 'font-medium' : undefined}
+ onClick={() => void perform(id, targets)}
+ >
+ <meta.icon aria-hidden />
+ {menuLabel(id, targets)}
+ </ContextMenuItem>
+ )
+ })}
+ </Fragment>
+ ))}
+ </ContextMenuContent>
+ </ContextMenu>
+ )
+}
diff --git a/src/renderer/src/components/FixLinkDialog.tsx b/src/renderer/src/components/FixLinkDialog.tsx
index 9efca83..8262b22 100644
--- a/src/renderer/src/components/FixLinkDialog.tsx
+++ b/src/renderer/src/components/FixLinkDialog.tsx
@@ -83,7 +83,7 @@ export function FixLinkDialog({
Cancel
</Button>
<Button type="submit" disabled={fixing || !url.trim()}>
- {fixing ? 'Checking…' : 'Continue download'}
+ {fixing ? 'Checking' : 'Continue download'}
</Button>
</DialogFooter>
</form>
diff --git a/src/renderer/src/components/LimitsDialog.tsx b/src/renderer/src/components/LimitsDialog.tsx
index 6e80b0e..48f87fd 100644
--- a/src/renderer/src/components/LimitsDialog.tsx
+++ b/src/renderer/src/components/LimitsDialog.tsx
@@ -298,7 +298,7 @@ function GeneralPage({
disabled={atDefaults}
onClick={() => setConfirmReset(true)}
>
- Reset to defaults…
+ Reset to defaults
</Button>
</div>
<AlertDialog open={confirmReset} onOpenChange={setConfirmReset}>
@@ -439,7 +439,7 @@ function NetworkPage({
disabled={busy || used === 0}
onClick={() => setReset('usage')}
>
- Reset data usage…
+ Reset data usage
</Button>
<Button
variant="secondary"
@@ -447,7 +447,7 @@ function NetworkPage({
disabled={busy || (preference?.speedLimit === undefined && dataLimit === undefined)}
onClick={() => setReset('limits')}
>
- Remove limits…
+ Remove limits
</Button>
</div>
<AlertDialog open={reset !== null} onOpenChange={(open) => !open && !busy && setReset(null)}>
diff --git a/src/renderer/src/components/MoreActionsMenu.tsx b/src/renderer/src/components/MoreActionsMenu.tsx
new file mode 100644
index 0000000..2359f65
--- /dev/null
+++ b/src/renderer/src/components/MoreActionsMenu.tsx
@@ -0,0 +1,72 @@
+import { Ellipsis } from 'lucide-react'
+import { Fragment } from 'react'
+import type { AvailableAction } from '../utils/downloadActions'
+import { useDownloadActions } from './downloadActionsContext'
+import { ACTION_META, menuLabel } from './downloadActionMeta'
+import { Button } from './ui/button'
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger
+} from './ui/dropdown-menu'
+import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip'
+
+/** The selection toolbar's "More actions": what the right-click menu offers for the selection,
+ * less what has a button of its own. Same items, names, order and groups. Nothing, when there's
+ * nothing to offer. */
+export function MoreActionsMenu({
+ groups,
+ disabled = false
+}: {
+ groups: AvailableAction[][]
+ disabled?: boolean
+}): React.JSX.Element | null {
+ const { perform } = useDownloadActions()
+ if (groups.length === 0) return null
+ return (
+ <DropdownMenu>
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <DropdownMenuTrigger
+ render={
+ <Button
+ type="button"
+ size="icon-sm"
+ variant="secondary"
+ aria-label="More actions"
+ disabled={disabled}
+ >
+ <Ellipsis />
+ </Button>
+ }
+ />
+ }
+ />
+ <TooltipContent>More actions</TooltipContent>
+ </Tooltip>
+ <DropdownMenuContent align="end" className="min-w-52">
+ {groups.map((group, index) => (
+ <Fragment key={group[0].id}>
+ {index > 0 && <DropdownMenuSeparator />}
+ {group.map(({ id, targets }) => {
+ const meta = ACTION_META[id]
+ return (
+ <DropdownMenuItem
+ key={id}
+ variant={meta.destructive ? 'destructive' : 'default'}
+ onClick={() => void perform(id, targets)}
+ >
+ <meta.icon aria-hidden />
+ {menuLabel(id, targets)}
+ </DropdownMenuItem>
+ )
+ })}
+ </Fragment>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )
+}
diff --git a/src/renderer/src/components/NetworkRow.tsx b/src/renderer/src/components/NetworkRow.tsx
index c6fe249..dc18bfb 100644
--- a/src/renderer/src/components/NetworkRow.tsx
+++ b/src/renderer/src/components/NetworkRow.tsx
@@ -426,7 +426,7 @@ export function NetworkRow({
size="xs"
onClick={() => setExpanded((value) => !value)}
aria-expanded={expanded}
- className="h-auto cursor-pointer rounded-[4px] border-[0.5px] bg-card px-[7px] py-[3px] font-mono text-[10.5px] leading-none font-medium text-[var(--text-secondary)] aria-expanded:bg-secondary dark:bg-card"
+ className="h-auto cursor-default rounded-[4px] border-[0.5px] bg-card px-[7px] py-[3px] font-mono text-[10.5px] leading-none font-medium text-[var(--text-secondary)] aria-expanded:bg-secondary dark:bg-card"
>
{connections.length} {noun}
{connections.length === 1 ? '' : 's'}{' '}
diff --git a/src/renderer/src/components/NetworksMenu.tsx b/src/renderer/src/components/NetworksMenu.tsx
index 5e2e5e2..2ec9507 100644
--- a/src/renderer/src/components/NetworksMenu.tsx
+++ b/src/renderer/src/components/NetworksMenu.tsx
@@ -162,7 +162,7 @@ export function NetworksMenu({
onOpenLimits(null)
}}
>
- Speed &amp; data limits…
+ Speed &amp; data limits
</button>
</PopoverContent>
</Popover>
diff --git a/src/renderer/src/components/NewDownloadDialog.tsx b/src/renderer/src/components/NewDownloadDialog.tsx
index 5f5dbec..b8b7580 100644
--- a/src/renderer/src/components/NewDownloadDialog.tsx
+++ b/src/renderer/src/components/NewDownloadDialog.tsx
@@ -194,9 +194,9 @@ function NewDownloadForm({ onDone }: { onDone: () => void }): React.JSX.Element
Boolean(destinationDir) &&
!starting
const startLabel = starting
- ? 'Starting…'
+ ? 'Starting'
: probe.status === 'probing'
- ? 'Checking…'
+ ? 'Checking'
: full
? 'Add to queue'
: 'Download'
@@ -397,7 +397,7 @@ function NewDownloadForm({ onDone }: { onDone: () => void }): React.JSX.Element
linkInput.current?.focus()
}}
aria-label="Clear link"
- className="flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-full text-muted-foreground hover:bg-secondary hover:text-foreground"
+ className="flex size-5 shrink-0 cursor-default items-center justify-center rounded-full text-muted-foreground hover:bg-secondary hover:text-foreground"
>
<X aria-hidden className="size-3.5" />
</button>
@@ -409,7 +409,7 @@ function NewDownloadForm({ onDone }: { onDone: () => void }): React.JSX.Element
</div>
<Button type="button" variant="secondary" onClick={handleOpenTorrent} className="h-9">
<FolderOpen data-icon="inline-start" />
- Open .torrent…
+ Open .torrent
</Button>
</div>
@@ -507,7 +507,7 @@ function NewDownloadForm({ onDone }: { onDone: () => void }): React.JSX.Element
{toDisplayPath(destinationDir, homeDir)}
</div>
<Button type="button" variant="secondary" size="sm" onClick={handleBrowse}>
- Change…
+ Change
</Button>
</div>
diff --git a/src/renderer/src/components/RemoveDialog.tsx b/src/renderer/src/components/RemoveDialog.tsx
new file mode 100644
index 0000000..e951f86
--- /dev/null
+++ b/src/renderer/src/components/RemoveDialog.tsx
@@ -0,0 +1,138 @@
+import { isDone, isFailed, type DownloadItem } from '../utils/downloadActions'
+import { TRASH_NAME } from './downloadActionMeta'
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle
+} from './ui/alert-dialog'
+import { buttonVariants } from './ui/button'
+
+/** What the dialog asks about: `remove` takes downloads off the list (their files stay), `cancel`
+ * stops unfinished ones, `trash` moves their files to the Trash. */
+export type RemoveMode = 'remove' | 'cancel' | 'trash'
+
+/** The one confirmation for taking downloads away, wherever it's asked from: a download's own
+ * screen, the list's toolbar and menu, and clearing the finished list. */
+export function RemoveDialog({
+ open,
+ onOpenChange,
+ mode,
+ items,
+ clearAll = false,
+ busy = false,
+ error = null,
+ onConfirm
+}: {
+ open: boolean
+ onOpenChange: (open: boolean) => void
+ mode: RemoveMode
+ items: DownloadItem[]
+ /** Clearing the whole finished list: no per-file choices. */
+ clearAll?: boolean
+ busy?: boolean
+ error?: string | null
+ onConfirm: () => void
+}): React.JSX.Element {
+ return (
+ <AlertDialog open={open} onOpenChange={onOpenChange}>
+ <AlertDialogContent>
+ <RemoveDialogBody
+ mode={mode}
+ items={items}
+ clearAll={clearAll}
+ busy={busy}
+ error={error}
+ onConfirm={onConfirm}
+ />
+ </AlertDialogContent>
+ </AlertDialog>
+ )
+}
+
+function RemoveDialogBody({
+ mode,
+ items,
+ clearAll,
+ busy,
+ error,
+ onConfirm
+}: {
+ mode: RemoveMode
+ items: DownloadItem[]
+ clearAll: boolean
+ busy: boolean
+ error: string | null
+ onConfirm: () => void
+}): React.JSX.Element {
+ const count = items.length
+ const one = count === 1
+ const anyFailed = items.some(isFailed)
+ const anyFinished = items.some(isDone)
+
+ let title: string
+ let description: string
+ let confirm: string
+ let dismiss = 'Cancel'
+ let destructive = true
+ if (mode === 'cancel') {
+ title = one ? 'Cancel download?' : `Cancel ${count} downloads?`
+ description = 'The part already downloaded will be deleted.'
+ confirm = one ? 'Cancel download' : 'Cancel downloads'
+ dismiss = 'Keep'
+ } else if (mode === 'trash') {
+ // Said as what it comes to: the file is deleted, into the Trash.
+ title = one ? 'Delete file?' : `Delete ${count} files?`
+ description = `The ${one ? 'file' : 'files'} will be moved to the ${TRASH_NAME}.`
+ confirm = one ? 'Delete file' : 'Delete files'
+ } else {
+ title = clearAll
+ ? 'Clear finished list?'
+ : one
+ ? 'Remove from list?'
+ : `Remove ${count} downloads from list?`
+ description = !anyFailed
+ ? `The downloaded ${one && !clearAll ? 'file stays' : 'files stay'} on your computer.`
+ : anyFinished
+ ? 'Finished files stay on your computer. Failed downloads lose the part they already downloaded.'
+ : 'The part already downloaded will be deleted.'
+ confirm = clearAll ? 'Clear list' : 'Remove'
+ // Only the list changes, unless a failed one's partial data goes with it.
+ destructive = anyFailed
+ }
+
+ return (
+ <>
+ <AlertDialogHeader>
+ <AlertDialogTitle>{title}</AlertDialogTitle>
+ <AlertDialogDescription>{description}</AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ {error && (
+ <p role="alert" className="text-[13px] text-destructive">
+ {error}
+ </p>
+ )}
+ <AlertDialogCancel disabled={busy}>{dismiss}</AlertDialogCancel>
+ <AlertDialogAction
+ disabled={busy || count === 0}
+ className={buttonVariants({
+ variant: destructive ? 'destructive' : 'default',
+ size: 'sm'
+ })}
+ onClick={(event) => {
+ // Stays open until the removal is done, and open if it fails.
+ event.preventDefault()
+ onConfirm()
+ }}
+ >
+ {confirm}
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </>
+ )
+}
diff --git a/src/renderer/src/components/ThemeToggle.tsx b/src/renderer/src/components/ThemeToggle.tsx
index e05c036..751ddd3 100644
--- a/src/renderer/src/components/ThemeToggle.tsx
+++ b/src/renderer/src/components/ThemeToggle.tsx
@@ -52,7 +52,7 @@ export function ThemeToggle(): React.JSX.Element {
type="button"
aria-label={current.nextLabel}
onClick={toggle}
- className="flex size-[26px] shrink-0 cursor-pointer items-center justify-center rounded-[6px] border-[0.5px] border-border bg-secondary text-[var(--text-secondary)] [-webkit-app-region:no-drag]"
+ className="flex size-[26px] shrink-0 cursor-default items-center justify-center rounded-[6px] border-[0.5px] border-border bg-secondary text-[var(--text-secondary)] [-webkit-app-region:no-drag]"
>
{current.icon}
</button>
diff --git a/src/renderer/src/components/UpdateIndicator.tsx b/src/renderer/src/components/UpdateIndicator.tsx
index 232ab8f..39c6aaf 100644
--- a/src/renderer/src/components/UpdateIndicator.tsx
+++ b/src/renderer/src/components/UpdateIndicator.tsx
@@ -20,7 +20,7 @@ export function UpdateIndicator(): React.JSX.Element | null {
target="_blank"
rel="noreferrer"
aria-label={`Update available: ${availableUpdate.version}`}
- className="flex size-[26px] shrink-0 cursor-pointer items-center justify-center rounded-[6px] border-[0.5px] border-border bg-secondary text-[var(--text-secondary)] [-webkit-app-region:no-drag]"
+ className="flex size-[26px] shrink-0 cursor-default items-center justify-center rounded-[6px] border-[0.5px] border-border bg-secondary text-[var(--text-secondary)] [-webkit-app-region:no-drag]"
>
<CircleArrowUp size={15} strokeWidth={1.3} />
</a>
diff --git a/src/renderer/src/components/downloadActionMeta.ts b/src/renderer/src/components/downloadActionMeta.ts
new file mode 100644
index 0000000..2ab8a6f
--- /dev/null
+++ b/src/renderer/src/components/downloadActionMeta.ts
@@ -0,0 +1,137 @@
+import {
+ Copy,
+ Download,
+ ExternalLink,
+ FolderOpen,
+ ListX,
+ Pause,
+ Play,
+ RotateCw,
+ Trash2,
+ Wrench,
+ X,
+ type LucideIcon
+} from 'lucide-react'
+import type { ActionId, DownloadItem } from '../utils/downloadActions'
+
+const MAC = window.plexo.platform === 'darwin'
+export const TRASH_NAME = window.plexo.platform === 'win32' ? 'Recycle Bin' : 'Trash'
+const REVEAL_LABEL = MAC ? 'Show in Finder' : 'Show in folder'
+
+const SOMETHING_WRONG = 'Something went wrong'
+
+interface ActionMeta {
+ /** For one download: menus and a download's own screen. */
+ label: string
+ /** For several, in a menu. */
+ many?: (count: number) => string
+ /** On the selection toolbar's own button, before the count. */
+ toolbar?: string
+ /** For one download only: its toolbar button has no count. */
+ single?: boolean
+ /** What its button says while it works. */
+ working?: string
+ /** The title of the dialog that says it didn't work. */
+ failure: string
+ icon: LucideIcon
+ destructive?: boolean
+}
+
+export const ACTION_META: Record<ActionId, ActionMeta> = {
+ pause: {
+ label: 'Pause',
+ many: (n) => `Pause ${n} downloads`,
+ toolbar: 'Pause',
+ working: 'Pausing',
+ failure: 'Couldn’t pause',
+ icon: Pause
+ },
+ resume: {
+ label: 'Resume',
+ many: (n) => `Resume ${n} downloads`,
+ toolbar: 'Resume',
+ working: 'Resuming',
+ failure: 'Couldn’t resume',
+ icon: Play
+ },
+ retry: {
+ label: 'Retry',
+ many: (n) => `Retry ${n} downloads`,
+ toolbar: 'Retry',
+ working: 'Retrying',
+ failure: 'Couldn’t retry',
+ icon: RotateCw
+ },
+ fix: {
+ label: 'Fix link',
+ toolbar: 'Fix link',
+ single: true,
+ failure: SOMETHING_WRONG,
+ icon: Wrench
+ },
+ again: {
+ label: 'Download again',
+ toolbar: 'Download again',
+ single: true,
+ failure: 'Couldn’t start again',
+ icon: Download
+ },
+ open: {
+ label: 'Open',
+ toolbar: 'Open',
+ single: true,
+ failure: 'Couldn’t open file',
+ icon: ExternalLink
+ },
+ reveal: {
+ label: REVEAL_LABEL,
+ toolbar: REVEAL_LABEL,
+ single: true,
+ failure: 'Couldn’t show file',
+ icon: FolderOpen
+ },
+ copy: {
+ label: 'Copy link',
+ many: (n) => `Copy ${n} links`,
+ failure: 'Couldn’t copy link',
+ icon: Copy
+ },
+ cancel: {
+ label: 'Cancel download',
+ many: (n) => `Cancel ${n} downloads`,
+ toolbar: 'Cancel downloads',
+ failure: SOMETHING_WRONG,
+ icon: X,
+ destructive: true
+ },
+ remove: {
+ label: 'Remove from list',
+ many: (n) => `Remove ${n} from list`,
+ toolbar: 'Remove from list',
+ failure: SOMETHING_WRONG,
+ icon: ListX
+ },
+ trash: {
+ label: `Move file to ${TRASH_NAME}`,
+ many: (n) => `Move ${n} files to ${TRASH_NAME}`,
+ toolbar: `Move to ${TRASH_NAME}`,
+ failure: SOMETHING_WRONG,
+ icon: Trash2,
+ destructive: true
+ }
+}
+
+/** The name in a menu: spelled out for several ("Pause 3 downloads"). */
+export function menuLabel(id: ActionId, items: DownloadItem[]): string {
+ const meta = ACTION_META[id]
+ if (id === 'copy' && items.every((item) => item.url.startsWith('magnet:')))
+ return items.length > 1 ? `Copy ${items.length} magnet links` : 'Copy magnet link'
+ return items.length > 1 && meta.many ? meta.many(items.length) : meta.label
+}
+
+/** The name on a toolbar button: with the count, however many ("Pause (1)"). */
+export function toolbarLabel(id: ActionId, count: number): string {
+ const meta = ACTION_META[id]
+ const name = meta.toolbar ?? meta.label
+ return meta.single ? name : `${name} (${count})`
+}
diff --git a/src/renderer/src/components/downloadActionsContext.ts b/src/renderer/src/components/downloadActionsContext.ts
new file mode 100644
index 0000000..3690a98
--- /dev/null
+++ b/src/renderer/src/components/downloadActionsContext.ts
@@ -0,0 +1,31 @@
+import { createContext, useContext } from 'react'
+import type { ActionId, DownloadItem } from '../utils/downloadActions'
+
+export interface Actions {
+ /** Does `id` to `targets`, or asks first where it deletes something. Resolves once it's been
+ * sent (a question that's asked resolves at once): true if it went through, false if it failed
+ * (a dialog says why). */
+ perform: (id: ActionId, targets: DownloadItem[]) => Promise<boolean>
+ /** Asks to clear the whole finished list. */
+ askClearFinished: () => void
+}
+
+export interface ActionsState {
+ /** A removal is under way. */
+ busy: boolean
+}
+
+export const ActionsContext = createContext<Actions | null>(null)
+export const StateContext = createContext<ActionsState>({ busy: false })
+
+/** The actions, which never change: safe to pass to memoized rows. */
+export function useDownloadActions(): Actions {
+ const actions = useContext(ActionsContext)
+ if (!actions) throw new Error('useDownloadActions needs a DownloadActionsProvider')
+ return actions
+}
+
+/** Whether a removal is under way. Changes as it does. */
+export function useDownloadActionsState(): ActionsState {
+ return useContext(StateContext)
+}
diff --git a/src/renderer/src/components/ui/alert-dialog.tsx b/src/renderer/src/components/ui/alert-dialog.tsx
index bac7bc5..f5964ef 100644
--- a/src/renderer/src/components/ui/alert-dialog.tsx
+++ b/src/renderer/src/components/ui/alert-dialog.tsx
@@ -79,7 +79,7 @@ function AlertDialogTitle({
return (
<AlertDialogPrimitive.Title
data-slot="alert-dialog-title"
- className={cn('text-sm font-semibold', className)}
+ className={cn('text-sm font-semibold wrap-break-word', className)}
{...props}
/>
)
diff --git a/src/renderer/src/components/ui/context-menu.tsx b/src/renderer/src/components/ui/context-menu.tsx
new file mode 100644
index 0000000..c9b06b6
--- /dev/null
+++ b/src/renderer/src/components/ui/context-menu.tsx
@@ -0,0 +1,255 @@
+import * as React from 'react'
+import { ContextMenu as ContextMenuPrimitive } from '@base-ui/react/context-menu'
+import { cn } from 'cn'
+import { ChevronRightIcon, CheckIcon } from 'lucide-react'
+
+function ContextMenu({ ...props }: ContextMenuPrimitive.Root.Props): React.JSX.Element {
+ return <ContextMenuPrimitive.Root data-slot="context-menu" {...props} />
+}
+
+function ContextMenuPortal({ ...props }: ContextMenuPrimitive.Portal.Props): React.JSX.Element {
+ return <ContextMenuPrimitive.Portal data-slot="context-menu-portal" {...props} />
+}
+
+function ContextMenuTrigger({
+ className,
+ ...props
+}: ContextMenuPrimitive.Trigger.Props): React.JSX.Element {
+ return (
+ <ContextMenuPrimitive.Trigger
+ data-slot="context-menu-trigger"
+ className={cn('select-none', className)}
+ {...props}
+ />
+ )
+}
+
+function ContextMenuContent({
+ className,
+ align = 'start',
+ alignOffset = 4,
+ side = 'right',
+ sideOffset = 0,
+ ...props
+}: ContextMenuPrimitive.Popup.Props &
+ Pick<
+ ContextMenuPrimitive.Positioner.Props,
+ 'align' | 'alignOffset' | 'side' | 'sideOffset'
+ >): React.JSX.Element {
+ return (
+ <ContextMenuPrimitive.Portal>
+ <ContextMenuPrimitive.Positioner
+ className="isolate z-50 outline-none"
+ align={align}
+ alignOffset={alignOffset}
+ side={side}
+ sideOffset={sideOffset}
+ >
+ <ContextMenuPrimitive.Popup
+ data-slot="context-menu-content"
+ className={cn(
+ 'z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
+ className
+ )}
+ {...props}
+ />
+ </ContextMenuPrimitive.Positioner>
+ </ContextMenuPrimitive.Portal>
+ )
+}
+
+function ContextMenuGroup({ ...props }: ContextMenuPrimitive.Group.Props): React.JSX.Element {
+ return <ContextMenuPrimitive.Group data-slot="context-menu-group" {...props} />
+}
+
+function ContextMenuLabel({
+ className,
+ inset,
+ ...props
+}: ContextMenuPrimitive.GroupLabel.Props & {
+ inset?: boolean
+}): React.JSX.Element {
+ return (
+ <ContextMenuPrimitive.GroupLabel
+ data-slot="context-menu-label"
+ data-inset={inset}
+ className={cn(
+ 'px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7',
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function ContextMenuItem({
+ className,
+ inset,
+ variant = 'default',
+ ...props
+}: ContextMenuPrimitive.Item.Props & {
+ inset?: boolean
+ variant?: 'default' | 'destructive'
+}): React.JSX.Element {
+ return (
+ <ContextMenuPrimitive.Item
+ data-slot="context-menu-item"
+ data-inset={inset}
+ data-variant={variant}
+ className={cn(
+ "group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none data-highlighted:bg-muted data-highlighted:text-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:data-highlighted:bg-destructive/10 data-[variant=destructive]:data-highlighted:text-destructive dark:data-[variant=destructive]:data-highlighted:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function ContextMenuSub({ ...props }: ContextMenuPrimitive.SubmenuRoot.Props): React.JSX.Element {
+ return <ContextMenuPrimitive.SubmenuRoot data-slot="context-menu-sub" {...props} />
+}
+
+function ContextMenuSubTrigger({
+ className,
+ inset,
+ children,
+ ...props
+}: ContextMenuPrimitive.SubmenuTrigger.Props & {
+ inset?: boolean
+}): React.JSX.Element {
+ return (
+ <ContextMenuPrimitive.SubmenuTrigger
+ data-slot="context-menu-sub-trigger"
+ data-inset={inset}
+ className={cn(
+ "flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none data-highlighted:bg-muted data-highlighted:text-foreground data-inset:pl-7 data-open:bg-muted data-open:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <ChevronRightIcon className="ml-auto" />
+ </ContextMenuPrimitive.SubmenuTrigger>
+ )
+}
+
+function ContextMenuSubContent({
+ ...props
+}: React.ComponentProps<typeof ContextMenuContent>): React.JSX.Element {
+ return (
+ <ContextMenuContent
+ data-slot="context-menu-sub-content"
+ className="shadow-lg"
+ side="right"
+ {...props}
+ />
+ )
+}
+
+function ContextMenuCheckboxItem({
+ className,
+ children,
+ checked,
+ inset,
+ ...props
+}: ContextMenuPrimitive.CheckboxItem.Props & {
+ inset?: boolean
+}): React.JSX.Element {
+ return (
+ <ContextMenuPrimitive.CheckboxItem
+ data-slot="context-menu-checkbox-item"
+ data-inset={inset}
+ className={cn(
+ "relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-highlighted:bg-muted data-highlighted:text-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ className
+ )}
+ checked={checked}
+ {...props}
+ >
+ <span className="pointer-events-none absolute right-2">
+ <ContextMenuPrimitive.CheckboxItemIndicator>
+ <CheckIcon />
+ </ContextMenuPrimitive.CheckboxItemIndicator>
+ </span>
+ {children}
+ </ContextMenuPrimitive.CheckboxItem>
+ )
+}
+
+function ContextMenuRadioGroup({
+ ...props
+}: ContextMenuPrimitive.RadioGroup.Props): React.JSX.Element {
+ return <ContextMenuPrimitive.RadioGroup data-slot="context-menu-radio-group" {...props} />
+}
+
+function ContextMenuRadioItem({
+ className,
+ children,
+ inset,
+ ...props
+}: ContextMenuPrimitive.RadioItem.Props & {
+ inset?: boolean
+}): React.JSX.Element {
+ return (
+ <ContextMenuPrimitive.RadioItem
+ data-slot="context-menu-radio-item"
+ data-inset={inset}
+ className={cn(
+ "relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-highlighted:bg-muted data-highlighted:text-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ className
+ )}
+ {...props}
+ >
+ <span className="pointer-events-none absolute right-2">
+ <ContextMenuPrimitive.RadioItemIndicator>
+ <CheckIcon />
+ </ContextMenuPrimitive.RadioItemIndicator>
+ </span>
+ {children}
+ </ContextMenuPrimitive.RadioItem>
+ )
+}
+
+function ContextMenuSeparator({
+ className,
+ ...props
+}: ContextMenuPrimitive.Separator.Props): React.JSX.Element {
+ return (
+ <ContextMenuPrimitive.Separator
+ data-slot="context-menu-separator"
+ className={cn('-mx-1 my-1 h-px bg-border', className)}
+ {...props}
+ />
+ )
+}
+
+function ContextMenuShortcut({
+ className,
+ ...props
+}: React.ComponentProps<'span'>): React.JSX.Element {
+ return (
+ <span
+ data-slot="context-menu-shortcut"
+ className={cn('ml-auto text-xs tracking-widest text-muted-foreground', className)}
+ {...props}
+ />
+ )
+}
+
+export {
+ ContextMenu,
+ ContextMenuTrigger,
+ ContextMenuContent,
+ ContextMenuItem,
+ ContextMenuCheckboxItem,
+ ContextMenuRadioItem,
+ ContextMenuLabel,
+ ContextMenuSeparator,
+ ContextMenuShortcut,
+ ContextMenuGroup,
+ ContextMenuPortal,
+ ContextMenuSub,
+ ContextMenuSubContent,
+ ContextMenuSubTrigger,
+ ContextMenuRadioGroup
+}
diff --git a/src/renderer/src/components/ui/dropdown-menu.tsx b/src/renderer/src/components/ui/dropdown-menu.tsx
new file mode 100644
index 0000000..02c8d3d
--- /dev/null
+++ b/src/renderer/src/components/ui/dropdown-menu.tsx
@@ -0,0 +1,264 @@
+import * as React from 'react'
+import { Menu as MenuPrimitive } from '@base-ui/react/menu'
+import { cn } from 'cn'
+import { ChevronRightIcon, CheckIcon } from 'lucide-react'
+
+function DropdownMenu({ ...props }: MenuPrimitive.Root.Props): React.JSX.Element {
+ return <MenuPrimitive.Root data-slot="dropdown-menu" {...props} />
+}
+
+function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props): React.JSX.Element {
+ return <MenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
+}
+
+function DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props): React.JSX.Element {
+ return <MenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />
+}
+
+function DropdownMenuContent({
+ align = 'start',
+ alignOffset = 0,
+ side = 'bottom',
+ sideOffset = 4,
+ className,
+ ...props
+}: MenuPrimitive.Popup.Props &
+ Pick<
+ MenuPrimitive.Positioner.Props,
+ 'align' | 'alignOffset' | 'side' | 'sideOffset'
+ >): React.JSX.Element {
+ return (
+ <MenuPrimitive.Portal>
+ <MenuPrimitive.Positioner
+ className="isolate z-50 outline-none"
+ align={align}
+ alignOffset={alignOffset}
+ side={side}
+ sideOffset={sideOffset}
+ >
+ <MenuPrimitive.Popup
+ data-slot="dropdown-menu-content"
+ className={cn(
+ 'z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95',
+ className
+ )}
+ {...props}
+ />
+ </MenuPrimitive.Positioner>
+ </MenuPrimitive.Portal>
+ )
+}
+
+function DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props): React.JSX.Element {
+ return <MenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
+}
+
+function DropdownMenuLabel({
+ className,
+ inset,
+ ...props
+}: MenuPrimitive.GroupLabel.Props & {
+ inset?: boolean
+}): React.JSX.Element {
+ return (
+ <MenuPrimitive.GroupLabel
+ data-slot="dropdown-menu-label"
+ data-inset={inset}
+ className={cn(
+ 'px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7',
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function DropdownMenuItem({
+ className,
+ inset,
+ variant = 'default',
+ ...props
+}: MenuPrimitive.Item.Props & {
+ inset?: boolean
+ variant?: 'default' | 'destructive'
+}): React.JSX.Element {
+ return (
+ <MenuPrimitive.Item
+ data-slot="dropdown-menu-item"
+ data-inset={inset}
+ data-variant={variant}
+ className={cn(
+ "group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props): React.JSX.Element {
+ return <MenuPrimitive.SubmenuRoot data-slot="dropdown-menu-sub" {...props} />
+}
+
+function DropdownMenuSubTrigger({
+ className,
+ inset,
+ children,
+ ...props
+}: MenuPrimitive.SubmenuTrigger.Props & {
+ inset?: boolean
+}): React.JSX.Element {
+ return (
+ <MenuPrimitive.SubmenuTrigger
+ data-slot="dropdown-menu-sub-trigger"
+ data-inset={inset}
+ className={cn(
+ "flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <ChevronRightIcon className="ml-auto" />
+ </MenuPrimitive.SubmenuTrigger>
+ )
+}
+
+function DropdownMenuSubContent({
+ align = 'start',
+ alignOffset = -3,
+ side = 'right',
+ sideOffset = 0,
+ className,
+ ...props
+}: React.ComponentProps<typeof DropdownMenuContent>): React.JSX.Element {
+ return (
+ <DropdownMenuContent
+ data-slot="dropdown-menu-sub-content"
+ className={cn(
+ 'w-auto min-w-[96px] rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
+ className
+ )}
+ align={align}
+ alignOffset={alignOffset}
+ side={side}
+ sideOffset={sideOffset}
+ {...props}
+ />
+ )
+}
+
+function DropdownMenuCheckboxItem({
+ className,
+ children,
+ checked,
+ inset,
+ ...props
+}: MenuPrimitive.CheckboxItem.Props & {
+ inset?: boolean
+}): React.JSX.Element {
+ return (
+ <MenuPrimitive.CheckboxItem
+ data-slot="dropdown-menu-checkbox-item"
+ data-inset={inset}
+ className={cn(
+ "relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ className
+ )}
+ checked={checked}
+ {...props}
+ >
+ <span
+ className="pointer-events-none absolute right-2 flex items-center justify-center"
+ data-slot="dropdown-menu-checkbox-item-indicator"
+ >
+ <MenuPrimitive.CheckboxItemIndicator>
+ <CheckIcon />
+ </MenuPrimitive.CheckboxItemIndicator>
+ </span>
+ {children}
+ </MenuPrimitive.CheckboxItem>
+ )
+}
+
+function DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props): React.JSX.Element {
+ return <MenuPrimitive.RadioGroup data-slot="dropdown-menu-radio-group" {...props} />
+}
+
+function DropdownMenuRadioItem({
+ className,
+ children,
+ inset,
+ ...props
+}: MenuPrimitive.RadioItem.Props & {
+ inset?: boolean
+}): React.JSX.Element {
+ return (
+ <MenuPrimitive.RadioItem
+ data-slot="dropdown-menu-radio-item"
+ data-inset={inset}
+ className={cn(
+ "relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ className
+ )}
+ {...props}
+ >
+ <span
+ className="pointer-events-none absolute right-2 flex items-center justify-center"
+ data-slot="dropdown-menu-radio-item-indicator"
+ >
+ <MenuPrimitive.RadioItemIndicator>
+ <CheckIcon />
+ </MenuPrimitive.RadioItemIndicator>
+ </span>
+ {children}
+ </MenuPrimitive.RadioItem>
+ )
+}
+
+function DropdownMenuSeparator({
+ className,
+ ...props
+}: MenuPrimitive.Separator.Props): React.JSX.Element {
+ return (
+ <MenuPrimitive.Separator
+ data-slot="dropdown-menu-separator"
+ className={cn('-mx-1 my-1 h-px bg-border', className)}
+ {...props}
+ />
+ )
+}
+
+function DropdownMenuShortcut({
+ className,
+ ...props
+}: React.ComponentProps<'span'>): React.JSX.Element {
+ return (
+ <span
+ data-slot="dropdown-menu-shortcut"
+ className={cn(
+ 'ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground',
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+export {
+ DropdownMenu,
+ DropdownMenuPortal,
+ DropdownMenuTrigger,
+ DropdownMenuContent,
+ DropdownMenuGroup,
+ DropdownMenuLabel,
+ DropdownMenuItem,
+ DropdownMenuCheckboxItem,
+ DropdownMenuRadioGroup,
+ DropdownMenuRadioItem,
+ DropdownMenuSeparator,
+ DropdownMenuShortcut,
+ DropdownMenuSub,
+ DropdownMenuSubTrigger,
+ DropdownMenuSubContent
+}
diff --git a/src/renderer/src/screens/CompleteScreen.tsx b/src/renderer/src/screens/CompleteScreen.tsx
index 5f7a770..4d9275b 100644
--- a/src/renderer/src/screens/CompleteScreen.tsx
+++ b/src/renderer/src/screens/CompleteScreen.tsx
@@ -2,7 +2,6 @@ import type { DownloadState, FinishedDownload } from '@shared/types'
import { HeroBand } from '../components/HeroBand'
import { DetailHeader } from '../components/DetailHeader'
import { ThroughputChart } from '../components/ThroughputChart'
-import { Button } from '../components/ui/button'
import { useNetworkVisuals } from '../hooks/useNetworkVisuals'
import { useAppStore } from '../store/useAppStore'
import {
@@ -56,16 +55,9 @@ export function CompleteScreen({
: download.totalBlocks
const files = isTorrent && download.files.total > 1 ? download.files : null
- // Gone since the list was read: main sends history again, marking it missing here.
- const handleReveal = (): void => void window.plexo.revealDownload(download.id)
-
return (
<div className="flex h-full flex-col bg-background">
- <DetailHeader download={download}>
- <Button type="button" onClick={handleReveal} disabled={missing}>
- {window.plexo.platform === 'darwin' ? 'Show in Finder' : 'Show in folder'}
- </Button>
- </DetailHeader>
+ <DetailHeader download={download} />
<div role="status" className="sr-only">
Download complete: {download.fileName}
</div>
diff --git a/src/renderer/src/screens/DownloadingScreen.tsx b/src/renderer/src/screens/DownloadingScreen.tsx
index 2bd1871..2e6138f 100644
--- a/src/renderer/src/screens/DownloadingScreen.tsx
+++ b/src/renderer/src/screens/DownloadingScreen.tsx
@@ -129,18 +129,7 @@ export const DownloadingScreen = memo(function DownloadingScreen({
return () => clearInterval(interval)
}, [isPaused])
- // Resuming round-trips through the main process to re-verify the download before flipping
- // status away from 'paused' (an ETag re-check over the network for a real download) — with no
- // feedback in between, a slow check reads as the button not having registered the click.
- const [resuming, setResuming] = useState(false)
const [filesOpen, setFilesOpen] = useState(false)
- useEffect(() => {
- if (!isPaused || download.error) {
- // eslint-disable-next-line react-hooks/set-state-in-effect
- setResuming(false)
- }
- }, [isPaused, download.error])
-
useEffect(() => {
if (isPaused) {
const label = isQueued ? 'Queued' : 'Paused'
@@ -158,16 +147,6 @@ export const DownloadingScreen = memo(function DownloadingScreen({
(isPaused && download.pausedAt ? Math.max(0, now - download.pausedAt) : 0)
const elapsedSeconds = Math.max(0, (now - download.startedAt - totalPausedMs) / 1000)
- const handlePauseResume = (): void => {
- // A queued one is paused out of the queue, as a running one is.
- if (isPaused && !isQueued) {
- setResuming(true)
- void window.plexo.resumeDownload(download.id)
- } else {
- void window.plexo.pauseDownload(download.id)
- }
- }
-
const effectiveSpeed = isPaused ? 0 : download.speedBytesPerSec
const [speedValue, speedUnit] = formatSpeed(effectiveSpeed).split(' ')
// The cap over every download, beside the speed it holds down — slow mode named, so a low
@@ -225,20 +204,10 @@ export const DownloadingScreen = memo(function DownloadingScreen({
: null
const throughputStatusLabel = isPaused ? null : `LAST ${SPEED_HISTORY_SECONDS}S`
- const pauseResumeLabel = resuming ? 'Resuming…' : isPaused && !isQueued ? 'Resume' : 'Pause'
return (
<div className="flex h-full flex-col bg-background">
- <DetailHeader download={download}>
- <Button
- type="button"
- variant={isPaused && !isQueued ? 'default' : 'secondary'}
- onClick={handlePauseResume}
- disabled={resuming}
- >
- {pauseResumeLabel}
- </Button>
- </DetailHeader>
+ <DetailHeader download={download} />
{/* Hero band — always visible under the header */}
<HeroBand>
{/* At their designed size: a wider window opens a gap between the speed and the chart
@@ -385,7 +354,7 @@ export const DownloadingScreen = memo(function DownloadingScreen({
size="xs"
onClick={() => setFilesOpen((open) => !open)}
aria-expanded={filesOpen}
- className="h-auto cursor-pointer rounded-[4px] border-[0.5px] bg-card px-[7px] py-[3px] font-mono text-[10.5px] leading-none font-medium text-[var(--text-secondary)] aria-expanded:bg-secondary dark:bg-card"
+ className="h-auto cursor-default rounded-[4px] border-[0.5px] bg-card px-[7px] py-[3px] font-mono text-[10.5px] leading-none font-medium text-[var(--text-secondary)] aria-expanded:bg-secondary dark:bg-card"
>
{describeFileCount(download.files.chosen, download.files.total)}{' '}
<span aria-hidden className="text-[7.5px] opacity-75">
diff --git a/src/renderer/src/screens/DownloadsScreen.tsx b/src/renderer/src/screens/DownloadsScreen.tsx
index 6167457..98f21ef 100644
--- a/src/renderer/src/screens/DownloadsScreen.tsx
+++ b/src/renderer/src/screens/DownloadsScreen.tsx
@@ -1,26 +1,19 @@
import { EXTENSION_PAGE_URL } from '@shared/browserBridge'
import type { DownloadState, FinishedDownload } from '@shared/types'
-import { ChevronRight, Pause, Play, Plus, RotateCw, X, type LucideIcon } from 'lucide-react'
+import { ChevronRight, Plus, X } from 'lucide-react'
import { cn } from 'cn'
import { Fragment, memo, useCallback, useEffect, useState } from 'react'
+import { DownloadContextMenu } from '../components/DownloadContextMenu'
+import { useDownloadActions, useDownloadActionsState } from '../components/downloadActionsContext'
+import { ACTION_META, toolbarLabel } from '../components/downloadActionMeta'
+import { MoreActionsMenu } from '../components/MoreActionsMenu'
import { DownloadFilterMenu } from '../components/DownloadFilterMenu'
import { CombineDiagram } from '../components/CombineDiagram'
-import { FixLinkDialog } from '../components/FixLinkDialog'
import { LimitsDialog } from '../components/LimitsDialog'
import { networkStatusText } from '../components/NetworkRow'
import { NetworksMenu } from '../components/NetworksMenu'
import { TorrentBadge } from '../components/TorrentBadge'
-import {
- AlertDialog,
- AlertDialogAction,
- AlertDialogCancel,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogTitle
-} from '../components/ui/alert-dialog'
-import { Button, buttonVariants } from '../components/ui/button'
+import { Button } from '../components/ui/button'
import { Checkbox } from '../components/ui/checkbox'
import { Tooltip, TooltipContent, TooltipTrigger } from '../components/ui/tooltip'
import { useNetworkVisuals, type ResolveNetworkVisual } from '../hooks/useNetworkVisuals'
@@ -33,11 +26,17 @@ import {
formatPercent,
formatWhen,
isFolder,
- linkExpired,
sourceOf,
wantedBytes
} from '../utils/format'
import { useFormatSpeed } from '../hooks/useFormatSpeed'
+import {
+ availableActions,
+ isFinished,
+ rowAction,
+ splitToolbar,
+ type ActionId
+} from '../utils/downloadActions'
type Item = DownloadState | FinishedDownload
@@ -51,8 +50,6 @@ function filterOf(item: Item): Exclude<DownloadFilter, 'all'> {
return item.status === 'error' ? 'failed' : 'progress'
}
-const isFinished = (item: Item): item is FinishedDownload => 'unitsWritten' in item
-
function groupsOf(downloads: DownloadState[], history: FinishedDownload[]): Group[] {
const byStatus = (status: DownloadState['status']): DownloadState[] =>
downloads.filter((download) => download.status === status)
@@ -92,17 +89,11 @@ export function DownloadsScreen(): React.JSX.Element {
const history = useAppStore((store) => store.history)
const setView = useAppStore((store) => store.setView)
const openNewDownload = useAppStore((store) => store.openNewDownload)
- const removeDownload = useAppStore((store) => store.removeDownload)
const filter = useAppStore((store) => store.downloadFilter)
const setFilter = useAppStore((store) => store.setDownloadFilter)
const [selected, setSelected] = useState<Set<string>>(new Set())
- const [fixing, setFixing] = useState<DownloadState | null>(null)
- const [confirmation, setConfirmation] = useState<{
- kind: 'cancel' | 'trash'
- ids: string[]
- } | null>(null)
- const [busy, setBusy] = useState(false)
- const [actionError, setActionError] = useState<string | null>(null)
+ const { perform, askClearFinished } = useDownloadActions()
+ const { busy } = useDownloadActionsState()
const [limitsOpen, setLimitsOpen] = useState(false)
const [limitsPage, setLimitsPage] = useState<string | null>(null)
const [now, setNow] = useState(() => Date.now())
@@ -147,78 +138,40 @@ export function DownloadsScreen(): React.JSX.Element {
const networkVisual = useNetworkVisuals()
const selectRow = useCallback((id: string, on: boolean) => toggle([id], on), [toggle])
const openRow = useCallback((id: string) => setView({ name: 'download', id }), [setView])
- const fixRow = useCallback((item: Item) => {
- if (!isFinished(item)) setFixing(item)
- }, [])
- const againRow = useCallback(
- (item: Item) => {
- removeDownload(item.id)
- openNewDownload(item.url)
- },
- [removeDownload, openNewDownload]
- )
-
- const pausable = chosen.filter(
- (item): item is DownloadState =>
- !isFinished(item) && (item.status === 'downloading' || item.status === 'queued')
- )
- const resumable = chosen.filter(
- (item): item is DownloadState => !isFinished(item) && item.status === 'paused'
- )
- const retryable = chosen.filter(
- (item): item is DownloadState =>
- !isFinished(item) && item.status === 'error' && item.resumable !== false && !linkExpired(item)
- )
- const unfinished = chosen.filter((item) => !isFinished(item) && item.status !== 'completed')
- const finished = chosen.filter((item) => isFinished(item) || item.status === 'completed')
- const trashable = finished.filter(
- (item) =>
- !(isFinished(item) && item.missing) &&
- (item.kind !== 'torrent' ||
- !item.folder ||
- !isFinished(item) ||
- !!item.downloadedFiles?.length)
- )
- const confirmationItems = confirmation
- ? chosen.filter(
- (item) =>
- confirmation.ids.includes(item.id) &&
- (confirmation.kind === 'cancel' ? unfinished.includes(item) : trashable.includes(item))
+ // Keys for the selection: Esc clears it, Select all, and Delete takes
+ // the selected off the list (with Cmd/Ctrl, moves their files to the Trash), each asking first.
+ useEffect(() => {
+ const onKeyDown = (event: KeyboardEvent): void => {
+ const target = event.target
+ if (
+ event.defaultPrevented ||
+ (target instanceof HTMLElement &&
+ (target.isContentEditable || ['INPUT', 'TEXTAREA'].includes(target.tagName))) ||
+ document.querySelector('[role="dialog"], [role="alertdialog"], [role="menu"]')
)
- : []
-
- const runAction = async (
- targets: Item[],
- action: 'pause' | 'resume' | 'remove' | 'trash'
- ): Promise<void> => {
- if (busy) return
- setBusy(true)
- setActionError(null)
- try {
- for (const item of targets) {
- if (action === 'pause') await window.plexo.pauseDownload(item.id)
- else if (action === 'resume') await window.plexo.resumeDownload(item.id)
- else {
- await window.plexo.removeDownload(item.id, { trashFile: action === 'trash' })
- useAppStore.setState((store) => {
- const { [item.id]: removed, ...downloads } = store.downloads
- void removed
- return { downloads, history: store.history.filter((entry) => entry.id !== item.id) }
- })
- setSelected((previous) => {
- const next = new Set(previous)
- next.delete(item.id)
- return next
- })
- }
+ return
+ const command = window.plexo.platform === 'darwin' ? event.metaKey : event.ctrlKey
+ if (event.key === 'Escape') setSelected(new Set())
+ else if (command && event.key.toLowerCase() === 'a') {
+ event.preventDefault()
+ setSelected(new Set(items.map((item) => item.id)))
+ } else if (event.key === 'Delete' || event.key === 'Backspace') {
+ const id = command ? 'trash' : 'remove'
+ const action = availableActions(chosen)
+ .flat()
+ .find((available) => available.id === id)
+ if (!action) return
+ event.preventDefault()
+ void perform(id, action.targets)
}
- } catch (error) {
- setActionError(describeError(error))
- } finally {
- setBusy(false)
- setConfirmation(null)
}
- }
+ window.addEventListener('keydown', onKeyDown)
+ return () => window.removeEventListener('keydown', onKeyDown)
+ }, [items, chosen, perform])
+
+ // What the toolbar offers: the two actions most needed for what's selected as buttons, and
+ // the rest of what the menu does for the selection behind More, so six never need more room.
+ const { buttons: toolbarButtons, more: moreActions } = splitToolbar(availableActions(chosen))
return (
<div className="flex h-full flex-col bg-background">
@@ -288,85 +241,22 @@ export function DownloadsScreen(): React.JSX.Element {
</Button>
<div className="flex-1" />
<div className="flex min-w-0 items-center gap-2 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
- {pausable.length > 0 && (
- <Button
- type="button"
- size="sm"
- variant="secondary"
- disabled={busy}
- onClick={() => void runAction(pausable, 'pause')}
- >
- Pause ({pausable.length})
- </Button>
- )}
- {resumable.length > 0 && (
- <Button
- type="button"
- size="sm"
- variant="secondary"
- disabled={busy}
- onClick={() => void runAction(resumable, 'resume')}
- >
- Resume ({resumable.length})
- </Button>
- )}
- {retryable.length > 0 && (
- <Button
- type="button"
- size="sm"
- variant="secondary"
- disabled={busy}
- onClick={() => void runAction(retryable, 'resume')}
- >
- Retry ({retryable.length})
- </Button>
- )}
- {finished.length > 0 && (
+ {toolbarButtons.map(({ id, targets }) => (
<Button
+ key={id}
type="button"
size="sm"
- variant="secondary"
+ variant={ACTION_META[id].destructive ? 'destructive' : 'secondary'}
disabled={busy}
- onClick={() => void runAction(finished, 'remove')}
+ onClick={() => void perform(id, targets)}
>
- Remove from list ({finished.length})
+ {toolbarLabel(id, targets.length)}
</Button>
- )}
- {unfinished.length > 0 && (
- <Button
- type="button"
- size="sm"
- variant="destructive"
- disabled={busy}
- onClick={() =>
- setConfirmation({ kind: 'cancel', ids: unfinished.map((item) => item.id) })
- }
- >
- Cancel downloads… ({unfinished.length})
- </Button>
- )}
- {trashable.length > 0 && (
- <Button
- type="button"
- size="sm"
- variant="destructive"
- disabled={busy}
- onClick={() =>
- setConfirmation({ kind: 'trash', ids: trashable.map((item) => item.id) })
- }
- >
- Move files to {window.plexo.platform === 'win32' ? 'Recycle Bin' : 'Trash'}… (
- {trashable.length})
- </Button>
- )}
+ ))}
+ <MoreActionsMenu groups={moreActions} disabled={busy} />
</div>
</div>
)}
- {actionError && (
- <div role="alert" className="border-b border-border px-5 py-2 text-[12px] text-destructive">
- {actionError}
- </div>
- )}
<div className="min-h-0 flex-1 overflow-y-auto px-5 pb-5">
{groups.length === 0 &&
@@ -409,88 +299,46 @@ export function DownloadsScreen(): React.JSX.Element {
</h2>
<div className="flex-1" />
{group.label === 'Finished' && history.length > 0 && (
- <Tooltip>
- <TooltipTrigger
- render={
- <button
- type="button"
- className="text-[12.5px] text-[var(--text-secondary)] hover:text-foreground"
- onClick={() => void window.plexo.clearHistory()}
- >
- Clear finished list
- </button>
- }
- />
- <TooltipContent>Downloaded files stay on your computer</TooltipContent>
- </Tooltip>
+ <button
+ type="button"
+ className="text-[12.5px] text-[var(--text-secondary)] hover:text-foreground"
+ onClick={askClearFinished}
+ >
+ Clear finished list
+ </button>
)}
</div>
{group.items.map((item) => (
- <DownloadRow
+ <DownloadContextMenu
key={item.id}
item={item}
- now={now}
selected={selected.has(item.id)}
- networkVisual={
- isFinished(item) || item.status === 'completed' ? undefined : networkVisual
- }
- onSelect={selectRow}
- onOpen={openRow}
- onFix={fixRow}
- onAgain={againRow}
- />
+ chosen={chosen}
+ >
+ <DownloadRow
+ item={item}
+ now={now}
+ selected={selected.has(item.id)}
+ networkVisual={
+ isFinished(item) || item.status === 'completed' ? undefined : networkVisual
+ }
+ onSelect={selectRow}
+ onOpen={openRow}
+ onPerform={perform}
+ />
+ </DownloadContextMenu>
))}
</section>
)
})}
</div>
- <FixLinkDialog download={fixing} onClose={() => setFixing(null)} />
<LimitsDialog
open={limitsOpen}
onOpenChange={setLimitsOpen}
page={limitsPage}
onPageChange={setLimitsPage}
/>
-
- <AlertDialog
- open={confirmation !== null}
- onOpenChange={(open) => !open && setConfirmation(null)}
- >
- <AlertDialogContent>
- <AlertDialogHeader>
- <AlertDialogTitle>
- {confirmation?.kind === 'cancel'
- ? 'Cancel'
- : `Move files to ${window.plexo.platform === 'win32' ? 'Recycle Bin' : 'Trash'} for`}{' '}
- {confirmationItems.length} {confirmationItems.length === 1 ? 'download' : 'downloads'}
- ?
- </AlertDialogTitle>
- <AlertDialogDescription>
- {confirmation?.kind === 'cancel'
- ? 'This stops the selected unfinished downloads and deletes their downloaded data. Finished downloads stay unchanged.'
- : `This moves the selected finished downloads’ files to the ${window.plexo.platform === 'win32' ? 'Recycle Bin' : 'Trash'} and removes them from the list. Unrelated files stay in place.`}
- </AlertDialogDescription>
- </AlertDialogHeader>
- <AlertDialogFooter>
- <AlertDialogCancel>Cancel</AlertDialogCancel>
- <AlertDialogAction
- disabled={busy || confirmationItems.length === 0}
- className={buttonVariants({ variant: 'destructive', size: 'sm' })}
- onClick={() =>
- void runAction(
- confirmationItems,
- confirmation?.kind === 'cancel' ? 'remove' : 'trash'
- )
- }
- >
- {confirmation?.kind === 'cancel'
- ? 'Cancel downloads'
- : `Move files to ${window.plexo.platform === 'win32' ? 'Recycle Bin' : 'Trash'}`}
- </AlertDialogAction>
- </AlertDialogFooter>
- </AlertDialogContent>
- </AlertDialog>
</div>
)
}
@@ -532,7 +380,7 @@ function EmptyState(): React.JSX.Element {
variant="secondary"
onClick={() => window.plexo.openNetworkSettings()}
>
- Network settings…
+ Network settings
</Button>
</div>
</>
@@ -568,8 +416,7 @@ const DownloadRow = memo(function DownloadRow({
networkVisual,
onSelect,
onOpen,
- onFix,
- onAgain
+ onPerform
}: {
item: Item
now: number
@@ -578,10 +425,11 @@ const DownloadRow = memo(function DownloadRow({
networkVisual?: ResolveNetworkVisual
onSelect: (id: string, on: boolean) => void
onOpen: (id: string) => void
- onFix: (item: Item) => void
- onAgain: (item: Item) => void
+ /** Does what the row's button says, the way the menu, the toolbar and its screen do. */
+ onPerform: (id: ActionId, targets: Item[]) => Promise<boolean>
}): React.JSX.Element {
const formatSpeed = useFormatSpeed()
+ const [working, setWorking] = useState(false)
const finished = isFinished(item) || item.status === 'completed'
const badge = isFolder(item) ? 'DIR' : fileExtensionBadge(item.fileName)
const wanted = wantedBytes(item)
@@ -589,7 +437,6 @@ const DownloadRow = memo(function DownloadRow({
let detail: string
let tone = 'text-muted-foreground'
- let action: { label: string; run: () => void; icon?: LucideIcon } | null = null
if (isFinished(item) || item.status === 'completed') {
detail = [
formatBytes(wanted || item.bytesDownloaded),
@@ -616,41 +463,21 @@ const DownloadRow = memo(function DownloadRow({
]
.filter(Boolean)
.join(' · ')
- action = {
- label: 'Pause',
- icon: Pause,
- run: () => void window.plexo.pauseDownload(download.id)
- }
break
case 'queued':
detail = `Waiting for a turn · ${sizes}`
- action = {
- label: 'Pause',
- icon: Pause,
- run: () => void window.plexo.pauseDownload(download.id)
- }
break
case 'paused':
detail = wanted > 0 ? `Paused at ${percent}% · ${sizes}` : `Paused · ${sizes}`
- action = {
- label: 'Resume',
- icon: Play,
- run: () => void window.plexo.resumeDownload(download.id)
- }
break
default:
detail = describeError(download.error ?? 'Something went wrong')
tone = 'text-[var(--color-danger)]'
- if (linkExpired(download)) action = { label: 'Fix link', run: () => onFix(item) }
- else if (download.resumable !== false) {
- action = {
- label: 'Retry',
- icon: RotateCw,
- run: () => void window.plexo.resumeDownload(download.id)
- }
- } else action = { label: 'Download again', run: () => onAgain(item) }
}
}
+ // Its next step, if it has one: the first thing its menu offers.
+ const actionId = rowAction(item)
+ const action = actionId ? ACTION_META[actionId] : null
// The bar shows each network's share of the file in its color; a failed one shows in red.
const segments =
@@ -806,7 +633,7 @@ const DownloadRow = memo(function DownloadRow({
<div className={`truncate font-mono text-[11.5px] leading-tight ${tone}`}>{detail}</div>
</div>
</button>
- {action?.icon ? (
+ {action && (
<Tooltip>
<TooltipTrigger
render={
@@ -815,21 +642,22 @@ const DownloadRow = memo(function DownloadRow({
size="icon-sm"
variant="ghost"
aria-label={`${action.label} ${item.fileName}`}
- onClick={action.run}
+ aria-busy={working}
+ disabled={working}
+ onClick={() => {
+ setWorking(true)
+ void onPerform(actionId!, [item]).finally(() => setWorking(false))
+ }}
className="text-muted-foreground group-hover/download-row:text-foreground"
>
<action.icon />
</Button>
}
/>
- <TooltipContent>{action.label}</TooltipContent>
+ <TooltipContent>
+ {working && action.working ? action.working : action.label}
+ </TooltipContent>
</Tooltip>
- ) : (
- action && (
- <Button type="button" size="sm" variant="secondary" onClick={action.run}>
- {action.label}
- </Button>
- )
)}
<button
type="button"
diff --git a/src/renderer/src/screens/ErrorScreen.tsx b/src/renderer/src/screens/ErrorScreen.tsx
index 663535c..dc3e8fe 100644
--- a/src/renderer/src/screens/ErrorScreen.tsx
+++ b/src/renderer/src/screens/ErrorScreen.tsx
@@ -1,38 +1,19 @@
import type { DownloadState } from '@shared/types'
import { Folder } from 'lucide-react'
import { useState } from 'react'
-import { FixLinkDialog } from '../components/FixLinkDialog'
import { DetailHeader } from '../components/DetailHeader'
import { TruncatedText } from '../components/TruncatedText'
-import { Button } from '../components/ui/button'
import {
describeError,
fileExtensionBadge,
formatBytes,
isFolder,
- linkExpired,
wantedBytes
} from '../utils/format'
-import { useAppStore } from '../store/useAppStore'
export function ErrorScreen({ download }: { download: DownloadState }): React.JSX.Element {
- const removeDownload = useAppStore((store) => store.removeDownload)
- const openNewDownload = useAppStore((store) => store.openNewDownload)
- const setView = useAppStore((store) => store.setView)
- // Nothing of it can be kept: it goes, and its link waits in New download to start over.
- const handleDownloadAgain = (): void => {
- removeDownload(download.id)
- setView({ name: 'list' })
- openNewDownload(download.url)
- }
const [copied, setCopied] = useState(false)
- const [resuming, setResuming] = useState(false)
- const [fixing, setFixing] = useState(false)
- // Its link stopped working: a fresh one carries on from here, rather than Resume asking again.
- const expired = linkExpired(download)
const cancelled = download.status === 'cancelled'
- // What it downloaded is still there to pick up from.
- const resumable = !cancelled && download.resumable !== false && download.bytesDownloaded > 0
const knownSize = download.totalBytes > 0
const percent = knownSize
? Math.min(100, Math.round((download.bytesDownloaded / wantedBytes(download)) * 100))
@@ -56,28 +37,7 @@ export function ErrorScreen({ download }: { download: DownloadState }): React.JS
return (
<div className="flex h-full flex-col bg-background">
- <DetailHeader download={download}>
- {expired ? (
- <Button type="button" onClick={() => setFixing(true)}>
- Fix link
- </Button>
- ) : resumable ? (
- <Button
- type="button"
- disabled={resuming}
- onClick={() => {
- setResuming(true)
- void window.plexo.resumeDownload(download.id).finally(() => setResuming(false))
- }}
- >
- {resuming ? 'Retrying…' : 'Retry'}
- </Button>
- ) : (
- <Button type="button" onClick={handleDownloadAgain}>
- Download again
- </Button>
- )}
- </DetailHeader>
+ <DetailHeader download={download} />
<div className="flex flex-1 flex-col items-center justify-center px-5 py-6">
<div className="flex w-full max-w-[440px] flex-col items-center gap-[18px] rounded-xl border-[0.5px] border-border bg-card p-6 text-center">
{/* Status Icon */}
@@ -187,8 +147,6 @@ export function ErrorScreen({ download }: { download: DownloadState }): React.JS
</div>
</div>
</div>
-
- <FixLinkDialog download={fixing ? download : null} onClose={() => setFixing(false)} />
</div>
)
}
diff --git a/src/renderer/src/store/useAppStore.ts b/src/renderer/src/store/useAppStore.ts
index b997593..2b5e4d4 100644
--- a/src/renderer/src/store/useAppStore.ts
+++ b/src/renderer/src/store/useAppStore.ts
@@ -81,8 +81,8 @@ interface AppStore {
receiveDownloadUpdate: (update: DownloadUpdate) => void
/** Finished downloads as main lists them; any that finished leave `downloads`. */
receiveHistory: (history: FinishedDownload[]) => void
- /** Removes a download (cancelling one under way), or forgets a finished one. */
- removeDownload: (id: string, options?: { trashFile?: boolean }) => void
+ /** Drops a download from the window's view once the main process has removed it. */
+ forgetDownload: (id: string) => void
setView: (view: View) => void
/** Opens New download, with `link` in its link field when one is given. */
openNewDownload: (link?: string) => void
@@ -211,11 +211,10 @@ export const useAppStore = create<AppStore>((set, get) => ({
set({ history, downloads })
},
- removeDownload: (id, options) => {
+ forgetDownload: (id) => {
const { [id]: removed, ...downloads } = get().downloads
void removed
set({ downloads, history: get().history.filter((entry) => entry.id !== id) })
- void window.plexo.removeDownload(id, options).catch(() => {})
},
setView: (view) => set({ view }),
diff --git a/src/renderer/src/utils/downloadActions.ts b/src/renderer/src/utils/downloadActions.ts
new file mode 100644
index 0000000..e82b273
--- /dev/null
+++ b/src/renderer/src/utils/downloadActions.ts
@@ -0,0 +1,159 @@
+import type { DownloadState, FinishedDownload } from '@shared/types'
+import { linkExpired } from './format'
+
+/** Everything the app can do to a download, decided in one place. The row's button, the
+ * right-click menu, the selection toolbar and a download's own screen all read this list, so
+ * they can't disagree about what is offered, when, or in what order. How an action is named,
+ * drawn and confirmed is in components/downloadActionMeta.ts and DownloadActionsProvider.tsx. */
+export type ActionId =
+ | 'pause'
+ | 'resume'
+ | 'retry'
+ | 'fix'
+ | 'again'
+ | 'open'
+ | 'reveal'
+ | 'copy'
+ | 'cancel'
+ | 'remove'
+ | 'trash'
+
+export type DownloadItem = DownloadState | FinishedDownload
+
+export const isFinished = (item: DownloadItem): item is FinishedDownload => 'unitsWritten' in item
+export const isDone = (item: DownloadItem): boolean =>
+ isFinished(item) || item.status === 'completed'
+export const isFailed = (item: DownloadItem): item is DownloadState =>
+ !isFinished(item) && item.status === 'error'
+/** Going, waiting or paused: stopping it deletes what it downloaded so far. */
+export const isCancellable = (item: DownloadItem): item is DownloadState =>
+ !isFinished(item) && ['downloading', 'queued', 'paused'].includes(item.status)
+/** Finished, but its file is no longer where it was saved. */
+export const isMissing = (item: DownloadItem): boolean => isFinished(item) && !!item.missing
+/** Finished, with its file (or a torrent's own files) still there to move to the Trash. */
+export const isTrashable = (item: DownloadItem): boolean =>
+ isDone(item) &&
+ !isMissing(item) &&
+ (item.kind !== 'torrent' || !item.folder || !isFinished(item) || !!item.downloadedFiles?.length)
+
+/** What a failed download can do next. `fix`: its link stopped working, a fresh one carries on
+ * from here. `retry`: what it saved is still there to pick up from. `again`: nothing of it can
+ * be kept, so it starts over from its link (a retry with nothing saved has no partial file to
+ * resume). */
+export type FailureAction = 'fix' | 'retry' | 'again'
+
+export function failureAction(download: DownloadState): FailureAction {
+ if (linkExpired(download)) return 'fix'
+ return download.resumable !== false && download.bytesDownloaded > 0 ? 'retry' : 'again'
+}
+
+const appliesTo: Record<ActionId, (item: DownloadItem) => boolean> = {
+ pause: (item) => !isFinished(item) && (item.status === 'downloading' || item.status === 'queued'),
+ resume: (item) => !isFinished(item) && item.status === 'paused',
+ retry: (item) => isFailed(item) && failureAction(item) === 'retry',
+ fix: (item) => isFailed(item) && failureAction(item) === 'fix',
+ again: (item) => isFailed(item) && failureAction(item) === 'again',
+ open: (item) => isDone(item) && !isMissing(item),
+ reveal: (item) => (isDone(item) && !isMissing(item)) || isCancellable(item),
+ copy: (item) => /^(https?:|magnet:)/i.test(item.url),
+ cancel: isCancellable,
+ remove: (item) => isDone(item) || isFailed(item),
+ trash: isTrashable
+}
+
+/** These make sense for one download at a time: with several selected, they aren't offered. */
+const SINGLE_ONLY: ReadonlySet<ActionId> = new Set(['fix', 'again', 'open', 'reveal'])
+
+/** The order they're shown in, in groups: what to do with it, its link, getting rid of it.
+ * Menus put a separator between groups. */
+export const ACTION_GROUPS: readonly (readonly ActionId[])[] = [
+ ['pause', 'resume', 'retry', 'fix', 'again', 'open', 'reveal'],
+ ['copy'],
+ ['cancel', 'remove', 'trash']
+]
+
+export interface AvailableAction {
+ id: ActionId
+ /** The downloads it applies to: with a mixed selection, only the ones it's valid for. */
+ targets: DownloadItem[]
+}
+
+/** What can be done to these downloads, in display order and in groups. An action is offered
+ * when it's valid for at least one of them, and then acts on just those. */
+export function availableActions(items: DownloadItem[]): AvailableAction[][] {
+ return ACTION_GROUPS.map((group) =>
+ group.flatMap((id): AvailableAction[] => {
+ if (SINGLE_ONLY.has(id) && items.length !== 1) return []
+ const targets = items.filter(appliesTo[id])
+ return targets.length > 0 ? [{ id, targets }] : []
+ })
+ ).filter((group) => group.length > 0)
+}
+
+/** Which actions earn a button on the selection toolbar, most needed first; the rest are behind
+ * More. What's needed most is the next step (pause, resume, retry, fix, start over, open), then
+ * getting rid of it: a download in progress is cancelled, a finished one is shown, then removed.
+ * That gives each state two sensible buttons: Pause and Cancel; Resume and Cancel; Retry and
+ * Remove; Open and Show in Finder; and for several finished, Remove and Move to Trash. */
+export const TOOLBAR_PRIORITY: readonly ActionId[] = [
+ 'pause',
+ 'resume',
+ 'retry',
+ 'fix',
+ 'again',
+ 'open',
+ 'cancel',
+ 'reveal',
+ 'remove',
+ 'trash',
+ 'copy'
+]
+
+/** How many go on the toolbar as buttons. */
+export const TOOLBAR_SLOTS = 2
+
+/** The toolbar's two buttons, and what's left for its More menu (the menu's own groups, less
+ * the buttons). */
+export function splitToolbar(groups: AvailableAction[][]): {
+ buttons: AvailableAction[]
+ more: AvailableAction[][]
+} {
+ const buttons = groups
+ .flat()
+ .sort((a, b) => TOOLBAR_PRIORITY.indexOf(a.id) - TOOLBAR_PRIORITY.indexOf(b.id))
+ .slice(0, TOOLBAR_SLOTS)
+ const shown = new Set(buttons.map(({ id }) => id))
+ return {
+ buttons,
+ more: groups
+ .map((group) => group.filter(({ id }) => !shown.has(id)))
+ .filter((group) => group.length > 0)
+ }
+}
+
+/** The single button a row shows when idle: the next step for that download, if it has one. */
+export const ROW_ACTIONS: readonly ActionId[] = ['pause', 'resume', 'retry', 'fix', 'again']
+
+export function rowAction(item: DownloadItem): ActionId | null {
+ return ROW_ACTIONS.find((id) => appliesTo[id](item)) ?? null
+}
+
+/** The ways out of a download from its own screen, in the order the menu has them: Cancel while
+ * it's unfinished; Remove from the list, and moving its file to the Trash, after. */
+export const MANAGE_ACTIONS: readonly ActionId[] = ['cancel', 'remove', 'trash']
+
+export function manageActions(item: DownloadItem): ActionId[] {
+ return MANAGE_ACTIONS.filter((id) => appliesTo[id](item))
+}
+
+/** The one of them every download that can be taken away has. */
+export function manageAction(item: DownloadItem): ActionId | null {
+ return (['cancel', 'remove'] as const).find((id) => appliesTo[id](item)) ?? null
+}
+
+/** What a download's own screen offers beside that: its next steps, in order. */
+export const HEADER_ACTIONS: readonly ActionId[] = [...ROW_ACTIONS, 'open', 'reveal']
+
+export function headerActions(item: DownloadItem): ActionId[] {
+ return HEADER_ACTIONS.filter((id) => appliesTo[id](item))
+}
diff --git a/src/shared/ipc-channels.ts b/src/shared/ipc-channels.ts
index 7d9ba13..5b3129d 100644
--- a/src/shared/ipc-channels.ts
+++ b/src/shared/ipc-channels.ts
@@ -9,6 +9,7 @@ export const IpcChannels = {
chooseTorrentFile: 'dialog:choose-torrent-file',
readClipboardText: 'clipboard:read-text',
revealDownload: 'shell:reveal-download',
+ openDownload: 'shell:open-download',
startDownload: 'download:start',
listDownloads: 'download:list',
listHistory: 'history:list',
diff --git a/src/shared/ipc-contract.ts b/src/shared/ipc-contract.ts
index 06515f2..5bf7db6 100644
--- a/src/shared/ipc-contract.ts
+++ b/src/shared/ipc-contract.ts
@@ -26,6 +26,9 @@ export interface IpcContract {
/** Shows a download's file in its folder, by the download's own path. False when nothing is
* there any more: history is re-sent, with it marked missing. */
revealDownload: { args: [id: string]; result: boolean }
+ /** Opens a download's file (a torrent's folder) with the OS default. False when it's gone or
+ * nothing could open it. */
+ openDownload: { args: [id: string]; result: boolean }
/** `linkId`: the PendingLink whose browser sign-in it starts with. */
startDownload: { args: [request: StartDownloadRequest, linkId?: string]; result: string }
/** Every download, oldest first, each as a snapshot. */
diff --git a/tsconfig.e2e.json b/tsconfig.e2e.json
index f2289b0..3dfbfc0 100644
--- a/tsconfig.e2e.json
+++ b/tsconfig.e2e.json
@@ -8,6 +8,10 @@
],
"compilerOptions": {
"noEmit": true,
- "lib": ["ESNext", "DOM"]
+ "lib": ["ESNext", "DOM"],
+ "baseUrl": ".",
+ "paths": {
+ "@shared/*": ["src/shared/*"]
+ }
}
}