import { memo, useState } from "react"; import { Pressable, StyleSheet, Text, View } from "react-native"; import { colors, monoFont } from "@/lib/theme"; type Props = { toolName: string; status: "running" | "done" | "error"; argsPreview?: string; detail?: string; }; const STATUS_COLOR: Record = { running: colors.warning, done: colors.success, error: colors.error, }; function ToolCallCardComponent({ toolName, status, argsPreview, detail }: Props) { const [expanded, setExpanded] = useState(false); const output = detail?.trim() ?? ""; const expandable = output.length > 0; return ( setExpanded((value) => !value) : undefined} > {status === "error" ? "✕" : "❯"} {toolName} {argsPreview ? ( {argsPreview} ) : ( )} {status === "running" ? running… : null} {expandable ? {expanded ? "−" : "+"} : null} {expandable ? ( {expanded ? ( {output} ) : ( {output} )} ) : null} ); } export const ToolCallCard = memo(ToolCallCardComponent); const styles = StyleSheet.create({ container: { alignSelf: "stretch", paddingVertical: 2, gap: 4, }, header: { flexDirection: "row", alignItems: "center", gap: 8, }, prompt: { fontFamily: monoFont, fontSize: 12, fontWeight: "700", }, name: { color: colors.textSecondary, fontFamily: monoFont, fontSize: 13, fontWeight: "600", }, args: { flex: 1, color: colors.textMuted, fontFamily: monoFont, fontSize: 12, }, spacer: { flex: 1, }, statusLabel: { color: colors.warning, fontFamily: monoFont, fontSize: 11, }, chevron: { color: colors.textMuted, fontFamily: monoFont, fontSize: 13, }, outputWrap: { borderLeftWidth: 1, borderLeftColor: colors.borderSubtle, marginLeft: 4, paddingLeft: 10, }, output: { color: colors.textSecondary, fontFamily: monoFont, fontSize: 12, lineHeight: 17, }, outputPreview: { color: colors.textMuted, fontFamily: monoFont, fontSize: 12, lineHeight: 17, }, });