fixup: 处理 PR #386 review 中尚未覆盖的 4 项

- src/cli/print.ts: cron onFire 改用 createAutonomyQueuedPromptIfNoActiveSource
  并以 prompt 文本作为 sourceId,避免同一定时提示在前一次 run 仍活跃时被重复
  入队叠加;顺手移除 4 个已没人引用的 dead import
  (commitAutonomyQueuedPrompt / prepareAutonomyTurnPrompt /
   markAutonomyRunCancelled / createAutonomyQueuedPrompt)
- src/services/compact/postCompactCleanup.ts: 在 void import().then() 处加
  注释,明确 sweepFileContentCache 是有意的 fire-and-forget,函数对外保持
  同步签名是设计而非疏忽
- src/utils/autonomyFlows.ts: 给 selectPersistedAutonomyFlows 的两阶段排序
  加文档注释(先按 active+updatedAt 选 top-N,再统一按 updatedAt 重排)
- tests/integration/autonomy-lifecycle-user-flow.test.ts: stderr 断言失败时
  把实际 stderr 内容写进 message,方便 CI 失败时定位
This commit is contained in:
Claude
2026-04-29 12:45:02 +00:00
parent f8388e44ed
commit 6b7cfda9b1
4 changed files with 25 additions and 12 deletions

View File

@@ -170,6 +170,12 @@ function isManagedFlowStatusActive(status: AutonomyFlowStatus): boolean {
function selectPersistedAutonomyFlows(
flows: AutonomyFlowRecord[],
): AutonomyFlowRecord[] {
// Two-phase sort. Phase 1: priority sort (active flows first, then by
// updatedAt desc) selects the AUTONOMY_FLOWS_MAX most-relevant records to
// retain — active flows are guaranteed a slot before any inactive flow is
// considered. Phase 2: re-sort the retained slice by updatedAt desc only,
// so the persisted file is in plain reverse-chronological order regardless
// of activity status. Listings/UI consume the persisted order directly.
const retained = flows
.slice()
.map(cloneFlowRecord)