@@ -37,7 +37,7 @@ export function FeatureTabGroup({
3737 const [ , setView ] = useAtom ( viewAtom ) ;
3838 const [ hasLogo , setHasLogo ] = useState ( true ) ; // Default true to hide name initially
3939 const [ showCreateDialog , setShowCreateDialog ] = useState ( false ) ;
40- const [ defaultFeatureName , setDefaultFeatureName ] = useState ( "" ) ;
40+ const [ nextSeq , setNextSeq ] = useState ( 0 ) ;
4141
4242 useEffect ( ( ) => {
4343 invoke < string | null > ( "get_project_logo" , { projectPath : project . path } )
@@ -139,8 +139,8 @@ export function FeatureTabGroup({
139139 e ?. stopPropagation ( ) ;
140140 if ( ! workspace ) return ;
141141
142- const counter = ( project . feature_counter ?? 0 ) + 1 ;
143- setDefaultFeatureName ( `# ${ counter } ` ) ;
142+ // Use global counter
143+ setNextSeq ( ( workspace . feature_counter ?? 0 ) + 1 ) ;
144144 setShowCreateDialog ( true ) ;
145145 } ;
146146
@@ -149,9 +149,8 @@ export function FeatureTabGroup({
149149
150150 setView ( { type : "workspace" } ) ;
151151
152- const counter = ( project . feature_counter ?? 0 ) + 1 ;
153-
154152 try {
153+ // Backend handles seq and feature_counter atomically (global)
155154 const feature = await invoke < Feature > ( "workspace_create_feature" , {
156155 projectId : project . id ,
157156 name,
@@ -162,9 +161,8 @@ export function FeatureTabGroup({
162161 p . id === project . id
163162 ? {
164163 ...p ,
165- features : [ ...p . features , { ... feature , seq : counter , description : description || undefined } ] ,
164+ features : [ ...p . features , feature ] ,
166165 active_feature_id : feature . id ,
167- feature_counter : counter ,
168166 view_mode : "features" as const ,
169167 }
170168 : p
@@ -174,6 +172,7 @@ export function FeatureTabGroup({
174172 ...workspace ,
175173 projects : newProjects ,
176174 active_project_id : project . id ,
175+ feature_counter : feature . seq ,
177176 } ;
178177
179178 setWorkspace ( newWorkspace ) ;
@@ -277,7 +276,7 @@ export function FeatureTabGroup({
277276 < CreateFeatureDialog
278277 open = { showCreateDialog }
279278 onOpenChange = { setShowCreateDialog }
280- defaultName = { defaultFeatureName }
279+ seq = { nextSeq }
281280 onSubmit = { handleCreateFeature }
282281 />
283282 </ >
@@ -332,17 +331,15 @@ export function FeatureTabGroup({
332331 </ SortableContext >
333332 ) }
334333
335- { /* Add button - only show for active project */ }
336- { isActiveProject && (
337- < button
338- onClick = { handleAddFeature }
339- onPointerDown = { ( e ) => e . stopPropagation ( ) }
340- className = "p-1 text-muted-foreground hover:text-ink hover:bg-card-alt rounded transition-colors"
341- title = "New Feature"
342- >
343- < PlusIcon className = "w-3.5 h-3.5" />
344- </ button >
345- ) }
334+ { /* Add button */ }
335+ < button
336+ onClick = { handleAddFeature }
337+ onPointerDown = { ( e ) => e . stopPropagation ( ) }
338+ className = "p-1 text-muted-foreground hover:text-ink hover:bg-card-alt rounded transition-colors"
339+ title = "New Feature"
340+ >
341+ < PlusIcon className = "w-3.5 h-3.5" />
342+ </ button >
346343 </ div >
347344
348345 { /* Separator between project groups */ }
@@ -351,7 +348,7 @@ export function FeatureTabGroup({
351348 < CreateFeatureDialog
352349 open = { showCreateDialog }
353350 onOpenChange = { setShowCreateDialog }
354- defaultName = { defaultFeatureName }
351+ seq = { nextSeq }
355352 onSubmit = { handleCreateFeature }
356353 />
357354 </ >
0 commit comments