From cc2dcaa306d8a4d3ec9b42b7fbeba02dfd0fc205 Mon Sep 17 00:00:00 2001 From: Prasanna721 <106952318+Prasanna721@users.noreply.github.com> Date: Thu, 19 Feb 2026 06:54:32 +0000 Subject: [PATCH 1/2] fix: space deletion not switching to Nova Spaces and new space not appearing in dropdown (#747) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### fix: space selector state bugs on create and delete Two related bugs in the space selector caused by query cache key mismatches in `use-project-mutations.ts`: 1. New spaces not appearing in dropdown until refresh — wrong query cache was being invalidated after creation. 2. App stuck on deleted space instead of switching to Nova Spaces — delete handler was reading from an empty cache, so the selection never updated. --- apps/web/hooks/use-project-mutations.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/web/hooks/use-project-mutations.ts b/apps/web/hooks/use-project-mutations.ts index b9573edb..d9cfa335 100644 --- a/apps/web/hooks/use-project-mutations.ts +++ b/apps/web/hooks/use-project-mutations.ts @@ -4,7 +4,7 @@ import { $fetch } from "@lib/api" import { useMutation, useQueryClient } from "@tanstack/react-query" import { toast } from "sonner" import { useProject } from "@/stores" -import type { Project } from "@repo/lib/types" +import type { ContainerTagListType } from "@repo/lib/types" export function useProjectMutations() { const queryClient = useQueryClient() @@ -29,6 +29,7 @@ export function useProjectMutations() { onSuccess: (data) => { toast.success("Project created successfully!") queryClient.invalidateQueries({ queryKey: ["projects"] }) + queryClient.invalidateQueries({ queryKey: ["container-tags"] }) if (data?.containerTag) { setSelectedProjects([data.containerTag]) @@ -63,14 +64,12 @@ export function useProjectMutations() { }, onSuccess: (_, variables) => { toast.success("Project deleted successfully") - queryClient.invalidateQueries({ queryKey: ["projects"] }) - queryClient.invalidateQueries({ queryKey: ["container-tags"] }) - const allProjects = - queryClient.getQueryData(["projects"]) || [] - const deletedProject = allProjects.find( - (p) => p.id === variables.projectId, - ) + const allTags = + queryClient.getQueryData(["container-tags"]) || + [] + const deletedProject = allTags.find((p) => p.id === variables.projectId) + if ( deletedProject?.containerTag && selectedProjects.includes(deletedProject.containerTag) @@ -79,6 +78,9 @@ export function useProjectMutations() { selectedProjects.filter((tag) => tag !== deletedProject.containerTag), ) } + + queryClient.invalidateQueries({ queryKey: ["projects"] }) + queryClient.invalidateQueries({ queryKey: ["container-tags"] }) }, onError: (error) => { toast.error("Failed to delete project", { From 7339822997ef053b41e9d24e86503e2efa108cb1 Mon Sep 17 00:00:00 2001 From: Prasanna721 <106952318+Prasanna721@users.noreply.github.com> Date: Thu, 19 Feb 2026 07:09:47 +0000 Subject: [PATCH 2/2] fix: space deletion state cleanup and single-select for add document (#748) fix: space deletion + new space not reflecting in selector Deleting a space wasn't switching back to Nova Spaces because we were reading stale cache data New spaces created from the add-document modal weren't showing up in the dropdown Added single-select mode to the space selector in the add-document flow since you're picking one space, not multiple. --- apps/web/components/add-document/index.tsx | 61 +++++++++++---------- apps/web/components/add-space-modal.tsx | 7 ++- apps/web/components/select-spaces-modal.tsx | 55 ++++++++++++++----- apps/web/components/space-selector.tsx | 36 +++++++----- 4 files changed, 100 insertions(+), 59 deletions(-) diff --git a/apps/web/components/add-document/index.tsx b/apps/web/components/add-document/index.tsx index 2310c956..cf875329 100644 --- a/apps/web/components/add-document/index.tsx +++ b/apps/web/components/add-document/index.tsx @@ -380,40 +380,42 @@ export function AddDocument({
- {activeTab === "note" && ( - - )} - {activeTab === "link" && ( - - )} - {activeTab === "file" && ( - - )} - {activeTab === "connect" && ( - - )} +
+ {activeTab === "note" && ( + + )} + {activeTab === "link" && ( + + )} + {activeTab === "file" && ( + + )} + {activeTab === "connect" && ( + + )} +
@@ -424,6 +426,7 @@ export function AddDocument({ setLocalSelectedProject(projects[0] ?? localSelectedProject) } variant="insideOut" + singleSelect /> )}
void + onCreated?: (containerTag: string) => void }) { const [spaceName, setSpaceName] = useState("") const [emoji, setEmoji] = useState("📁") @@ -87,8 +89,11 @@ export function AddSpaceModal({ createProjectMutation.mutate( { name: trimmedName, emoji: emoji || undefined }, { - onSuccess: () => { + onSuccess: (data) => { analytics.spaceCreated() + if (data?.containerTag) { + onCreated?.(data.containerTag) + } handleClose() }, }, diff --git a/apps/web/components/select-spaces-modal.tsx b/apps/web/components/select-spaces-modal.tsx index ad49a4ce..895bbf6d 100644 --- a/apps/web/components/select-spaces-modal.tsx +++ b/apps/web/components/select-spaces-modal.tsx @@ -16,6 +16,7 @@ interface SelectSpacesModalProps { selectedProjects: string[] onApply: (selected: string[]) => void projects: ContainerTagListType[] + singleSelect?: boolean } export function SelectSpacesModal({ @@ -24,6 +25,7 @@ export function SelectSpacesModal({ selectedProjects, onApply, projects, + singleSelect = false, }: SelectSpacesModalProps) { const [searchQuery, setSearchQuery] = useState("") const [localSelection, setLocalSelection] = @@ -44,6 +46,10 @@ export function SelectSpacesModal({ } const handleToggle = (containerTag: string) => { + if (singleSelect) { + setLocalSelection([containerTag]) + return + } setLocalSelection((prev) => { if (prev.includes(containerTag)) { return prev.filter((tag) => tag !== containerTag) @@ -117,10 +123,12 @@ export function SelectSpacesModal({ dmSans125ClassName(), )} > - Select Spaces + Select Space{!singleSelect && "s"}

- Choose one or more spaces to filter your memories + {singleSelect + ? "Choose a space for your memory" + : "Choose one or more spaces to filter your memories"}

-
- {isSelected && } -
+ {singleSelect ? ( +
+ {isSelected && ( +
+ )} +
+ ) : ( +
+ {isSelected && } +
+ )} {project.emoji || "📁"} {project.name ?? project.containerTag} @@ -195,9 +216,13 @@ export function SelectSpacesModal({

- {localSelection.length === 0 - ? "No spaces selected (showing all)" - : `${localSelection.length} space${localSelection.length > 1 ? "s" : ""} selected`} + {singleSelect + ? localSelection.length === 0 + ? "No space selected" + : "1 space selected" + : localSelection.length === 0 + ? "No spaces selected (showing all)" + : `${localSelection.length} space${localSelection.length > 1 ? "s" : ""} selected`}

{showNewSpace && ( @@ -386,6 +392,7 @@ export function SpaceSelector({ setShowCreateDialog(false)} + onCreated={(containerTag) => onValueChange([containerTag])} />