Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(desktop): prevent duplicate welcome toast on login

Naiyuan Qing0d113186186b
diff --git a/apps/desktop/src/renderer/src/App.tsx b/apps/desktop/src/renderer/src/App.tsx
index 68a23c6216..73213be935 100644
--- a/apps/desktop/src/renderer/src/App.tsx
+++ b/apps/desktop/src/renderer/src/App.tsx
@@ -88,16 +88,15 @@ export default function App() {
const setCompleted = useOnboardingStore((s) => s.setCompleted)
useEffect(() => {
- let cleanupAuth: (() => void) | undefined
+ // Setup auth callback listener BEFORE async operations
+ // This ensures cleanup works correctly in React Strict Mode
+ const cleanupAuth = setupAuthCallbackListener()
async function hydrateState() {
try {
// Load auth state first
await useAuthStore.getState().loadAuth()
- // Setup auth callback listener
- cleanupAuth = setupAuthCallbackListener()
-
// Load onboarding state
const completed = await window.electronAPI.appState.getOnboardingCompleted()
setCompleted(completed)
@@ -119,7 +118,7 @@ export default function App() {
useCronJobsStore.getState().fetch()
return () => {
- cleanupAuth?.()
+ cleanupAuth()
}
}, [setCompleted])
diff --git a/apps/desktop/src/renderer/src/stores/auth.ts b/apps/desktop/src/renderer/src/stores/auth.ts
index 2dd541219d..129c253e10 100644
--- a/apps/desktop/src/renderer/src/stores/auth.ts
+++ b/apps/desktop/src/renderer/src/stores/auth.ts
@@ -108,14 +108,14 @@ export const useAuthStore = create<AuthState>((set) => ({
*/
export function setupAuthCallbackListener(): () => void {
window.electronAPI.auth.onAuthCallback(async (data) => {
- console.log('[AuthStore] Received auth callback:', data)
if (data.sid && data.user) {
useAuthStore.setState({
sid: data.sid,
user: data.user,
isAuthenticated: true,
})
- toast.success(`Welcome back, ${data.user.name}`)
+ // Use a fixed ID to prevent duplicate toasts
+ toast.success(`Welcome back, ${data.user.name}`, { id: 'auth-welcome' })
}
})