import type { Session } from "agents-shared/contract"; import type { Part, Reason } from "agents-shared/find"; import { repositories, repositoryLinks, sessionKey } from "agents-shared/repos"; import { age, sessionTitle, statusLabel } from "agents-shared/sessions"; import * as Clipboard from "expo-clipboard"; import { Link } from "expo-router"; import { memo } from "react"; import { Pressable, StyleSheet, Text, useWindowDimensions, View } from "react-native"; import { haptic } from "@/haptics"; import { color, inset } from "@/theme"; import { type } from "@/type"; import { useCalendar } from "@/zone"; import { HarnessBadge } from "./Harness"; import { Highlight, MatchReason } from "./Highlight"; import { openLink, RepoRail } from "./RepoRail"; export const SessionRow = memo(function SessionRow({ session: s, now, match }: { session: Session; now: number; match?: { title: Part[]; reason: Reason } }) { const cal = useCalendar(); const recent = s.status === "recent"; const repos = repositoryLinks(repositories(s)); const when = age(s.updated, cal, now); const large = useWindowDimensions().fontScale > 1.35; const place = s.worktree || s.project || "No project"; const flags = [s.subagent && "Subagent", s.archived && "Archived"].filter(Boolean).join(" · "); return ( {({ pressed }) => ( {match ? ( ) : ( {sessionTitle(s)} )} {large ? null : {when}} {large ? `${when} · ` : ""} {place} {s.host ? ` · ${s.host}` : ""} {" · "} {statusLabel(s.status)} {flags ? ` · ${flags}` : ""} {match ? : null} )} { void Clipboard.setStringAsync(s.id); haptic.success(); }} /> {repos.map((repo) => ( openLink(repo.href)} /> ))} {repos.length ? ( ) : null} ); }); const styles = StyleSheet.create({ item: { backgroundColor: color.surface, paddingBottom: 10 }, row: { flexDirection: "row", alignItems: "flex-start", gap: 12, paddingHorizontal: inset, paddingTop: 10 }, content: { flex: 1, gap: 2 }, titleLine: { flexDirection: "row", alignItems: "flex-start", gap: 8 }, rail: { marginTop: 6 }, });