Skip to content

Commit c380c37

Browse files
committed
Link deployments to preview urls; add more menu to view deployment
1 parent 0a3e638 commit c380c37

File tree

2 files changed

+65
-17
lines changed

2 files changed

+65
-17
lines changed

app/api/tasks/[taskId]/deployment/route.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ function convertFeedbackUrlToDeploymentUrl(url: string): string {
1414
return url
1515
}
1616

17+
// Helper function to generate Vercel inspector URL from details_url or check ID
18+
function getInspectorUrl(detailsUrl?: string): string | undefined {
19+
if (!detailsUrl) return undefined
20+
21+
// If it's already a vercel.com URL, return it
22+
if (detailsUrl.includes('vercel.com')) {
23+
return detailsUrl
24+
}
25+
26+
return undefined
27+
}
28+
1729
export async function GET(request: NextRequest, { params }: { params: Promise<{ taskId: string }> }) {
1830
try {
1931
const session = await getServerSession()
@@ -50,6 +62,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
5062
data: {
5163
hasDeployment: true,
5264
previewUrl,
65+
inspectorUrl: undefined,
5366
cached: true,
5467
},
5568
})
@@ -187,11 +200,16 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
187200
// Store the preview URL in the database
188201
await db.update(tasks).set({ previewUrl }).where(eq(tasks.id, taskId))
189202

203+
// Get inspector URL from details_url
204+
const detailsUrl = vercelDeploymentCheck?.details_url ?? vercelPreviewCheck?.details_url
205+
const inspectorUrl = detailsUrl ? getInspectorUrl(detailsUrl) : undefined
206+
190207
return NextResponse.json({
191208
success: true,
192209
data: {
193210
hasDeployment: true,
194211
previewUrl,
212+
inspectorUrl,
195213
checkId: vercelDeploymentCheck?.id || vercelPreviewCheck?.id,
196214
createdAt: vercelDeploymentCheck?.completed_at || vercelPreviewCheck?.completed_at,
197215
},
@@ -244,6 +262,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
244262
data: {
245263
hasDeployment: true,
246264
previewUrl,
265+
inspectorUrl: undefined,
247266
deploymentId: deployment.id,
248267
createdAt: deployment.created_at,
249268
},
@@ -285,6 +304,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
285304
data: {
286305
hasDeployment: true,
287306
previewUrl,
307+
inspectorUrl: getInspectorUrl(vercelStatus.target_url),
288308
createdAt: vercelStatus.created_at,
289309
},
290310
})

components/task-chat.tsx

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ interface CheckRun {
5454
interface DeploymentInfo {
5555
hasDeployment: boolean
5656
previewUrl?: string
57+
inspectorUrl?: string
5758
message?: string
5859
createdAt?: string
5960
}
@@ -646,24 +647,51 @@ export function TaskChat({ taskId, task }: TaskChatProps) {
646647
</div>
647648
) : (
648649
<div className="space-y-2 px-2">
649-
<a
650-
href={deployment.previewUrl}
651-
target="_blank"
652-
rel="noopener noreferrer"
653-
className="flex items-center gap-3 p-2 rounded-md hover:bg-muted/50 transition-colors"
654-
>
655-
<svg className="w-4 h-4 flex-shrink-0" viewBox="0 0 76 65" fill="currentColor">
656-
<path d="M37.5274 0L75.0548 65H0L37.5274 0Z" />
657-
</svg>
658-
<div className="flex-1 min-w-0">
659-
<div className="text-xs font-medium truncate">Vercel Preview</div>
660-
<div className="text-xs text-muted-foreground">
661-
{deployment.createdAt
662-
? `Deployed ${new Date(deployment.createdAt).toLocaleString()}`
663-
: 'Preview deployment'}
650+
<div className="flex items-center gap-2 p-2 rounded-md hover:bg-muted/50 transition-colors group">
651+
<a
652+
href={deployment.previewUrl}
653+
target="_blank"
654+
rel="noopener noreferrer"
655+
className="flex items-center gap-3 flex-1 min-w-0"
656+
>
657+
<svg className="w-4 h-4 flex-shrink-0" viewBox="0 0 76 65" fill="currentColor">
658+
<path d="M37.5274 0L75.0548 65H0L37.5274 0Z" />
659+
</svg>
660+
<div className="flex-1 min-w-0">
661+
<div className="text-xs font-medium truncate">Vercel Preview</div>
662+
<div className="text-xs text-muted-foreground">
663+
{deployment.createdAt
664+
? `Deployed ${new Date(deployment.createdAt).toLocaleString()}`
665+
: 'Preview deployment'}
666+
</div>
664667
</div>
665-
</div>
666-
</a>
668+
</a>
669+
{deployment.inspectorUrl && (
670+
<DropdownMenu>
671+
<DropdownMenuTrigger asChild>
672+
<Button
673+
variant="ghost"
674+
size="icon"
675+
className="h-8 w-8 opacity-0 group-hover:opacity-100 transition-opacity"
676+
>
677+
<MoreVertical className="h-4 w-4" />
678+
</Button>
679+
</DropdownMenuTrigger>
680+
<DropdownMenuContent align="end">
681+
<DropdownMenuItem asChild>
682+
<a
683+
href={deployment.inspectorUrl}
684+
target="_blank"
685+
rel="noopener noreferrer"
686+
className="cursor-pointer"
687+
>
688+
View Deployment
689+
</a>
690+
</DropdownMenuItem>
691+
</DropdownMenuContent>
692+
</DropdownMenu>
693+
)}
694+
</div>
667695
</div>
668696
)}
669697
</div>

0 commit comments

Comments
 (0)