Skip to content

Commit c4d5bdd

Browse files
committed
Use fresh store state for command center cell assignment
1 parent 16d05f0 commit c4d5bdd

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

apps/code/src/renderer/features/sidebar/components/SidebarMenu.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)