feat(planner): live tool-call visibility + skip planner for knowledge questions - #16
Open
wangkailang wants to merge 1 commit into
Open
feat(planner): live tool-call visibility + skip planner for knowledge questions#16wangkailang wants to merge 1 commit into
wangkailang wants to merge 1 commit into
Conversation
… 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>
Contributor
There was a problem hiding this comment.
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-artifactto push each tool-result artifact as it happens and update the running plan UI immediately. - Enhanced
needsPlanning()withisKnowledgeQuestion+hasFileReferencegating to skip planning for knowledge-only prompts. - Added
needsPlanningunit 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.
| */ | ||
| const hasFileReference = (prompt: string): boolean => { | ||
| const fileSignals = [ | ||
| /\.[a-z0-9]{2,5}\b/i, |
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ai:plan-step-artifact增量推送到渲染端,plan-viewer 在 running 自动展开的状态下立刻显示已执行的工具调用与参数,不再只看到旋转图标和 sub-step 勾选。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— 无错误🤖 Generated with Claude Code