The Suggestions page: the support agent's draft replies (~/aimsight-support), read-only from Supabase Conversations (table and bucket suggestions): status, reason, the reply to copy and its figures to download; SUPABASE_CONVERSATIONS_* from the app's .env (the service's EnvironmentFile); nothing is sent from the app
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
54bcce1281
commit
f0470295fa
6 files changed
+170
-4
No files matched your search
@@ -0,0 +1,69 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Anchor, Badge, Button, Card, CopyButton, Group, Image, ScrollArea, SimpleGrid, Stack, Table, Text, Textarea, Title } from "@mantine/core";
|
||||
import { call } from "../common.jsx";
|
||||
|
||||
const when = t => (t ? t.slice(0, 16).replace("T", " ") : "");
|
||||
const COLORS = { ready: "green", needs_human: "orange", failed: "red", skipped: "gray" };
|
||||
|
||||
// The support agent's suggestions (~/aimsight-support), read-only from Supabase Conversations: one per customer message,
|
||||
// newest first; a click shows the draft reply (to copy into the mail in LibreDesk) and its figures (to download and paste)
|
||||
export default function Suggestions() {
|
||||
const [list, setList] = useState([]), [open, setOpen] = useState(null);
|
||||
const read = () => call("/api/suggestions").then(l => l && setList(l));
|
||||
useEffect(() => { read(); }, []);
|
||||
const s = list.find(r => r.id === open);
|
||||
return (
|
||||
<Stack gap="lg" maw={1200}>
|
||||
<div>
|
||||
<Title order={2}>Suggestions</Title>
|
||||
<Text c="dimmed">The support agent's draft replies to the customers' questions about their data. Nothing is sent from
|
||||
here: copy the reply and the figures into the mail in LibreDesk, adapt it, send it.</Text>
|
||||
</div>
|
||||
<Card shadow="sm" withBorder>
|
||||
<Stack gap="md">
|
||||
<Group><Button variant="default" onClick={read}>Refresh</Button></Group>
|
||||
{list.length ? (
|
||||
<ScrollArea.Autosize mah={400}>
|
||||
<Table highlightOnHover verticalSpacing={4} stickyHeader>
|
||||
<Table.Thead><Table.Tr><Table.Th>Ref.</Table.Th><Table.Th>Subject</Table.Th><Table.Th>Status</Table.Th>
|
||||
<Table.Th>Reason</Table.Th><Table.Th>Updated (UTC)</Table.Th></Table.Tr></Table.Thead>
|
||||
<Table.Tbody>
|
||||
{list.map(r => (
|
||||
<Table.Tr key={r.id} onClick={() => setOpen(r.id)} style={{ cursor: "pointer" }}
|
||||
bg={open === r.id ? "var(--mantine-primary-color-light)" : undefined}>
|
||||
<Table.Td ff="monospace">{r.reference}</Table.Td><Table.Td>{r.subject}</Table.Td>
|
||||
<Table.Td><Badge color={COLORS[r.status] || "blue"} variant="light">{r.status}</Badge></Table.Td>
|
||||
<Table.Td>{r.error || r.triage?.reason || ""}</Table.Td><Table.Td ff="monospace">{when(r.updated_at)}</Table.Td>
|
||||
</Table.Tr>
|
||||
))}
|
||||
</Table.Tbody>
|
||||
</Table>
|
||||
</ScrollArea.Autosize>
|
||||
) : <Text c="dimmed" size="sm">No suggestion yet.</Text>}
|
||||
</Stack>
|
||||
</Card>
|
||||
{s && (
|
||||
<Card shadow="sm" withBorder>
|
||||
<Stack gap="md">
|
||||
<Text size="sm" c="dimmed">#{s.reference} {s.subject} · station {s.triage?.station || "?"} · days {(s.triage?.range || []).join(" → ")}</Text>
|
||||
{s.reply ? (
|
||||
<>
|
||||
<Textarea value={s.reply} readOnly autosize minRows={6} />
|
||||
<Group><CopyButton value={s.reply}>{({ copied, copy }) => <Button onClick={copy}>{copied ? "Copied" : "Copy the reply"}</Button>}</CopyButton></Group>
|
||||
<SimpleGrid cols={{ base: 1, md: 2 }}>
|
||||
{s.figures.map(f => (
|
||||
<Stack key={f.path} gap={4}>
|
||||
<Image src={`/api/suggestions/figure/${f.path}`} alt={f.caption} />
|
||||
<Group justify="space-between"><Text size="xs">{f.caption}</Text>
|
||||
<Anchor size="xs" href={`/api/suggestions/figure/${f.path}`} download={f.path.replace("/", "_")}>Download</Anchor></Group>
|
||||
</Stack>
|
||||
))}
|
||||
</SimpleGrid>
|
||||
</>
|
||||
) : <Text size="sm">{s.error || "In progress: " + s.status}</Text>}
|
||||
</Stack>
|
||||
</Card>
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user