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.

💄 style(document-modal): show skeleton for title while loading (#14377)

Arvin Xud2d81ba64a26
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index a38a7c6c868..61f9541286a 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -514,6 +514,7 @@
"taskDetail.properties": "Properties",
"taskDetail.reassignDisabled": "Cannot reassign agent while task is running",
"taskDetail.rerunTask": "Re-run task",
+ "taskDetail.runNow": "Run now",
"taskDetail.runTask": "Run",
"taskDetail.saveModelConfig": "Save",
"taskDetail.status.backlog": "Backlog",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 9a665bee067..b09bf637c4a 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -514,6 +514,7 @@
"taskDetail.properties": "属性",
"taskDetail.reassignDisabled": "任务运行中,无法切换 Agent",
"taskDetail.rerunTask": "重新运行",
+ "taskDetail.runNow": "立即运行",
"taskDetail.runTask": "运行",
"taskDetail.saveModelConfig": "保存",
"taskDetail.status.backlog": "待办",
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskArtifacts.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskArtifacts.tsx
index 60ebdc48b8c..78c97a62faf 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskArtifacts.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskArtifacts.tsx
@@ -15,6 +15,7 @@ import { FileTextIcon, MoreHorizontal, Package, Trash } from 'lucide-react';
import { memo, useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import Time from '@/routes/(main)/home/features/components/Time';
import { useDocumentStore } from '@/store/document';
import { useTaskStore } from '@/store/task';
import { taskDetailSelectors } from '@/store/task/selectors';
@@ -94,6 +95,7 @@ const ArtifactCard = memo<{ node: TaskDetailWorkspaceNode }>(({ node }) => {
{node.sourceTaskIdentifier}
</Tag>
)}
+ {node.createdAt && <Time date={node.createdAt} />}
<DropdownMenu items={menuItems}>
<ActionIcon
icon={MoreHorizontal}
@@ -112,7 +114,15 @@ const TaskArtifacts = memo(() => {
const workspace = useTaskStore(taskDetailSelectors.activeTaskWorkspace);
const [isExpanded, setIsExpanded] = useState(true);
- const items = useMemo(() => flattenWorkspace(workspace), [workspace]);
+ const items = useMemo(
+ () =>
+ [...flattenWorkspace(workspace)].sort((a, b) => {
+ const aTime = a.createdAt ? new Date(a.createdAt).getTime() : 0;
+ const bTime = b.createdAt ? new Date(b.createdAt).getTime() : 0;
+ return bTime - aTime;
+ }),
+ [workspace],
+ );
if (items.length === 0) return null;
diff --git a/src/features/AgentTasks/AgentTaskDetail/TaskDetailRunPauseAction.tsx b/src/features/AgentTasks/AgentTaskDetail/TaskDetailRunPauseAction.tsx
index f5a4d1ee39f..8aa1d9c7a83 100644
--- a/src/features/AgentTasks/AgentTaskDetail/TaskDetailRunPauseAction.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/TaskDetailRunPauseAction.tsx
@@ -1,5 +1,6 @@
-import { Button, Flexbox, Text } from '@lobehub/ui';
-import { CalendarOffIcon, PlayIcon, RotateCcwIcon } from 'lucide-react';
+import { Button, DropdownMenu, Flexbox, Text } from '@lobehub/ui';
+import { Space } from 'antd';
+import { CalendarOffIcon, ChevronDown, PlayIcon, RotateCcwIcon } from 'lucide-react';
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -43,6 +44,7 @@ const TaskDetailRunPauseAction = memo(() => {
const [isStarting, setIsStarting] = useState(false);
const [isCancellingSchedule, setIsCancellingSchedule] = useState(false);
+ const [isRunningNow, setIsRunningNow] = useState(false);
const handleRunOrPause = useCallback(async () => {
if (!taskId) return;
@@ -71,6 +73,19 @@ const TaskDetailRunPauseAction = memo(() => {
updateTaskStatus,
]);
+ const handleRunNow = useCallback(async () => {
+ if (!taskId) return;
+ setIsRunningNow(true);
+ try {
+ if (!assigneeAgentId && inboxAgentId) {
+ await updateTask(taskId, { assigneeAgentId: inboxAgentId });
+ }
+ await runTask(taskId);
+ } finally {
+ setIsRunningNow(false);
+ }
+ }, [taskId, assigneeAgentId, inboxAgentId, runTask, updateTask]);
+
const handleCancelSchedule = useCallback(async () => {
if (!taskId) return;
setIsCancellingSchedule(true);
@@ -116,13 +131,29 @@ const TaskDetailRunPauseAction = memo(() => {
if (isScheduled) {
return (
<Flexbox horizontal align={'center'} gap={12}>
- <Button
- icon={CalendarOffIcon}
- loading={isCancellingSchedule}
- onClick={handleCancelSchedule}
- >
- {t('taskDetail.cancelSchedule')}
- </Button>
+ <Space.Compact>
+ <Button
+ disabled={isRunningNow}
+ icon={CalendarOffIcon}
+ loading={isCancellingSchedule}
+ onClick={handleCancelSchedule}
+ >
+ {t('taskDetail.cancelSchedule')}
+ </Button>
+ <DropdownMenu
+ items={[
+ {
+ disabled: isRunningNow || isCancellingSchedule,
+ icon: PlayIcon,
+ key: 'runNow',
+ label: t('taskDetail.runNow'),
+ onClick: handleRunNow,
+ },
+ ]}
+ >
+ <Button disabled={isCancellingSchedule} icon={ChevronDown} loading={isRunningNow} />
+ </DropdownMenu>
+ </Space.Compact>
{countdownText && (
<Text fontSize={12} type={'secondary'}>
{t('taskDetail.nextRunCountdown', { countdown: countdownText })}
diff --git a/src/features/DocumentModal/Header.tsx b/src/features/DocumentModal/Header.tsx
index 04e054f32a9..8166bca74b8 100644
--- a/src/features/DocumentModal/Header.tsx
+++ b/src/features/DocumentModal/Header.tsx
@@ -1,6 +1,6 @@
'use client';
-import { ActionIcon, Avatar, Flexbox, Text } from '@lobehub/ui';
+import { ActionIcon, Avatar, Flexbox, Skeleton, Text } from '@lobehub/ui';
import { cssVar } from 'antd-style';
import { XIcon } from 'lucide-react';
import { memo } from 'react';
@@ -11,6 +11,8 @@ import { AutoSaveHint } from '@/features/EditorCanvas';
import { usePageAgentPanelControl } from '@/features/PageEditor/RightPanel/OverrideContext';
import { usePageEditorStore } from '@/features/PageEditor/store';
import ToggleRightPanelButton from '@/features/RightPanel/ToggleRightPanelButton';
+import { useDocumentStore } from '@/store/document';
+import { editorSelectors } from '@/store/document/slices/editor';
const HEADER_HEIGHT = 44;
@@ -22,6 +24,7 @@ const DocumentModalHeader = memo<DocumentModalHeaderProps>(({ onClose }) => {
const { t } = useTranslation(['file', 'common']);
const [documentId, emoji, title] = usePageEditorStore((s) => [s.documentId, s.emoji, s.title]);
+ const isDocumentLoading = useDocumentStore(editorSelectors.isDocumentLoading(documentId));
const { expand: showPageAgentPanel, toggle: togglePageAgentPanel } = usePageAgentPanelControl();
return (
@@ -37,10 +40,20 @@ const DocumentModalHeader = memo<DocumentModalHeaderProps>(({ onClose }) => {
>
<Flexbox allowShrink horizontal align={'center'} gap={6} style={{ minWidth: 0 }}>
{emoji && <Avatar avatar={emoji} shape={'square'} size={24} />}
- <Text ellipsis style={{ minWidth: 0 }} weight={500}>
- {title || t('pageEditor.titlePlaceholder')}
- </Text>
- {documentId && <AutoSaveHint documentId={documentId} style={{ marginLeft: 4 }} />}
+ {isDocumentLoading && !title ? (
+ <Skeleton.Button
+ active
+ size={'small'}
+ style={{ height: 14, minWidth: 120, width: 120 }}
+ />
+ ) : (
+ <Text ellipsis style={{ minWidth: 0 }} weight={500}>
+ {title || t('pageEditor.titlePlaceholder')}
+ </Text>
+ )}
+ {documentId && !isDocumentLoading && (
+ <AutoSaveHint documentId={documentId} style={{ marginLeft: 4 }} />
+ )}
</Flexbox>
<Flexbox horizontal align={'center'} gap={4}>
<ToggleRightPanelButton
diff --git a/src/features/PageEditor/TitleSection.tsx b/src/features/PageEditor/TitleSection.tsx
index c594e199f22..8bad524220f 100644
--- a/src/features/PageEditor/TitleSection.tsx
+++ b/src/features/PageEditor/TitleSection.tsx
@@ -1,12 +1,14 @@
'use client';
-import { Button, Flexbox, Icon, TextArea } from '@lobehub/ui';
+import { Button, Flexbox, Icon, Skeleton, TextArea } from '@lobehub/ui';
import { cssVar } from 'antd-style';
import { SmilePlus } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import EmojiPicker from '@/components/EmojiPicker';
+import { useDocumentStore } from '@/store/document';
+import { editorSelectors } from '@/store/document/slices/editor';
import { useGlobalStore } from '@/store/global';
import { globalGeneralSelectors } from '@/store/global/selectors';
import { truncateByWeightedLength } from '@/utils/textLength';
@@ -17,11 +19,14 @@ const TitleSection = memo(() => {
const { t } = useTranslation('file');
const locale = useGlobalStore(globalGeneralSelectors.currentLanguage);
+ const documentId = usePageEditorStore((s) => s.documentId);
const emoji = usePageEditorStore((s) => s.emoji);
const title = usePageEditorStore((s) => s.title);
const setEmoji = usePageEditorStore((s) => s.setEmoji);
const setTitle = usePageEditorStore((s) => s.setTitle);
const handleTitleSubmit = usePageEditorStore((s) => s.handleTitleSubmit);
+ const isDocumentLoading = useDocumentStore(editorSelectors.isDocumentLoading(documentId));
+ const showTitleSkeleton = isDocumentLoading && !title;
const [isHoveringTitle, setIsHoveringTitle] = useState(false);
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
@@ -85,29 +90,33 @@ const TitleSection = memo(() => {
)}
{/* Title Input */}
- <TextArea
- autoSize={{ minRows: 1 }}
- placeholder={t('pageEditor.titlePlaceholder')}
- value={title}
- variant={'borderless'}
- style={{
- fontSize: 36,
- fontWeight: 600,
- padding: 0,
- resize: 'none',
- width: '100%',
- }}
- onChange={(e) => {
- const truncated = truncateByWeightedLength(e.target.value, 100);
- setTitle(truncated);
- }}
- onKeyDown={(e) => {
- if (e.key === 'Enter') {
- e.preventDefault();
- handleTitleSubmit();
- }
- }}
- />
+ {showTitleSkeleton ? (
+ <Skeleton.Button active style={{ height: 44, width: 320 }} />
+ ) : (
+ <TextArea
+ autoSize={{ minRows: 1 }}
+ placeholder={t('pageEditor.titlePlaceholder')}
+ value={title}
+ variant={'borderless'}
+ style={{
+ fontSize: 36,
+ fontWeight: 600,
+ padding: 0,
+ resize: 'none',
+ width: '100%',
+ }}
+ onChange={(e) => {
+ const truncated = truncateByWeightedLength(e.target.value, 100);
+ setTitle(truncated);
+ }}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ handleTitleSubmit();
+ }
+ }}
+ />
+ )}
</Flexbox>
);
});
diff --git a/src/locales/default/chat.ts b/src/locales/default/chat.ts
index a5b96e1b7eb..9df1123791c 100644
--- a/src/locales/default/chat.ts
+++ b/src/locales/default/chat.ts
@@ -599,6 +599,7 @@ export default {
'taskDetail.nextRunCountdown': 'Next run in {{countdown}}',
'taskDetail.pauseTask': 'Pause task',
'taskDetail.rerunTask': 'Re-run task',
+ 'taskDetail.runNow': 'Run now',
'taskDetail.runTask': 'Run',
'taskDetail.stopTask': 'Stop task',
'taskDetail.navigation': 'Navigation',