Support page: choose a PDF or a reply mail (D-141)

PDF | Mail before Analyser. In mail mode the support agent gets ecrire_mail
(body + figures of the session as attachments, mail-vN.json) instead of the
presentation tools; its prompt ends with prompts/support-mail.md, without
presentation.md and modele.typ. The page shows the text, Copier, and the
attachments to download. check_sortie_mail in API/support/check.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-11-05 16:48:17 +01:00
1 parent b475da0acc
commit ee3875fe75
13 files changed
+161 -31

No files matched your search

+40 -7
View File
@@ -1,7 +1,7 @@
import { useEffect, useRef, useState } from "react";
import { ActionIcon, Badge, Button, Grid, Group, Image, Paper, ScrollArea, Select, SimpleGrid, Stack, Text, Textarea, Title, Tooltip } from "@mantine/core";
import { ActionIcon, Anchor, Badge, Button, CopyButton, Grid, Group, Image, Paper, ScrollArea, SegmentedControl, Select, SimpleGrid, Stack, Text, Textarea, Title, Tooltip } from "@mantine/core";
import { notifications } from "@mantine/notifications";
import { IconChartLine, IconDownload, IconPhoto, IconSend } from "@tabler/icons-react";
import { IconChartLine, IconCheck, IconCopy, IconDownload, IconPhoto, IconSend } from "@tabler/icons-react";
import { appel, Carte, poster } from "../commun.jsx";
export const AGENTS = ["support", "analyste"];
@@ -24,7 +24,7 @@ export function Etat({ occupe }) {
function Saisie({ occupe }) {
const [mail, setMail] = useState(""), [contexte, setContexte] = useState(""), [images, setImages] = useState([]);
const [fils, setFils] = useState(null), [fil, setFil] = useState(null);
const [fils, setFils] = useState(null), [fil, setFil] = useState(null), [sortie, setSortie] = useState("pdf");
// LibreDesk : la liste au premier clic sur le menu ; un fil choisi remplit le mail et ses images, qu'on peut retoucher
const listerFils = async () => fils || setFils(await appel("/api/libredesk") || []);
@@ -48,11 +48,16 @@ function Saisie({ occupe }) {
async function analyser() {
if (!mail.trim()) return notifications.show({ color: "orange", message: "Colle d'abord le mail du client." });
const envoi = images.map(({ type, base64 }, i) => ({ nom: `capture-${i + 1}`, type, base64 }));
if (await poster("/api/analyser", { mail, contexte, images: envoi })) setImages([]); // pas de captures d'un client à l'autre
if (await poster("/api/analyser", { mail, contexte, images: envoi, sortie })) setImages([]); // pas de captures d'un client à l'autre
}
return (
<Carte surtitre="Demande" titre="Le mail du client" action={<Button onClick={analyser} disabled={occupe}>Analyser</Button>}>
<Carte surtitre="Demande" titre="Le mail du client" action={
<Group gap="sm">
<SegmentedControl value={sortie} onChange={setSortie} disabled={occupe}
data={[{ value: "pdf", label: "PDF" }, { value: "mail", label: "Mail" }]} />
<Button onClick={analyser} disabled={occupe}>Analyser</Button>
</Group>}>
<Grid p="lg" gutter="lg">
<Grid.Col span={{ base: 12, md: 8 }}>
<Select label="Depuis LibreDesk" placeholder="Choisir une conversation" searchable clearable mb="sm"
@@ -111,6 +116,34 @@ function Fil({ agent, evenements, occupe, seance }) {
);
}
// La sortie mail : le texte à copier, les pièces jointes à télécharger
function Mail({ version }) {
const [m, setM] = useState(null);
useEffect(() => { version && appel("/api/mail").then(setM); }, [version]);
return (
<Carte surtitre="Mail de réponse" titre={version ? `Version ${version.match(/\d+/)[0]}` : "Pas encore de mail"}
action={m && <CopyButton value={m.texte}>{({ copied, copy }) =>
<Button variant="light" onClick={copy} leftSection={copied ? <IconCheck size={16} /> : <IconCopy size={16} />}>
{copied ? "Copié" : "Copier"}</Button>}</CopyButton>}>
{m ? (
<Stack p="lg" gap="md">
<Text size="sm" style={{ whiteSpace: "pre-wrap" }}>{m.texte}</Text>
{m.pieces_jointes.length > 0 && (
<Group gap="md" align="flex-start">
{m.pieces_jointes.map(p => (
<Stack key={`${version}-${p}`} gap={4} align="center">
<Image src={`/api/piece/${encodeURIComponent(p)}?v=${version}`} h={120} w="auto" radius="sm" alt={p} />
<Anchor size="xs" href={`/api/piece/${encodeURIComponent(p)}?telecharger=true&v=${version}`}>{p}</Anchor>
</Stack>
))}
</Group>
)}
</Stack>
) : <Text c="dimmed" ta="center" p="xl">Le mail s'affiche ici dès que le support l'a écrit.</Text>}
</Carte>
);
}
function Rapport({ version, dossier }) {
const src = `/api/pdf?v=${version}`;
return (
@@ -135,7 +168,7 @@ export default function Support({ etat, evenements }) {
<Group justify="space-between" align="flex-end">
<div>
<Title order={2}>Support</Title>
<Text c="dimmed">Colle le mail du client et ton contexte, puis Analyser ; parle au support ou à l'analyste dans leur fil.</Text>
<Text c="dimmed">Colle le mail du client et ton contexte, choisis PDF ou Mail, puis Analyser ; parle au support ou à l'analyste dans leur fil.</Text>
</div>
{etat.station && (
<Group gap="xs">
@@ -149,7 +182,7 @@ export default function Support({ etat, evenements }) {
{AGENTS.map(a => <Fil key={a} agent={a} occupe={etat.occupe[a]} seance={etat.dossier}
evenements={evenements.filter(e => e.agent === a)} />)}
</SimpleGrid>
<Rapport version={etat.version} dossier={etat.dossier} />
{etat.sortie === "mail" ? <Mail version={etat.version} /> : <Rapport version={etat.version} dossier={etat.dossier} />}
</Stack>
);
}