1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
"use client"
import { Badge } from "@/ui/badge"
import { Button } from "@/ui/button"
import { GlassMenuEffect } from "@/ui/glass-effect"
import { Brain, Calendar, ExternalLink, FileText, Hash, X } from "lucide-react"
import { motion } from "motion/react"
import { memo } from "react"
import {
GoogleDocs,
GoogleDrive,
GoogleSheets,
GoogleSlides,
MicrosoftExcel,
MicrosoftOneNote,
MicrosoftPowerpoint,
MicrosoftWord,
NotionDoc,
OneDrive,
PDF,
} from "@/assets/icons"
import { HeadingH3Bold } from "@/ui/heading"
import type { DocumentWithMemories, MemoryEntry } from "@/types"
import type { NodeDetailPanelProps } from "@/types"
import * as styles from "./node-detail-panel.css"
const formatDocumentType = (type: string) => {
// Special case for PDF
if (type.toLowerCase() === "pdf") return "PDF"
// Replace underscores with spaces and capitalize each word
return type
.split("_")
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
.join(" ")
}
const getDocumentIcon = (type: string) => {
const iconProps = { className: "w-5 h-5 text-slate-300" }
switch (type) {
case "google_doc":
return <GoogleDocs {...iconProps} />
case "google_sheet":
return <GoogleSheets {...iconProps} />
case "google_slide":
return <GoogleSlides {...iconProps} />
case "google_drive":
return <GoogleDrive {...iconProps} />
case "notion":
case "notion_doc":
return <NotionDoc {...iconProps} />
case "word":
case "microsoft_word":
return <MicrosoftWord {...iconProps} />
case "excel":
case "microsoft_excel":
return <MicrosoftExcel {...iconProps} />
case "powerpoint":
case "microsoft_powerpoint":
return <MicrosoftPowerpoint {...iconProps} />
case "onenote":
case "microsoft_onenote":
return <MicrosoftOneNote {...iconProps} />
case "onedrive":
return <OneDrive {...iconProps} />
case "pdf":
return <PDF {...iconProps} />
default:
{
/*@ts-ignore */
}
return <FileText {...iconProps} />
}
}
export const NodeDetailPanel = memo(function NodeDetailPanel({
node,
onClose,
variant = "console",
}: NodeDetailPanelProps) {
if (!node) return null
const isDocument = node.type === "document"
const data = node.data
return (
<motion.div
animate={{ opacity: 1 }}
className={styles.container}
exit={{ opacity: 0 }}
initial={{ opacity: 0 }}
transition={{
duration: 0.2,
ease: "easeInOut",
}}
>
{/* Glass effect background */}
<GlassMenuEffect rounded="xl" />
<motion.div
animate={{ opacity: 1 }}
className={styles.content}
initial={{ opacity: 0 }}
transition={{ delay: 0.05, duration: 0.15 }}
>
<div className={styles.header}>
<div className={styles.headerLeft}>
{isDocument ? (
getDocumentIcon((data as DocumentWithMemories).type ?? "")
) : (
// @ts-ignore
<Brain className={styles.headerIconMemory} />
)}
<HeadingH3Bold>{isDocument ? "Document" : "Memory"}</HeadingH3Bold>
</div>
<motion.div whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.9 }}>
<Button
className={styles.closeButton}
onClick={onClose}
size="sm"
variant="ghost"
>
{/* @ts-ignore */}
<X className={styles.closeIcon} />
</Button>
</motion.div>
</div>
<div className={styles.sections}>
{isDocument ? (
<>
<div className={styles.section}>
<span className={styles.sectionLabel}>Title</span>
<p className={styles.sectionValue}>
{(data as DocumentWithMemories).title || "Untitled Document"}
</p>
</div>
{(data as DocumentWithMemories).summary && (
<div className={styles.section}>
<span className={styles.sectionLabel}>Summary</span>
<p className={styles.sectionValueTruncated}>
{(data as DocumentWithMemories).summary}
</p>
</div>
)}
<div className={styles.section}>
<span className={styles.sectionLabel}>Type</span>
<p className={styles.sectionValue}>
{formatDocumentType(
(data as DocumentWithMemories).type ?? "",
)}
</p>
</div>
<div className={styles.section}>
<span className={styles.sectionLabel}>Memory Count</span>
<p className={styles.sectionValue}>
{(data as DocumentWithMemories).memoryEntries.length} memories
</p>
</div>
{((data as DocumentWithMemories).url ||
(data as DocumentWithMemories).customId) && (
<div className={styles.section}>
<span className={styles.sectionLabel}>URL</span>
<a
className={styles.link}
href={(() => {
const doc = data as DocumentWithMemories
if (doc.type === "google_doc" && doc.customId) {
return `https://docs.google.com/document/d/${doc.customId}`
}
if (doc.type === "google_sheet" && doc.customId) {
return `https://docs.google.com/spreadsheets/d/${doc.customId}`
}
if (doc.type === "google_slide" && doc.customId) {
return `https://docs.google.com/presentation/d/${doc.customId}`
}
return doc.url ?? undefined
})()}
rel="noopener noreferrer"
target="_blank"
>
{/* @ts-ignore */}
<ExternalLink className={styles.linkIcon} />
View Document
</a>
</div>
)}
</>
) : (
<>
<div className={styles.section}>
<span className={styles.sectionLabel}>Memory</span>
<p className={styles.sectionValue}>
{(data as MemoryEntry).memory}
</p>
{(data as MemoryEntry).isForgotten && (
<Badge className={styles.badge} variant="destructive">
Forgotten
</Badge>
)}
{(data as MemoryEntry).forgetAfter && (
<p className={styles.expiryText}>
Expires:{" "}
{(data as MemoryEntry).forgetAfter
? new Date(
(data as MemoryEntry).forgetAfter!,
).toLocaleDateString()
: ""}{" "}
{"forgetReason" in data && (data as any).forgetReason
? `- ${(data as any).forgetReason}`
: null}
</p>
)}
</div>
<div className={styles.section}>
<span className={styles.sectionLabel}>Space</span>
<p className={styles.sectionValue}>
{(data as MemoryEntry).spaceId || "Default"}
</p>
</div>
</>
)}
<div className={styles.footer}>
<div className={styles.metadata}>
<span className={styles.metadataItem}>
{/* @ts-ignore */}
<Calendar className={styles.metadataIcon} />
{new Date(data.createdAt).toLocaleDateString()}
</span>
<span className={styles.metadataItem}>
{/* @ts-ignore */}
<Hash className={styles.metadataIcon} />
{node.id}
</span>
</div>
</div>
</div>
</motion.div>
</motion.div>
)
})
NodeDetailPanel.displayName = "NodeDetailPanel"
|