--- import { resolveOrgOwners } from "@/lib/repo-owner"; import { getDatabase, schema } from "@/db"; import BaseLayout from "@/layouts/BaseLayout.astro"; import { desc, eq, inArray } from "drizzle-orm"; import StackCard from "@/components/dashboard/StackCard.astro"; import { Layers, ArrowLeft } from "lucide-react"; const user = Astro.locals.user; if (!user) { return Astro.redirect("/login"); } const db = getDatabase(); // Fetch user's stacks const userPrs = await db.query.pullRequests.findMany({ where: eq(schema.pullRequests.authorId, user.id), columns: { id: true }, }); let stacks: any[] = []; const prIds = (await resolveOrgOwners(userPrs)).map((pr: any) => pr.id); if (prIds.length > 0) { const stackEntries = await db.query.prStackEntries.findMany({ where: inArray(schema.prStackEntries.pullRequestId, prIds), columns: { stackId: true }, }); const uniqueStackIds = [...new Set(stackEntries.map((e) => e.stackId))]; if (uniqueStackIds.length > 0) { const dbStacks = await db.query.prStacks.findMany({ where: inArray(schema.prStacks.id, uniqueStackIds), orderBy: [desc(schema.prStacks.updatedAt)], with: { repository: { with: { owner: true, }, }, entries: { orderBy: (entries, { asc }) => [asc(entries.stackOrder)], with: { pullRequest: true, }, }, }, }); stacks = dbStacks.map((stack) => ({ id: stack.id, name: stack.name || `Stack-${stack.id.substring(0, 6)}`, baseBranch: stack.baseBranch, status: stack.status, repoName: stack.repository.name, repoOwner: stack.repository.owner.username, updatedAt: stack.updatedAt.toISOString(), prs: stack.entries.map((entry) => ({ id: entry.pullRequest.id, number: entry.pullRequest.number, title: entry.pullRequest.title, status: entry.pullRequest.state, url: `/${stack.repository.owner.username}/${stack.repository.name}/pulls/${entry.pullRequest.number}`, position: entry.stackOrder, isMerged: entry.pullRequest.state === "merged", isClosed: entry.pullRequest.state === "closed", })), })); } } ---

Your Stacks {stacks.length}

Manage and visualize your stacked pull requests

Dashboard
{ stacks.length > 0 ? (
{stacks.map((stack) => ( ))}
) : (

No active stacks

Create stacked pull requests with the OpenCodeHub CLI to manage dependent changes cleanly.

och stack create <branch>
) }