Skip to content

Cannot delete project with only archived threads #1880

@jamesainslie

Description

@jamesainslie

Bug

Right-clicking a project in the sidebar and selecting Remove project shows:

Project is not empty
Delete all threads in this project before removing it.

…even when the sidebar shows no threads under that project.

Root Cause

The deletion guard in Sidebar.tsx checks threadIdsByProjectId[projectId] which includes all non-deleted threads — including archived ones. But the sidebar rendering filters archived threads out (.filter((thread) => thread.archivedAt === null)), so they're invisible to the user.

Projects that only contain archived threads appear empty but can't be deleted.

Suggested Fix

In handleProjectContextMenu, filter out archived threads before the emptiness check so it matches what the sidebar displays:

       const projectThreadIds = threadIdsByProjectId[projectId] ?? [];
-      if (projectThreadIds.length > 0) {
+      const visibleThreadIds = projectThreadIds.filter(
+        (threadId) => sidebarThreadsById[threadId]?.archivedAt === null,
+      );
+      if (visibleThreadIds.length > 0) {

And add sidebarThreadsById to the useCallback dependency array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions