feat: 建立小妍持续进化机制并支持 checkpoint 续接 - #67
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The checkpoint handoff apply logic can fail to re-trigger on repeated navigation/dismiss scenarios due to missing location-state syncing and a non-reset restored-id guard.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR establishes a long-term “小妍持续进化” governance plan (metrics, evaluation gates, Codex upgrade workflow) and implements a versioned “workbench checkpoint → Copilot(/chat)” handoff so users can resume research with restored context and a prefilled, editable continuation prompt.
Changes:
- Add and link the continuous-evolution plan document, and require following it during model/agent upgrades.
- Route workbench checkpoint actions to
/chatwith a structured, versioned handoff inLink state. - Add Copilot-side restore/apply logic, a removable checkpoint context bar, and regression tests for handoff behaviors.
File summaries
| File | Description |
|---|---|
| README.md | Adds entry point link to the continuous evolution plan. |
| AGENTS.md | Adds enforcement note to follow the evolution plan during Codex/agent upgrades. |
| docs/xiaoyan-continuous-evolution-plan.md | New long-term governance + evaluation plan and iteration records. |
| apps/desktop/src/pages/Copilot.tsx | Applies checkpoint handoff on /chat, prioritizes restoring source session, renders context bar, updates new-chat/reset flow. |
| apps/desktop/src/features/workbench/shared.ts | Extends link actions to carry state for router handoff payloads. |
| apps/desktop/src/features/workbench/OverviewModuleViews.tsx | Passes state through workbench Link components. |
| apps/desktop/src/features/workbench/checkpointOverview.ts | Builds checkpoint handoff payload and routes actions to /chat. |
| apps/desktop/src/features/research-context/checkpointHandoff.ts | Adds versioned handoff normalization + prompt builder with size limits and guardrails. |
| apps/desktop/src/features/copilot/useCopilotCheckpointHandoff.ts | Adds hook state + apply/dismiss logic for checkpoint handoff restore and prompt prefilling. |
| apps/desktop/src/features/copilot/CopilotCheckpointContextBar.tsx | Adds UI bar showing checkpoint context and a dismiss button. |
| apps/desktop/src/tests/pages/Copilot.test.tsx | Adds tests for session restore + prompt prefilling + dismiss behavior, plus fallback when session missing. |
| apps/desktop/src/tests/features/workbench/checkpointOverview.test.ts | Adds tests ensuring workbench checkpoint actions create a valid handoff state. |
| apps/desktop/src/tests/features/copilot/checkpointHandoff.test.ts | Adds tests for handoff normalization, version rejection, prompt generation, and size limits. |
Review details
- Files reviewed: 13/13 changed files
- Comments generated: 3
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| export function useCopilotCheckpointHandoffState(locationState: unknown) { | ||
| const [handoff, setHandoff] = useState(() => readResearchCheckpointHandoff(locationState)); | ||
| const activeHandoffRef = useRef(handoff); | ||
|
|
||
| useEffect(() => { | ||
| activeHandoffRef.current = handoff; | ||
| }, [handoff]); | ||
|
|
||
| const clearHandoff = useCallback(() => { | ||
| activeHandoffRef.current = null; | ||
| setHandoff(null); | ||
| }, []); | ||
|
|
||
| return { handoff, setHandoff, activeHandoffRef, clearHandoff }; | ||
| } |
| const restoredHandoffRef = useRef<string | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| if (!handoff || !sessionsLoaded) return; | ||
| if (restoredHandoffRef.current === handoff.id) return; | ||
| restoredHandoffRef.current = handoff.id; | ||
| markLastSessionRestored(); |
| - 目标切片:工作台 checkpoint → 小妍原会话 → 可编辑续接请求 → 继续执行 | ||
| - 文档改动:更新事实基线、推进顺序与本记录 | ||
| - 代码与测试改动:新增 checkpoint handoff 纯函数和上下文条;更新工作台导航、小妍恢复逻辑及相关测试 | ||
| - 自动验证:桌面端 type-check 通过;lint 0 error(18 条既有 warning);完整单元测试 120 个文件、435 项全部通过 |
变更内容
背景与影响
小妍此前的 checkpoint 入口只负责页面跳转,用户跨天恢复研究时仍需重复解释目标、进展和下一步。本 PR 建立持续进化的长期治理机制,并打通首个“工作台 checkpoint → 小妍 → 原会话/上下文 → 可编辑下一步”的垂直切片。
验证
pnpm --dir apps/desktop run type-checkpnpm --dir apps/desktop run test:81 个测试文件、306 项测试通过pnpm --dir apps/desktop run lint:0 error,18 条仓库既有 warninggit diff --check origin/master...HEAD