-
Notifications
You must be signed in to change notification settings - Fork 44
feat(agents): applications landing polish + chat dedup fix #2742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dmarticus
wants to merge
3
commits into
posthog-code/m3a-final
Choose a base branch
from
dylan/agent-builder
base: posthog-code/m3a-final
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+278
−172
Open
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
163 changes: 101 additions & 62 deletions
163
packages/ui/src/features/agent-applications/agent-builder/AgentBuilderHeaderControls.tsx
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 |
|---|---|---|
| @@ -1,77 +1,116 @@ | ||
| import { NavigationArrowIcon, SparkleIcon } from "@phosphor-icons/react"; | ||
| import { agentChatStore } from "@posthog/core/agent-chat/agentChatStore"; | ||
| import { SidebarSimpleIcon, SparkleIcon } from "@phosphor-icons/react"; | ||
| import { | ||
| Button, | ||
| Tooltip, | ||
| TooltipContent, | ||
| TooltipProvider, | ||
| TooltipTrigger, | ||
| } from "@posthog/quill"; | ||
| import { useFeatureFlag } from "@posthog/ui/features/feature-flags/useFeatureFlag"; | ||
| import { Button } from "@posthog/ui/primitives/Button"; | ||
| import { Badge, Flex, Tooltip } from "@radix-ui/themes"; | ||
| import { useStore } from "zustand"; | ||
| import { Flex } from "@radix-ui/themes"; | ||
| import { AGENT_PLATFORM_FLAG } from "../featureFlag"; | ||
| import { headerActionForPage } from "./agentBuilderActions"; | ||
| import { | ||
| AGENT_BUILDER_CHAT_ID, | ||
| type AgentBuilderPageContext, | ||
| useAgentBuilderStore, | ||
| } from "./agentBuilderStore"; | ||
| import { EditWithAIButton } from "./EditWithAIButton"; | ||
| import { useAgentBuilderStore } from "./agentBuilderStore"; | ||
|
|
||
| /** | ||
| * The agents-header control cluster — identical across every agents view. Driven | ||
| * by the view's `context`, it renders: | ||
| * - a "Following" indicator while the agent builder is mid-turn and follow mode | ||
| * is on (so it's clear the builder is steering navigation), | ||
| * - a contextual AI button (New agent / Explain this session / …), | ||
| * - a "show" button that opens the dock, ONLY when it's hidden (the inverse of | ||
| * the hide button inside the dock header). | ||
| * All buttons are small. Renders nothing unless the `agent-platform` flag is on. | ||
| * The agents-header control cluster — identical across every agents view. | ||
| * | ||
| * One split button is the single entry point into the Agent Builder dock: | ||
| * - the primary segment is the contextual "edit with AI" action for the view | ||
| * you're on (New agent / Edit configuration / Explain this session / …) — it | ||
| * opens the dock and seeds the matching prompt, | ||
| * - the trailing segment just opens/closes the dock without seeding, so you | ||
| * can peek at or dismiss the existing conversation. | ||
| * The two were previously near-identical gold buttons; fusing them keeps both | ||
| * affordances but with one sparkle (the AI identity) and one neutral toggle. | ||
| * Views with no obvious action (Scouts) collapse to the lone open/close toggle. | ||
| * Renders nothing unless the `agent-platform` flag is on. | ||
| */ | ||
| export function AgentBuilderHeaderControls({ | ||
| context, | ||
| }: { | ||
| context: AgentBuilderPageContext; | ||
| }) { | ||
| export function AgentBuilderHeaderControls() { | ||
| const enabled = useFeatureFlag(AGENT_PLATFORM_FLAG); | ||
| const visible = useAgentBuilderStore((s) => s.visible); | ||
| const setVisible = useAgentBuilderStore((s) => s.setVisible); | ||
| const followMode = useAgentBuilderStore((s) => s.followMode); | ||
| const status = useStore( | ||
| agentChatStore, | ||
| (s) => s.chats[AGENT_BUILDER_CHAT_ID]?.status, | ||
| ); | ||
| const page = useAgentBuilderStore((s) => s.page); | ||
| const toggleVisible = useAgentBuilderStore((s) => s.toggleVisible); | ||
| const startAgentBuilder = useAgentBuilderStore((s) => s.startAgentBuilder); | ||
|
|
||
| if (!enabled) return null; | ||
|
|
||
| const running = status === "streaming" || status === "starting"; | ||
| const action = headerActionForPage(context); | ||
| const action = headerActionForPage(page); | ||
| const toggleTip = visible | ||
| ? "Hide the agent builder (⌘⇧I)" | ||
| : "Open the agent builder (⌘⇧I)"; | ||
|
|
||
| return ( | ||
| <Flex align="center" gap="2" className="shrink-0"> | ||
| {running && followMode ? ( | ||
| <Tooltip content="The agent builder is navigating this view"> | ||
| <Badge color="purple" variant="soft" size="1"> | ||
| <NavigationArrowIcon size={11} weight="fill" /> | ||
| Following | ||
| </Badge> | ||
| </Tooltip> | ||
| ) : null} | ||
| {action ? ( | ||
| <EditWithAIButton | ||
| prompt={action.prompt} | ||
| agentSlug={action.agentSlug} | ||
| label={action.label} | ||
| size="1" | ||
| /> | ||
| ) : null} | ||
| {!visible ? ( | ||
| <Tooltip content="Open the agent builder (⌘⇧I)"> | ||
| <Button | ||
| variant="outline" | ||
| size="1" | ||
| onClick={() => setVisible(true)} | ||
| aria-label="Open agent builder" | ||
| > | ||
| <SparkleIcon size={14} weight="fill" /> | ||
| </Button> | ||
| </Tooltip> | ||
| ) : null} | ||
| </Flex> | ||
| <TooltipProvider delay={500}> | ||
| <Flex align="center" gap="2" className="shrink-0"> | ||
| {action ? ( | ||
| <div className="flex items-center"> | ||
| <Tooltip> | ||
| <TooltipTrigger | ||
| render={ | ||
| <Button | ||
| variant="outline" | ||
| size="sm" | ||
| className="rounded-s-[3px] rounded-e-none" | ||
| onClick={() => | ||
| startAgentBuilder(action.prompt, action.agentSlug) | ||
| } | ||
| > | ||
| <SparkleIcon | ||
| size={14} | ||
| weight="fill" | ||
| className="text-(--accent-9)" | ||
| /> | ||
| {action.label} | ||
| </Button> | ||
| } | ||
| /> | ||
| <TooltipContent side="top"> | ||
| Open the agent builder and start here | ||
| </TooltipContent> | ||
| </Tooltip> | ||
| <Tooltip> | ||
| <TooltipTrigger | ||
| render={ | ||
| <Button | ||
| variant="outline" | ||
| size="icon-sm" | ||
| className="rounded-s-none rounded-e-[3px] border-s-0" | ||
| aria-label={toggleTip} | ||
| onClick={toggleVisible} | ||
| > | ||
| <SidebarSimpleIcon | ||
| size={14} | ||
| weight={visible ? "fill" : "regular"} | ||
| /> | ||
| </Button> | ||
| } | ||
| /> | ||
| <TooltipContent side="top">{toggleTip}</TooltipContent> | ||
| </Tooltip> | ||
| </div> | ||
| ) : ( | ||
| <Tooltip> | ||
| <TooltipTrigger | ||
| render={ | ||
| <Button | ||
| variant="outline" | ||
| size="icon-sm" | ||
| aria-label={toggleTip} | ||
| onClick={toggleVisible} | ||
| > | ||
| <SparkleIcon | ||
| size={14} | ||
| weight="fill" | ||
| className="text-(--accent-9)" | ||
| /> | ||
| </Button> | ||
| } | ||
| /> | ||
| <TooltipContent side="top">{toggleTip}</TooltipContent> | ||
| </Tooltip> | ||
| )} | ||
| </Flex> | ||
| </TooltipProvider> | ||
| ); | ||
| } |
35 changes: 0 additions & 35 deletions
35
packages/ui/src/features/agent-applications/agent-builder/EditWithAIButton.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
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
Oops, something went wrong.
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.
it.eachtable is more concise and makes adding more whitespace variants (e.g., leading spaces, both ends) trivial.Context Used: Do not attempt to comment on incorrect alphabetica... (source)
Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!