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
@@ -32,6 +32,7 @@ import {
|
||||
* 已完成阶段不重来;见 runtime/runs/worker.py)。刷新页面 = 重置(不自动重连)。
|
||||
*/
|
||||
const ENABLE_PAUSE_RESUME_UI = true;
|
||||
const RESUMABLE_HISTORY_STATUSES = new Set(['in_progress', 'draft_ready', 'review_ready']);
|
||||
import { countArticleWords } from '../../utils/wordCount';
|
||||
import { AIWritingForm } from './AIWritingForm';
|
||||
import { AIWritingTimeline } from './AIWritingTimeline';
|
||||
@@ -80,7 +81,7 @@ export function AIWritingPanel({
|
||||
} = {}) {
|
||||
const navigate = useNavigate();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const { state, startWriting, submitIntervention, pauseWriting, resumeWriting, reset } = useAIWriting();
|
||||
const { state, startWriting, submitIntervention, pauseWriting, resumeWriting, continueWriting, reset } = useAIWriting();
|
||||
const { historySession, isHistoryMode, openHistory, closeHistory } = useAIWritingHistory();
|
||||
const writingForm = useWritingFormOptional();
|
||||
const { sessions, loading: sessionsLoading, refresh, rename, remove, markBackground, clearBackground } = useAIWritingSessions();
|
||||
@@ -198,6 +199,15 @@ export function AIWritingPanel({
|
||||
reset();
|
||||
}, [closeHistory, reset]);
|
||||
|
||||
const canRestoreHistory =
|
||||
isHistoryMode && !!historySession && RESUMABLE_HISTORY_STATUSES.has(historySession.status);
|
||||
|
||||
const handleRestoreHistory = useCallback(() => {
|
||||
if (!historySession || !RESUMABLE_HISTORY_STATUSES.has(historySession.status)) return;
|
||||
closeHistory();
|
||||
continueWriting(historySession.id);
|
||||
}, [historySession, closeHistory, continueWriting]);
|
||||
|
||||
// ── 后台挂起:把当前写作转后台,后端自动驱动到定稿(离页/刷新/切号不打断) ──
|
||||
// 与「多智能体会商」一致:点击后**立刻**回到初始页面,挂起请求 fire-and-forget;
|
||||
// 历史下拉靠乐观标记马上显示「挂起中」,不等后端确认。
|
||||
@@ -307,19 +317,33 @@ export function AIWritingPanel({
|
||||
)}
|
||||
{/* 头部 */}
|
||||
<div className="flex items-center justify-between px-4 py-2.5 border-b shrink-0">
|
||||
<span
|
||||
className={cn(
|
||||
'text-sm font-semibold shrink-0 min-w-0 truncate',
|
||||
isHistoryMode && 'flex-1 mr-2',
|
||||
!isIdle && !isHistoryMode && 'cursor-pointer hover:text-primary transition-colors',
|
||||
<div className="flex min-w-0 flex-1 items-center gap-2">
|
||||
{canRestoreHistory && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-7 px-2 text-xs gap-1 text-emerald-600 hover:text-emerald-700 hover:bg-emerald-50 dark:hover:bg-emerald-950/30"
|
||||
onClick={handleRestoreHistory}
|
||||
title="恢复写作:跳过已完成阶段,从未完成阶段重新开始"
|
||||
>
|
||||
<Play className="size-3 fill-current" />
|
||||
恢复
|
||||
</Button>
|
||||
)}
|
||||
onClick={() => { if (!isIdle && !isHistoryMode && state.request) setReqDialogOpen(true); }}
|
||||
title={isHistoryMode ? (historySession?.draft_title ?? historySession?.title) : undefined}
|
||||
>
|
||||
{isHistoryMode
|
||||
? (historySession?.draft_title ?? historySession?.title ?? '写作历史')
|
||||
: 'AI 智能写作'}
|
||||
</span>
|
||||
<span
|
||||
className={cn(
|
||||
'text-sm font-semibold shrink-0 min-w-0 truncate',
|
||||
isHistoryMode && 'flex-1 mr-2',
|
||||
!isIdle && !isHistoryMode && 'cursor-pointer hover:text-primary transition-colors',
|
||||
)}
|
||||
onClick={() => { if (!isIdle && !isHistoryMode && state.request) setReqDialogOpen(true); }}
|
||||
title={isHistoryMode ? (historySession?.draft_title ?? historySession?.title) : undefined}
|
||||
>
|
||||
{isHistoryMode
|
||||
? (historySession?.draft_title ?? historySession?.title ?? '写作历史')
|
||||
: 'AI 智能写作'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
{/* ⚠️ 临时调试:admin 一键清理 —— 阶段 7 删冗余时移除 */}
|
||||
<Button
|
||||
|
||||
Reference in new issue
Block a user