feat(ai写作): 左栏智能体 Tab 内嵌问答并优化模块侧栏
AI 写作页默认展示智能体 Tab,在页内复用 ai-writing 模块配置与 AgentChatPage;确认类型后侧栏扁平展示类型名并支持整块收起动画。同步历史回看、流式续跑、改写菜单与 researcher 检索相关改动。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c11307aa67
commit
5de74e90dc
21 files changed
+1379
-386
No files matched your search
@@ -12,7 +12,6 @@ import {
|
||||
Newspaper,
|
||||
PanelLeftClose,
|
||||
Pencil,
|
||||
Play,
|
||||
Plus,
|
||||
RefreshCw,
|
||||
Search,
|
||||
@@ -110,17 +109,12 @@ const WRITING_STATUS_PILL: Record<string, { label: string; className: string; sp
|
||||
error: { label: "出错", className: "text-rose-500" },
|
||||
};
|
||||
|
||||
/** 可「继续未完成」的状态:有可恢复的 checkpoint(mid-stage 或停在确认点)。done/error 终态、
|
||||
* background 自有进度弹窗,都不算。 */
|
||||
const RESUMABLE_STATUSES = new Set(["in_progress", "draft_ready", "review_ready"]);
|
||||
|
||||
/** 单条历史记录项 —— 样式参考多智能体会商的 HistoryDropdown 列表项(圆角卡片 + 状态药丸 + 操作按钮)。 */
|
||||
function WritingHistoryItem({
|
||||
session,
|
||||
isCurrent,
|
||||
onSelect,
|
||||
onShowProgress,
|
||||
onContinue,
|
||||
onDelete,
|
||||
onRename,
|
||||
}: {
|
||||
@@ -128,8 +122,6 @@ function WritingHistoryItem({
|
||||
isCurrent: boolean;
|
||||
onSelect: () => void;
|
||||
onShowProgress?: () => void;
|
||||
/** 继续这条未完成的会话(从 checkpoint 续跑当前阶段 / 显示确认卡)。 */
|
||||
onContinue?: () => void;
|
||||
onDelete: () => void;
|
||||
onRename: (title: string) => void;
|
||||
}) {
|
||||
@@ -137,10 +129,9 @@ function WritingHistoryItem({
|
||||
const [value, setValue] = useState(session.title);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const isBackground = session.status === "background";
|
||||
const canContinue = !!onContinue && RESUMABLE_STATUSES.has(session.status);
|
||||
// 行/标题主点击:未完成→继续续跑;挂起中→看进度弹窗;其余(完成/出错)→只读历史回看。
|
||||
const primary = isBackground && onShowProgress ? onShowProgress : (canContinue ? onContinue! : onSelect);
|
||||
const primaryTitle = isBackground ? "查看进度" : canContinue ? "继续未完成" : "打开历史";
|
||||
// Row/title click only opens the history view; restore starts from the detail header.
|
||||
const primary = isBackground && onShowProgress ? onShowProgress : onSelect;
|
||||
const primaryTitle = isBackground ? "查看进度" : "打开历史";
|
||||
const pill = WRITING_STATUS_PILL[session.status] ?? { label: session.status, className: "text-slate-400" };
|
||||
|
||||
useEffect(() => {
|
||||
@@ -200,16 +191,6 @@ function WritingHistoryItem({
|
||||
|
||||
{!renaming && (
|
||||
<div className="flex shrink-0 items-center gap-0.5">
|
||||
{canContinue && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onContinue}
|
||||
title="继续未完成"
|
||||
className="rounded p-1 text-emerald-500 transition hover:bg-emerald-50 hover:text-emerald-600"
|
||||
>
|
||||
<Play className="size-3.5 fill-current" />
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={isBackground && onShowProgress ? onShowProgress : onSelect}
|
||||
@@ -258,7 +239,7 @@ export function ResearchSidebar({
|
||||
}) {
|
||||
const navigate = useNavigate();
|
||||
const { templates, refresh } = useResearchTemplates();
|
||||
const { startWriting, continueWriting } = useAIWriting();
|
||||
const { startWriting } = useAIWriting();
|
||||
const {
|
||||
notebooks,
|
||||
isLoading: notebooksLoading,
|
||||
@@ -286,7 +267,7 @@ export function ResearchSidebar({
|
||||
rename: renameSession,
|
||||
remove: removeSession,
|
||||
} = useAIWritingSessions();
|
||||
const { openHistory, closeHistory, historySession } = useAIWritingHistory();
|
||||
const { openHistory, historySession } = useAIWritingHistory();
|
||||
|
||||
// 进入/返回写作配置页时刷新一次历史(本侧栏仅在 idle 态挂载,故等同每次回到表单刷新)。
|
||||
useEffect(() => {
|
||||
@@ -296,11 +277,6 @@ export function ResearchSidebar({
|
||||
const handleSelectHistory = (session: AIWritingSessionSummary) => {
|
||||
void openHistory(session);
|
||||
};
|
||||
// 「继续未完成」:退出只读历史态(若在),把该会话设为活跃并从 checkpoint 续跑。
|
||||
const handleContinue = (session: AIWritingSessionSummary) => {
|
||||
closeHistory();
|
||||
continueWriting(session.id);
|
||||
};
|
||||
// 「挂起中」记录:交给右侧面板打开进度流程图弹窗(沿用面板已有的 window 事件解耦模式,
|
||||
// 与 ai-writing:open-session 一致),本侧栏不直接持有弹窗状态。
|
||||
const handleShowProgress = (session: AIWritingSessionSummary) => {
|
||||
@@ -617,7 +593,6 @@ export function ResearchSidebar({
|
||||
isCurrent={s.id === (historySession?.id ?? null)}
|
||||
onSelect={() => handleSelectHistory(s)}
|
||||
onShowProgress={() => handleShowProgress(s)}
|
||||
onContinue={() => handleContinue(s)}
|
||||
onDelete={() => removeSession(s.id)}
|
||||
onRename={(title) => renameSession(s.id, title)}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user