Agent chat workspace
Fix auth redirect loopAgent
The login page keeps bouncing back to itself after a successful sign-in. Trace the redirect and propose a fix.
The loop comes from middleware treating a brand-new session as anonymous for one request. After sign-in, callbackUrl still resolves to /login, so the next navigation bounces.
Prefer a stable post-auth destination and ignore login as a callback target:
lib/auth/resolve-post-auth-path.ts
export function resolvePostAuthPath(session: Session, callbackUrl?: string) {
if (callbackUrl && !callbackUrl.startsWith("/login")) {
return callbackUrl
}
return session.user.defaultWorkspace ?? "/dashboard"
}Clear stale callback values on successful auth so login can never become the next hop.
Cursor-style agent shell with thinking, tool calls, code, actions, and Prompt Input.