feat: 公开定时任务页面、Word 导出、定时任务实时刷新与技能详情重构
- 新增 /public/scheduled-tasks/:taskId 公开只读访问页与对应的 /api/public/scheduled-tasks 后端路由(无需登录) - 新增对话整体 / 单条消息 / Markdown 工件 "另存为 Word (.docx)" 能力 - 定时任务列表与运行列表在任务执行中自动轮询刷新,并新增"正在执行"标记 - 定时任务运行消息接口在事件存储为空时回退到 LangGraph checkpoint, 让正在执行的任务也能立即看到提示词与流式输出 - 技能详情对话框由折叠面板改为 Tab 切换(Detail / SKILL.md), 并支持 Rendered / Raw 切换、一键复制 - config.yaml 增加 database (MySQL) 与 checkpointer (SQLite) 配置块 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7e75c5b9b9
commit
d339db4799
18 files changed
+1617
-125
No files matched your search
@@ -48,6 +48,7 @@ export const enUS: Translations = {
|
||||
export: "Export",
|
||||
exportAsMarkdown: "Export as Markdown",
|
||||
exportAsJSON: "Export as JSON",
|
||||
exportAsWord: "Export as Word",
|
||||
exportSuccess: "Conversation exported",
|
||||
},
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ export interface Translations {
|
||||
export: string;
|
||||
exportAsMarkdown: string;
|
||||
exportAsJSON: string;
|
||||
exportAsWord: string;
|
||||
exportSuccess: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ export const zhCN: Translations = {
|
||||
export: "导出",
|
||||
exportAsMarkdown: "导出为 Markdown",
|
||||
exportAsJSON: "导出为 JSON",
|
||||
exportAsWord: "导出为 Word",
|
||||
exportSuccess: "对话已导出",
|
||||
},
|
||||
|
||||
|
||||
@@ -41,6 +41,11 @@ export function useSchedulerThread() {
|
||||
});
|
||||
}
|
||||
|
||||
/** A task is currently executing — used to drive live polling of the task list. */
|
||||
function taskIsLive(status?: string | null): boolean {
|
||||
return status === "running" || status === "pending";
|
||||
}
|
||||
|
||||
export function useScheduledTasks(
|
||||
params: { search?: string; tagIds?: string[] } = {},
|
||||
) {
|
||||
@@ -51,6 +56,12 @@ export function useScheduledTasks(
|
||||
queryFn: () => listScheduledTasks({ search, tagIds }),
|
||||
refetchOnWindowFocus: false,
|
||||
placeholderData: keepPreviousData,
|
||||
// Poll the list while any task is currently executing so its last_status
|
||||
// and last_run_at refresh without a manual reload.
|
||||
refetchInterval: (query) =>
|
||||
(query.state.data ?? []).some((task) => taskIsLive(task.last_status))
|
||||
? 5000
|
||||
: false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -60,6 +71,13 @@ export function useScheduledTaskRuns(taskId?: string | null) {
|
||||
queryFn: () => listScheduledTaskRuns(taskId!),
|
||||
enabled: !!taskId,
|
||||
refetchOnWindowFocus: false,
|
||||
// Poll the run list while any run is in flight so the user can watch
|
||||
// status transitions (pending → running → succeeded/failed) without
|
||||
// refreshing the page.
|
||||
refetchInterval: (query) =>
|
||||
(query.state.data ?? []).some((run) => runIsLive(run.status))
|
||||
? 4000
|
||||
: false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -113,6 +131,11 @@ export function useAllScheduledTasks(
|
||||
enabled: params.enabled ?? true,
|
||||
refetchOnWindowFocus: false,
|
||||
placeholderData: keepPreviousData,
|
||||
// Mirror the user list polling so the admin view also refreshes live.
|
||||
refetchInterval: (query) =>
|
||||
(query.state.data ?? []).some((task) => taskIsLive(task.last_status))
|
||||
? 5000
|
||||
: false,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -123,6 +146,11 @@ export function useAdminScheduledTaskRuns(taskId?: string | null) {
|
||||
queryFn: () => adminListScheduledTaskRuns(taskId!),
|
||||
enabled: !!taskId,
|
||||
refetchOnWindowFocus: false,
|
||||
// Poll while any run is still executing so admins see live progress.
|
||||
refetchInterval: (query) =>
|
||||
(query.state.data ?? []).some((run) => runIsLive(run.status))
|
||||
? 4000
|
||||
: false,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { Message } from "@langchain/langgraph-sdk";
|
||||
|
||||
import { downloadMarkdownAsDocx } from "@/core/scheduled-tasks/markdown-docx";
|
||||
|
||||
import {
|
||||
extractContentFromMessage,
|
||||
extractReasoningContentFromMessage,
|
||||
@@ -138,3 +140,17 @@ export function exportThreadAsJSON(thread: AgentThread, messages: Message[]) {
|
||||
const filename = `${sanitizeFilename(titleOfThread(thread))}.json`;
|
||||
downloadAsFile(json, filename, "application/json;charset=utf-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the conversation as a Word document (.docx). The whole thread is
|
||||
* serialised to Markdown first (same formatter the `.md` export uses), and
|
||||
* then converted to a docx Blob in the browser via `markdownToDocxBlob`.
|
||||
*/
|
||||
export async function exportThreadAsWord(
|
||||
thread: AgentThread,
|
||||
messages: Message[],
|
||||
): Promise<void> {
|
||||
const markdown = formatThreadAsMarkdown(thread, messages);
|
||||
const title = titleOfThread(thread);
|
||||
await downloadMarkdownAsDocx(markdown, sanitizeFilename(title), title);
|
||||
}
|
||||
Reference in new issue
Block a user