Skip to content

Commit 1dbd454

Browse files
committed
feat: switch to all spaces on empty state (#816)
1 parent 13d69aa commit 1dbd454

File tree

3 files changed

+96
-21
lines changed

3 files changed

+96
-21
lines changed

apps/web/app/(app)/page.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,13 @@ function ViewErrorFallback() {
6666
export default function NewPage() {
6767
const isMobile = useIsMobile()
6868
const { user, session } = useAuth()
69-
const { selectedProject, isNovaSpaces, novaContainerTags, selectedProjects } =
70-
useProject()
69+
const {
70+
selectedProject,
71+
isNovaSpaces,
72+
novaContainerTags,
73+
selectedProjects,
74+
setSelectedProjects,
75+
} = useProject()
7176
const selectedProjectTag = selectedProjects[0]
7277
const isNovaContext =
7378
isNovaSpaces ||
@@ -81,6 +86,12 @@ export default function NewPage() {
8186
: (allProjects.find((p) => p.containerTag === selectedProjectTag)
8287
?.name ?? selectedProjectTag)
8388
: undefined
89+
90+
const handleSwitchToAllSpacesFromEmptyState = useCallback(() => {
91+
analytics.spaceSwitched({ space_id: "nova_spaces" })
92+
setSelectedProjects([])
93+
}, [setSelectedProjects])
94+
8495
const { viewMode, setViewMode } = useViewMode()
8596
const queryClient = useQueryClient()
8697

@@ -466,6 +477,9 @@ export default function NewPage() {
466477
onOpenIntegrations: handleOpenIntegrations,
467478
isAllSpaces: isNovaSpaces,
468479
spaceName: emptyStateSpaceName,
480+
onSwitchToAllSpaces: isNovaSpaces
481+
? undefined
482+
: handleSwitchToAllSpacesFromEmptyState,
469483
}
470484
: undefined
471485
}

apps/web/components/memories-grid.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ interface NovaEmptyStateProps {
100100
) => void
101101
isAllSpaces: boolean
102102
spaceName?: string
103+
onSwitchToAllSpaces?: () => void
103104
}
104105

105106
interface MemoriesGridProps {
@@ -512,6 +513,7 @@ export function MemoriesGrid({
512513
onOpenIntegrations={emptyStateProps.onOpenIntegrations}
513514
isAllSpaces={emptyStateProps.isAllSpaces}
514515
spaceName={emptyStateProps.spaceName}
516+
onSwitchToAllSpaces={emptyStateProps.onSwitchToAllSpaces}
515517
/>
516518
) : isEmpty ? (
517519
<div className="h-full flex items-center justify-center p-4">

apps/web/components/nova/nova-empty-state.tsx

Lines changed: 78 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface NovaEmptyStateProps {
1515
) => void
1616
isAllSpaces: boolean
1717
spaceName?: string
18+
onSwitchToAllSpaces?: () => void
1819
}
1920

2021
const cardClass = cn(
@@ -28,19 +29,13 @@ export function NovaEmptyState({
2829
onOpenIntegrations,
2930
isAllSpaces,
3031
spaceName,
32+
onSwitchToAllSpaces,
3133
}: NovaEmptyStateProps) {
3234
const handleInstallChrome = () => {
3335
window.open(CHROME_EXTENSION_URL, "_blank", "noopener,noreferrer")
3436
}
3537

36-
const title = isAllSpaces
37-
? "Help Nova get to know you"
38-
: "This space is empty"
39-
const subtitle = isAllSpaces
40-
? "Add your first memory to get started."
41-
: spaceName
42-
? `Add memories to ${spaceName} to get started.`
43-
: "Add memories to this space to get started."
38+
const showSingleSpaceEmpty = !isAllSpaces && onSwitchToAllSpaces
4439

4540
return (
4641
<div
@@ -49,17 +44,81 @@ export function NovaEmptyState({
4944
>
5045
<div className="max-w-xl w-full flex flex-col items-center text-center">
5146
<NovaOrb size={80} className="blur-[2px]! mb-4" />
52-
<h2
53-
className={cn(
54-
"text-white text-xl md:text-2xl font-medium mb-2",
55-
dmSansClassName(),
56-
)}
57-
>
58-
{title}
59-
</h2>
60-
<p className={cn("text-[#8B8B8B] text-sm mb-6", dmSansClassName())}>
61-
{subtitle}
62-
</p>
47+
{isAllSpaces ? (
48+
<>
49+
<h2
50+
className={cn(
51+
"text-white text-xl md:text-2xl font-medium mb-2",
52+
dmSansClassName(),
53+
)}
54+
>
55+
Help Nova get to know you
56+
</h2>
57+
<p className={cn("text-[#8B8B8B] text-sm mb-6", dmSansClassName())}>
58+
Add your first memory to get started.
59+
</p>
60+
</>
61+
) : showSingleSpaceEmpty ? (
62+
<>
63+
<h2
64+
className={cn(
65+
"text-white text-xl md:text-2xl font-medium mb-2",
66+
dmSansClassName(),
67+
)}
68+
>
69+
{spaceName ? (
70+
<>
71+
<span className="text-[#fafafa] font-medium">
72+
"{spaceName}"
73+
</span>{" "}
74+
is empty
75+
</>
76+
) : (
77+
"This space is empty"
78+
)}
79+
</h2>
80+
<p className={cn("text-[#8B8B8B] text-sm mb-3", dmSansClassName())}>
81+
Your memories may be in another space.
82+
</p>
83+
<button
84+
id="nova-empty-view-all-spaces"
85+
type="button"
86+
onClick={onSwitchToAllSpaces}
87+
className={cn(
88+
"text-[#4BA0FA] text-sm font-medium flex items-center gap-1 mb-6",
89+
"hover:text-[#6BB0FF] transition-colors",
90+
dmSansClassName(),
91+
)}
92+
>
93+
View all spaces
94+
<ArrowRight className="size-3.5" />
95+
</button>
96+
</>
97+
) : (
98+
<>
99+
<h2
100+
className={cn(
101+
"text-white text-xl md:text-2xl font-medium mb-2",
102+
dmSansClassName(),
103+
)}
104+
>
105+
This space is empty
106+
</h2>
107+
<p className={cn("text-[#8B8B8B] text-sm mb-6", dmSansClassName())}>
108+
{spaceName ? (
109+
<>
110+
Add memories to{" "}
111+
<span className="text-[#fafafa] font-medium">
112+
"{spaceName}"
113+
</span>{" "}
114+
to get started.
115+
</>
116+
) : (
117+
"Add memories to this space to get started."
118+
)}
119+
</p>
120+
</>
121+
)}
63122

64123
<div className="grid grid-cols-1 sm:grid-cols-3 gap-3 w-full mb-4">
65124
<button

0 commit comments

Comments
 (0)