Skip to content

feat(planner): live tool-call visibility + skip planner for knowledge questions - #16

Open
wangkailang wants to merge 1 commit into
mainfrom
feat/plan-progress-visibility
Open

feat(planner): live tool-call visibility + skip planner for knowledge questions#16
wangkailang wants to merge 1 commit into
mainfrom
feat/plan-progress-visibility

Conversation

@wangkailang

Copy link
Copy Markdown
Owner

Summary

  • 计划步骤运行中实时显示 artifacts:每次 tool-result 通过新事件 ai:plan-step-artifact 增量推送到渲染端,plan-viewer 在 running 自动展开的状态下立刻显示已执行的工具调用与参数,不再只看到旋转图标和 sub-step 勾选。
  • 知识/分析问答不再误触 planner:新增 isKnowledgeQuestion + hasFileReference 双重门,阻止 "分析 A 与 B 的区别" 这类纯知识题进入计划流程。仍然落到 planner 的请求(例如长文本兜底)由 system prompt 显式允许产出单步 answer 计划,避免 LLM 习惯性扫描本地工作区。
  • 新增 src/main/planner/__tests__/needs-planning.test.ts 锁定 7 类知识题、含文件引用的多步任务、以及简单单动作请求的判定行为(10 用例)。

Test plan

  • npm run test — 13 files / 140 tests 全部通过
  • npx tsc --noEmit — 无错误
  • 手动:在 chat 中触发 plan 执行,确认运行中的步骤实时出现 tool-call 列表
  • 手动:发送 "分析 X 与 Y 的区别",确认走普通 chat 而非 planner,没有触发 listDirectory

🤖 Generated with Claude Code

… questions

Two UX fixes for the plan execution flow:

1. Stream artifacts incrementally during step execution. Previously the
   running step only showed sub-step ticks; tool-call details were
   batched until step completion. Now each tool-result emits
   ai:plan-step-artifact, the renderer appends it to the running step,
   and plan-viewer's auto-expansion makes the operation log visible
   live.

2. Skip the planner for pure knowledge / analytical questions
   (e.g. "分析 A 与 B 的区别", "compare X vs Y") that don't reference
   any workspace file. The previous heuristic only checked for
   multi-action connectors like "以及", which falsely triggered the
   planner and caused the LLM to scan the local workspace for
   unrelated topics. Adds isKnowledgeQuestion + hasFileReference
   gates and a planner-side single-step "answer" fallback.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 9, 2026 13:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the planner experience in FileWork by (1) streaming tool-call artifacts to the renderer while a plan step is still running, and (2) preventing pure knowledge/analysis questions from entering the planning flow.

Changes:

  • Added incremental IPC event ai:plan-step-artifact to push each tool-result artifact as it happens and update the running plan UI immediately.
  • Enhanced needsPlanning() with isKnowledgeQuestion + hasFileReference gating to skip planning for knowledge-only prompts.
  • Added needsPlanning unit tests covering knowledge prompts, file-referencing analysis prompts, multi-step tasks, and simple single-action prompts.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/renderer/components/chat/usePlanFlow.ts Subscribes to incremental onPlanStepArtifact and appends artifacts into the running step’s plan message state.
src/preload/index.ts Exposes onPlanStepArtifact IPC subscription to the renderer API.
src/main/planner/index.ts Adds knowledge-question/file-reference heuristics and updates planner system prompt guidance for “answer-only” plans.
src/main/planner/executor.ts Emits ai:plan-step-artifact per tool-result to enable live artifact visibility.
src/main/planner/tests/needs-planning.test.ts Adds vitest coverage to lock in the new planning heuristics behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/planner/index.ts
*/
const hasFileReference = (prompt: string): boolean => {
const fileSignals = [
/\.[a-z0-9]{2,5}\b/i,
Comment thread src/main/planner/index.ts
Comment on lines 146 to 150
## Rules
- You MUST output valid JSON as the LAST part of your response, wrapped in \`\`\`json code fence.
- Break complex requests into 3-7 discrete steps. NEVER output a single step for a multi-part request.
- EXCEPTION: For pure knowledge / analytical questions with no file targets, output exactly ONE step: { "action": "answer", "description": "<short restatement of the user's question>" } — no skillId, no subSteps, no verify. The executor will answer directly without searching the workspace.
- Each step should be a discrete, independently executable action.
Comment on lines +257 to +261
// Stream the artifact immediately so the renderer can show
// what the running step has done so far.
if (!sender.isDestroyed()) {
sender.send("ai:plan-step-artifact", {
id: taskId,
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.

2 participants