Skip to content

fix(agent-builder): don't auto-send prompt when opening the dock#3486

Merged
trunk-io[bot] merged 3 commits into
mainfrom
posthog-code/agent-builder-no-autosend
Jul 16, 2026
Merged

fix(agent-builder): don't auto-send prompt when opening the dock#3486
trunk-io[bot] merged 3 commits into
mainfrom
posthog-code/agent-builder-no-autosend

Conversation

@dmarticus

Copy link
Copy Markdown
Contributor

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

  • The seeded prompt now prefills the composer instead of being auto-sent. The user reviews it (and can edit it) and hits send. This keeps the contextual header buttons as a one-click "auto prompt" affordance without starting a conversation by itself.
  • Because prefilling is non-destructive, the start-fresh-vs-continue confirmation dialog is no longer needed and has been removed (AgentBuilderSeedDialog).
  • The empty-state suggestion chips are unchanged — they still send on an explicit click.

How did you test this?

  • pnpm --filter @posthog/ui typecheck — clean
  • pnpm biome lint on the changed files — clean
  • pnpm --filter @posthog/ui test — 1659 tests pass

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog from a Slack thread

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
@trunk-io

trunk-io Bot commented Jul 15, 2026

Copy link
Copy Markdown

😎 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.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

React Doctor found 2 issues in 2 files · 2 warnings.

2 warnings

src/features/agent-applications/agent-builder/AgentBuilderDock.tsx

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

Reviewed by React Doctor for commit 1d1ef19.

@dmarticus
dmarticus marked this pull request as ready for review July 16, 2026 17:44
@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 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
@posthog

posthog Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

👋 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(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@daniloc daniloc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yerrr

@trunk-io
trunk-io Bot merged commit c505944 into main Jul 16, 2026
31 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/agent-builder-no-autosend branch July 16, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants