Skip to content

fix(checkpoint): repair broken checkpoint system and add rewind message truncation#66

Open
baochipham942-eng wants to merge 27 commits intomainfrom
fix/checkpoint-system
Open

fix(checkpoint): repair broken checkpoint system and add rewind message truncation#66
baochipham942-eng wants to merge 27 commits intomainfrom
fix/checkpoint-system

Conversation

@baochipham942-eng
Copy link
Copy Markdown
Owner

Summary

  • Checkpoint 失效修复: 工具重命名为 PascalCase 后 FILE_WRITE_TOOLS 仍为旧名,导致 checkpoint 从未创建。改为 ['Write', 'Edit'] 并使用 tool.name 规范名
  • Preview 逻辑对齐: 预览现在显示目标消息之后所有受影响文件,与 rewindFiles() 实际回滚范围一致
  • Rewind 消息截断: 回滚文件的同时截断 DB 消息 + 同步 orchestrator 内存 + 刷新前端 UI

Changed Files

文件 变更
fileCheckpointMiddleware.ts FILE_WRITE_TOOLS['Write', 'Edit']
toolExecutor.ts toolNametool.name (规范名)
checkpoint.ipc.ts 重写:preview 对齐 rewind 范围 + 消息截断 + orchestrator 依赖注入
ipc/index.ts 传入 { getOrchestrator } 依赖
databaseService.ts 新增 deleteMessagesFrom(sessionId, fromTimestamp)
RewindPanel.tsx Rewind 后刷新前端消息列表
ipc.ts 类型新增 messagesRemoved 字段
agent-core.md 更新 Checkpoint 系统文档(架构图 + 限制 + 完整表结构)
ARCHITECTURE.md 修正文件路径

Test plan

  • npm run typecheck 零错误
  • 在 dev 模式下 Edit/Write 文件后检查 SQLite file_checkpoints 表有记录
  • Esc+Esc 打开 RewindPanel,选择检查点后预览显示所有后续受影响文件
  • 执行 Rewind 后:文件恢复 + 对话消息被截断 + UI 刷新

🤖 Generated with Claude Code

林晨 and others added 27 commits March 5, 2026 23:44
- Fix script path resolution for esbuild bundled output (findScript helper)
- Fix ASR engine detection via IPC instead of hardcoded Web Speech API
- Fix audio chunk validity (sliding window with WebM header)
- Fix VAD stale closure bug (read analyser directly)
- Add concurrent ASR request lock (asrBusyRef)
- Reduce polling interval to 1s with sliding window (~5s audio)
- Use MPS float16 for Apple Silicon acceleration
- Add user choice after transcription (generate minutes or skip)
- Remove unnecessary ffprobe/tail extraction (frontend sends window)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace Qwen3-ASR with FunASR pipeline (Paraformer-zh + FSMN-VAD + CT-Punc)
for better Chinese recognition accuracy and lower latency. Add WebSocket
streaming mode support for future real-time use.

- New: funasrService.ts (JSONL stdio, same protocol as qwen3AsrService)
- New: funasr-server.py (--serve / --ws / --check / --audio modes)
- Delete: qwen3AsrService.ts, qwen3-asr-inference.py
- Update: meeting.ipc.ts, index.ts, useMeetingRecorder.ts labels

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove meeting recorder feature from Electron app. Replace with
standalone CLI tool (scripts/demo-meeting-asr.py) using proper
architecture: AudioWorklet PCM → Silero VAD → Qwen3-ASR.

Key improvements:
- VAD-based sentence segmentation (no more duplicates/hallucinations)
- 1.2-1.5s ASR latency (down from ~6s)
- Auto-save to JSON/TXT/SRT on Ctrl+C
- Speaker diarization support (--spk flag)

Deleted: 10 files (meeting UI, IPC handlers, FunASR service)
Modified: 8 files (removed meeting references)
Added: CLI tool + spec doc

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… test coverage improvements

Sprint 1 (止血):
- Fix shared→main circular dependency: move PermissionPreset to shared/types
- Fix renderer→main layer violation: move ErrorCode/ErrorSeverity to shared/types
- Replace 9 sync IO calls with async in agentLoop (eliminates main thread blocking)
- Fix timer leak in sessionStateManager (add clearInterval on app quit)
- Add missing .catch() to 3 Promise chains in bootstrap.ts

Sprint 2 (结构优化):
- Split AgentLoop.run() from ~1200 lines to 185 lines + 7 sub-methods
- Extract NudgeManager (625 lines) from AgentLoop (reduces class by 442 lines)
- Improve Provider type safety: any count 33→15, add OpenAI/Claude message interfaces
- Fix 8 silent catch blocks in databaseService with filtered logger.warn
- Remove 2 dead functions from contextBuilder (117 lines)
- Clean up 7 unused imports from agentLoop

Sprint 3 (质量提升):
- Replace 110+ catch(: any) with catch(: unknown) across 70 files
- Add 47 new tests: Provider (15), NudgeManager (8), IPC (18), Shell (6)
- Fix 3 pre-existing test failures (events, antiPatternDetector, cleanXml)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Three-column replay view (turn navigator + structured message flow + analytics sidebar)
that reconstructs session data from telemetry tables for post-hoc analysis.

- Backend: replayService.ts — telemetry_turns + telemetry_tool_calls JOIN,
  tool category taxonomy (9 categories from agentsview), self-repair detection
- Frontend: SessionReplayView (3-column layout), ReplayMessageBlock (5 block types:
  user/thinking/text/tool_call/error), ReplayAnalyticsSidebar (tool distribution,
  thinking ratio, self-repair rate, error taxonomy)
- IPC: replay:get-structured-data channel registered
- Fix: 11 pre-existing typecheck errors (channels.ts, TestResultsDashboard, preload)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
借鉴 Google Deep Research 模板和 DeerFlow 2.0:
- SKILL.md 4 阶段方法论替代硬编码 prompt
- Reflection 节点 (6 类信息平衡检查 + 双重守卫终止)
- URL 压缩/展开 (研究阶段省 token, 报告阶段还原为 markdown link)
- 分模型策略 (queryModel/reportModel)
- Memory/TaskList/Swarm 集成 (opt-in)
- Source 聚合 (使用驱动去重)
- 报告截断续写 (finishReason=length 自动续写, 最多 2 轮)
- Kimi K2.5 输出限制修正 (output 16K→32K, context 128K→256K)
- 持久化 E2E 测试脚手架 (scripts/test-deep-research.sh)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sprint 1: Lock UI to gen8
- Delete GenerationBadge.tsx (279 lines) and useGeneration.ts (93 lines)
- Remove generation selector from TaskPanel, App.tsx startup logic
- Simplify ChatView (32 suggestion cards → 4 gen8 cards)
- Lock GenerationManager.switchGeneration() to always return gen8
- toolRegistry/toolExecutor ignore generation filtering
- promptService/builder always use gen8 prompt

Sprint 2: Remove generation artifacts
- Delete 7 prompt files (gen1-gen7.ts) and generationMap.ts
- Remove `generations: [...]` field from 80+ tool definitions
- Remove GenerationId filtering from toolSearchService, decorators, MCP servers
- Simplify metadata.ts to gen8 only, IPC to list+getCurrent only
- Clean up shared types, IPC channels, builtinConfig

127 files changed. TypeScript zero errors. CLI E2E verified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Research pipeline:
- taskRouter: detect research intent → route to researchPlanner→researchExecutor
- researchPlanner: enforce multi-angle decomposition (dimension field + 3+ coverage)
- researchExecutor: wire up DeepResearchConfig model fields (queryModel/reportModel)
- webSearch: dynamic date injection via dynamicDescription

UI improvements:
- Remove EnhancedThinkingIndicator (brain icon doesn't fit design)
- Fix empty thinking block rendering (trim check)
- Smart word-boundary truncation for search query display
- Add search source labels in collapsed summary (via perplexity, exa...)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Intent classification:
- New intentClassifier.ts: GLM-4-Flash (free) classifies research intent in ~1s
- Integrated into agentLoop.initializeRun() — works for both CLI and GUI paths
- Research mode prompt injection: forces multi-angle search planning
- 5s timeout + graceful fallback to normal mode

Search source routing:
- routeSources(): selects 2-3 best-fit sources based on query characteristics
- Chinese → perplexity+tavily, Technical → exa+perplexity, News → brave+perplexity
- Research mode expands to 3-4 sources; quick mode uses 2
- User-specified sources always take precedence
- Structured logging for routing decisions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- toolRegistry.ts: re-add imports from shell/file/planning/network/mcp/memory/vision/skill modules
- run.ts: fix string | undefined type error with fallback default

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Skip Kimi K2.5 translation when query language matches target language
  (Chinese query + language='zh' → no translation needed)
- When translation IS needed, prefer QuickModel (GLM-4-Flash, free)
  over main model, with fallback chain
- Result: search time drops from 90-255s to 6-9s per call

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
P0: Brave 429 circuit breaker (10min cooldown) + research mode excludes brave
P0: Evidence chain binding - [S1] citations + credibility ratings in report
P0: Pre-load web_fetch in research mode to avoid wasting an iteration
P1: Year fallback strategy - prefer 2025/latest over 2026 in prompts
P1: High-risk site blacklist (zhihu/weixin/jianshu) with fallback hints
P1: SSE progress hints - "正在搜索 (第X轮)" stage indicators
P2: Facts vs Inferences separation (📊 vs 📈) in report
P2: Source credibility rating (⭐⭐⭐/⭐⭐/⭐)

Result: 80s→4m20s for deep research (was 10min+ before translation fix),
report quality significantly improved with citations and data provenance.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ility

- New: .code-agent/skills/research/SKILL.md with research prompt
- agentLoop.ts: load prompt from skill file, fallback to minimal hardcoded
- intentClassifier.ts: keyword quick check before LLM (0ms vs 5-8s)
- intentClassifier.ts: increase timeout from 5s to 8s for GLM-4-Flash
- Verified: "深入调研" triggers keyword match → skill load → research mode

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Research mode: auto_extract=true by default (skip separate web_fetch)
- Remove Duration from model output (keep in logs)
- Add dedup statistics logging
- SKILL.md: guide model to use recency param, reduce web_fetch usage
- dynamicDescription: hint recency + auto_extract capabilities

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- channels/index.ts & channelManager.ts: removed false DEPRECATED tags (actively used in bootstrap)
- parallelAgentCoordinator.ts: replaced DEPRECATED with NOTE (used by spawnAgent.ts)
- agent/index.ts: restored ParallelAgentCoordinator export

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… v1 design

Orchestrator's 5-phase unified design was superseded by organic evolution
of src/main/agent/ (85 files, 32K lines). Only taskOrchestrator survives
as it has zero internal dependencies. Other phases archived for reference:
- Phase 1 (routing): replaced by hybrid/taskRouter + intentClassifier
- Phase 2 (execution): replaced by AgentLoop + SubagentExecutor
- Phase 3 (realtime): cloud backend never deployed
- Phase 4 (multi-agent): replaced by agent/ module (14x larger)
- Phase 5 (strategy): replaced by self-evolving system

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lers)

Design preserved in docs/archived/evaluation/ for future A/B testing scenarios.
ParallelEvaluator evaluates 'which candidate is better' (comparator),
distinct from SwissCheeseEvaluator which evaluates 'how good is this session' (scorer).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rename 10 tools from snake_case to PascalCase (read_file→Read, write_file→Write,
bash→Bash, glob→Glob, grep→Grep, tool_search→ToolSearch, ask_user_question→AskUserQuestion,
web_search→WebSearch, spawn_agent→Agent). edit_file intentionally kept as-is.

Add TOOL_ALIASES backward compatibility map in toolRegistry for all old names.
Update CORE_TOOLS list and deferred tools metadata accordingly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add inputTokens/outputTokens to Message interface
- Add plan_mode_entered/exited, task_stats, context_compacting/compacted to AgentEvent
- Add TaskStatsData interface to shared/types/agent
- Add onToolExecutionLog to AgentLoopConfig
- Add MCPOAuthConfig/OAuthTokens to mcp/types
- Create orchestrator module stub for bootstrap.ts import
- Fix mcpServer constructor parameter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge functionally related deferred tools using action-based dispatch pattern:
- Process (8→1): process_list/poll/log/write/submit/kill + kill_shell + task_output
- MCPUnified (6→1): mcp + list_tools/list_resources/read_resource/get_status/add_server
- TaskManager (4→1): TaskCreate/Get/List/Update
- Plan (2→1): plan_read + plan_update
- PlanMode (2→1): enter_plan_mode + exit_plan_mode
- WebFetch (2→1): web_fetch + http_request
- ReadDocument (3→1): read_pdf + read_docx + read_xlsx
- Browser (2→1): browser_navigate + browser_action
- Computer (2→1): screenshot + computer_use

Deferred entries 73→51. Old names preserved as aliases. Group 10 (8 generate
tools) intentionally skipped due to parameter divergence.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove all .generations property checks (property removed from Tool interface)
- Update tool name assertions to PascalCase (bash→Bash, read_file→Read, etc.)
- Adapt generation-manager tests: only gen8 exists, switchGeneration always returns gen8
- Adapt builder tests: buildAllPrompts returns only gen8, no gen1-gen7 differentiation
- Adapt tool-registry tests: use PascalCase names for registry.get()
- Fix webSearch test: duration no longer included in header output
- Remove generation filtering test (ToolExecutor no longer checks generations)
- 108 test failures → 0 failures (85 files pass, 3 intentionally skipped)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…cation on rewind

4 fixes:
1. fileCheckpointMiddleware: FILE_WRITE_TOOLS aligned to PascalCase ('Write','Edit')
   - After tool rename (session 3), checkpoints were never created
2. toolExecutor: pass tool.name (canonical) instead of toolName (input)
   - Ensures alias inputs (write_file) still match middleware filter
3. checkpoint.ipc preview: show all affected files from target onward
   - Previously only showed files for the exact messageId
4. Rewind now truncates conversation (DB + orchestrator + frontend)
   - databaseService.deleteMessagesFrom() for DB truncation
   - Orchestrator.setMessages() for in-memory sync
   - RewindPanel fetches fresh messages after rewind

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
code-agent Ready Ready Preview, Comment Mar 8, 2026 6:05am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant