Skip to content

Commit 3160358

Browse files
committed
fix(extension): resolve sign-in loop and stale spaces (supermemoryai#1016)
## What Fixes two bugs reported by a customer (Plain T-1289) using the Supermemory browser extension. ### Bug 1 — extension sign-in loop When a user logs out of the _extension_ but is still authenticated in the _web app_, the extension's Sign-in button opens `/login`, which short-circuited via a bare `router.replace("/")`. That path never carried the `extension-auth-success` flag the dashboard waits on before `postMessage`\-ing the session token to the extension content script — so the extension never received a token and stayed stuck on "Sign in" indefinitely. Now the already-authenticated redirect carries `?extension-auth-success=true`, matching the existing fresh-login callback behavior (no new token exposure). ### Bug 2 — stale / deleted spaces The extension's stored default space (`local:sm-default-project`) was only set when none existed, never reconciled. After renaming/deleting spaces in the web app, the popup kept showing save buttons pointing at dead spaces. Now the popup reconciles the stored default against the freshly-fetched live list: resets to the first space if the stored one was deleted, and refreshes the cached copy (label/containerTag) if it was renamed.
1 parent ab068e2 commit 3160358

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

apps/browser-extension/entrypoints/popup/App.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,21 @@ function App() {
175175
setShowProjectSelector(true)
176176
}
177177

178+
// Reconcile stored default against live list: reset if deleted, refresh if renamed.
178179
useEffect(() => {
179-
if (!defaultProject && projects.length > 0) {
180-
const firstProject = projects[0]
181-
setDefaultProjectMutation.mutate(firstProject)
180+
if (projects.length === 0) return
181+
if (!defaultProject) {
182+
setDefaultProjectMutation.mutate(projects[0])
183+
return
184+
}
185+
const live = projects.find((p) => p.id === defaultProject.id)
186+
if (!live) {
187+
setDefaultProjectMutation.mutate(projects[0])
188+
} else if (
189+
live.name !== defaultProject.name ||
190+
live.containerTag !== defaultProject.containerTag
191+
) {
192+
setDefaultProjectMutation.mutate(live)
182193
}
183194
}, [defaultProject, projects, setDefaultProjectMutation])
184195

apps/browser-extension/wxt.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default defineConfig({
2929
manifest: {
3030
name: "supermemory",
3131
homepage_url: "https://supermemory.ai",
32-
version: "6.1.3",
32+
version: "6.1.4",
3333
permissions: ["storage", "activeTab", "webRequest", "tabs"],
3434
host_permissions: [
3535
"*://x.com/*",

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,11 @@ export default function LoginPage() {
140140
)
141141
return
142142
}
143-
router.replace("/")
144-
}, [
145-
sessionPending,
146-
sessionData?.session,
147-
oauthQueryForResume,
148-
params,
149-
router,
150-
])
143+
// Carry the flag so the dashboard posts the session token to the extension (else: sign-in loop).
144+
const dest = new URL("/", window.location.origin)
145+
dest.searchParams.set("extension-auth-success", "true")
146+
window.location.assign(dest.toString())
147+
}, [sessionPending, sessionData?.session, oauthQueryForResume, params])
151148

152149
// Get redirect URL from query params
153150
const redirectUrl = params.get("redirect")

0 commit comments

Comments
 (0)