Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(task-dock): promote the upload dock into an app-level task dock (#19146)

Innei8bf9734dfbdd
diff --git a/.github/scripts/size-gate-comment.cjs b/.github/scripts/size-gate-comment.cjs
index 09845a9b476..623eaeeb924 100644
--- a/.github/scripts/size-gate-comment.cjs
+++ b/.github/scripts/size-gate-comment.cjs
@@ -8,6 +8,9 @@
*
* `identifier` keeps one comment per gate: the web (e2e) and desktop (asar)
* workflows run independently on the same PR and must not overwrite each other.
+ *
+ * A failing gate also submits a REQUEST_CHANGES review from github-actions so the
+ * job itself can stay green; a passing run dismisses that review again.
*/
const sizeGateComment = async ({
github,
@@ -39,6 +42,7 @@ ${report}
const existing = comments.find((comment) => comment.body.includes(commentIdentifier));
+ let commentId;
if (existing) {
await github.rest.issues.updateComment({
body,
@@ -46,18 +50,71 @@ ${report}
owner: context.repo.owner,
repo: context.repo.repo,
});
- console.log(`Updated existing comment ID: ${existing.id}`);
- return { id: existing.id, updated: true };
+ commentId = existing.id;
+ } else {
+ const created = await github.rest.issues.createComment({
+ body,
+ issue_number: number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ });
+ commentId = created.data.id;
}
+ console.log(`${existing ? 'Updated' : 'Created'} comment ID: ${commentId}`);
+
+ await syncReview({ commentId, context, failed, github, identifier, number, title });
- const result = await github.rest.issues.createComment({
+ return { id: commentId, updated: Boolean(existing) };
+};
+
+const syncReview = async ({ github, context, number, title, failed, identifier, commentId }) => {
+ const marker = `<!-- SIZE-GATE-REVIEW-${identifier} -->`;
+ const repo = { owner: context.repo.owner, repo: context.repo.repo };
+ const reviews = await github.paginate(github.rest.pulls.listReviews, {
+ ...repo,
+ pull_number: number,
+ });
+ const open = reviews.filter(
+ (review) => review.state === 'CHANGES_REQUESTED' && review.body?.includes(marker),
+ );
+
+ if (!failed) {
+ for (const review of open) {
+ await github.rest.pulls.dismissReview({
+ ...repo,
+ message: `Bundle Size Gate — ${title} passes on the latest build.`,
+ pull_number: number,
+ review_id: review.id,
+ });
+ console.log(`Dismissed size gate review ID: ${review.id}`);
+ }
+ return;
+ }
+
+ const reportUrl = `https://github.com/${repo.owner}/${repo.repo}/pull/${number}#issuecomment-${commentId}`;
+ const body = `${marker}
+### ❌ Bundle Size Gate — ${title}
+
+The size gate failed on the latest build. See the [report](${reportUrl}) for the offending entries; this review is dismissed automatically once the gate passes again.`;
+
+ if (open.length > 0) {
+ await github.rest.pulls.updateReview({
+ ...repo,
+ body,
+ pull_number: number,
+ review_id: open[0].id,
+ });
+ console.log(`Updated size gate review ID: ${open[0].id}`);
+ return;
+ }
+
+ const created = await github.rest.pulls.createReview({
+ ...repo,
body,
- issue_number: number,
- owner: context.repo.owner,
- repo: context.repo.repo,
+ event: 'REQUEST_CHANGES',
+ pull_number: number,
});
- console.log(`Created new comment ID: ${result.data.id}`);
- return { id: result.data.id, updated: false };
+ console.log(`Requested changes via review ID: ${created.data.id}`);
};
module.exports = sizeGateComment;
diff --git a/.github/scripts/size-gate-comment.test.cjs b/.github/scripts/size-gate-comment.test.cjs
new file mode 100644
index 00000000000..5654cbe4dda
--- /dev/null
+++ b/.github/scripts/size-gate-comment.test.cjs
@@ -0,0 +1,85 @@
+const assert = require('node:assert/strict');
+const { test } = require('node:test');
+
+const sizeGateComment = require('./size-gate-comment.cjs');
+
+const MARKER = '<!-- SIZE-GATE-REVIEW-web -->';
+
+const fakeGithub = ({ comments = [], reviews = [] } = {}) => {
+ const calls = [];
+ const record =
+ (name, data = {}) =>
+ async (params) => {
+ calls.push({ name, params });
+ return { data };
+ };
+ return {
+ calls,
+ paginate: async (fn, params) => (await fn(params)).data,
+ rest: {
+ issues: {
+ createComment: record('createComment', { id: 42 }),
+ listComments: record('listComments', comments),
+ updateComment: record('updateComment'),
+ },
+ pulls: {
+ createReview: record('createReview', { id: 7 }),
+ dismissReview: record('dismissReview'),
+ listReviews: record('listReviews', reviews),
+ updateReview: record('updateReview'),
+ },
+ },
+ };
+};
+
+const run = (github, failed) =>
+ sizeGateComment({
+ context: { repo: { owner: 'o', repo: 'r' } },
+ failed,
+ github,
+ identifier: 'web',
+ issueNumber: 1,
+ report: 'report',
+ title: 'Web dist',
+ });
+
+test('a failing gate requests changes once and links the report comment', async () => {
+ const github = fakeGithub();
+ await run(github, true);
+ const review = github.calls.find((c) => c.name === 'createReview');
+ assert.equal(review.params.event, 'REQUEST_CHANGES');
+ assert.ok(review.params.body.includes(MARKER));
+ assert.ok(review.params.body.includes('#issuecomment-42'));
+});
+
+test('a still-failing gate updates the open review instead of stacking another', async () => {
+ const github = fakeGithub({
+ reviews: [{ body: `${MARKER} old`, id: 9, state: 'CHANGES_REQUESTED' }],
+ });
+ await run(github, true);
+ assert.equal(
+ github.calls.some((c) => c.name === 'createReview'),
+ false,
+ );
+ assert.equal(github.calls.find((c) => c.name === 'updateReview').params.review_id, 9);
+});
+
+test('a passing gate dismisses only its own open review', async () => {
+ const github = fakeGithub({
+ reviews: [
+ { body: `${MARKER} old`, id: 9, state: 'CHANGES_REQUESTED' },
+ { body: 'human review', id: 10, state: 'CHANGES_REQUESTED' },
+ { body: `${MARKER} done`, id: 11, state: 'DISMISSED' },
+ ],
+ });
+ await run(github, false);
+ const dismissed = github.calls.filter((c) => c.name === 'dismissReview');
+ assert.deepEqual(
+ dismissed.map((c) => c.params.review_id),
+ [9],
+ );
+ assert.equal(
+ github.calls.some((c) => c.name === 'createReview'),
+ false,
+ );
+});
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index b21dba81d11..ab5337c6efa 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -135,6 +135,7 @@ jobs:
- name: Check web dist size against baseline
if: env.SIZE_GATE_ENABLED == 'true'
id: dist_size_check
+ continue-on-error: true
run: node .github/scripts/bundle-size-gate.cjs check --current size-report/web.json --baseline .size-baseline/web.json --label "Web dist" --report size-report/report.md
# ===== Entry static-import graph gate =====
@@ -178,6 +179,7 @@ jobs:
- name: Check entry static-import graph against baseline
if: env.SIZE_GATE_ENABLED == 'true'
id: entry_graph_check
+ continue-on-error: true
run: node .github/scripts/bundle-size-gate.cjs check --current size-report/entry-graph.json --baseline .size-baseline/entry-graph.json --label "First-screen static import graph (gzip)" --report size-report/report.md --floor 65536
- name: Comment bundle size report on PR
diff --git a/.github/workflows/pr-build-desktop.yml b/.github/workflows/pr-build-desktop.yml
index f05f6050717..43f14502aa2 100644
--- a/.github/workflows/pr-build-desktop.yml
+++ b/.github/workflows/pr-build-desktop.yml
@@ -280,6 +280,7 @@ jobs:
- name: Check ASAR sizes against baseline
id: asar_size_check
+ continue-on-error: true
shell: bash
run: |
status=0
diff --git a/locales/en-US/common.json b/locales/en-US/common.json
index 2a6d4b011ac..0ce1ca4a589 100644
--- a/locales/en-US/common.json
+++ b/locales/en-US/common.json
@@ -504,6 +504,18 @@
"tab.setting": "Settings",
"tab.tasks": "Tasks",
"tab.video": "Video",
+ "taskDock.activeOf": "{{active}} running · {{total}} total",
+ "taskDock.cancelAll": "Cancel all",
+ "taskDock.collapse": "Collapse",
+ "taskDock.expand": "Expand",
+ "taskDock.group.publish": "Publishing",
+ "taskDock.group.upload": "Uploads",
+ "taskDock.open": "Open",
+ "taskDock.status.cancelled": "Cancelled",
+ "taskDock.status.error": "Some tasks need attention",
+ "taskDock.status.running": "In progress",
+ "taskDock.status.success": "All done",
+ "taskDock.totalCount": "{{count}} items",
"taskTemplate.action.connect.button": "Connect {{provider}}",
"taskTemplate.action.connect.error": "Connection failed, please try again.",
"taskTemplate.action.connect.popupBlocked": "Connection popup blocked. Allow popups in your browser to continue.",
diff --git a/locales/zh-CN/common.json b/locales/zh-CN/common.json
index 8cfb5e54bc6..f800dabbd80 100644
--- a/locales/zh-CN/common.json
+++ b/locales/zh-CN/common.json
@@ -504,6 +504,18 @@
"tab.setting": "设置",
"tab.tasks": "任务",
"tab.video": "视频",
+ "taskDock.activeOf": "{{active}} 个进行中 · 共 {{total}}",
+ "taskDock.cancelAll": "全部取消",
+ "taskDock.collapse": "收起",
+ "taskDock.expand": "展开",
+ "taskDock.group.publish": "发布",
+ "taskDock.group.upload": "上传",
+ "taskDock.open": "打开",
+ "taskDock.status.cancelled": "已取消",
+ "taskDock.status.error": "有任务未完成",
+ "taskDock.status.running": "进行中",
+ "taskDock.status.success": "已完成",
+ "taskDock.totalCount": "{{count}} 项",
"taskTemplate.action.connect.button": "连接 {{provider}}",
"taskTemplate.action.connect.error": "连接失败,请重试。",
"taskTemplate.action.connect.popupBlocked": "连接弹出窗口被阻止。请在浏览器中允许弹出窗口以继续。",
diff --git a/packages/locales/src/default/common.ts b/packages/locales/src/default/common.ts
index ab60fb6bcc5..d45c85b925f 100644
--- a/packages/locales/src/default/common.ts
+++ b/packages/locales/src/default/common.ts
@@ -620,6 +620,18 @@ export default {
'tab.setting': 'Settings',
'tab.tasks': 'Tasks',
'tab.video': 'Video',
+ 'taskDock.activeOf': '{{active}} running · {{total}} total',
+ 'taskDock.cancelAll': 'Cancel all',
+ 'taskDock.collapse': 'Collapse',
+ 'taskDock.expand': 'Expand',
+ 'taskDock.group.publish': 'Publishing',
+ 'taskDock.group.upload': 'Uploads',
+ 'taskDock.open': 'Open',
+ 'taskDock.status.cancelled': 'Cancelled',
+ 'taskDock.status.error': 'Some tasks need attention',
+ 'taskDock.status.running': 'In progress',
+ 'taskDock.status.success': 'All done',
+ 'taskDock.totalCount': '{{count}} items',
'telemetry.allow': 'Allow',
'telemetry.deny': 'Deny',
'telemetry.desc':
diff --git a/src/business/client/features/DockTasks.ts b/src/business/client/features/DockTasks.ts
new file mode 100644
index 00000000000..7a0cba8199d
--- /dev/null
+++ b/src/business/client/features/DockTasks.ts
@@ -0,0 +1,5 @@
+import type { DockTask } from '@/features/TaskDock/type';
+
+export function useBusinessDockTasks(): DockTask[] {
+ return [];
+}
diff --git a/src/features/ResourceManager/components/UploadDock/Item.tsx b/src/features/ResourceManager/components/UploadDock/Item.tsx
deleted file mode 100644
index e037fe36017..00000000000
--- a/src/features/ResourceManager/components/UploadDock/Item.tsx
+++ /dev/null
@@ -1,173 +0,0 @@
-import { Flexbox } from '@lobehub/ui';
-import { ActionIcon, Text } from '@lobehub/ui/base-ui';
-import { createStaticStyles } from 'antd-style';
-import { RotateCwIcon, XIcon } from 'lucide-react';
-import { type ReactNode } from 'react';
-import { memo, useMemo } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { FileUploadErrorActions } from '@/business/client/features/FileUploadErrorActions';
-import FileIcon from '@/components/FileIcon';
-import { useFileStore } from '@/store/file';
-import { type UploadFileItem } from '@/types/files/upload';
-import { formatSize, formatSpeed, formatTime } from '@/utils/format';
-
-const styles = createStaticStyles(({ css, cssVar }) => {
- return {
- cancelButton: css`
- opacity: 0;
- transition: opacity 0.2s ease;
- `,
- container: css`
- &:hover .cancel-button {
- opacity: 1;
- }
- `,
- progress: css`
- position: absolute;
- inset-block: 0;
- inset-inline: 0 1%;
-
- height: 100%;
- border-block-end: 3px solid ${cssVar.geekblue};
-
- background: ${cssVar.colorFillTertiary};
- `,
- title: css`
- overflow: hidden;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 1;
-
- font-size: 15px;
- text-overflow: ellipsis;
- `,
- };
-});
-
-type UploadItemProps = UploadFileItem;
-
-const UploadItem = memo<UploadItemProps>(({ error, errorCode, id, file, status, uploadState }) => {
- const { t } = useTranslation('file');
- const { type, name, size } = file;
- const cancelUpload = useFileStore((s) => s.cancelUpload);
- const retryDockUpload = useFileStore((s) => s.retryDockUpload);
-
- const desc: ReactNode = useMemo(() => {
- switch (status) {
- case 'uploading': {
- const textArray = [
- uploadState?.speed ? formatSpeed(uploadState.speed) : '',
- uploadState?.restTime
- ? t('uploadDock.body.item.restTime', {
- time: formatTime(uploadState?.restTime),
- })
- : '',
- ].filter(Boolean);
-
- return (
- <Text style={{ fontSize: 12 }} type={'secondary'}>
- {uploadState?.progress ? formatSize(size * (uploadState.progress / 100)) : '-'}/
- {formatSize(size)}
- {textArray.length === 0 ? '' : ' · ' + textArray.join(' · ')}
- </Text>
- );
- }
- case 'pending': {
- return (
- <Text style={{ fontSize: 12 }} type={'secondary'}>
- {formatSize(size)} · {t('uploadDock.body.item.pending')}
- {uploadState?.progress ? ` ${uploadState.progress}%` : ''}
- </Text>
- );
- }
-
- case 'processing': {
- return (
- <Text style={{ fontSize: 12 }} type={'secondary'}>
- {formatSize(size)} · {t('uploadDock.body.item.processing')}
- </Text>
- );
- }
-
- case 'success': {
- return (
- <Text style={{ fontSize: 12 }} type={'secondary'}>
- {formatSize(size)} · {t('uploadDock.body.item.done')}
- </Text>
- );
- }
- case 'error': {
- return (
- <Flexbox gap={6}>
- <Text style={{ fontSize: 12 }} type={'danger'}>
- {error || `${formatSize(size)} · ${t('uploadDock.body.item.error')}`}
- </Text>
- {errorCode ? <FileUploadErrorActions code={errorCode} /> : null}
- </Flexbox>
- );
- }
- case 'cancelled': {
- return (
- <Text style={{ fontSize: 12 }} type={'warning'}>
- {formatSize(size)} · {t('uploadDock.body.item.cancelled')}
- </Text>
- );
- }
- default: {
- return '';
- }
- }
- }, [error, errorCode, status, uploadState, size, t]);
-
- return (
- <Flexbox
- horizontal
- align={'center'}
- className={styles.container}
- gap={12}
- key={name}
- paddingBlock={8}
- paddingInline={12}
- style={{ position: 'relative' }}
- >
- <FileIcon fileName={name} fileType={type} size={36} />
- <Flexbox flex={1} style={{ overflow: 'hidden' }}>
- <div className={styles.title}>{name}</div>
- {desc}
- </Flexbox>
-
- {(status === 'uploading' || status === 'pending') && (
- <ActionIcon
- className={`${styles.cancelButton} cancel-button`}
- icon={XIcon}
- size="small"
- title={t('uploadDock.body.item.cancel')}
- onClick={() => {
- cancelUpload(id);
- }}
- />
- )}
-
- {status === 'error' && !errorCode ? (
- <ActionIcon
- icon={RotateCwIcon}
- size="small"
- title={t('uploadDock.body.item.retry')}
- onClick={() => {
- void retryDockUpload(id);
- }}
- />
- ) : null}
-
- {status === 'uploading' && !!uploadState && (
- <div
- className={styles.progress}
- style={{ insetInlineEnd: `${100 - uploadState.progress}%` }}
- />
- )}
- </Flexbox>
- );
-});
-
-export default UploadItem;
diff --git a/src/features/ResourceManager/components/UploadDock/index.tsx b/src/features/ResourceManager/components/UploadDock/index.tsx
deleted file mode 100644
index 6781c5db314..00000000000
--- a/src/features/ResourceManager/components/UploadDock/index.tsx
+++ /dev/null
@@ -1,258 +0,0 @@
-import { CheckCircleFilled, CloseCircleFilled } from '@ant-design/icons';
-import { Center, Flexbox, Icon } from '@lobehub/ui';
-import { ActionIcon, Text } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cssVar } from 'antd-style';
-import isEqual from 'fast-deep-equal';
-import { UploadIcon, XIcon } from 'lucide-react';
-import { AnimatePresence, m } from 'motion/react';
-import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
-import { useTranslation } from 'react-i18next';
-
-import { fileManagerSelectors, useFileStore } from '@/store/file';
-
-import Item from './Item';
-
-const styles = createStaticStyles(({ css }) => {
- return {
- container: css`
- position: fixed;
- z-index: 100;
- inset-block-end: 24px;
- inset-inline-end: 24px;
-
- overflow: hidden;
-
- width: 360px;
- border: 1px solid ${cssVar.colorSplit};
- border-radius: 8px;
-
- box-shadow: ${cssVar.boxShadow};
- `,
- progress: css`
- pointer-events: none;
-
- position: absolute;
- inset-block: 0;
- inset-inline: 0 1%;
-
- height: 100%;
- border-block-end: 3px solid ${cssVar.geekblue};
-
- background: ${cssVar.colorFillTertiary};
- `,
- title: css`
- height: 36px;
- font-size: 16px;
- color: ${cssVar.colorText};
- `,
- };
-});
-
-/**
- * Show & manage current uploading tasks
- */
-const UploadDock = memo(() => {
- const { t } = useTranslation('file');
- const [show, setShow] = useState(true);
-
- const dispatchDockFileList = useFileStore((s) => s.dispatchDockFileList);
- const expand = useFileStore((s) => s.uploadDockExpanded);
- const setExpand = useFileStore((s) => s.setUploadDockExpanded);
- const totalUploadingProgress = useFileStore(fileManagerSelectors.overviewUploadingProgress);
- const fileList = useFileStore(fileManagerSelectors.dockFileList, isEqual);
- const cancelUploads = useFileStore((s) => s.cancelUploads);
- const overviewUploadingStatus = useFileStore(
- fileManagerSelectors.overviewUploadingStatus,
- isEqual,
- );
- const isUploading = overviewUploadingStatus === 'uploading';
-
- const hasCancellableUploads = useMemo(
- () => fileList.some((item) => item.status === 'uploading' || item.status === 'pending'),
- [fileList],
- );
-
- const cancelAllActiveUploads = useCallback(() => {
- cancelUploads(
- fileList
- .filter((item) => item.status === 'uploading' || item.status === 'pending')
- .map((item) => item.id),
- );
- }, [cancelUploads, fileList]);
-
- const icon = useMemo(() => {
- switch (overviewUploadingStatus) {
- case 'success': {
- return <CheckCircleFilled style={{ color: cssVar.colorSuccess }} />;
- }
- case 'error': {
- return <CloseCircleFilled style={{ color: cssVar.colorError }} />;
- }
-
- default: {
- return <Icon icon={UploadIcon} />;
- }
- }
- }, [overviewUploadingStatus]);
-
- const count = fileList.length;
-
- useEffect(() => {
- if (show) return;
- if (isUploading) setShow(true);
- }, [isUploading, show]);
-
- const autoDismissTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
-
- useEffect(() => {
- if (overviewUploadingStatus !== 'success') {
- if (autoDismissTimerRef.current) {
- clearTimeout(autoDismissTimerRef.current);
- }
- return;
- }
-
- autoDismissTimerRef.current = setTimeout(() => {
- setShow(false);
- dispatchDockFileList({ ids: fileList.map((item) => item.id), type: 'removeFiles' });
- }, 3000);
-
- return () => {
- if (autoDismissTimerRef.current) {
- clearTimeout(autoDismissTimerRef.current);
- }
- };
- }, [overviewUploadingStatus, fileList, dispatchDockFileList]);
-
- if (count === 0 || !show) return;
-
- return (
- <Flexbox className={styles.container}>
- <Flexbox
- horizontal
- align={'center'}
- justify={'space-between'}
- style={{
- background: cssVar.colorBgContainer,
- borderBottom: expand ? `1px solid ${cssVar.colorSplit}` : undefined,
- borderBottomLeftRadius: expand ? 0 : 8,
- borderBottomRightRadius: expand ? 0 : 8,
- borderTopLeftRadius: 8,
- borderTopRightRadius: 8,
- cursor: 'pointer',
- paddingBlock: 8,
- paddingInline: '24px 12px',
- transition: 'all 0.3s ease-in-out',
- }}
- onClick={() => {
- setExpand(!expand);
- }}
- >
- <Flexbox horizontal align={'center'} className={styles.title} gap={16}>
- {icon}
- {t(`uploadDock.uploadStatus.${overviewUploadingStatus}`)} ·{' '}
- {t('uploadDock.totalCount', { count })}
- </Flexbox>
- <Flexbox
- horizontal
- align={'center'}
- gap={12}
- onClick={(e) => {
- e.stopPropagation();
- }}
- >
- {hasCancellableUploads && (
- <Text
- style={{ cursor: 'pointer', flexShrink: 0, fontSize: 13 }}
- type={'secondary'}
- onClick={cancelAllActiveUploads}
- >
- {t('uploadDock.header.cancelAll')}
- </Text>
- )}
- {!isUploading && (
- <ActionIcon
- icon={XIcon}
- onClick={() => {
- setShow(false);
- dispatchDockFileList({ ids: fileList.map((item) => item.id), type: 'removeFiles' });
- }}
- />
- )}
- </Flexbox>
- </Flexbox>
-
- <AnimatePresence mode="wait">
- {expand ? (
- <m.div
- animate={{ height: 400, opacity: 1 }}
- exit={{ height: 0, opacity: 0 }}
- initial={{ height: 0, opacity: 0 }}
- key="expanded"
- style={{ overflow: 'hidden' }}
- transition={{ duration: 0.3, ease: 'easeInOut' }}
- >
- <Flexbox
- style={{
- background: cssVar.colorBgContainer,
- borderBottomLeftRadius: 8,
- borderBottomRightRadius: 8,
- height: 400,
- }}
- >
- <Flexbox
- flex={1}
- gap={8}
- paddingBlock={8}
- style={{ minHeight: 0, overflowY: 'scroll' }}
- >
- {fileList.map((item) => (
- <Item key={item.id} {...item} />
- ))}
- </Flexbox>
- {isUploading && (
- <Center style={{ flexShrink: 0, height: 40, minHeight: 40 }}>
- <Text
- style={{ cursor: 'pointer' }}
- type={'secondary'}
- onClick={() => {
- setExpand(false);
- }}
- >
- {t('uploadDock.body.collapse')}
- </Text>
- </Center>
- )}
- </Flexbox>
- </m.div>
- ) : (
- overviewUploadingStatus !== 'pending' && (
- <m.div
- animate={{ opacity: 1, scaleY: 1 }}
- exit={{ opacity: 0, scaleY: 0 }}
- initial={{ opacity: 0, scaleY: 0 }}
- key="collapsed"
- style={{ originY: 0 }}
- transition={{ duration: 0.2, ease: 'easeOut' }}
- >
- <div
- className={styles.progress}
- style={{
- borderColor:
- overviewUploadingStatus === 'success'
- ? cssVar.colorSuccess
- : overviewUploadingStatus === 'error'
- ? cssVar.colorError
- : undefined,
- insetInlineEnd: `${100 - totalUploadingProgress}%`,
- }}
- />
- </m.div>
- )
- )}
- </AnimatePresence>
- </Flexbox>
- );
-});
-
-export default UploadDock;
diff --git a/src/features/ResourceManager/index.tsx b/src/features/ResourceManager/index.tsx
index adaeb2ccb69..61d5b9138a2 100644
--- a/src/features/ResourceManager/index.tsx
+++ b/src/features/ResourceManager/index.tsx
@@ -16,7 +16,6 @@ import { documentSelectors } from '@/store/file/slices/document/selectors';
import FileEditor from './components/Editor';
import Explorer from './components/Explorer';
-import UploadDock from './components/UploadDock';
import { useTopLevelFileUpload } from './hooks/useTopLevelFileUpload';
const ChunkDrawer = dynamic(() => import('./components/ChunkDrawer'), { ssr: false });
@@ -178,7 +177,6 @@ const ResourceManager = memo<ResourceManagerProps>(({ content }) => {
)}
</Flexbox>
</DragUploadZone>
- <UploadDock />
<ChunkDrawer />
</>
);
diff --git a/src/features/TaskDock/Item.tsx b/src/features/TaskDock/Item.tsx
new file mode 100644
index 00000000000..e99fe325a06
--- /dev/null
+++ b/src/features/TaskDock/Item.tsx
@@ -0,0 +1,148 @@
+import { Flexbox } from '@lobehub/ui';
+import { ActionIcon, Button, Text } from '@lobehub/ui/base-ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import { CopyIcon, ExternalLinkIcon, RotateCwIcon, XIcon } from 'lucide-react';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import type { DockTask } from './type';
+
+const styles = createStaticStyles(({ css }) => ({
+ action: css`
+ opacity: 0;
+ transition: opacity 0.2s ease;
+ `,
+ container: css`
+ &:hover .dock-task-action {
+ opacity: 1;
+ }
+ `,
+ progress: css`
+ pointer-events: none;
+
+ position: absolute;
+ inset-block-end: 0;
+ inset-inline-start: 0;
+
+ height: 2px;
+
+ background: ${cssVar.geekblue};
+
+ transition: inset-inline-end 0.2s linear;
+ `,
+ result: css`
+ border-block-start: 1px solid ${cssVar.colorFillQuaternary};
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ resultLabel: css`
+ min-width: 0;
+ font-family: ${cssVar.fontFamilyCode};
+ font-size: ${cssVar.fontSizeSM}px;
+ `,
+ title: css`
+ overflow: hidden;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 1;
+
+ font-size: 14px;
+ line-height: 1.4;
+ text-overflow: ellipsis;
+ `,
+}));
+
+interface ItemProps extends DockTask {
+ /** A solo card has no group gutter, so its result strip is flush left. */
+ solo?: boolean;
+}
+
+const Item = memo<ItemProps>(
+ ({ cancel, detail, dismiss, extra, icon, progress, result, retry, solo, status, title }) => {
+ const { t } = useTranslation('common');
+ // A finished task is the user's to clear. The panel puts that on its
+ // header; a solo card has no header, so the row carries it.
+ const closable = dismiss && status !== 'running' && status !== 'pending';
+
+ return (
+ <Flexbox>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.container}
+ gap={12}
+ paddingBlock={8}
+ paddingInline={12}
+ style={{ position: 'relative' }}
+ >
+ {icon}
+ <Flexbox flex={1} gap={2} style={{ overflow: 'hidden' }}>
+ <div className={styles.title}>{title}</div>
+ {detail}
+ {extra}
+ </Flexbox>
+
+ {cancel && (
+ <ActionIcon
+ className={`${styles.action} dock-task-action`}
+ icon={XIcon}
+ size="small"
+ title={t('cancel')}
+ onClick={cancel}
+ />
+ )}
+
+ {retry && (
+ <ActionIcon icon={RotateCwIcon} size="small" title={t('retry')} onClick={retry} />
+ )}
+
+ {closable && (
+ <ActionIcon icon={XIcon} size="small" title={t('close')} onClick={dismiss} />
+ )}
+
+ {status === 'running' && progress !== undefined && (
+ <div className={styles.progress} style={{ insetInlineEnd: `${100 - progress}%` }} />
+ )}
+ </Flexbox>
+
+ {result && (
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.result}
+ gap={8}
+ paddingBlock={6}
+ style={{ paddingInlineEnd: 8, paddingInlineStart: solo ? 12 : 48 }}
+ >
+ <Text
+ ellipsis
+ className={styles.resultLabel}
+ type={result.onOpen ? undefined : 'secondary'}
+ >
+ {result.label}
+ </Text>
+ {result.onCopy && (
+ <ActionIcon icon={CopyIcon} size="small" title={t('copy')} onClick={result.onCopy} />
+ )}
+ {result.onOpen && (
+ <ActionIcon
+ icon={ExternalLinkIcon}
+ size="small"
+ title={t('taskDock.open')}
+ onClick={result.onOpen}
+ />
+ )}
+ {result.action && (
+ <Button size={'small'} onClick={result.onAction}>
+ {result.action}
+ </Button>
+ )}
+ </Flexbox>
+ )}
+ </Flexbox>
+ );
+ },
+);
+
+Item.displayName = 'TaskDockItem';
+
+export default Item;
diff --git a/src/features/TaskDock/index.tsx b/src/features/TaskDock/index.tsx
new file mode 100644
index 00000000000..f5fc9861c50
--- /dev/null
+++ b/src/features/TaskDock/index.tsx
@@ -0,0 +1,279 @@
+import { Flexbox, Icon } from '@lobehub/ui';
+import { ActionIcon, Text } from '@lobehub/ui/base-ui';
+import { createStaticStyles, cssVar } from 'antd-style';
+import {
+ CheckIcon,
+ ChevronDownIcon,
+ CircleSlashIcon,
+ LoaderCircleIcon,
+ TriangleAlertIcon,
+ XIcon,
+} from 'lucide-react';
+import { AnimatePresence, m } from 'motion/react';
+import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import Item from './Item';
+import {
+ groupDockTasks,
+ hasCancellableTask,
+ isActiveTask,
+ resolveDockOverview,
+ shouldAutoDismiss,
+} from './presentation';
+import type { DockTask } from './type';
+import { useDockTasks } from './useDockTasks';
+
+/** How long a resultless success stays readable before it clears itself. */
+const AUTO_DISMISS_DELAY = 3000;
+/** Lets a burst of dismissals finish before the dock changes shape. */
+const SHAPE_SETTLE_DELAY = 400;
+
+const styles = createStaticStyles(({ css }) => ({
+ container: css`
+ position: fixed;
+ z-index: 100;
+ inset-block-end: 24px;
+ inset-inline-end: 24px;
+
+ overflow: hidden;
+
+ width: 340px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: 12px;
+
+ background: ${cssVar.colorBgContainer};
+ box-shadow: ${cssVar.boxShadowSecondary};
+ `,
+ groupHead: css`
+ border-block-end: 1px solid ${cssVar.colorFillQuaternary};
+
+ font-family: ${cssVar.fontFamilyCode};
+ font-size: 11px;
+ color: ${cssVar.colorTextDescription};
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ head: css`
+ cursor: pointer;
+ padding-block: 9px;
+ padding-inline: 12px;
+ `,
+ headDivider: css`
+ border-block-end: 1px solid ${cssVar.colorBorderSecondary};
+ `,
+ list: css`
+ overflow-y: auto;
+ max-height: 340px;
+ `,
+ row: css`
+ &:not(:first-child) {
+ border-block-start: 1px solid ${cssVar.colorFillQuaternary};
+ }
+ `,
+}));
+
+const useSettledShape = (count: number): 'solo' | 'panel' => {
+ const [shape, setShape] = useState<'solo' | 'panel'>(count > 1 ? 'panel' : 'solo');
+
+ useEffect(() => {
+ const next = count > 1 ? 'panel' : 'solo';
+ if (next === shape) return;
+ // Growing is unambiguous; shrinking waits, so a burst of dismissals does
+ // not morph the dock once per task on its way down to one.
+ if (next === 'panel') {
+ setShape('panel');
+ return;
+ }
+
+ const timer = setTimeout(() => setShape('solo'), SHAPE_SETTLE_DELAY);
+
+ return () => clearTimeout(timer);
+ }, [count, shape]);
+
+ return shape;
+};
+
+const useAutoDismiss = (tasks: DockTask[]) => {
+ const tasksRef = useRef(tasks);
+ tasksRef.current = tasks;
+
+ const dismissable = tasks.filter((task) => shouldAutoDismiss(task) && !!task.dismiss);
+ const ids = dismissable.map((task) => task.id).join('|');
+
+ useEffect(() => {
+ if (!ids) return;
+
+ const timers = ids.split('|').map((id) =>
+ setTimeout(() => {
+ const task = tasksRef.current.find((candidate) => candidate.id === id);
+ if (task && shouldAutoDismiss(task)) task.dismiss?.();
+ }, AUTO_DISMISS_DELAY),
+ );
+
+ return () => timers.forEach((timer) => clearTimeout(timer));
+ }, [ids]);
+};
+
+/**
+ * App-level dock for background work. Producers contribute tasks through
+ * `useDockTasks`; the dock owns the shape, the aggregate header and dismissal.
+ */
+const TaskDock = memo(() => {
+ const { t } = useTranslation('common');
+ const [expand, setExpand] = useState(true);
+
+ const tasks = useDockTasks();
+ const shape = useSettledShape(tasks.length);
+ useAutoDismiss(tasks);
+
+ const { activeCount, status } = useMemo(() => resolveDockOverview(tasks), [tasks]);
+ const groups = useMemo(() => groupDockTasks(tasks), [tasks]);
+ const isRunning = status === 'running';
+ const canCancel = useMemo(() => hasCancellableTask(tasks), [tasks]);
+
+ const dismissAll = useCallback(() => {
+ tasks.forEach((task) => task.dismiss?.());
+ }, [tasks]);
+
+ const cancelAll = useCallback(() => {
+ const batched = new Set<string>();
+
+ for (const task of tasks) {
+ if (!task.groupCancel) {
+ task.cancel?.();
+ continue;
+ }
+ if (batched.has(task.groupLabel)) continue;
+ batched.add(task.groupLabel);
+ task.groupCancel();
+ }
+ }, [tasks]);
+
+ const icon = useMemo(() => {
+ switch (status) {
+ case 'success': {
+ return <Icon color={cssVar.colorSuccess} icon={CheckIcon} size={16} />;
+ }
+ case 'error': {
+ return <Icon color={cssVar.colorError} icon={TriangleAlertIcon} size={16} />;
+ }
+ case 'cancelled': {
+ return <Icon color={cssVar.colorTextDescription} icon={CircleSlashIcon} size={16} />;
+ }
+ default: {
+ return <Icon spin icon={LoaderCircleIcon} size={16} />;
+ }
+ }
+ }, [status]);
+
+ if (tasks.length === 0) return null;
+
+ // One task speaks for itself: no header, no group gutter, just the row and
+ // whatever it left behind.
+ if (shape === 'solo') {
+ return (
+ <Flexbox className={styles.container}>
+ <Item {...tasks[0]} solo />
+ </Flexbox>
+ );
+ }
+
+ return (
+ <Flexbox className={styles.container}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={`${styles.head} ${expand ? styles.headDivider : ''}`}
+ gap={10}
+ onClick={() => setExpand(!expand)}
+ >
+ {icon}
+ <Flexbox horizontal align={'baseline'} flex={1} gap={7} style={{ minWidth: 0 }}>
+ <Text style={{ fontSize: 14 }}>{t(`taskDock.status.${status}`)}</Text>
+ <Text ellipsis style={{ fontSize: 12 }} type={'secondary'}>
+ {activeCount > 0
+ ? t('taskDock.activeOf', { active: activeCount, total: tasks.length })
+ : t('taskDock.totalCount', { count: tasks.length })}
+ </Text>
+ </Flexbox>
+ <Flexbox
+ horizontal
+ align={'center'}
+ gap={4}
+ onClick={(e) => {
+ e.stopPropagation();
+ }}
+ >
+ {canCancel && (
+ <Text
+ style={{ cursor: 'pointer', flexShrink: 0, fontSize: 12 }}
+ type={'secondary'}
+ onClick={cancelAll}
+ >
+ {t('taskDock.cancelAll')}
+ </Text>
+ )}
+ {isRunning ? (
+ <ActionIcon
+ icon={ChevronDownIcon}
+ size={'small'}
+ style={{ transform: expand ? undefined : 'rotate(180deg)' }}
+ title={t(expand ? 'taskDock.collapse' : 'taskDock.expand')}
+ onClick={() => setExpand(!expand)}
+ />
+ ) : (
+ <ActionIcon icon={XIcon} size={'small'} onClick={dismissAll} />
+ )}
+ </Flexbox>
+ </Flexbox>
+
+ <AnimatePresence initial={false}>
+ {expand && (
+ <m.div
+ animate={{ height: 'auto', opacity: 1 }}
+ exit={{ height: 0, opacity: 0 }}
+ initial={{ height: 0, opacity: 0 }}
+ style={{ overflow: 'hidden' }}
+ transition={{ duration: 0.22, ease: 'easeInOut' }}
+ >
+ <Flexbox className={styles.list}>
+ {groups.map((group) => (
+ <Flexbox key={group.label}>
+ <Flexbox
+ horizontal
+ align={'center'}
+ className={styles.groupHead}
+ justify={'space-between'}
+ paddingBlock={5}
+ // The count aligns with the rows' action glyphs, which sit
+ // 5px inside their own hit area — not with the row padding.
+ style={{ paddingInlineEnd: 19, paddingInlineStart: 12 }}
+ >
+ <span>{group.label}</span>
+ <span>
+ {group.tasks.some(isActiveTask)
+ ? `${group.tasks.filter(isActiveTask).length} / ${group.tasks.length}`
+ : group.tasks.length}
+ </span>
+ </Flexbox>
+ {group.tasks.map((task) => (
+ <Flexbox className={styles.row} key={task.id}>
+ <Item {...task} />
+ </Flexbox>
+ ))}
+ </Flexbox>
+ ))}
+ </Flexbox>
+ </m.div>
+ )}
+ </AnimatePresence>
+ </Flexbox>
+ );
+});
+
+TaskDock.displayName = 'TaskDock';
+
+export default TaskDock;
diff --git a/src/features/TaskDock/presentation.test.ts b/src/features/TaskDock/presentation.test.ts
new file mode 100644
index 00000000000..7166beb9f2d
--- /dev/null
+++ b/src/features/TaskDock/presentation.test.ts
@@ -0,0 +1,94 @@
+import { describe, expect, it, vi } from 'vitest';
+
+import {
+ groupDockTasks,
+ hasCancellableTask,
+ resolveDockOverview,
+ shouldAutoDismiss,
+} from './presentation';
+import type { DockTask, DockTaskStatus } from './type';
+
+const task = (status: DockTaskStatus, extra: Partial<DockTask> = {}): DockTask => ({
+ groupLabel: 'Uploads',
+ id: `${status}-${Math.random()}`,
+ status,
+ title: 'index.html',
+ ...extra,
+});
+
+describe('resolveDockOverview', () => {
+ it('stays running while any task is pending or running', () => {
+ const overview = resolveDockOverview([task('success'), task('error'), task('pending')]);
+
+ expect(overview.status).toBe('running');
+ expect(overview.activeCount).toBe(1);
+ });
+
+ it('averages progress across active tasks only', () => {
+ const overview = resolveDockOverview([
+ task('running', { progress: 20 }),
+ task('running', { progress: 80 }),
+ task('success', { progress: 100 }),
+ ]);
+
+ expect(overview.progress).toBe(50);
+ });
+
+ it('treats a running task without progress as zero', () => {
+ expect(resolveDockOverview([task('running')]).progress).toBe(0);
+ });
+
+ it('reports error over success once nothing is active', () => {
+ expect(resolveDockOverview([task('success'), task('error')]).status).toBe('error');
+ });
+
+ it('settles at 100 with no active task', () => {
+ const overview = resolveDockOverview([task('success')]);
+
+ expect(overview).toEqual({ activeCount: 0, progress: 100, status: 'success' });
+ });
+
+ it('falls back to cancelled when nothing succeeded or failed', () => {
+ expect(resolveDockOverview([task('cancelled')]).status).toBe('cancelled');
+ });
+});
+
+describe('hasCancellableTask', () => {
+ it('only counts active tasks that expose a cancel', () => {
+ expect(hasCancellableTask([task('running')])).toBe(false);
+ expect(hasCancellableTask([task('success', { cancel: vi.fn() })])).toBe(false);
+ expect(hasCancellableTask([task('running', { cancel: vi.fn() })])).toBe(true);
+ });
+});
+
+describe('groupDockTasks', () => {
+ it('keeps both group order and task order', () => {
+ const groups = groupDockTasks([
+ task('running', { groupLabel: 'Publishing', title: 'index.html' }),
+ task('running', { groupLabel: 'Uploads', title: 'hero.png' }),
+ task('pending', { groupLabel: 'Publishing', title: 'about.html' }),
+ ]);
+
+ expect(groups.map((group) => group.label)).toEqual(['Publishing', 'Uploads']);
+ expect(groups[0].tasks.map((t) => t.title)).toEqual(['index.html', 'about.html']);
+ });
+
+ it('returns nothing for an empty list', () => {
+ expect(groupDockTasks([])).toEqual([]);
+ });
+});
+
+describe('shouldAutoDismiss', () => {
+ it('clears a success with nothing to hand back', () => {
+ expect(shouldAutoDismiss(task('success'))).toBe(true);
+ });
+
+ it('keeps a success that left a result', () => {
+ expect(shouldAutoDismiss(task('success', { result: { label: 'lobe.link/x' } }))).toBe(false);
+ });
+
+ it('never clears a failure or an active task', () => {
+ expect(shouldAutoDismiss(task('error'))).toBe(false);
+ expect(shouldAutoDismiss(task('running'))).toBe(false);
+ });
+});
diff --git a/src/features/TaskDock/presentation.ts b/src/features/TaskDock/presentation.ts
new file mode 100644
index 00000000000..88ec870525d
--- /dev/null
+++ b/src/features/TaskDock/presentation.ts
@@ -0,0 +1,63 @@
+import type { DockTask, DockTaskStatus } from './type';
+
+const ACTIVE: ReadonlySet<DockTaskStatus> = new Set(['pending', 'running']);
+
+export type DockOverviewStatus = 'running' | 'success' | 'error' | 'cancelled';
+
+export interface DockOverview {
+ activeCount: number;
+ /** 0-100 across the active tasks, or 100 once nothing is running. */
+ progress: number;
+ status: DockOverviewStatus;
+}
+
+export const isActiveTask = (task: DockTask): boolean => ACTIVE.has(task.status);
+
+export const resolveDockOverview = (tasks: DockTask[]): DockOverview => {
+ const active = tasks.filter(isActiveTask);
+
+ const status: DockOverviewStatus =
+ active.length > 0
+ ? 'running'
+ : tasks.some((task) => task.status === 'error')
+ ? 'error'
+ : tasks.some((task) => task.status === 'success')
+ ? 'success'
+ : 'cancelled';
+
+ const progress =
+ active.length === 0
+ ? 100
+ : active.reduce((total, task) => total + (task.progress ?? 0), 0) / active.length;
+
+ return { activeCount: active.length, progress, status };
+};
+
+export const hasCancellableTask = (tasks: DockTask[]): boolean =>
+ tasks.some((task) => isActiveTask(task) && !!task.cancel);
+
+export interface DockTaskGroup {
+ label: string;
+ tasks: DockTask[];
+}
+
+/** Groups by `groupLabel`, keeping both the group order and the task order. */
+export const groupDockTasks = (tasks: DockTask[]): DockTaskGroup[] => {
+ const groups: DockTaskGroup[] = [];
+
+ for (const task of tasks) {
+ const group = groups.find((candidate) => candidate.label === task.groupLabel);
+ if (group) group.tasks.push(task);
+ else groups.push({ label: task.groupLabel, tasks: [task] });
+ }
+
+ return groups;
+};
+
+/**
+ * A finished task with nothing to hand back has said all it can, so the dock
+ * clears it. One that left a result — a published URL, a stored file — waits
+ * for the user, and a failure always does.
+ */
+export const shouldAutoDismiss = (task: DockTask): boolean =>
+ task.status === 'success' && !task.result;
diff --git a/src/features/TaskDock/providers/useFileUploadDockTasks.tsx b/src/features/TaskDock/providers/useFileUploadDockTasks.tsx
new file mode 100644
index 00000000000..593a605fd87
--- /dev/null
+++ b/src/features/TaskDock/providers/useFileUploadDockTasks.tsx
@@ -0,0 +1,126 @@
+import { Text } from '@lobehub/ui/base-ui';
+import isEqual from 'fast-deep-equal';
+import { useCallback, useMemo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { FileUploadErrorActions } from '@/business/client/features/FileUploadErrorActions';
+import FileIcon from '@/components/FileIcon';
+import { fileManagerSelectors, useFileStore } from '@/store/file';
+import type { UploadFileItem } from '@/types/files/upload';
+import { formatSize, formatSpeed, formatTime } from '@/utils/format';
+
+import type { DockTask, DockTaskStatus } from '../type';
+
+const STATUS_MAP: Record<UploadFileItem['status'], DockTaskStatus> = {
+ cancelled: 'cancelled',
+ error: 'error',
+ pending: 'pending',
+ processing: 'running',
+ success: 'success',
+ uploading: 'running',
+};
+
+export const useFileUploadDockTasks = (): DockTask[] => {
+ const { t } = useTranslation(['file', 'common']);
+ const fileList = useFileStore(fileManagerSelectors.dockFileList, isEqual);
+ const cancelUpload = useFileStore((s) => s.cancelUpload);
+ const cancelUploads = useFileStore((s) => s.cancelUploads);
+ const retryDockUpload = useFileStore((s) => s.retryDockUpload);
+ const dispatchDockFileList = useFileStore((s) => s.dispatchDockFileList);
+
+ const describe = useCallback(
+ ({ error, file, status, uploadState }: UploadFileItem) => {
+ const size = formatSize(file.size);
+
+ switch (status) {
+ case 'uploading': {
+ const trailing = [
+ uploadState?.speed ? formatSpeed(uploadState.speed) : '',
+ uploadState?.restTime
+ ? t('uploadDock.body.item.restTime', { time: formatTime(uploadState.restTime) })
+ : '',
+ ].filter(Boolean);
+
+ return (
+ <Text style={{ fontSize: 12 }} type={'secondary'}>
+ {uploadState?.progress ? formatSize(file.size * (uploadState.progress / 100)) : '-'}/
+ {size}
+ {trailing.length === 0 ? '' : ' · ' + trailing.join(' · ')}
+ </Text>
+ );
+ }
+ case 'pending': {
+ return (
+ <Text style={{ fontSize: 12 }} type={'secondary'}>
+ {size} · {t('uploadDock.body.item.pending')}
+ {uploadState?.progress ? ` ${uploadState.progress}%` : ''}
+ </Text>
+ );
+ }
+ case 'processing': {
+ return (
+ <Text style={{ fontSize: 12 }} type={'secondary'}>
+ {size} · {t('uploadDock.body.item.processing')}
+ </Text>
+ );
+ }
+ case 'success': {
+ return (
+ <Text style={{ fontSize: 12 }} type={'secondary'}>
+ {size} · {t('uploadDock.body.item.done')}
+ </Text>
+ );
+ }
+ case 'error': {
+ return (
+ <Text style={{ fontSize: 12 }} type={'danger'}>
+ {error || `${size} · ${t('uploadDock.body.item.error')}`}
+ </Text>
+ );
+ }
+ case 'cancelled': {
+ return (
+ <Text style={{ fontSize: 12 }} type={'warning'}>
+ {size} · {t('uploadDock.body.item.cancelled')}
+ </Text>
+ );
+ }
+ }
+ },
+ [t],
+ );
+
+ const cancelActiveUploads = useCallback(() => {
+ cancelUploads(
+ fileList
+ .filter((item) => item.status === 'uploading' || item.status === 'pending')
+ .map((item) => item.id),
+ );
+ }, [cancelUploads, fileList]);
+
+ return useMemo(
+ () =>
+ fileList.map((item): DockTask => {
+ const { errorCode, file, id, status, uploadState } = item;
+ const active = status === 'uploading' || status === 'pending';
+
+ return {
+ // A file with its own remedy action keeps that action instead of a
+ // bare retry — the remedy is what actually unblocks the upload.
+ ...(status === 'error' && !errorCode ? { retry: () => void retryDockUpload(id) } : {}),
+ ...(active ? { cancel: () => cancelUpload(id) } : {}),
+ detail: describe(item),
+ groupCancel: cancelActiveUploads,
+ dismiss: () => dispatchDockFileList({ ids: [id], type: 'removeFiles' }),
+ extra: errorCode ? <FileUploadErrorActions code={errorCode} /> : undefined,
+ groupLabel: t('taskDock.group.upload', { ns: 'common' }),
+ icon: <FileIcon fileName={file.name} fileType={file.type} size={30} />,
+ id,
+ progress: uploadState?.progress,
+ status: STATUS_MAP[status],
+ title: file.name,
+ };
+ }),
+ [cancelActiveUploads, cancelUpload, describe, dispatchDockFileList, fileList, retryDockUpload],
+ );
+};
diff --git a/src/features/TaskDock/type.ts b/src/features/TaskDock/type.ts
new file mode 100644
index 00000000000..fc37d9ac6b1
--- /dev/null
+++ b/src/features/TaskDock/type.ts
@@ -0,0 +1,49 @@
+import type { ReactNode } from 'react';
+
+export type DockTaskStatus = 'pending' | 'running' | 'success' | 'error' | 'cancelled';
+
+export interface DockTaskResult {
+ /** Label for the trailing action button; omit for a url-only result. */
+ action?: string;
+ /** Shown on the strip; a url renders in the code face, anything else muted. */
+ label: string;
+ onAction?: () => void;
+ onCopy?: () => void;
+ onOpen?: () => void;
+}
+
+export interface DockTask {
+ cancel?: () => void;
+ detail?: ReactNode;
+ /**
+ * Removes the task from its producer. The dock calls it when the row is
+ * closed, and — for a task with no `result` — once its success has been
+ * shown long enough to read.
+ */
+ dismiss?: () => void;
+ /** Producer-supplied action node, rendered after the built-in row actions. */
+ extra?: ReactNode;
+ /**
+ * Cancels every active task this producer owns in one operation. Shared by
+ * all of its tasks; the dock calls it once per group rather than walking
+ * `cancel` per task, which a producer may implement as a full-list update.
+ */
+ groupCancel?: () => void;
+ /** Translated section heading; tasks sharing one keep their producer order. */
+ groupLabel: string;
+ icon?: ReactNode;
+ id: string;
+ /** 0-100. Omit while the task has no measurable progress. */
+ progress?: number;
+ /**
+ * What the finished task leaves behind — a published URL, a stored file.
+ * A task with a result stays until the user closes it; one without
+ * dissipates on its own.
+ */
+ result?: DockTaskResult;
+ retry?: () => void;
+ status: DockTaskStatus;
+ title: string;
+}
+
+export type DockTaskProvider = () => DockTask[];
diff --git a/src/features/TaskDock/useDockTasks.ts b/src/features/TaskDock/useDockTasks.ts
new file mode 100644
index 00000000000..e29748b3c9d
--- /dev/null
+++ b/src/features/TaskDock/useDockTasks.ts
@@ -0,0 +1,13 @@
+import { useMemo } from 'react';
+
+import { useBusinessDockTasks } from '@/business/client/features/DockTasks';
+
+import { useFileUploadDockTasks } from './providers/useFileUploadDockTasks';
+import type { DockTask } from './type';
+
+export const useDockTasks = (): DockTask[] => {
+ const business = useBusinessDockTasks();
+ const uploads = useFileUploadDockTasks();
+
+ return useMemo(() => [...business, ...uploads], [business, uploads]);
+};
diff --git a/src/layout/SPAGlobalProvider/index.tsx b/src/layout/SPAGlobalProvider/index.tsx
index fbed5c5c2bb..f21f2e8b061 100644
--- a/src/layout/SPAGlobalProvider/index.tsx
+++ b/src/layout/SPAGlobalProvider/index.tsx
@@ -30,6 +30,7 @@ registerNativeContextMenuInterceptor();
const DevDock = lazy(() => import('@/features/DevDock'));
const ImperativeMountHost = lazy(() => import('@/components/ImperativeMount'));
const DynamicFavicon = lazy(() => import('@/layout/GlobalProvider/DynamicFavicon'));
+const TaskDock = lazy(() => import('@/features/TaskDock'));
const devDockLayoutStyle: CSSProperties = {
alignItems: 'center',
@@ -108,6 +109,7 @@ const SPAGlobalProvider = memo<PropsWithChildren>(({ children }) => {
<ToastHost />
<ContextMenuHost />
<Suspense>
+ <TaskDock />
<ImperativeMountHost />
</Suspense>
</LazyMotion>
diff --git a/src/store/file/slices/fileManager/action.ts b/src/store/file/slices/fileManager/action.ts
index cf1648f120c..b2621d4fb93 100644
--- a/src/store/file/slices/fileManager/action.ts
+++ b/src/store/file/slices/fileManager/action.ts
@@ -527,10 +527,6 @@ export class FileManageActionImpl {
this.#set({ pendingRenameItemId: id }, false, 'setPendingRenameItemId');
};
- setUploadDockExpanded = (expanded: boolean): void => {
- this.#set({ uploadDockExpanded: expanded }, false, 'setUploadDockExpanded');
- };
-
toggleEmbeddingIds = (ids: string[], loading?: boolean): void => {
this.#set((state) => {
const nextValue = new Set(state.creatingEmbeddingTaskIds);
diff --git a/src/store/file/slices/fileManager/initialState.ts b/src/store/file/slices/fileManager/initialState.ts
index a8b62cd3f78..eff994bdeec 100644
--- a/src/store/file/slices/fileManager/initialState.ts
+++ b/src/store/file/slices/fileManager/initialState.ts
@@ -12,7 +12,6 @@ export interface FileManagerState {
fileListOffset: number;
pendingRenameItemId: string | null;
queryListParams?: QueryFileListParams;
- uploadDockExpanded: boolean;
}
export const initialFileManagerState: FileManagerState = {
@@ -24,5 +23,4 @@ export const initialFileManagerState: FileManagerState = {
fileListHasMore: false,
fileListOffset: 0,
pendingRenameItemId: null,
- uploadDockExpanded: true,
};