Skip to content

Commit 672ea7f

Browse files
authored
Merge pull request #105 from AgentWorkforce/fix-cloud-link
Fix cloud link
2 parents e791671 + b1b8082 commit 672ea7f

File tree

4 files changed

+75
-5
lines changed

4 files changed

+75
-5
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"id": "traj_rsavt0jipi3c",
3+
"version": 1,
4+
"task": {
5+
"title": "Power agent session - ready for tasks"
6+
},
7+
"status": "active",
8+
"startedAt": "2026-01-08T07:54:35.678Z",
9+
"agents": [
10+
{
11+
"name": "khaliqgant",
12+
"role": "lead",
13+
"joinedAt": "2026-01-08T07:54:35.679Z"
14+
}
15+
],
16+
"chapters": [
17+
{
18+
"id": "chap_cgughl8lm8b5",
19+
"title": "Work",
20+
"agentName": "default",
21+
"startedAt": "2026-01-08T08:04:56.261Z",
22+
"events": [
23+
{
24+
"ts": 1767859496262,
25+
"type": "decision",
26+
"content": "Fixed cloud link auth flow - two bugs: Fixed cloud link auth flow - two bugs",
27+
"raw": {
28+
"question": "Fixed cloud link auth flow - two bugs",
29+
"chosen": "Fixed cloud link auth flow - two bugs",
30+
"alternatives": [],
31+
"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"
32+
},
33+
"significance": "high"
34+
},
35+
{
36+
"ts": 1767859507874,
37+
"type": "decision",
38+
"content": "Fixed login page return URL support: Fixed login page return URL support",
39+
"raw": {
40+
"question": "Fixed login page return URL support",
41+
"chosen": "Fixed login page return URL support",
42+
"alternatives": [],
43+
"reasoning": "Added useSearchParams to read return query param and redirect back after login instead of always going to /app"
44+
},
45+
"significance": "high"
46+
}
47+
]
48+
}
49+
],
50+
"commits": [],
51+
"filesChanged": [],
52+
"projectId": "/Users/khaliqgant/Projects/agent-workforce/relay",
53+
"tags": []
54+
}

.trajectories/index.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 1,
3-
"lastUpdated": "2026-01-07T21:41:49.091Z",
3+
"lastUpdated": "2026-01-08T08:05:07.874Z",
44
"trajectories": {
55
"traj_ozd98si6a7ns": {
66
"title": "Fix thinking indicator showing on all messages",
@@ -498,6 +498,12 @@
498498
"startedAt": "2026-01-07T21:41:28.024Z",
499499
"completedAt": "2026-01-07T21:41:49.080Z",
500500
"path": "/Users/khaliqgant/Projects/agent-workforce/relay/.trajectories/completed/2026-01/traj_lgtodco7dp1n.json"
501+
},
502+
"traj_rsavt0jipi3c": {
503+
"title": "Power agent session - ready for tasks",
504+
"status": "active",
505+
"startedAt": "2026-01-08T07:54:35.678Z",
506+
"path": "/Users/khaliqgant/Projects/agent-workforce/relay/.trajectories/active/traj_rsavt0jipi3c.json"
501507
}
502508
}
503509
}

src/dashboard/app/cloud/link/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ function CloudLinkContent() {
6767

6868
const checkAuth = async () => {
6969
try {
70-
const data = await api.get<{ userId?: string }>('/api/auth/session');
71-
if (data.userId) {
70+
const data = await api.get<{ authenticated?: boolean; user?: { id: string } }>('/api/auth/session');
71+
if (data.authenticated && data.user?.id) {
7272
setState('ready');
7373
} else {
7474
setState('auth-required');

src/dashboard/app/login/page.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@
99
'use client';
1010

1111
import React, { useState, useEffect, useRef } from 'react';
12+
import { useSearchParams } from 'next/navigation';
1213
import Nango from '@nangohq/frontend';
1314
import { LogoIcon } from '../../react-components/Logo';
1415

1516
export default function LoginPage() {
17+
const searchParams = useSearchParams();
1618
const [isReady, setIsReady] = useState(false);
1719
const [isAuthenticating, setIsAuthenticating] = useState(false);
1820
const [authStatus, setAuthStatus] = useState<string>('');
1921
const [error, setError] = useState('');
22+
23+
// Get return URL from query params (used by cloud link flow)
24+
const returnUrl = searchParams.get('return');
2025

2126
// Store Nango instance and session token - initialized on mount
2227
const nangoRef = useRef<InstanceType<typeof Nango> | null>(null);
@@ -82,8 +87,13 @@ export default function LoginPage() {
8287
try {
8388
const result = await checkAuthStatus(connectionId);
8489
if (result && result.ready) {
85-
// Redirect to connect-repos if no repos, otherwise to app
86-
window.location.href = result.hasRepos ? '/app' : '/connect-repos';
90+
// Redirect to return URL if provided (e.g., cloud link flow),
91+
// otherwise to connect-repos if no repos, or to app
92+
if (returnUrl) {
93+
window.location.href = returnUrl;
94+
} else {
95+
window.location.href = result.hasRepos ? '/app' : '/connect-repos';
96+
}
8797
return;
8898
}
8999

0 commit comments

Comments
 (0)