open-swe/ui/src/routes/usage.tsx

339 lines
11 KiB
TypeScript
Raw Normal View History

chore: cherry-pick clean upstream fixes + cherry-pick runbook (#117) * fix: make plan view mobile friendly (#1636) Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 7ee3e0572406359632502b0d65450709a03645ea) * fix: return to thread after plan approval (#1637) Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit f32e492ab46c120130e0c63eeca3eb353f10d83e) * feat: reviews block agenda, sticky headers, accurate diff scroll (#1653) Rework the AI-sorted blocks experience on the PR reviews page into a Google-Docs-style outline: the left sidebar is now a clean number+title agenda with scroll-spy highlighting of the active block; each block shows its title + description (sticky) above its diff; and diff rows are pinned to a uniform height so scroll-to lands precisely via the virtualizer's own geometry instead of an estimate-driven correction loop. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 0b76afdc955e33805c7623d1502a75a9c7c9c1b7) * fix: jump + ResizeObserver settle for review scroll-to (#1655) Replace smooth-scroll plus frame-count correction loops on the PR reviews page with an instant jump that re-asserts its target via a ResizeObserver (the real "layout settled" signal). Block/file navigation and finding/comment centering now land deterministically as off-screen cards mount, files expand, and annotation cards measure, instead of racing a smooth-scroll animation against height reconciliation. Holds bail on user wheel/touch input and after a short ceiling, and a new navigation cancels the previous hold. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> Co-authored-by: Johannes du Plessis <johannes@langchain.dev> (cherry picked from commit 7530653bba7774d66a54b8bef0d2bbc25f519942) * fix: purge expired thread_wakeup crons (#1656) * fix: purge expired thread_wakeup crons One-shot wakeup crons set an end_time that stops re-firing but the cron row is never deleted, so dead rows accumulate (86 in prod). Add a purge that deletes thread_wakeup crons past their end_time, called opportunistically before scheduling a new wakeup, plus a one-time backfill script. Conservative: matches only kind=thread_wakeup with a past end_time. * chore: retrigger Open SWE review --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 9e5a1924ef306269322c31342a1831e57831cfee) * fix: add top padding to sticky review block header (#1660) * fix: add top padding to sticky review block header The sticky per-block header on the reviews page had padding below but none above, so the block number badge sat glued against the top edge when pinned. Add matching top padding for breathing room. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * chore: use py-2 shorthand for review block header padding Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 23bd4a63fc5ba0fe853babf79ed33feb866cc8b2) * fix: use global tokens for sidebar filter popover border (#1661) The filter popover renders via base-ui Menu.Portal into document.body, outside the .agents-ui container where the --ui-* CSS variables are scoped. As a result border-[var(--ui-border)] resolved to an undefined variable and border-color fell back to currentColor, producing a strong near-black border (separators/hover/labels were similarly off). Switch the portaled popup styling to the same global shadcn tokens the theme/settings popover (SidebarUserMenu) already uses (border-border, bg-border, bg-muted, text-muted-foreground). These are defined at :root so they resolve inside portals too, and match the settings popover. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 63eb9a08209f683016abf01cdcc548bc5905f158) * fix: preserve dashboard redirect after login (#1668) * fix: preserve dashboard redirect after login Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * test: cover plan login redirect in e2e Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> --------- Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit bc7ce59169b5350da7286164afb83a7b037b528d) * Disable React StrictMode (#1654) Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 6575c327a3ac2b107a6e79a04fa61168d779dbf0) * docs(upstream-sync): add cherry-pick runbook Repo-specific runbook for bringing upstream (langchain-ai/open-swe) commits into the fork: triage-sync discovery, the git cp workflow, the triage ledger, themed-branch layout, and conflict/regression handling. --------- Co-authored-by: Johannes du Plessis <johannes@langchain.dev> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> Co-authored-by: Ramon Nogueira <ramon.nogueira@langchain.dev> Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: Caroline di Vittorio <43390382+carolinedivittorio@users.noreply.github.com>
2026-07-03 11:48:40 -04:00
import { createFileRoute } from "@tanstack/react-router"
import { useQuery } from "@tanstack/react-query"
import type {
ReviewerStatsPayload,
UsageLeaderboardPeriod,
UsageLeaderboardRow,
} from "@/lib/api"
import { AppShell, SettingsSection } from "@/components/AppShell"
import { Avatar, AvatarFallback } from "@/components/ui/avatar"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import { Skeleton } from "@/components/ui/skeleton"
import { api } from "@/lib/api"
chore: cherry-pick clean upstream fixes + cherry-pick runbook (#117) * fix: make plan view mobile friendly (#1636) Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 7ee3e0572406359632502b0d65450709a03645ea) * fix: return to thread after plan approval (#1637) Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit f32e492ab46c120130e0c63eeca3eb353f10d83e) * feat: reviews block agenda, sticky headers, accurate diff scroll (#1653) Rework the AI-sorted blocks experience on the PR reviews page into a Google-Docs-style outline: the left sidebar is now a clean number+title agenda with scroll-spy highlighting of the active block; each block shows its title + description (sticky) above its diff; and diff rows are pinned to a uniform height so scroll-to lands precisely via the virtualizer's own geometry instead of an estimate-driven correction loop. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 0b76afdc955e33805c7623d1502a75a9c7c9c1b7) * fix: jump + ResizeObserver settle for review scroll-to (#1655) Replace smooth-scroll plus frame-count correction loops on the PR reviews page with an instant jump that re-asserts its target via a ResizeObserver (the real "layout settled" signal). Block/file navigation and finding/comment centering now land deterministically as off-screen cards mount, files expand, and annotation cards measure, instead of racing a smooth-scroll animation against height reconciliation. Holds bail on user wheel/touch input and after a short ceiling, and a new navigation cancels the previous hold. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> Co-authored-by: Johannes du Plessis <johannes@langchain.dev> (cherry picked from commit 7530653bba7774d66a54b8bef0d2bbc25f519942) * fix: purge expired thread_wakeup crons (#1656) * fix: purge expired thread_wakeup crons One-shot wakeup crons set an end_time that stops re-firing but the cron row is never deleted, so dead rows accumulate (86 in prod). Add a purge that deletes thread_wakeup crons past their end_time, called opportunistically before scheduling a new wakeup, plus a one-time backfill script. Conservative: matches only kind=thread_wakeup with a past end_time. * chore: retrigger Open SWE review --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 9e5a1924ef306269322c31342a1831e57831cfee) * fix: add top padding to sticky review block header (#1660) * fix: add top padding to sticky review block header The sticky per-block header on the reviews page had padding below but none above, so the block number badge sat glued against the top edge when pinned. Add matching top padding for breathing room. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * chore: use py-2 shorthand for review block header padding Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 23bd4a63fc5ba0fe853babf79ed33feb866cc8b2) * fix: use global tokens for sidebar filter popover border (#1661) The filter popover renders via base-ui Menu.Portal into document.body, outside the .agents-ui container where the --ui-* CSS variables are scoped. As a result border-[var(--ui-border)] resolved to an undefined variable and border-color fell back to currentColor, producing a strong near-black border (separators/hover/labels were similarly off). Switch the portaled popup styling to the same global shadcn tokens the theme/settings popover (SidebarUserMenu) already uses (border-border, bg-border, bg-muted, text-muted-foreground). These are defined at :root so they resolve inside portals too, and match the settings popover. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 63eb9a08209f683016abf01cdcc548bc5905f158) * fix: preserve dashboard redirect after login (#1668) * fix: preserve dashboard redirect after login Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * test: cover plan login redirect in e2e Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> --------- Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit bc7ce59169b5350da7286164afb83a7b037b528d) * Disable React StrictMode (#1654) Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 6575c327a3ac2b107a6e79a04fa61168d779dbf0) * docs(upstream-sync): add cherry-pick runbook Repo-specific runbook for bringing upstream (langchain-ai/open-swe) commits into the fork: triage-sync discovery, the git cp workflow, the triage ledger, themed-branch layout, and conflict/regression handling. --------- Co-authored-by: Johannes du Plessis <johannes@langchain.dev> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> Co-authored-by: Ramon Nogueira <ramon.nogueira@langchain.dev> Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: Caroline di Vittorio <43390382+carolinedivittorio@users.noreply.github.com>
2026-07-03 11:48:40 -04:00
import { RequireLogin } from "@/lib/auth-redirect"
import { useSession } from "@/lib/session"
export const Route = createFileRoute("/usage")({
validateSearch: (search: Record<string, unknown>) => ({
period: typeof search.period === "string" ? search.period : undefined,
}),
component: UsagePage,
})
const PERIOD_LABELS: Record<UsageLeaderboardPeriod, string> = {
"7d": "Last 7 days",
"30d": "Last 30 days",
all: "All time",
}
function UsagePage() {
const session = useSession()
const period =
(Route.useSearch().period as UsageLeaderboardPeriod | undefined) ?? "30d"
const navigate = Route.useNavigate()
const activePeriod: UsageLeaderboardPeriod = ["7d", "30d", "all"].includes(
period
)
? period
: "30d"
const leaderboard = useQuery({
queryKey: ["usageLeaderboard", activePeriod],
queryFn: () => api.usageLeaderboard(activePeriod, 10),
enabled: !!session.data,
staleTime: 5 * 60 * 1000,
})
if (session.isLoading) {
return (
<main className="p-6">
<Skeleton className="h-64 w-full" />
</main>
)
}
chore: cherry-pick clean upstream fixes + cherry-pick runbook (#117) * fix: make plan view mobile friendly (#1636) Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 7ee3e0572406359632502b0d65450709a03645ea) * fix: return to thread after plan approval (#1637) Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit f32e492ab46c120130e0c63eeca3eb353f10d83e) * feat: reviews block agenda, sticky headers, accurate diff scroll (#1653) Rework the AI-sorted blocks experience on the PR reviews page into a Google-Docs-style outline: the left sidebar is now a clean number+title agenda with scroll-spy highlighting of the active block; each block shows its title + description (sticky) above its diff; and diff rows are pinned to a uniform height so scroll-to lands precisely via the virtualizer's own geometry instead of an estimate-driven correction loop. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 0b76afdc955e33805c7623d1502a75a9c7c9c1b7) * fix: jump + ResizeObserver settle for review scroll-to (#1655) Replace smooth-scroll plus frame-count correction loops on the PR reviews page with an instant jump that re-asserts its target via a ResizeObserver (the real "layout settled" signal). Block/file navigation and finding/comment centering now land deterministically as off-screen cards mount, files expand, and annotation cards measure, instead of racing a smooth-scroll animation against height reconciliation. Holds bail on user wheel/touch input and after a short ceiling, and a new navigation cancels the previous hold. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> Co-authored-by: Johannes du Plessis <johannes@langchain.dev> (cherry picked from commit 7530653bba7774d66a54b8bef0d2bbc25f519942) * fix: purge expired thread_wakeup crons (#1656) * fix: purge expired thread_wakeup crons One-shot wakeup crons set an end_time that stops re-firing but the cron row is never deleted, so dead rows accumulate (86 in prod). Add a purge that deletes thread_wakeup crons past their end_time, called opportunistically before scheduling a new wakeup, plus a one-time backfill script. Conservative: matches only kind=thread_wakeup with a past end_time. * chore: retrigger Open SWE review --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 9e5a1924ef306269322c31342a1831e57831cfee) * fix: add top padding to sticky review block header (#1660) * fix: add top padding to sticky review block header The sticky per-block header on the reviews page had padding below but none above, so the block number badge sat glued against the top edge when pinned. Add matching top padding for breathing room. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * chore: use py-2 shorthand for review block header padding Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> --------- Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 23bd4a63fc5ba0fe853babf79ed33feb866cc8b2) * fix: use global tokens for sidebar filter popover border (#1661) The filter popover renders via base-ui Menu.Portal into document.body, outside the .agents-ui container where the --ui-* CSS variables are scoped. As a result border-[var(--ui-border)] resolved to an undefined variable and border-color fell back to currentColor, producing a strong near-black border (separators/hover/labels were similarly off). Switch the portaled popup styling to the same global shadcn tokens the theme/settings popover (SidebarUserMenu) already uses (border-border, bg-border, bg-muted, text-muted-foreground). These are defined at :root so they resolve inside portals too, and match the settings popover. Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 63eb9a08209f683016abf01cdcc548bc5905f158) * fix: preserve dashboard redirect after login (#1668) * fix: preserve dashboard redirect after login Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> * test: cover plan login redirect in e2e Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> --------- Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit bc7ce59169b5350da7286164afb83a7b037b528d) * Disable React StrictMode (#1654) Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> (cherry picked from commit 6575c327a3ac2b107a6e79a04fa61168d779dbf0) * docs(upstream-sync): add cherry-pick runbook Repo-specific runbook for bringing upstream (langchain-ai/open-swe) commits into the fork: triage-sync discovery, the git cp workflow, the triage ledger, themed-branch layout, and conflict/regression handling. --------- Co-authored-by: Johannes du Plessis <johannes@langchain.dev> Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com> Co-authored-by: Ramon Nogueira <ramon.nogueira@langchain.dev> Co-authored-by: Ramon Nogueira <270434257+ramon-langchain@users.noreply.github.com> Co-authored-by: Caroline di Vittorio <43390382+carolinedivittorio@users.noreply.github.com>
2026-07-03 11:48:40 -04:00
if (!session.data) return <RequireLogin />
return (
<AppShell user={session.data} title="Usage" className="max-w-5xl">
<SettingsSection
title="Agent leaderboard"
description="Ranked by merged PRs, then agent lines of code, PRs opened, and agent runs."
action={
<Select
value={activePeriod}
onValueChange={(value) =>
navigate({
to: "/usage",
search: { period: value as UsageLeaderboardPeriod },
})
}
>
<SelectTrigger className="w-36">
<SelectValue />
</SelectTrigger>
<SelectContent>
{Object.entries(PERIOD_LABELS).map(([value, label]) => (
<SelectItem key={value} value={value}>
{label}
</SelectItem>
))}
</SelectContent>
</Select>
}
>
{leaderboard.isLoading ? (
<div className="space-y-2 p-4">
<Skeleton className="h-12 w-full" />
<Skeleton className="h-12 w-full" />
<Skeleton className="h-12 w-full" />
</div>
) : leaderboard.isError ? (
<p className="p-4 text-xs text-destructive">
Failed to load usage data: {leaderboard.error.message}
</p>
) : !leaderboard.data?.rows.length ? (
<div className="p-6 text-center text-xs text-muted-foreground">
No Open SWE Agent usage has been recorded for{" "}
{PERIOD_LABELS[activePeriod].toLowerCase()} yet.
</div>
) : (
<UsageTable
rows={leaderboard.data.rows}
totalMembers={leaderboard.data.total_members}
/>
)}
</SettingsSection>
<SettingsSection
title="Reviewer stats"
description="Issues surfaced by Open SWE Review and how often users addressed them."
>
{leaderboard.isLoading ? (
<div className="grid gap-3 p-4 sm:grid-cols-2">
<Skeleton className="h-24 w-full" />
<Skeleton className="h-24 w-full" />
<Skeleton className="h-24 w-full" />
<Skeleton className="h-24 w-full" />
</div>
) : leaderboard.isError ? (
<p className="p-4 text-xs text-destructive">
Failed to load reviewer stats: {leaderboard.error.message}
</p>
) : leaderboard.data?.reviewer_stats ? (
<ReviewerStats stats={leaderboard.data.reviewer_stats} />
) : (
<div className="p-6 text-center text-xs text-muted-foreground">
No reviewer stats have been recorded for{" "}
{PERIOD_LABELS[activePeriod].toLowerCase()} yet.
</div>
)}
</SettingsSection>
</AppShell>
)
}
function UsageTable({
rows,
totalMembers,
}: {
rows: Array<UsageLeaderboardRow>
totalMembers: number
}) {
return (
<div className="overflow-x-auto">
<table className="w-full min-w-[760px] text-xs">
<thead className="border-b border-border text-xs text-muted-foreground">
<tr>
<th className="w-14 px-4 py-3 text-left font-normal">Rank</th>
<th className="px-2 py-3 text-left font-normal">User</th>
<th className="px-2 py-3 text-left font-normal">Favorite Model</th>
<th className="px-2 py-3 text-right font-normal">Agent Runs</th>
<th className="px-2 py-3 text-right font-normal">PRs Opened</th>
<th className="px-2 py-3 text-right font-normal">Merged PRs</th>
<th className="px-4 py-3 text-right font-normal">Agent LOC</th>
</tr>
</thead>
<tbody className="divide-y divide-border">
{rows.map((row) => (
<tr
key={`${row.rank}-${row.user.github_login ?? row.user.email ?? row.user.name}`}
>
<td className="px-4 py-3 text-muted-foreground">{row.rank}</td>
<td className="px-2 py-3">
<UserCell row={row} />
</td>
<td className="max-w-48 truncate px-2 py-3 text-muted-foreground">
{row.favorite_model}
</td>
<td className="px-2 py-3 text-right tabular-nums">
{formatNumber(row.agent_runs)}
</td>
<td className="px-2 py-3 text-right tabular-nums">
{formatNumber(row.prs_opened)}
</td>
<td className="px-2 py-3 text-right tabular-nums">
{formatNumber(row.merged_prs)}
</td>
<td
className="px-4 py-3 text-right tabular-nums"
title={`${formatNumber(row.additions)} additions, ${formatNumber(row.deletions)} deletions`}
>
{formatNumber(row.agent_loc)}
</td>
</tr>
))}
</tbody>
</table>
<div className="border-t border-border px-4 py-3 text-xs text-muted-foreground">
Top {Math.min(10, totalMembers)} of {formatNumber(totalMembers)} member
{totalMembers === 1 ? "" : "s"}
</div>
</div>
)
}
function ReviewerStats({ stats }: { stats: ReviewerStatsPayload }) {
const cards = [
{
label: "Reviewed PRs",
value: stats.reviewed_prs,
helper: `${formatNumber(stats.prs_with_findings)} with findings`,
},
{
label: "Issues surfaced",
value: stats.surfaced_findings,
helper: `${formatNumber(stats.findings_recorded)} recorded`,
},
{
label: "Addressed & resolved",
value: stats.addressed_findings,
helper: `${formatPercent(stats.resolution_rate)} of surfaced`,
},
{
label: "Resolved after update",
value: stats.resolved_after_update,
helper: "Resolved on a later PR head",
},
{
label: "Awaiting follow-up",
value: stats.unresolved_surfaced_findings,
helper: "Surfaced but not resolved/dismissed",
},
{
label: "Dismissed",
value: stats.dismissed_findings,
helper: `${formatNumber(stats.human_replies)} human replies tracked`,
},
]
return (
<div className="space-y-4 p-4">
<div className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
{cards.map((card) => (
<div key={card.label} className="rounded-md border border-border p-3">
<div className="text-xs text-muted-foreground">{card.label}</div>
<div className="mt-1 text-lg font-medium tabular-nums">
{formatNumber(card.value)}
</div>
<div className="mt-1 text-xs text-muted-foreground">
{card.helper}
</div>
</div>
))}
</div>
<div className="grid gap-4 border-t border-border pt-4 sm:grid-cols-2">
<CounterList title="Top categories" rows={stats.top_categories} />
<CounterList title="Severity mix" rows={severityRows(stats)} />
</div>
</div>
)
}
function severityRows(
stats: ReviewerStatsPayload
): Array<{ name: string; count: number }> {
return ["critical", "high", "medium", "low"]
.map((severity) => ({
name: severity,
count: stats.severity_counts[severity] ?? 0,
}))
.filter((row) => row.count > 0)
}
function CounterList({
title,
rows,
}: {
title: string
rows: Array<{ name: string; count: number }>
}) {
return (
<div>
<h3 className="text-xs font-medium text-muted-foreground">{title}</h3>
{rows.length ? (
<ul className="mt-2 space-y-2 text-xs">
{rows.map((row) => (
<li
key={row.name}
className="flex items-center justify-between gap-3"
>
<span className="truncate text-foreground">{row.name}</span>
<span className="text-muted-foreground tabular-nums">
{formatNumber(row.count)}
</span>
</li>
))}
</ul>
) : (
<p className="mt-2 text-xs text-muted-foreground">No data yet.</p>
)}
</div>
)
}
function UserCell({ row }: { row: UsageLeaderboardRow }) {
const initials = initialsFor(row.user.name)
return (
<div className="flex min-w-0 items-center gap-2.5">
<Avatar>
<AvatarFallback>{initials}</AvatarFallback>
</Avatar>
<div className="flex min-w-0 flex-col">
<span className="truncate font-medium text-foreground">
{row.user.name}
</span>
<span className="truncate text-xs text-muted-foreground">
{row.user.email ?? row.user.github_login ?? "unknown"}
</span>
</div>
</div>
)
}
function initialsFor(name: string): string {
const parts = name.trim().split(/\s+/).filter(Boolean)
if (!parts.length) return "?"
const first = parts[0] ?? "?"
const second = parts[1]
if (!second) return first.slice(0, 2).toUpperCase()
return `${first[0] ?? ""}${second[0] ?? ""}`.toUpperCase()
}
function formatNumber(value: number): string {
return new Intl.NumberFormat().format(value)
}
function formatPercent(value: number): string {
return new Intl.NumberFormat(undefined, {
maximumFractionDigits: 0,
style: "percent",
}).format(value)
}