Skip to content

Commit b67e9f9

Browse files
18243133psj88520claude
authored
Fix/plan paste fixes (#1238)
* fix: 降低 paste 检测阈值,修复非 bracketed-paste 终端粘贴文本损坏 非 bracketed-paste 终端下,短粘贴(<800 chars)的 stdin chunk 作为独立 keystroke 走 useTextInput.onInput 路径,闭包中 cursor 未刷新导致多次插入 竞态。现将 ≥3 字符的非特殊键输入纳入 paste 累积模式,绕过逐 chunk 处理。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * @ fix: Plan模式三处缺陷修复 — ExploreAgent可用性 + 弹窗一致性 + 方案文件保护 1. areExplorePlanAgentsEnabled()移除GrowthBook A/B实验依赖(tengu_amber_stoat), 始终返回true,确保Explore/Plan agent在BUILTIN_EXPLORE_PLAN_AGENTS开启时始终可用 2. ExitPlanMode clear-context路径补setNeedsPlanModeExitAttachment(true), 确保清除上下文退出Plan模式后生成plan_mode_exit附件 3. Plan mode full/sparse指令强化Plan文件读取要求: "can read" -> "MUST use FileRead to read first before any changes", 新增"do NOT overwrite"禁止覆盖,Phase 1指令强化并行Explore Agent引导 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> @ --------- Co-authored-by: psj88520 <qq18243133@gmail.com> Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 2bca31e commit b67e9f9

4 files changed

Lines changed: 17 additions & 10 deletions

File tree

packages/builtin-tools/src/tools/AgentTool/builtInAgents.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import type { AgentDefinition } from './loadAgentsDir.js'
1212

1313
export function areExplorePlanAgentsEnabled(): boolean {
1414
if (feature('BUILTIN_EXPLORE_PLAN_AGENTS')) {
15-
// 3P default: true — Bedrock/Vertex keep agents enabled (matches pre-experiment
16-
// external behavior). A/B test treatment sets false to measure impact of removal.
17-
return getFeatureValue_CACHED_MAY_BE_STALE('tengu_amber_stoat', true)
15+
return true
1816
}
1917
return false
2018
}

src/components/permissions/ExitPlanModePermissionRequest/ExitPlanModePermissionRequest.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ export function ExitPlanModePermissionRequest({
450450
}));
451451

452452
setHasExitedPlanMode(true);
453+
setNeedsPlanModeExitAttachment(true);
453454
onDone();
454455
onReject();
455456
// Reject the tool use to unblock the query loop

src/hooks/usePasteHandler.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,15 @@ export function usePasteHandler({
255255
(input.length > PASTE_THRESHOLD ||
256256
pastePendingRef.current ||
257257
hasImageFilePath ||
258-
isFromPaste)
258+
isFromPaste ||
259+
(input.length >= 3 &&
260+
!key.return &&
261+
!key.tab &&
262+
!key.escape &&
263+
!key.upArrow &&
264+
!key.downArrow &&
265+
!key.leftArrow &&
266+
!key.rightArrow))
259267

260268
if (shouldHandleAsPaste) {
261269
pastePendingRef.current = true

src/utils/messages.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3586,7 +3586,7 @@ function getPlanModeV2Instructions(attachment: {
35863586
const agentCount = getPlanModeV2AgentCount()
35873587
const exploreAgentCount = getPlanModeV2ExploreAgentCount()
35883588
const planFileInfo = attachment.planExists
3589-
? `A plan file already exists at ${attachment.planFilePath}. You can read it and make incremental edits using the ${FileEditTool.name} tool.`
3589+
? `A plan file already exists at ${attachment.planFilePath}. You MUST use ${FileReadTool.name} to read it first before making any changes. Make incremental edits using the ${FileEditTool.name} tool — do NOT overwrite the entire file unless the user explicitly asks for a complete rewrite.`
35903590
: `No plan file exists yet. You should create your plan at ${attachment.planFilePath} using the ${FileWriteTool.name} tool.`
35913591

35923592
const content = `Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits (with the exception of the plan file mentioned below), run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received.
@@ -3603,10 +3603,10 @@ Goal: Gain a comprehensive understanding of the user's request by reading throug
36033603
1. Focus on understanding the user's request and the code associated with their request. Actively search for existing functions, utilities, and patterns that can be reused — avoid proposing new code when suitable implementations already exist.
36043604
36053605
2. **Launch up to ${exploreAgentCount} ${EXPLORE_AGENT.agentType} agents IN PARALLEL** (single message, multiple tool calls) to efficiently explore the codebase.
3606-
- Use 1 agent when the task is isolated to known files, the user provided specific file paths, or you're making a small targeted change.
3606+
- For tasks with well-known file targets, 1 agent may suffice. In most cases, prefer launching 2-3 agents with complementary search focuses to maximize coverage.
36073607
- Use multiple agents when: the scope is uncertain, multiple areas of the codebase are involved, or you need to understand existing patterns before planning.
3608-
- Quality over quantity - ${exploreAgentCount} agents maximum, but you should try to use the minimum number of agents necessary (usually just 1)
3609-
- If using multiple agents: Provide each agent with a specific search focus or area to explore. Example: One agent searches for existing implementations, another explores related components, a third investigating testing patterns
3608+
- Quality over quantity - ${exploreAgentCount} agents maximum. Do NOT skip exploration — always use at least 1 Explore agent in Phase 1.
3609+
- When using multiple agents: Provide each agent with a specific search focus or area to explore. Example: One agent searches for existing implementations, another explores related components, a third investigates testing patterns
36103610
36113611
### Phase 2: Design
36123612
Goal: Design an implementation approach.
@@ -3690,7 +3690,7 @@ function getPlanModeInterviewInstructions(attachment: {
36903690
planExists?: boolean
36913691
}): UserMessage[] {
36923692
const planFileInfo = attachment.planExists
3693-
? `A plan file already exists at ${attachment.planFilePath}. You can read it and make incremental edits using the ${FileEditTool.name} tool.`
3693+
? `A plan file already exists at ${attachment.planFilePath}. You MUST use ${FileReadTool.name} to read it first before making any changes. Make incremental edits using the ${FileEditTool.name} tool — do NOT overwrite the entire file unless the user explicitly asks for a complete rewrite.`
36943694
: `No plan file exists yet. You should create your plan at ${attachment.planFilePath} using the ${FileWriteTool.name} tool.`
36953695

36963696
const content = `Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits (with the exception of the plan file mentioned below), run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received.
@@ -3752,7 +3752,7 @@ function getPlanModeV2SparseInstructions(attachment: {
37523752
}): UserMessage[] {
37533753
const workflowDescription = isPlanModeInterviewPhaseEnabled()
37543754
? 'Follow iterative workflow: explore codebase, interview user, write to plan incrementally.'
3755-
: 'Follow 5-phase workflow.'
3755+
: `Follow 5-phase workflow. Phase 1: use ${EXPLORE_AGENT.agentType} agents for code exploration.`
37563756

37573757
const content = `Plan mode still active (see full instructions earlier in conversation). Read-only except plan file (${attachment.planFilePath}). ${workflowDescription} End turns with ${ASK_USER_QUESTION_TOOL_NAME} (for clarifications) or ${ExitPlanModeV2Tool.name} (for plan approval). Never ask about plan approval via text or AskUserQuestion.`
37583758

0 commit comments

Comments
 (0)