@@ -139,11 +139,12 @@ function SidebarMenuComponent() {
139139 if ( task ) {
140140 const workspace = workspaces [ taskId ] ;
141141 const taskData = allSidebarTasks . find ( ( t ) => t . id === taskId ) ;
142- const isInCommandCenter = commandCenterCells . includes ( taskId ) ;
143- const firstEmptyIndex = commandCenterCells . findIndex (
142+ const isInCommandCenter = commandCenterCells . some (
143+ ( id ) => id === taskId && taskMap . has ( id ) ,
144+ ) ;
145+ const hasEmptyCommandCenterCell = commandCenterCells . some (
144146 ( id ) => id == null || ! taskMap . has ( id ) ,
145147 ) ;
146- const hasEmptyCommandCenterCell = firstEmptyIndex !== - 1 ;
147148
148149 showContextMenu ( task , e , {
149150 worktreePath : workspace ?. worktreePath ?? undefined ,
@@ -155,8 +156,10 @@ function SidebarMenuComponent() {
155156 onTogglePin : ( ) => togglePin ( taskId ) ,
156157 onArchivePrior : handleArchivePrior ,
157158 onAddToCommandCenter : ( ) => {
158- if ( firstEmptyIndex !== - 1 ) {
159- assignTaskToCommandCenter ( firstEmptyIndex , taskId ) ;
159+ const cells = useCommandCenterStore . getState ( ) . cells ;
160+ const idx = cells . findIndex ( ( id ) => id == null || ! taskMap . has ( id ) ) ;
161+ if ( idx !== - 1 ) {
162+ assignTaskToCommandCenter ( idx , taskId ) ;
160163 navigateToCommandCenter ( ) ;
161164 } else {
162165 toast . info ( "Command center is full" ) ;
0 commit comments