diff --git a/src/app/s/[sessionId]/page.tsx b/src/app/s/[sessionId]/page.tsx index 4d8581b893..dc2ea344ae 100644 --- a/src/app/s/[sessionId]/page.tsx +++ b/src/app/s/[sessionId]/page.tsx @@ -1,10 +1,109 @@ -export default function SharedSessionPage({ params }: { params: { sessionId: string } }) { - const { sessionId } = params; +import { db } from '@/lib/drizzle'; +import { eq } from 'drizzle-orm'; +import { cli_sessions_v2, kilocode_users } from '@/db/schema'; +import { notFound } from 'next/navigation'; +import { validate as isValidUUID } from 'uuid'; +import { AnimatedLogo } from '@/components/AnimatedLogo'; +import { CopyableCommand } from '@/components/CopyableCommand'; +import { APP_URL } from '@/lib/constants'; +import { OpenInCliButton } from '@/app/share/[shareId]/open-in-cli-button'; +import { Card, CardContent, CardHeader } from '@/components/ui/card'; + +export const revalidate = 86400; + +export default async function SharedSessionPage({ + params, +}: { + params: Promise<{ sessionId: string }>; +}) { + const { sessionId } = await params; + + // Validate sessionId is a valid UUID before querying the database + if (!isValidUUID(sessionId)) { + return notFound(); + } + + const sessionResult = await db + .select({ + ownerName: kilocode_users.google_user_name, + title: cli_sessions_v2.title, + }) + .from(cli_sessions_v2) + .leftJoin(kilocode_users, eq(cli_sessions_v2.kilo_user_id, kilocode_users.id)) + .where(eq(cli_sessions_v2.public_id, sessionId)) + .limit(1); + + if (sessionResult.length === 0) { + return notFound(); + } + + const session = sessionResult[0]; + const shareUrl = `${APP_URL}/s/${sessionId}`; + const importCommand = `kilo import ${shareUrl}`; return ( -
-

Shared session

-

Session: {sessionId}

-
+
+
+
+
+
+
+ +
+
+
+ +
+ + + +

+ {session.ownerName ?? 'Someone'} shared a session +

+ {session.title && ( +
+ {session.title} +
+ )} +
+ + +
+
+
+
Import in CLI
+
+ Copy the command, then paste it in your terminal. +
+
+
+ +
+
+ +
+ +
+
+ +
+ Need the CLI?{' '} + + Install Kilo + +
+
+
+
+
+
); }