Repository navigation
Choose an agent setup from the new tab menu #34728
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
Merged
Merged
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
3fc5e5a
Unify dedicated agent launch choices and argument badges
brennanb2025 81573b9
Enable action model and effort menus with argument migration
brennanb2025 00c2827
Bound argument choice edit range processing
brennanb2025 560e1c3
Preserve independent action effort through launch and migration
brennanb2025 8bfb374
Preserve literal config arguments and explicit launch permissions
brennanb2025 758bcd9
Respect repository action argument groups and share launch controls
brennanb2025 6fab063
Remove duplicate action launch command coverage
brennanb2025 2149451
Add agent setup search and controls to the new tab menu
brennanb2025 04e0c44
Show inherited choices beside picker reset options
brennanb2025 ddc271d
Keep terminal Arguments separate from shared launch choices
brennanb2025 b6fc29e
Launch default agents from rows and select resolved setup values
brennanb2025 43c778e
Keep terminal settings available while Chat defaults load
brennanb2025 1bbf3bb
Reuse existing launch setup controls and Arguments editor
brennanb2025 8406e91
Unify Source Control action choices and repository overrides
brennanb2025 052570c
Merge main into Source Control action choices
brennanb2025 00c0236
Use precise types in action choice contracts
brennanb2025 1e4cd82
Consolidate action choice test imports
brennanb2025 0abf019
Correct action choice types and integration test boundaries
brennanb2025 c88346f
Complete prepared terminal test result contract
brennanb2025 5b22618
Align action integration expectations with canonical choices
brennanb2025 cdb82bb
Keep launch defaults authoritative and couple CLI controls
brennanb2025 a3973db
Assert production Chat preparation runs in launch contract
brennanb2025 c93efee
Merge current stack base before final verification
brennanb2025 4612244
Merge main to resolve the final action launch test conflict
brennanb2025 b08155d
Preserve alternate Chat launches and bound picker argument derivation
brennanb2025 4beeadc
Merge stack base to resolve translation conflicts
brennanb2025 f2f2b18
Publish committed picker priority and satisfy control contracts
brennanb2025 d0116c4
test(mobile): type the file preview retry test helpers so the test ty…
brennanb2025 cea5fd2
Merge exact stack base inherited Mobile test typing repair
brennanb2025 9c1d837
fix: keep picker integration tests within compiler boundaries
brennanb2025 749bad4
fix: revalidate completed picker defaults on reopen
brennanb2025 78c3cd8
test: give exported launch fixture mocks portable signatures
brennanb2025 c8723b2
fix: keep fallback launch carriers out of action mode controls
brennanb2025 95febff
Preserve Fast argument badges outside dialog mode controls
brennanb2025 f030be4
Project existing Fast carriers independently of model capabilities
brennanb2025 68a7802
Keep setup focus during launch row pointer transitions
brennanb2025 b47be50
Allow declared tier choices without an inherited selection
brennanb2025 56ab342
fix: place agent setup beside the launch menu
brennanb2025 fff264a
Commit edited action arguments before planning and launch
brennanb2025 dd1f286
Merge main after the final action raw-edit repair
brennanb2025 8562de3
Name portable Source Control dialog fixture results
brennanb2025 6541033
Keep agent setup contained and preserve known argument policy
brennanb2025 3320861
Merge authorized stack base for inherited CI repairs
brennanb2025 1918508
Merge authorized stack fixture type correction
brennanb2025 cd1ab56
Use checked style properties in popup geometry fixture
brennanb2025 3571c9c
Keep setup scrolling inside a plain content wrapper
brennanb2025 2e676b4
Merge main after stack base squash and retarget
brennanb2025 40aae06
fix(agent-picker): match the setup panel to the approved layout
brennanb2025 efc43c0
fix(agent-picker): use primitive-owned spacing and update launch labe…
brennanb2025 50324a4
fix(agent-picker): add panel labels to localization catalogs
brennanb2025 0e7c036
Keep one launch setup open and align picker spacing
brennanb2025 de3d45e
Tighten launch model rows and clarify terminal hint
brennanb2025 fef2ff5
Keep keyboard focus in replacement launch setup
brennanb2025 fbca0a6
fix(tab-bar): keep a long agent setup result's chevron inside the menu
brennanb2025 a5e2894
Merge origin/main to resolve tab menu test conflicts
brennanb2025 881c7a8
test(agent-picker): wait for outgoing focus cleanup event
brennanb2025 e8b1456
Show empty model search feedback and name setup dialog
brennanb2025 152e55c
test: register selection catalog in launch guard fixture
brennanb2025 956e0f9
Merge origin/main and reuse shared permission menu items
brennanb2025 1a7523c
fix(agent-picker): retain setup drafts and contain Arguments
brennanb2025 9d1cd67
fix(agent-picker): retain authored setup route after alternate launch
brennanb2025 5b39fae
Merge origin/main for editor static-check repair
brennanb2025 3d85b56
style(agent-picker): use a ghost setup chevron with divider
brennanb2025 b966f23
style(agent-picker): apply muted color to setup glyph
brennanb2025 a229405
test(agent-picker): declare retained catalog default
brennanb2025 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
818 changes: 818 additions & 0 deletions
818
src/renderer/src/components/agent/AgentLaunchPickerMenu.test.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
222 changes: 222 additions & 0 deletions
222
src/renderer/src/components/agent/AgentLaunchPickerMenu.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 |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
| import { useId, useRef, useState, type PointerEvent } from 'react' | ||
| import { Input } from '@/components/ui/input' | ||
| import { DropdownMenuItem, DropdownMenuShortcut } from '@/components/ui/dropdown-menu' | ||
| import { AgentIcon } from '@/lib/agent-catalog' | ||
| import { useOptionalShortcutLabel } from '@/hooks/useShortcutLabel' | ||
| import { translate } from '@/i18n/i18n' | ||
| import { AgentLaunchSetupButton } from './AgentLaunchSetupButton' | ||
| import type { NewTabAgentMenuModel } from '../tab-bar/use-new-tab-agent-menu-rows' | ||
| import { chatUnavailableLabel } from '../tab-bar/tab-agent-row-presentation' | ||
| import type { NewTabAgentMenuRow } from '../../../../shared/agent-launch-picker-rows' | ||
| import { | ||
| searchAgentPickerSetups, | ||
| type AgentPickerDraft, | ||
| type AgentPickerEntry, | ||
| type AgentPickerSurface | ||
| } from '../../../../shared/agent-launch-picker' | ||
|
|
||
| export function pickerLaunchRow( | ||
| entry: AgentPickerEntry, | ||
| surface: AgentPickerSurface | ||
| ): NewTabAgentMenuRow { | ||
| return { | ||
| agent: entry.agent, | ||
| kind: surface === 'chat' ? 'chat' : 'cli', | ||
| executionHostId: entry.rows[0]?.executionHostId | ||
| } | ||
| } | ||
|
|
||
| type Launch = (row: NewTabAgentMenuRow, draft?: AgentPickerDraft, entry?: AgentPickerEntry) => void | ||
|
|
||
| function keepSetupFocus(event: PointerEvent<HTMLDivElement>) { | ||
| // Radix row hover must not steal focus from the row's portaled setup or its nested controls. | ||
| if (event.currentTarget.querySelector('[data-slot="popover-trigger"][aria-expanded="true"]')) { | ||
| event.preventDefault() | ||
| } | ||
| } | ||
|
|
||
| export function AgentLaunchPickerMenu({ | ||
| model, | ||
| disabled, | ||
| runLaunch, | ||
| entries, | ||
| hideSearch, | ||
| onSelectAgent | ||
| }: { | ||
| model: NewTabAgentMenuModel | ||
| disabled?: boolean | ||
| runLaunch: Launch | ||
| entries: AgentPickerEntry[] | ||
| hideSearch?: boolean | ||
| onSelectAgent?: (agent: AgentPickerEntry['agent']) => void | ||
| }) { | ||
| const [query, setQuery] = useState('') | ||
| const [openSetup, setOpenSetup] = useState<string | null>(null) | ||
| const root = useRef<HTMLDivElement>(null) | ||
| const shortcut = useOptionalShortcutLabel('tab.newAgent') | ||
| const setups = searchAgentPickerSetups(entries, query) | ||
| const words = query.trim().toLowerCase().split(/\s+/).filter(Boolean) | ||
| const visible = entries.filter((entry) => | ||
| words.every((word) => `${entry.agent} ${entry.label}`.toLowerCase().includes(word)) | ||
| ) | ||
| return ( | ||
| <div ref={root} data-agent-launch-picker="true"> | ||
| {!hideSearch ? ( | ||
| <div className="p-1"> | ||
| <Input | ||
| value={query} | ||
| autoFocus | ||
| placeholder={translate('agentPicker.search', 'Search agents and setups…')} | ||
| onChange={(event) => setQuery(event.target.value)} | ||
| onKeyDown={(event) => { | ||
| if (event.key === 'Escape') { | ||
| return | ||
| } | ||
| event.stopPropagation() | ||
| if (event.key === 'Enter' || event.key === 'ArrowDown') { | ||
| event.preventDefault() | ||
| const first = root.current?.querySelector<HTMLElement>( | ||
| '[role="menuitem"]:not([data-disabled])' | ||
| ) | ||
| if (event.key === 'Enter') { | ||
| first?.click() | ||
| } else { | ||
| first?.focus() | ||
| } | ||
| } | ||
| }} | ||
| /> | ||
| </div> | ||
| ) : null} | ||
| {setups.map((setup) => ( | ||
| <AgentPickerMenuRow | ||
| key={`${setup.entry.agent}:${setup.model.id}:${setup.choices.options?.effort ?? ''}`} | ||
| entry={setup.entry} | ||
| openSetup={openSetup} | ||
| onSetupOpenChange={setOpenSetup} | ||
| label={setup.label} | ||
| initial={{ | ||
| agent: setup.entry.agent, | ||
| surface: setup.entry.defaultSurface, | ||
| choices: setup.choices | ||
| }} | ||
| onSelectAgent={onSelectAgent} | ||
| disabled={disabled} | ||
| runLaunch={runLaunch} | ||
| /> | ||
| ))} | ||
| {visible.map((entry) => ( | ||
| <AgentPickerMenuRow | ||
| key={entry.agent} | ||
| entry={entry} | ||
| openSetup={openSetup} | ||
| onSetupOpenChange={setOpenSetup} | ||
| disabled={disabled} | ||
| runLaunch={runLaunch} | ||
| onSelectAgent={onSelectAgent} | ||
| shortcut={ | ||
| model.state === 'settled' && model.defaultTuiAgent === entry.agent | ||
| ? (shortcut ?? undefined) | ||
| : undefined | ||
| } | ||
| /> | ||
| ))} | ||
| {!visible.length && !setups.length ? ( | ||
| <DropdownMenuItem disabled> | ||
| {translate( | ||
| 'auto.components.agent.AgentCombobox.579c768bde', | ||
| 'No agents match your search.' | ||
| )} | ||
| </DropdownMenuItem> | ||
| ) : null} | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| function AgentPickerMenuRow({ | ||
| entry, | ||
| openSetup, | ||
| onSetupOpenChange, | ||
| label = entry.label, | ||
| initial, | ||
| disabled, | ||
| runLaunch, | ||
| shortcut, | ||
| onSelectAgent | ||
| }: { | ||
| entry: AgentPickerEntry | ||
| openSetup: string | null | ||
| onSetupOpenChange: (id: string | null) => void | ||
| label?: string | ||
| initial?: AgentPickerDraft | ||
| disabled?: boolean | ||
| runLaunch: Launch | ||
| shortcut?: string | ||
| onSelectAgent?: (agent: AgentPickerEntry['agent']) => void | ||
| }) { | ||
| const setupId = useId() | ||
| const item = useRef<HTMLDivElement>(null) | ||
| const configured = useRef<AgentPickerDraft | undefined>(undefined) | ||
| const unavailable = entry.rows.find((row) => row.kind === 'chat-unavailable') | ||
| return ( | ||
| <AgentLaunchSetupButton | ||
| entry={entry} | ||
| initial={initial} | ||
| open={openSetup === setupId} | ||
| replacedByAnotherSetup={openSetup !== null && openSetup !== setupId} | ||
| disabled={disabled} | ||
| onOpenChange={(next) => { | ||
| onSetupOpenChange(next ? setupId : null) | ||
| if (next) { | ||
| onSelectAgent?.(entry.agent) | ||
| } | ||
| }} | ||
| onUse={(draft) => { | ||
| configured.current = draft | ||
| item.current?.click() | ||
| }} | ||
| renderAnchor={(trigger) => ( | ||
| <DropdownMenuItem | ||
| ref={item} | ||
| variant="launch" | ||
| disabled={disabled || !entry.surfaces.length} | ||
| onSelect={() => { | ||
| const draft = configured.current ?? initial | ||
| configured.current = undefined | ||
| const surface = draft?.surface ?? entry.defaultSurface | ||
| const row = draft | ||
| ? pickerLaunchRow(entry, surface) | ||
| : (entry.rows.find((row) => | ||
| surface === 'chat' | ||
| ? row.kind === 'chat' | ||
| : row.kind === 'terminal' || row.kind === 'cli' | ||
| ) ?? pickerLaunchRow(entry, surface)) | ||
| if (draft) { | ||
| runLaunch(row, draft, entry) | ||
| } else { | ||
| runLaunch(row, undefined) | ||
| } | ||
| }} | ||
| onKeyDown={(event) => { | ||
| if (event.key === 'ArrowRight') { | ||
| event.preventDefault() | ||
| item.current?.querySelector<HTMLButtonElement>('button')?.focus() | ||
| } | ||
| }} | ||
| onPointerMove={keepSetupFocus} | ||
| onPointerLeave={keepSetupFocus} | ||
| > | ||
| <AgentIcon agent={entry.agent} size={14} /> | ||
| <span className="flex-1">{label}</span> | ||
| {shortcut ? <DropdownMenuShortcut>{shortcut}</DropdownMenuShortcut> : null} | ||
| {unavailable?.kind === 'chat-unavailable' && !entry.surfaces.includes('chat') ? ( | ||
| <span className="text-xs text-muted-foreground"> | ||
| {chatUnavailableLabel(unavailable.reason)} | ||
| </span> | ||
| ) : null} | ||
| {trigger} | ||
| </DropdownMenuItem> | ||
| )} | ||
| /> | ||
| ) | ||
| } | ||
173 changes: 173 additions & 0 deletions
173
src/renderer/src/components/agent/AgentLaunchSetupButton.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 |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| import { useLayoutEffect, useRef, useState, type KeyboardEvent, type ReactElement } from 'react' | ||
| import { flushSync } from 'react-dom' | ||
| import { ChevronRight } from 'lucide-react' | ||
| import { Button } from '@/components/ui/button' | ||
| import { Separator } from '@/components/ui/separator' | ||
| import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from '@/components/ui/popover' | ||
| import { translate } from '@/i18n/i18n' | ||
| import { AgentLaunchSetupPanel } from './AgentLaunchSetupPanel' | ||
| import type { AgentPickerDraft, AgentPickerEntry } from '../../../../shared/agent-launch-picker' | ||
|
|
||
| // The menu and its popovers unmount on dismissal; authored setups live for this app session. | ||
| const sessionDrafts = new Map<string, AgentPickerDraft>() | ||
|
|
||
| function setupKeyDown(event: KeyboardEvent<HTMLButtonElement>) { | ||
| if (event.key === 'Enter' || event.key === ' ') { | ||
| event.preventDefault() | ||
| event.stopPropagation() | ||
| event.currentTarget.click() | ||
| } else if (['ArrowLeft', 'ArrowUp', 'ArrowDown', 'Home', 'End'].includes(event.key)) { | ||
| const row = event.currentTarget.closest<HTMLElement>('[role="menuitem"]') | ||
| if (row) { | ||
| event.preventDefault() | ||
| event.stopPropagation() | ||
| row.focus() | ||
| if (event.key !== 'ArrowLeft') { | ||
| row.dispatchEvent(new window.KeyboardEvent('keydown', { key: event.key, bubbles: true })) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export function AgentLaunchSetupButton({ | ||
| entry, | ||
| initial, | ||
| renderAnchor, | ||
| disabled, | ||
| open: controlledOpen, | ||
| replacedByAnotherSetup = false, | ||
| onOpenChange, | ||
| onUse | ||
| }: { | ||
| entry: AgentPickerEntry | ||
| initial?: AgentPickerDraft | ||
| renderAnchor?: (trigger: ReactElement) => ReactElement | ||
| disabled?: boolean | ||
| open?: boolean | ||
| replacedByAnotherSetup?: boolean | ||
| onOpenChange?: (open: boolean) => void | ||
| onUse: (draft: AgentPickerDraft) => void | ||
| }) { | ||
| const draftKey = JSON.stringify([entry.ownerKey, entry.agent, initial]) | ||
| const [localOpen, setOpen] = useState(false) | ||
| const open = controlledOpen ?? localOpen | ||
| const closeFocus = useRef({ open, restore: true }) | ||
| useLayoutEffect(() => { | ||
| if (closeFocus.current.open && !open) { | ||
| // Preserve the close cause until Radix's deferred unmount autofocus runs. | ||
| closeFocus.current.restore = !replacedByAnotherSetup | ||
| } | ||
| closeFocus.current.open = open | ||
| }, [open, replacedByAnotherSetup]) | ||
| const [placement, setPlacement] = useState<'right' | 'bottom'>('right') | ||
| const content = useRef<HTMLDivElement>(null) | ||
| const anchor = useRef<HTMLDivElement>(null) | ||
| useLayoutEffect(() => { | ||
| if (!open) { | ||
| return | ||
| } | ||
| let frame = 0 | ||
| const measure = () => { | ||
| cancelAnimationFrame(frame) | ||
| // Let Radix publish collision space after the external resize and horizontal placement. | ||
| frame = requestAnimationFrame(() => { | ||
| flushSync(() => setPlacement('right')) | ||
| frame = requestAnimationFrame(() => { | ||
| if (!content.current) { | ||
| return | ||
| } | ||
| const style = window.getComputedStyle(content.current) | ||
| const available = Number.parseFloat( | ||
| style.getPropertyValue('--radix-popover-content-available-width') | ||
| ) | ||
| if (available < Number.parseFloat(style.minWidth)) { | ||
| setPlacement('bottom') | ||
| } | ||
| }) | ||
| }) | ||
| } | ||
| const observer = new ResizeObserver(measure) | ||
| observer.observe(document.documentElement) | ||
| if (anchor.current) { | ||
| observer.observe(anchor.current) | ||
| } | ||
| measure() | ||
| return () => { | ||
| observer.disconnect() | ||
| cancelAnimationFrame(frame) | ||
| } | ||
| }, [open]) | ||
| const changeOpen = (next: boolean) => { | ||
| if (next) { | ||
| setPlacement('right') | ||
| } | ||
| if (controlledOpen === undefined) { | ||
| setOpen(next) | ||
| } | ||
| onOpenChange?.(next) | ||
| } | ||
| const trigger = ( | ||
| <div className="flex shrink-0 items-center gap-1"> | ||
| <Separator orientation="vertical" className="data-[orientation=vertical]:h-4" /> | ||
| <PopoverTrigger asChild> | ||
| <Button | ||
| type="button" | ||
| variant="ghost" | ||
| size="icon-xs" | ||
| disabled={disabled} | ||
| aria-label={translate('agentPicker.configure', 'Configure {{agent}}', { | ||
| agent: entry.label | ||
| })} | ||
| onClick={(event) => event.stopPropagation()} | ||
| onKeyDown={setupKeyDown} | ||
| > | ||
| <ChevronRight className="text-muted-foreground" /> | ||
| </Button> | ||
| </PopoverTrigger> | ||
| </div> | ||
| ) | ||
| return ( | ||
| <Popover open={open} onOpenChange={changeOpen}> | ||
| {renderAnchor ? ( | ||
| <PopoverAnchor asChild ref={anchor}> | ||
| {renderAnchor(trigger)} | ||
| </PopoverAnchor> | ||
| ) : ( | ||
| trigger | ||
| )} | ||
| <PopoverContent | ||
| ref={content} | ||
| side={placement} | ||
| sticky="always" | ||
| align="start" | ||
| sideOffset={6} | ||
| aria-label={translate('agentPicker.configure', 'Configure {{agent}}', { | ||
| agent: entry.label | ||
| })} | ||
| className="flex w-104 min-w-64 max-w-(--radix-popover-content-available-width) max-h-(--radix-popover-content-available-height) flex-col" | ||
| onClick={(event) => event.stopPropagation()} | ||
| // Hovering another menu row moves focus there; only a click outside or Escape closes the panel. | ||
| onFocusOutside={(event) => event.preventDefault()} | ||
| onCloseAutoFocus={(event) => { | ||
| if (!closeFocus.current.restore) { | ||
| event.preventDefault() | ||
| } | ||
| }} | ||
| > | ||
| <div className="min-h-0 overflow-y-auto scrollbar-sleek"> | ||
| <AgentLaunchSetupPanel | ||
| key={draftKey} | ||
| entry={entry} | ||
| initial={sessionDrafts.get(draftKey) ?? initial} | ||
| disabled={disabled} | ||
| onDraftChange={(draft) => sessionDrafts.set(draftKey, draft)} | ||
| onUse={(draft) => { | ||
| onUse(draft) | ||
| changeOpen(false) | ||
| }} | ||
| /> | ||
| </div> | ||
| </PopoverContent> | ||
| </Popover> | ||
| ) | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.