This repository was archived by the owner on Aug 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
fix(agent-builder): don't auto-send prompt when opening the dock #3486
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 0 additions & 58 deletions
58
packages/ui/src/features/agent-applications/agent-builder/AgentBuilderSeedDialog.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,13 @@ import { | |
| import type { AcpMessage } from "@posthog/shared"; | ||
| import { ThreadView } from "@posthog/ui/features/sessions/components/ThreadView"; | ||
| import { Flex, Text, Tooltip } from "@radix-ui/themes"; | ||
| import { type KeyboardEvent, type ReactNode, useState } from "react"; | ||
| import { | ||
| type KeyboardEvent, | ||
| type ReactNode, | ||
| useEffect, | ||
| useRef, | ||
| useState, | ||
| } from "react"; | ||
|
|
||
| /** | ||
| * The conversation + composer half of a deployed-agent chat, shared by the | ||
|
|
@@ -28,6 +34,7 @@ export function AgentChatSurface({ | |
| composerDisabledReason, | ||
| scrollX = true, | ||
| placeholder = "Message this agent…", | ||
| draft, | ||
| onSend, | ||
| onCancel, | ||
| }: { | ||
|
|
@@ -50,6 +57,10 @@ export function AgentChatSurface({ | |
| scrollX?: boolean; | ||
| /** Composer placeholder. */ | ||
| placeholder?: string; | ||
| /** When set, prefills the composer with `text` (without sending). Bump | ||
| * `token` each time a new draft should repopulate the input — the same text | ||
| * re-applies on a fresh token so re-triggering a seeded prompt works. */ | ||
| draft?: { text: string; token: number }; | ||
| onSend: (text: string) => void; | ||
| onCancel: () => void; | ||
| }) { | ||
|
|
@@ -84,6 +95,7 @@ export function AgentChatSurface({ | |
| isStreaming={isStreaming} | ||
| placeholder={placeholder} | ||
| disabledReason={composerDisabledReason} | ||
| draft={draft} | ||
| onSend={onSend} | ||
| onCancel={onCancel} | ||
| /> | ||
|
|
@@ -95,17 +107,33 @@ function Composer({ | |
| isStreaming, | ||
| placeholder, | ||
| disabledReason, | ||
| draft, | ||
| onSend, | ||
| onCancel, | ||
| }: { | ||
| isStreaming: boolean; | ||
| placeholder: string; | ||
| disabledReason?: string; | ||
| draft?: { text: string; token: number }; | ||
| onSend: (text: string) => void; | ||
| onCancel: () => void; | ||
| }) { | ||
| const [text, setText] = useState(""); | ||
| const parked = !!disabledReason; | ||
| const textareaRef = useRef<HTMLTextAreaElement>(null); | ||
|
|
||
| // Prefill (but don't send) when a new draft lands — a seeded prompt drops into | ||
| // the composer for the user to review, edit, and send. Keyed on `token` so the | ||
| // same prompt re-applies on a fresh trigger. Never clobber text the user has | ||
| // 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(() => { | ||
| if (!draft || draft.token === lastDraftToken.current) return; | ||
| lastDraftToken.current = draft.token; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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((current) => (current.trim() ? current : draft.text)); | ||
| textareaRef.current?.focus(); | ||
| }, [draft]); | ||
|
|
||
| function submit() { | ||
| if (parked) return; | ||
|
|
@@ -132,6 +160,7 @@ function Composer({ | |
| <div className="shrink-0 px-3 pt-2 pb-3"> | ||
| <InputGroup className="h-auto cursor-text bg-card focus-within:ring-1 focus-within:ring-purple-9"> | ||
| <InputGroupTextarea | ||
| ref={textareaRef} | ||
| value={text} | ||
| onChange={(e) => setText(e.target.value)} | ||
| onKeyDown={onKeyDown} | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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