> ## Documentation Index
> Fetch the complete documentation index at: https://committ.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# useTaskSelection

> Multi-select state for bulk task operations on the Dashboard.

# useTaskSelection

**Source:** `hooks/commits/useTaskSelection.ts`

The useTaskSelection hook manages multi-select state for bulk task operations on the Dashboard commits screen.

***

## Selection State

The hook maintains a Set of selected task IDs internally, exposing it as a stable array for React rendering:

```typescript theme={null}
const [selectedIds, setSelectedIds] = useState<Set<string>>(new Set());
```

***

## Available Actions

| Action           | Behavior                                                                      |
| :--------------- | :---------------------------------------------------------------------------- |
| toggleSelect(id) | Adds or removes a task from the selection set                                 |
| selectAll(tasks) | Adds all visible task IDs to the selection set                                |
| clearSelection() | Empties the selection set and exits multi-select mode                         |
| bulkDelete()     | Iterates through selected IDs, calling deleteTask() via Triple-Write for each |

***

## Multi-Select Mode

The Dashboard enters multi-select mode when the user long-presses a task card. Visual indicators (checkmarks, highlighted backgrounds) appear on selected items. The mode exits automatically when the selection is cleared or all selected tasks are deleted.

***

## Bulk Delete Strategy

Bulk deletion iterates through the selected IDs sequentially (not in parallel) to avoid overwhelming the SyncLock. Each deletion goes through the full Triple-Write pipeline:

```
for (const id of selectedIds) {
  await deleteTask(id);  // Convex → SQLite → Re-arm alarms
}
```

Sequential execution ensures each deletion's rollback can complete before the next starts.
