Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -665,17 +665,29 @@ export default function ChatView({ threadId }: ChatViewProps) {
const questionChanged =
lastSyncedPendingInputRef.current?.requestId !== nextRequestId ||
lastSyncedPendingInputRef.current?.questionId !== nextQuestionId;
const textChangedExternally = promptRef.current !== nextCustomAnswer;

lastSyncedPendingInputRef.current = {
requestId: nextRequestId,
Copy link
Contributor

Choose a reason for hiding this comment

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

🟠 High components/ChatView.tsx:670

When advancing between pending user input questions, if the user typed a custom answer for the previous question, promptRef.current is not synchronized for the new question. The hasUserTypedInComposer check at line 677 returns early whenever promptRef.current.length > 0, regardless of whether questionChanged is true. This leaves promptRef.current stale for the new question, breaking @-mention resolution via applyPromptReplacement and the readComposerSnapshot fallback.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file apps/web/src/components/ChatView.tsx around line 670:

When advancing between pending user input questions, if the user typed a custom answer for the previous question, `promptRef.current` is not synchronized for the new question. The `hasUserTypedInComposer` check at line 677 returns early whenever `promptRef.current.length > 0`, regardless of whether `questionChanged` is true. This leaves `promptRef.current` stale for the new question, breaking @-mention resolution via `applyPromptReplacement` and the `readComposerSnapshot` fallback.

Evidence trail:
apps/web/src/components/ChatView.tsx lines 674-700 (REVIEWED_COMMIT): Shows the early return at lines 677-680 (`if (hasUserTypedInComposer) { return; }`) executing BEFORE the `questionChanged` check at line 683. The comment at line 683 states "For new questions (questionChanged), always sync" but this is unreachable when `promptRef.current.length > 0`. Line 2939 of `applyPromptReplacement` uses `promptRef.current` directly. Line 2989 of `readComposerSnapshot` falls back to `promptRef.current`.

Copy link
Author

Choose a reason for hiding this comment

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

fix it for me

questionId: nextQuestionId,
};

if (!questionChanged && !textChangedExternally) {
// Don't sync when there's user-typed content in the composer.
// This keeps the pending question input independent from the main composer draft.
// Previously, this would overwrite user-typed text when a planning question appeared.
const hasUserTypedInComposer = promptRef.current.length > 0;
if (hasUserTypedInComposer) {
return;
}

// For new questions (questionChanged), always sync to show the question's placeholder.
if (!questionChanged) {
// For same question: only sync if text actually changed externally.
const textChangedExternally = promptRef.current !== nextCustomAnswer;
if (!textChangedExternally) {
return;
}
}

promptRef.current = nextCustomAnswer;
const nextCursor = collapseExpandedComposerCursor(nextCustomAnswer, nextCustomAnswer.length);
setComposerCursor(nextCursor);
Expand Down