From 0b0bb11d36ff848d8acf3463e38c2ebb5dd632fb Mon Sep 17 00:00:00 2001 From: Bohdan Triapitsyn Date: Thu, 7 May 2026 19:35:46 +0300 Subject: [PATCH] fix: clarify conflict and response style prompts Conflict resolution prompts now ask for an analysis-first strategy Response style instructions are wrapped as system reminders Prompt templates stay separate from reminder formatting --- packages/ui/src/components/chat/ChatInput.tsx | 3 ++- packages/ui/src/lib/magicPrompts.ts | 13 ++++++++----- packages/ui/src/lib/systemReminder.ts | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 packages/ui/src/lib/systemReminder.ts diff --git a/packages/ui/src/components/chat/ChatInput.tsx b/packages/ui/src/components/chat/ChatInput.tsx index 25998fc3..6c9becb7 100644 --- a/packages/ui/src/components/chat/ChatInput.tsx +++ b/packages/ui/src/components/chat/ChatInput.tsx @@ -73,6 +73,7 @@ import { usePermissionStore } from '@/stores/permissionStore'; import { extractGitChangedFiles } from './changedFiles'; import { useI18n } from '@/lib/i18n'; import { fetchResponseStyleInstruction } from '@/lib/responseStyle'; +import { wrapSystemReminder } from '@/lib/systemReminder'; import { getSyncMessages } from '@/sync/sync-refs'; const MAX_VISIBLE_TEXTAREA_LINES = 8; @@ -1576,7 +1577,7 @@ const ChatInputComponent: React.FC = ({ onOpenSettings, scrollTo const responseStyleInstruction = await fetchResponseStyleInstruction().catch(() => null); if (responseStyleInstruction) { additionalParts.push({ - text: responseStyleInstruction, + text: wrapSystemReminder(responseStyleInstruction), synthetic: true, }); } diff --git a/packages/ui/src/lib/magicPrompts.ts b/packages/ui/src/lib/magicPrompts.ts index cbf1d912..d074ba59 100644 --- a/packages/ui/src/lib/magicPrompts.ts +++ b/packages/ui/src/lib/magicPrompts.ts @@ -288,7 +288,7 @@ Do not implement changes until I confirm; end with: "Next actions: <1 sentence>" { key: 'operation_label', description: 'Operation label in lower-case (merge/rebase).' }, { key: 'head_ref', description: 'Head reference for preserving intent.' }, ], - template: 'Resolve {{operation_label}} conflicts, stage the resolved files, and complete the {{operation_label}}. Preserve the intent of changes from {{head_ref}}.', + template: 'Investigate the {{operation_label}} conflicts and concisely report the intended resolution strategy without making modifications. Wait for confirmation before resolving, staging, or continuing the {{operation_label}}. Preserve the intent of changes from {{head_ref}}.', }, { id: 'git.conflict.resolve.instructions', @@ -307,13 +307,16 @@ Do not implement changes until I confirm; end with: "Next actions: <1 sentence>" - Operation: {{operation}} - Head Info: {{head_info}} -Required steps: +Required steps before confirmation: 1. Read each conflicted file to understand the conflict markers (<<<<<<< HEAD, =======, >>>>>>> ...) -2. Edit each file to resolve conflicts by choosing the correct code or merging both changes appropriately -3. Stage all resolved files with: git add -4. Complete the {{operation_label}} with: {{continue_cmd}} +2. Inspect the relevant surrounding code and changes from both sides +3. Report a concise per-file resolution strategy and any assumptions or tradeoffs +4. Wait for explicit user confirmation before editing files, staging files, or running: {{continue_cmd}} Important: +- Do not modify files before the user confirms the proposed strategy +- Do not stage files before the user confirms the proposed strategy +- Do not continue the {{operation_label}} before the user confirms the proposed strategy - Remove ALL conflict markers from files (<<<<<<< HEAD, =======, >>>>>>>) - Make sure the final code is syntactically correct and preserves intent from both sides - Do not leave any files with unresolved conflict markers diff --git a/packages/ui/src/lib/systemReminder.ts b/packages/ui/src/lib/systemReminder.ts new file mode 100644 index 00000000..c54d64b1 --- /dev/null +++ b/packages/ui/src/lib/systemReminder.ts @@ -0,0 +1,15 @@ +const SYSTEM_REMINDER_OPEN = ''; +const SYSTEM_REMINDER_CLOSE = ''; + +export const wrapSystemReminder = (text: string): string => { + const trimmed = text.trim(); + if (!trimmed) { + return ''; + } + + if (trimmed.startsWith(SYSTEM_REMINDER_OPEN) && trimmed.endsWith(SYSTEM_REMINDER_CLOSE)) { + return trimmed; + } + + return `${SYSTEM_REMINDER_OPEN}\n${trimmed}\n${SYSTEM_REMINDER_CLOSE}`; +};