@@ -2,8 +2,9 @@ import React, { useCallback } from "react";
22import { RUNTIME_MODE , type RuntimeMode } from "@/common/types/runtime" ;
33import { Select } from "../Select" ;
44import { RuntimeIconSelector } from "../RuntimeIconSelector" ;
5- import { Loader2 } from "lucide-react" ;
5+ import { Loader2 , Wand2 } from "lucide-react" ;
66import { cn } from "@/common/lib/utils" ;
7+ import { Tooltip , TooltipWrapper } from "../Tooltip" ;
78
89interface CreationControlsProps {
910 branches : string [ ] ;
@@ -44,17 +45,30 @@ export function CreationControls(props: CreationControlsProps) {
4445 const showTrunkBranchSelector =
4546 props . branches . length > 0 && props . runtimeMode !== RUNTIME_MODE . LOCAL ;
4647
47- const { onNameChange } = props ;
48+ const { onNameChange, onAutoGenerateChange } = props ;
49+
4850 const handleNameChange = useCallback (
4951 ( e : React . ChangeEvent < HTMLInputElement > ) => {
5052 onNameChange ( e . target . value ) ;
5153 } ,
5254 [ onNameChange ]
5355 ) ;
5456
57+ // Clicking into the input disables auto-generation so user can edit
58+ const handleInputFocus = useCallback ( ( ) => {
59+ if ( props . autoGenerateName ) {
60+ onAutoGenerateChange ( false ) ;
61+ }
62+ } , [ props . autoGenerateName , onAutoGenerateChange ] ) ;
63+
64+ // Toggle auto-generation via wand button
65+ const handleWandClick = useCallback ( ( ) => {
66+ onAutoGenerateChange ( ! props . autoGenerateName ) ;
67+ } , [ props . autoGenerateName , onAutoGenerateChange ] ) ;
68+
5569 return (
5670 < div className = "flex flex-col gap-2" >
57- { /* First row: Workspace name with auto-generate checkbox */ }
71+ { /* First row: Workspace name with magic wand toggle */ }
5872 < div className = "flex items-center gap-2" data-component = "WorkspaceNameGroup" >
5973 < label htmlFor = "workspace-name" className = "text-muted text-xs whitespace-nowrap" >
6074 Name:
@@ -65,31 +79,43 @@ export function CreationControls(props: CreationControlsProps) {
6579 type = "text"
6680 value = { props . workspaceName }
6781 onChange = { handleNameChange }
82+ onFocus = { handleInputFocus }
6883 placeholder = { props . isGeneratingName ? "Generating..." : "workspace-name" }
69- disabled = { props . disabled || props . autoGenerateName }
84+ disabled = { props . disabled }
7085 className = { cn (
7186 "bg-separator text-foreground border-border-medium focus:border-accent h-6 w-full rounded border px-2 pr-6 text-xs focus:outline-none disabled:opacity-50" ,
7287 props . nameError && "border-red-500"
7388 ) }
7489 />
75- { /* Loading indicator when generating */ }
76- { props . isGeneratingName && (
77- < div className = "absolute top-1/2 right-1 -translate-y-1/2" >
78- < Loader2 className = "text-muted h-3 w-3 animate-spin" />
79- </ div >
80- ) }
90+ { /* Magic wand / loading indicator */ }
91+ < div className = "absolute top-1/2 right-1.5 -translate-y-1/2" >
92+ { props . isGeneratingName ? (
93+ < Loader2 className = "text-accent h-3.5 w-3.5 animate-spin" />
94+ ) : (
95+ < TooltipWrapper inline >
96+ < button
97+ type = "button"
98+ onClick = { handleWandClick }
99+ disabled = { props . disabled }
100+ className = "flex items-center justify-center disabled:opacity-50"
101+ aria-label = { props . autoGenerateName ? "Disable auto-naming" : "Enable auto-naming" }
102+ >
103+ < Wand2
104+ className = { cn (
105+ "h-3.5 w-3.5 transition-colors" ,
106+ props . autoGenerateName
107+ ? "text-accent"
108+ : "text-muted-foreground opacity-50 hover:opacity-75"
109+ ) }
110+ />
111+ </ button >
112+ < Tooltip className = "tooltip" align = "center" >
113+ { props . autoGenerateName ? "Auto-naming enabled" : "Click to enable auto-naming" }
114+ </ Tooltip >
115+ </ TooltipWrapper >
116+ ) }
117+ </ div >
81118 </ div >
82- { /* Auto-generate checkbox */ }
83- < label className = "text-muted flex h-6 items-center gap-1 text-[10px] whitespace-nowrap" >
84- < input
85- type = "checkbox"
86- checked = { props . autoGenerateName }
87- onChange = { ( e ) => props . onAutoGenerateChange ( e . target . checked ) }
88- disabled = { props . disabled }
89- className = "h-3 w-3"
90- />
91- auto
92- </ label >
93119 { /* Error display - inline */ }
94120 { props . nameError && < span className = "text-xs text-red-500" > { props . nameError } </ span > }
95121 </ div >
0 commit comments