diff --git a/.trajectories/active/traj_rsavt0jipi3c.json b/.trajectories/active/traj_rsavt0jipi3c.json new file mode 100644 index 00000000..20c3d061 --- /dev/null +++ b/.trajectories/active/traj_rsavt0jipi3c.json @@ -0,0 +1,54 @@ +{ + "id": "traj_rsavt0jipi3c", + "version": 1, + "task": { + "title": "Power agent session - ready for tasks" + }, + "status": "active", + "startedAt": "2026-01-08T07:54:35.678Z", + "agents": [ + { + "name": "khaliqgant", + "role": "lead", + "joinedAt": "2026-01-08T07:54:35.679Z" + } + ], + "chapters": [ + { + "id": "chap_cgughl8lm8b5", + "title": "Work", + "agentName": "default", + "startedAt": "2026-01-08T08:04:56.261Z", + "events": [ + { + "ts": 1767859496262, + "type": "decision", + "content": "Fixed cloud link auth flow - two bugs: Fixed cloud link auth flow - two bugs", + "raw": { + "question": "Fixed cloud link auth flow - two bugs", + "chosen": "Fixed cloud link auth flow - two bugs", + "alternatives": [], + "reasoning": "1) Cloud link page checked for data.userId but API returns data.authenticated + data.user.id. 2) Login page ignored return URL param, so after login it went to /app instead of back to cloud link page" + }, + "significance": "high" + }, + { + "ts": 1767859507874, + "type": "decision", + "content": "Fixed login page return URL support: Fixed login page return URL support", + "raw": { + "question": "Fixed login page return URL support", + "chosen": "Fixed login page return URL support", + "alternatives": [], + "reasoning": "Added useSearchParams to read return query param and redirect back after login instead of always going to /app" + }, + "significance": "high" + } + ] + } + ], + "commits": [], + "filesChanged": [], + "projectId": "/Users/khaliqgant/Projects/agent-workforce/relay", + "tags": [] +} \ No newline at end of file diff --git a/.trajectories/index.json b/.trajectories/index.json index 3dec3b9c..04ab0a0a 100644 --- a/.trajectories/index.json +++ b/.trajectories/index.json @@ -1,6 +1,6 @@ { "version": 1, - "lastUpdated": "2026-01-07T21:41:49.091Z", + "lastUpdated": "2026-01-08T08:05:07.874Z", "trajectories": { "traj_ozd98si6a7ns": { "title": "Fix thinking indicator showing on all messages", @@ -498,6 +498,12 @@ "startedAt": "2026-01-07T21:41:28.024Z", "completedAt": "2026-01-07T21:41:49.080Z", "path": "/Users/khaliqgant/Projects/agent-workforce/relay/.trajectories/completed/2026-01/traj_lgtodco7dp1n.json" + }, + "traj_rsavt0jipi3c": { + "title": "Power agent session - ready for tasks", + "status": "active", + "startedAt": "2026-01-08T07:54:35.678Z", + "path": "/Users/khaliqgant/Projects/agent-workforce/relay/.trajectories/active/traj_rsavt0jipi3c.json" } } } \ No newline at end of file diff --git a/src/dashboard/app/cloud/link/page.tsx b/src/dashboard/app/cloud/link/page.tsx index b200de97..cd3a548b 100644 --- a/src/dashboard/app/cloud/link/page.tsx +++ b/src/dashboard/app/cloud/link/page.tsx @@ -67,8 +67,8 @@ function CloudLinkContent() { const checkAuth = async () => { try { - const data = await api.get<{ userId?: string }>('/api/auth/session'); - if (data.userId) { + const data = await api.get<{ authenticated?: boolean; user?: { id: string } }>('/api/auth/session'); + if (data.authenticated && data.user?.id) { setState('ready'); } else { setState('auth-required'); diff --git a/src/dashboard/app/login/page.tsx b/src/dashboard/app/login/page.tsx index 40c1075b..94ae3b86 100644 --- a/src/dashboard/app/login/page.tsx +++ b/src/dashboard/app/login/page.tsx @@ -9,14 +9,19 @@ 'use client'; import React, { useState, useEffect, useRef } from 'react'; +import { useSearchParams } from 'next/navigation'; import Nango from '@nangohq/frontend'; import { LogoIcon } from '../../react-components/Logo'; export default function LoginPage() { + const searchParams = useSearchParams(); const [isReady, setIsReady] = useState(false); const [isAuthenticating, setIsAuthenticating] = useState(false); const [authStatus, setAuthStatus] = useState(''); const [error, setError] = useState(''); + + // Get return URL from query params (used by cloud link flow) + const returnUrl = searchParams.get('return'); // Store Nango instance and session token - initialized on mount const nangoRef = useRef | null>(null); @@ -82,8 +87,13 @@ export default function LoginPage() { try { const result = await checkAuthStatus(connectionId); if (result && result.ready) { - // Redirect to connect-repos if no repos, otherwise to app - window.location.href = result.hasRepos ? '/app' : '/connect-repos'; + // Redirect to return URL if provided (e.g., cloud link flow), + // otherwise to connect-repos if no repos, or to app + if (returnUrl) { + window.location.href = returnUrl; + } else { + window.location.href = result.hasRepos ? '/app' : '/connect-repos'; + } return; }