fix(agent-builder): don't auto-send prompt when opening the dock#3486
Conversation
Opening the Agent Builder dock via a contextual action ("New agent",
"Edit configuration", etc.) used to auto-send the seeded prompt, so the
sidebar started a chat on its own. Instead, prefill the composer with the
seeded prompt and let the user review and hit send.
Since prefilling is non-destructive, the start-fresh-vs-continue
confirmation dialog is no longer needed and is removed.
Generated-By: PostHog Code
Task-Id: fc2c5587-1464-4cb1-9116-0e7a34f70734
|
😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details. |
|
React Doctor found 2 issues in 2 files · 2 warnings. 2 warnings
Reviewed by React Doctor for commit |
|
Reviews (1): Last reviewed commit: "fix(agent-builder): prefill seeded promp..." | Re-trigger Greptile |
| const lastDraftToken = useRef<number | null>(null); | ||
| useEffect(() => { | ||
| if (!draft || draft.token === lastDraftToken.current) return; | ||
| lastDraftToken.current = draft.token; |
There was a problem hiding this comment.
Seed Replaces Unsent Composer Text
When the dock is already open and the user has typed an unsent message, clicking a contextual header action creates a new draft token and this unconditional setText replaces their message with the canned prompt. The original text is silently lost, despite the new flow being described as non-destructive.
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
|
👋 Visual changes detected for this PR. Review and approve in PostHog Visual Review If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix. |
| // already typed but not sent: if the composer is non-empty, leave it as-is | ||
| // (still focusing it) so a seeded prompt is genuinely non-destructive. | ||
| const lastDraftToken = useRef<number | null>(null); | ||
| useEffect(() => { |
There was a problem hiding this comment.
I don't have context on how vigilant this project is against useEffect, but I do wonder if there's a tidier means of solving it
Problem
In the agent-platform Agent Builder UI, the "new agent" flow started with an automatic prompt: clicking the contextual header action (e.g. "New agent") opened the dock and immediately fired a canned prompt into the chat. Opening the sidebar shouldn't trigger a chat on its own — it should present an empty chat.
Changes
AgentBuilderSeedDialog).How did you test this?
pnpm --filter @posthog/ui typecheck— cleanpnpm biome linton the changed files — cleanpnpm --filter @posthog/ui test— 1659 tests passAutomatic notifications
Created with PostHog from a Slack thread