Skip to content

Commit b6357f5

Browse files
committed
fix: dashboard url, memories crud
1 parent d89bbdf commit b6357f5

5 files changed

Lines changed: 44 additions & 13 deletions

File tree

src/client/app/chat/page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const UpgradeToProModal = ({ isOpen, onClose }) => {
103103
const handleUpgrade = () => {
104104
const dashboardUrl = process.env.NEXT_PUBLIC_LANDING_PAGE_URL
105105
if (dashboardUrl) {
106-
window.open(`${dashboardUrl}/dashboard`, "_blank")
106+
window.location.href = `${dashboardUrl}/dashboard`
107107
}
108108
onClose()
109109
}

src/client/app/integrations/page.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const UpgradeToProModal = ({ isOpen, onClose }) => {
112112
const handleUpgrade = () => {
113113
const dashboardUrl = process.env.NEXT_PUBLIC_LANDING_PAGE_URL
114114
if (dashboardUrl) {
115-
window.open(`${dashboardUrl}/dashboard`, "_blank")
115+
window.location.href = `${dashboardUrl}/dashboard`
116116
}
117117
onClose()
118118
}
@@ -714,7 +714,9 @@ const IntegrationsPage = () => {
714714
const fetchIntegrations = useCallback(async () => {
715715
setLoading(true)
716716
try {
717-
const response = await fetch("/api/settings/integrations")
717+
const response = await fetch("/api/settings/integrations", {
718+
cache: "no-store"
719+
})
718720
const data = await response.json()
719721
if (!response.ok)
720722
throw new Error(data.error || "Failed to fetch integrations")
@@ -756,7 +758,29 @@ const IntegrationsPage = () => {
756758
setUpgradeModalOpen(true)
757759
}
758760

759-
const handleConnect = (integration) => {
761+
const handleConnect = async (integration) => {
762+
const isProFeature = PRO_ONLY_INTEGRATIONS.includes(integration.name)
763+
if (isProFeature && !isPro) {
764+
handleUpgradeClick()
765+
return
766+
}
767+
768+
// If it's a pro feature, refresh the session cookie before redirecting
769+
// to ensure the backend gets a fresh token with the correct roles.
770+
if (isProFeature) {
771+
const toastId = toast.loading("Preparing secure connection...")
772+
try {
773+
const res = await fetch("/api/auth/refresh-session")
774+
if (!res.ok) throw new Error("Session refresh failed")
775+
toast.dismiss(toastId)
776+
} catch (e) {
777+
toast.error("Could not prepare connection. Please try again.", {
778+
id: toastId
779+
})
780+
return // Stop if refresh fails
781+
}
782+
}
783+
760784
if (integration.name === "whatsapp") {
761785
setWhatsAppToConnect(integration)
762786
return
@@ -1257,17 +1281,17 @@ const IntegrationsPage = () => {
12571281
</button>
12581282
) : (
12591283
<button
1260-
onClick={(e) => {
1284+
onClick={async (e) => {
12611285
e.stopPropagation()
12621286
if (
12631287
integration.auth_type ===
12641288
"composio"
12651289
) {
1266-
handleComposioConnect(
1290+
await handleComposioConnect(
12671291
integration
12681292
)
12691293
} else {
1270-
handleConnect(integration)
1294+
await handleConnect(integration)
12711295
}
12721296
}}
12731297
className="flex items-center justify-center gap-2 w-full py-2 px-3 rounded-md bg-brand-orange hover:bg-brand-orange/90 text-brand-black font-semibold text-sm transition-colors"
@@ -1452,4 +1476,4 @@ const IntegrationsPage = () => {
14521476
)
14531477
}
14541478

1455-
export default IntegrationsPage
1479+
export default IntegrationsPage

src/client/app/memories/page.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,12 +484,16 @@ export default function MemoriesPage() {
484484
setIsLoading(true)
485485
try {
486486
if (view === "list") {
487-
const response = await fetch("/api/memories")
487+
const response = await fetch("/api/memories", {
488+
cache: "no-store"
489+
})
488490
if (!response.ok) throw new Error("Failed to fetch memories.")
489491
const data = await response.json()
490492
setMemories(data.memories || [])
491493
} else {
492-
const response = await fetch("/api/memories/graph")
494+
const response = await fetch("/api/memories/graph", {
495+
cache: "no-store"
496+
})
493497
if (!response.ok)
494498
throw new Error("Failed to fetch memory graph data.")
495499
const data = await response.json()

src/client/app/tasks/page.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const UpgradeToProModal = ({ isOpen, onClose }) => {
5959
const handleUpgrade = () => {
6060
const dashboardUrl = process.env.NEXT_PUBLIC_LANDING_PAGE_URL
6161
if (dashboardUrl) {
62-
window.open(`${dashboardUrl}/dashboard`, "_blank")
62+
window.location.href = `${dashboardUrl}/dashboard`
6363
}
6464
onClose()
6565
}

src/server/main/memories/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,14 @@ async def update_memory(user_id: str, memory_id: int, new_content: str) -> str:
135135
raise ValueError("Failed to analyze updated memory content.")
136136

137137
new_embedding = _get_normalized_embedding(new_content, task_type="RETRIEVAL_DOCUMENT")
138+
# Also re-evaluate the expiration based on the new content analysis
139+
expires_at = parse_duration(analysis.get("duration")) if analysis.get("memory_type") == "short-term" else None
138140

139141
async with conn.transaction():
140142
await conn.execute(
141-
"UPDATE facts SET content = $1, embedding = $2, updated_at = NOW() WHERE id = $3",
142-
new_content, new_embedding, memory_id
143+
# Update content, embedding, timestamp, and expiration
144+
"UPDATE facts SET content = $1, embedding = $2, updated_at = NOW(), expires_at = $4 WHERE id = $3",
145+
new_content, new_embedding, memory_id, expires_at
143146
)
144147
await conn.execute("DELETE FROM fact_topics WHERE fact_id = $1", memory_id)
145148
topic_names = analysis.get("topics", ["Miscellaneous"])

0 commit comments

Comments
 (0)