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:
maximeandClaude Opus 5.5 committed 2026-11-25 11:21:27 +01:00
1 parent 54bcce1281
commit f0470295fa
6 files changed
+170 -4

No files matched your search

+4 -2
View File
@@ -3,13 +3,14 @@ import {
ActionIcon, AppShell, Burger, ColorSwatch, Group, Loader, NavLink, ScrollArea, Text, Tooltip, useComputedColorScheme, useMantineColorScheme,
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { IconChartLine, IconCircleCheck, IconCircleDashed, IconFolder, IconMessages, IconMoon, IconPointFilled, IconSatellite, IconSun } from "@tabler/icons-react";
import { IconChartLine, IconCircleCheck, IconCircleDashed, IconFolder, IconMessages, IconMailForward, IconMoon, IconPointFilled, IconSatellite, IconSun } from "@tabler/icons-react";
const Data = lazy(() => import("./pages/Data.jsx")); // Plotly, loaded only here
const Stations = lazy(() => import("./pages/Stations.jsx"));
const Conversations = lazy(() => import("./pages/Conversations.jsx"));
const Points = lazy(() => import("./pages/Points.jsx"));
const PAGES = [["data", "Data", IconChartLine], ["points", "Points", IconPointFilled], ["stations", "Stations", IconSatellite], ["conversations", "Conversations", IconMessages]];
const Suggestions = lazy(() => import("./pages/Suggestions.jsx"));
const PAGES = [["data", "Data", IconChartLine], ["points", "Points", IconPointFilled], ["stations", "Stations", IconSatellite], ["conversations", "Conversations", IconMessages], ["suggestions", "Suggestions", IconMailForward]];
// The address: #/<page>?station=…&start=…&end=…; reloading keeps the page and the selection, Back works; without dates, the
// last 5 UTC days, today included (end excluded: tomorrow)
@@ -145,6 +146,7 @@ export default function App() {
<Suspense fallback={<Loader m="xl" />}>
{page === "stations" ? <Stations selection={selection} />
: page === "conversations" ? <Conversations />
: page === "suggestions" ? <Suggestions />
: page === "points" ? <Points selection={selection} choose={choose} />
: <Data selection={selection} choose={choose} analysis={analysis} setAnalysis={setAnalysis}
support={support} setSupport={setSupport} />}
+69
View File
@@ -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>
);
}