From 82715e839cddd09224b98e58b1f559835ed54962 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 17 Feb 2026 19:19:52 +0000 Subject: [PATCH] fix: integrate prompt-building helpers in onSend and resolve dual highlight conflict - Add extractTaggedPaths() to parse @path tokens from prompt text - Use buildPromptInput() for structured model input with 'Referenced paths:' block - Use buildUserVisiblePrompt() for readable user-facing message display - Pass autoHighlight={false} to Command in composer palette to prevent conflict between autocomplete's internal highlight and composerMenuIndex state --- apps/web/src/components/ChatView.tsx | 14 ++++++++++---- apps/web/src/composer-logic.ts | 9 +++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index 40d6116dd9..3693d72333 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -33,7 +33,10 @@ import { serverConfigQueryOptions } from "~/lib/serverReactQuery"; import { isElectron } from "../env"; import { buildBootstrapInput } from "../historyBootstrap"; import { + buildPromptInput, + buildUserVisiblePrompt, detectComposerTrigger, + extractTaggedPaths, replaceTextRange, } from "../composer-logic"; import { @@ -908,6 +911,9 @@ export default function ChatView() { const trimmed = prompt.trim(); if (!trimmed && composerImages.length === 0) return; if (!activeProject) return; + const { cleanText, paths: taggedPaths } = extractTaggedPaths(trimmed); + const userVisibleText = buildUserVisiblePrompt(cleanText, taggedPaths); + const modelText = buildPromptInput(cleanText, taggedPaths); const composerImagesSnapshot = [...composerImages]; // On first message: lock in branch + create worktree if needed. @@ -970,7 +976,7 @@ export default function ChatView() { type: "PUSH_USER_MESSAGE", threadId: activeThread.id, id: crypto.randomUUID(), - text: trimmed, + text: userVisibleText, ...(messageAttachments.length > 0 ? { attachments: messageAttachments } : {}), }); const previousMessages = activeThread.messages; @@ -998,14 +1004,14 @@ export default function ChatView() { const shouldBootstrap = previousMessages.length > 0 && (sessionInfo.continuityState === "new" || sessionInfo.continuityState === "fallback_new"); - const latestPromptForBootstrap = trimmed || IMAGE_ONLY_BOOTSTRAP_PROMPT; + const latestPromptForBootstrap = modelText || IMAGE_ONLY_BOOTSTRAP_PROMPT; const input = shouldBootstrap ? buildBootstrapInput( previousMessages, latestPromptForBootstrap, PROVIDER_SEND_TURN_MAX_INPUT_CHARS, ).text - : trimmed || undefined; + : modelText || undefined; await api.providers.sendTurn({ sessionId: sessionInfo.sessionId, ...(input ? { input } : {}), @@ -1247,7 +1253,7 @@ export default function ChatView() {
{composerMenuOpen && (
- +
{ + paths.push(path); + return ""; + }); + return { cleanText: cleanText.replace(/\s{2,}/g, " ").trim(), paths }; +} + export function buildUserVisiblePrompt(text: string, taggedPaths: string[]): string { const trimmedPrompt = text.trim(); const normalizedPaths = dedupePaths(taggedPaths);