Skip to content

Commit 1df8310

Browse files
authored
fix(agent-builder): don't clobber unsent composer text on prefill
A seeded prompt now only populates the composer when it's empty; if the user has already typed an unsent message, it's preserved (the composer is still focused). Keeps the prefill genuinely non-destructive. Addresses Greptile review feedback. Generated-By: PostHog Code Task-Id: fc2c5587-1464-4cb1-9116-0e7a34f70734
1 parent aa4d5e8 commit 1df8310

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/ui/src/features/agent-applications/components/AgentChatSurface.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ function Composer({
124124

125125
// Prefill (but don't send) when a new draft lands — a seeded prompt drops into
126126
// the composer for the user to review, edit, and send. Keyed on `token` so the
127-
// same prompt re-applies on a fresh trigger.
127+
// same prompt re-applies on a fresh trigger. Never clobber text the user has
128+
// already typed but not sent: if the composer is non-empty, leave it as-is
129+
// (still focusing it) so a seeded prompt is genuinely non-destructive.
128130
const lastDraftToken = useRef<number | null>(null);
129131
useEffect(() => {
130132
if (!draft || draft.token === lastDraftToken.current) return;
131133
lastDraftToken.current = draft.token;
132-
setText(draft.text);
134+
setText((current) => (current.trim() ? current : draft.text));
133135
textareaRef.current?.focus();
134136
}, [draft]);
135137

0 commit comments

Comments
 (0)