mirror of
https://github.com/siop-spelev/siop2.git
synced 2026-08-08 12:41:54 +00:00
feat(r5.3): écrans IA — assistant web, corpus administrable, suggestions OT/mobile
- Contrat (76 opérations) : Document expose inCorpus/indexedAt/chunkCount,
PATCH /documents/{id}/corpus (ASSETS.edit), POST /assistant/reindex
(bilan chiffré) ; ci-contract vérifie désormais aussi le client mobile.
- Web : page /assistant (chat sourcé — extraits exacts cités, Ouvrir vers
PDF authentifié ou fiche OT, avertissement permanent ; refus honnête
chiffré avec action utile) ; Bibliothèque = corpus (bandeau 09-08,
statut d'indexation par document, interrupteur d'exclusion PDF,
Réindexer tout) ; fiche OT : « Décrire pour suggérer » (Appliquer =
geste humain, liseré « suggéré » retiré au choix manuel).
- Mobile : chips de suggestion dans la clôture (un appui = un champ
pré-rempli, « réseau requis » hors-ligne — la file R4 n'en dépend pas).
- apps/ai : seuils AI_SEUIL_* configurables par env (CI + calibrage).
- CI e2e : service siop2-ai (embeddeur déterministe, seuils calibrés sur
mesures : match 0,66 vs bruit 0,11) + parcours R5 Playwright (PDF généré
xref valide → réindexation → réponse sourcée → refus → suggestion).
- Vérifié : 16/16 Playwright, 78 tests API, 23 pytest, 17 jest-expo ;
chaîne réelle au vrai modèle ONNX (web 7/7, mobile Expo web 6/6).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
149
apps/web/e2e/parcours-r5.spec.ts
Normal file
149
apps/web/e2e/parcours-r5.spec.ts
Normal file
@@ -0,0 +1,149 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* Recette R5 (plan de releases) : la bibliothèque EST le corpus (bandeau
|
||||
* 09-08, statut d'indexation, interrupteur, réindexation explicite) ; puis
|
||||
* l'assistant « sourcé ou silencieux » (réponse citée depuis le PDF téléversé,
|
||||
* refus honnête et chiffré sinon) ; enfin la suggestion de bilan sur un OT
|
||||
* (codes existants, appliqués par le geste humain, liseré « suggéré »).
|
||||
* Le service IA tourne avec l'embeddeur déterministe et des seuils abaissés
|
||||
* (ci.yml) — c'est le CIRCUIT qui se recette, le vrai modèle se recette en
|
||||
* local (journal R5.1).
|
||||
*/
|
||||
|
||||
const suffix = Date.now().toString(36);
|
||||
|
||||
/** PDF 1 page minimal mais VALIDE (xref calculée) — pypdf doit pouvoir en
|
||||
* extraire le texte : c'est ce qui alimente l'index côté service IA. */
|
||||
function pdfMinimal(texte: string): Buffer {
|
||||
const contenu = `BT /F1 12 Tf 72 720 Td (${texte.replace(/[()\\]/g, '\\$&')}) Tj ET`;
|
||||
const objets = [
|
||||
'<< /Type /Catalog /Pages 2 0 R >>',
|
||||
'<< /Type /Pages /Kids [3 0 R] /Count 1 >>',
|
||||
'<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R ' +
|
||||
'/Resources << /Font << /F1 5 0 R >> >> >>',
|
||||
`<< /Length ${contenu.length} >>\nstream\n${contenu}\nendstream`,
|
||||
'<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>',
|
||||
];
|
||||
let corps = '%PDF-1.4\n';
|
||||
const offsets: number[] = [];
|
||||
objets.forEach((objet, i) => {
|
||||
offsets.push(corps.length);
|
||||
corps += `${i + 1} 0 obj\n${objet}\nendobj\n`;
|
||||
});
|
||||
const debutXref = corps.length;
|
||||
corps += `xref\n0 ${objets.length + 1}\n0000000000 65535 f \n`;
|
||||
for (const offset of offsets) corps += `${String(offset).padStart(10, '0')} 00000 n \n`;
|
||||
corps += `trailer\n<< /Size ${objets.length + 1} /Root 1 0 R >>\nstartxref\n${debutXref}\n%%EOF`;
|
||||
return Buffer.from(corps, 'latin1');
|
||||
}
|
||||
|
||||
async function connexionDemo(page: import('@playwright/test').Page, nom: RegExp) {
|
||||
await page.goto('/connexion');
|
||||
await page.getByRole('button', { name: nom }).click();
|
||||
await expect(page.locator('.topbar')).toBeVisible();
|
||||
}
|
||||
|
||||
test('recette R5 : corpus → réindexation → assistant sourcé → refus honnête', async ({ page }) => {
|
||||
test.setTimeout(180_000); // deux réindexations complètes du corpus réel
|
||||
const fichier = `e2e-notice-${suffix}.pdf`;
|
||||
|
||||
// 1 · Nadia (gestionnaire, ASSETS.edit) — la bibliothèque est le corpus
|
||||
await connexionDemo(page, /Nadia Berrada/);
|
||||
await page.getByRole('link', { name: 'Fichiers' }).click();
|
||||
await expect(page.getByRole('heading', { name: /corpus de l'assistant/ })).toBeVisible();
|
||||
await expect(page.locator('.avert')).toContainText('Loi 09-08'); // l'anonymisation est DITE
|
||||
|
||||
// 2 · Téléverser une notice PDF de test rattachée à A1
|
||||
await page.getByRole('button', { name: 'Téléverser' }).click();
|
||||
await page.getByLabel("Rattacher à l'appareil *").selectOption({ index: 1 });
|
||||
await page.getByLabel('Choisir un fichier').setInputFiles({
|
||||
name: fichier,
|
||||
mimeType: 'application/pdf',
|
||||
buffer: pdfMinimal(
|
||||
'Couple de serrage des coulisseaux de guides : 25 Nm. Verifier le jeu lateral.',
|
||||
),
|
||||
});
|
||||
await page.getByRole('button', { name: 'Téléverser', exact: true }).last().click();
|
||||
const vignette = page.locator('.doc', { hasText: fichier });
|
||||
await expect(vignette).toBeVisible();
|
||||
await expect(vignette.locator('.st')).toHaveText('à indexer'); // jamais indexé à la naissance
|
||||
|
||||
// 3 · Réindexer tout — geste explicite, bilan chiffré, statut à jour
|
||||
await page.getByRole('button', { name: 'Réindexer tout' }).click();
|
||||
// l'ingestion réelle (MinIO + pypdf + embeddings) peut dépasser les 5 s
|
||||
await expect(page.getByText('Réindexation terminée')).toBeVisible({ timeout: 60_000 });
|
||||
await expect(vignette.locator('.st')).toContainText('indexé ·');
|
||||
await expect(vignette.locator('.st')).toContainText('extrait');
|
||||
|
||||
// 4 · L'assistant répond SOURCÉ depuis ce PDF (embeddeur déterministe :
|
||||
// la question reprend les mots de la notice)
|
||||
await page.getByRole('link', { name: 'Assistant' }).click();
|
||||
await expect(page.getByText('répond UNIQUEMENT depuis votre bibliothèque')).toBeVisible();
|
||||
await page
|
||||
.getByLabel('Poser une question')
|
||||
.fill('couple de serrage des coulisseaux de guides ?');
|
||||
await page.getByRole('button', { name: 'Envoyer' }).click();
|
||||
const source = page.locator('.source', { hasText: fichier });
|
||||
await expect(source).toBeVisible();
|
||||
await expect(source.locator('.extrait')).toContainText('25 Nm'); // l'extrait EXACT
|
||||
await expect(source.locator('.ou')).toContainText('p. 1'); // la citation pointe la page
|
||||
await expect(page.locator('.msg-r .avert')).toContainText('vous validez'); // pas un disclaimer caché
|
||||
|
||||
// 5 · Sans source au-dessus du seuil : refus honnête, chiffré, avec l'action utile
|
||||
await page.getByLabel('Poser une question').fill('xylophone quantique zorglub ?');
|
||||
await page.getByRole('button', { name: 'Envoyer' }).click();
|
||||
const refus = page.locator('.refus');
|
||||
await expect(refus).toBeVisible();
|
||||
await expect(refus).toContainText('je préfère ne pas inventer');
|
||||
await expect(refus).toContainText(/J'ai cherché dans \d+ documents? indexés? et \d+ bilans?/);
|
||||
await expect(refus.getByRole('link', { name: /Téléverser la notice/ })).toBeVisible();
|
||||
|
||||
// 6 · L'interrupteur exclut la notice — réversible, effectif à la réindexation
|
||||
await page.getByRole('link', { name: 'Fichiers' }).click();
|
||||
await vignette.getByRole('switch').click();
|
||||
await expect(vignette.locator('.st')).toHaveText('exclu du corpus');
|
||||
await page.getByRole('button', { name: 'Réindexer tout' }).click();
|
||||
await expect(page.getByText('Réindexation terminée')).toBeVisible({ timeout: 60_000 });
|
||||
|
||||
// Ménage : la notice de test sort de la bibliothèque
|
||||
page.on('dialog', (d) => void d.accept());
|
||||
await vignette.getByRole('button', { name: 'Supprimer' }).click();
|
||||
await expect(vignette).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('recette R5 : suggestion de bilan — codes existants, appliqués par l\'humain', async ({
|
||||
page,
|
||||
}) => {
|
||||
const titre = `E2E Suggestion ${suffix}`;
|
||||
|
||||
// 1 · Nadia crée un OT de dépannage sur A1
|
||||
await connexionDemo(page, /Nadia Berrada/);
|
||||
await page.getByRole('link', { name: 'Ordres de travail' }).click();
|
||||
await page.getByRole('button', { name: '+ Nouvel OT' }).click();
|
||||
await page.getByLabel('Objet *').fill(titre);
|
||||
await page.getByLabel('Équipement *').selectOption({ index: 1 });
|
||||
await page.getByRole('button', { name: "Créer l'OT (statut Ouvert)" }).click();
|
||||
await expect(page.getByRole('heading', { name: titre })).toBeVisible();
|
||||
|
||||
// 2 · Décrire pour suggérer — l'IA propose des codes EXISTANTS, justifiés
|
||||
await page
|
||||
.getByLabel('Décrire pour suggérer (optionnel)')
|
||||
.fill('Frottement mécanique sur les portes, nettoyage et graissage effectués, essais OK.');
|
||||
await page.getByRole('button', { name: /Suggérer les codes/ }).click();
|
||||
const suggestions = page.locator('.suggestion');
|
||||
await expect(suggestions.first()).toBeVisible();
|
||||
await expect(page.locator('.confiance').first()).toContainText('confiance');
|
||||
|
||||
// 3 · « Appliquer les N » : les sélecteurs se pré-remplissent, liseré « suggéré »
|
||||
await page.getByRole('button', { name: /Appliquer les \d/ }).click();
|
||||
await expect(page.locator('.champ-b[data-suggere]').first()).toBeVisible();
|
||||
const anomalie = page.locator('#bilan-ANOMALY');
|
||||
await expect(anomalie).not.toHaveValue('');
|
||||
|
||||
// 4 · Un choix MANUEL retire le liseré du champ concerné (l'humain a repris la main)
|
||||
const champAnomalie = page.locator('.champ-b', { has: anomalie });
|
||||
await expect(champAnomalie).toHaveAttribute('data-suggere', 'true');
|
||||
await anomalie.selectOption({ index: 1 });
|
||||
await expect(champAnomalie).not.toHaveAttribute('data-suggere', 'true');
|
||||
});
|
||||
@@ -14,6 +14,10 @@ const API_ENV = {
|
||||
DATABASE_URL:
|
||||
process.env.DATABASE_URL ?? 'postgresql://siop:siop@localhost:5432/siop',
|
||||
REDIS_URL: process.env.REDIS_URL ?? 'redis://localhost:6379',
|
||||
// R5 : le service IA écoute sur 8000 (CI : embeddeur déterministe,
|
||||
// seuils abaissés — voir ci.yml ; localement : lancez apps/ai avant).
|
||||
AI_SERVICE_URL: process.env.AI_SERVICE_URL ?? 'http://localhost:8000',
|
||||
AI_SERVICE_TOKEN: process.env.AI_SERVICE_TOKEN ?? 'dev-only-ai-token',
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Coquille } from '@/layout/coquille';
|
||||
import PageAchats from '@/pages/achats';
|
||||
import PageActivation from '@/pages/activation';
|
||||
import PageAscenseurs from '@/pages/ascenseurs';
|
||||
import PageAssistant from '@/pages/assistant';
|
||||
import PageBibliotheque from '@/pages/bibliotheque';
|
||||
import PageCategories from '@/pages/categories';
|
||||
import PageCompteurs from '@/pages/compteurs';
|
||||
@@ -67,6 +68,7 @@ export default function App() {
|
||||
<Route path="/tiers" element={dansCoquille(<PageTiers />)} />
|
||||
<Route path="/bibliotheque" element={dansCoquille(<PageBibliotheque />)} />
|
||||
<Route path="/statistiques" element={dansCoquille(<PageStatistiques />)} />
|
||||
<Route path="/assistant" element={dansCoquille(<PageAssistant />)} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
</QueryClientProvider>
|
||||
|
||||
57
apps/web/src/api/assistant.ts
Normal file
57
apps/web/src/api/assistant.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import type { AssistantAsk, SuggestBilan } from '@siop/shared';
|
||||
import { api } from './client';
|
||||
|
||||
/** Hooks R5 — l'assistant passe par l'API NestJS (le service IA n'est jamais
|
||||
* appelé du navigateur, ADR-004 §4). Le 503 est un état ATTENDU du contrat
|
||||
* (service éteint ou pas encore déployé) : les écrans l'affichent posément. */
|
||||
|
||||
async function unwrap<T>(res: { data?: T; error?: unknown; response: Response }): Promise<T> {
|
||||
if (res.response.status === 503) {
|
||||
throw new Error('Assistant indisponible pour le moment — réessayez dans un instant.');
|
||||
}
|
||||
if (res.error || res.data === undefined) {
|
||||
const message =
|
||||
(res.error as { message?: string } | undefined)?.message ??
|
||||
`Le serveur a répondu ${res.response.status}`;
|
||||
throw new Error(Array.isArray(message) ? message.join(' — ') : message);
|
||||
}
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export function useAskAssistant() {
|
||||
return useMutation({
|
||||
mutationFn: async (body: AssistantAsk) =>
|
||||
unwrap(await api.POST('/assistant/ask', { body })),
|
||||
});
|
||||
}
|
||||
|
||||
export function useSuggestBilan() {
|
||||
return useMutation({
|
||||
mutationFn: async (body: SuggestBilan) =>
|
||||
unwrap(await api.POST('/assistant/suggest-bilan', { body })),
|
||||
});
|
||||
}
|
||||
|
||||
export function useReindexAssistant() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async () => unwrap(await api.POST('/assistant/reindex')),
|
||||
// la réindexation met à jour indexedAt/chunkCount de chaque document
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['documents'] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useSetDocumentCorpus() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (input: { id: string; inCorpus: boolean }) =>
|
||||
unwrap(
|
||||
await api.PATCH('/documents/{id}/corpus', {
|
||||
params: { path: { id: input.id } },
|
||||
body: { inCorpus: input.inCorpus },
|
||||
}),
|
||||
),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['documents'] }),
|
||||
});
|
||||
}
|
||||
109
apps/web/src/api/schema.d.ts
vendored
109
apps/web/src/api/schema.d.ts
vendored
@@ -407,6 +407,23 @@ export interface paths {
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/documents/{id}/corpus": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
post?: never;
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
/** Inclure/exclure du corpus IA (D3 — réversible, effectif à la prochaine réindexation) */
|
||||
patch: operations["updateDocumentCorpus"];
|
||||
trace?: never;
|
||||
};
|
||||
"/documents/{id}": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
@@ -475,6 +492,23 @@ export interface paths {
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/assistant/reindex": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/** Réindexer le corpus (bibliothèque PDF + bilans clôturés, anonymisés à l’ingestion — D4) */
|
||||
post: operations["reindexAssistant"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/search": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
@@ -1437,6 +1471,9 @@ export interface components {
|
||||
uploadedByName: string | null;
|
||||
/** Format: date-time */
|
||||
createdAt: string;
|
||||
inCorpus: boolean;
|
||||
indexedAt: string | null;
|
||||
chunkCount: number;
|
||||
}[];
|
||||
};
|
||||
Document: {
|
||||
@@ -1452,6 +1489,12 @@ export interface components {
|
||||
uploadedByName: string | null;
|
||||
/** Format: date-time */
|
||||
createdAt: string;
|
||||
inCorpus: boolean;
|
||||
indexedAt: string | null;
|
||||
chunkCount: number;
|
||||
};
|
||||
DocumentCorpusUpdate: {
|
||||
inCorpus: boolean;
|
||||
};
|
||||
AnalyticsSummary: {
|
||||
months: number;
|
||||
@@ -1518,6 +1561,12 @@ export interface components {
|
||||
SuggestBilan: {
|
||||
description: string;
|
||||
};
|
||||
ReindexResult: {
|
||||
documentsIndexed: number;
|
||||
documentsSkipped: number;
|
||||
reportsIndexed: number;
|
||||
chunks: number;
|
||||
};
|
||||
SearchResponse: {
|
||||
workOrders: {
|
||||
/** Format: uuid */
|
||||
@@ -2990,6 +3039,39 @@ export interface operations {
|
||||
};
|
||||
};
|
||||
};
|
||||
updateDocumentCorpus: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
id: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["DocumentCorpusUpdate"];
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description Document mis à jour */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Document"];
|
||||
};
|
||||
};
|
||||
/** @description Inconnu */
|
||||
404: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content?: never;
|
||||
};
|
||||
};
|
||||
};
|
||||
deleteDocument: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
@@ -3101,6 +3183,33 @@ export interface operations {
|
||||
};
|
||||
};
|
||||
};
|
||||
reindexAssistant: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description Bilan d’indexation */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["ReindexResult"];
|
||||
};
|
||||
};
|
||||
/** @description Service IA indisponible */
|
||||
503: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content?: never;
|
||||
};
|
||||
};
|
||||
};
|
||||
globalSearch: {
|
||||
parameters: {
|
||||
query: {
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
type DocumentDto,
|
||||
type DocumentKind,
|
||||
} from '@siop/shared';
|
||||
import { useSetDocumentCorpus } from '@/api/assistant';
|
||||
import {
|
||||
blobDocument,
|
||||
ouvrirDocument,
|
||||
@@ -63,11 +64,62 @@ function ApercuVignette({ doc }: { doc: DocumentDto }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function VignetteDoc({ doc, surSuppression }: { doc: DocumentDto; surSuppression?: (id: string) => void }) {
|
||||
/** Statut corpus (R5, D3) : lisible d'un coup d'œil, jamais ambigu. */
|
||||
function StatutCorpus({ doc }: { doc: DocumentDto }) {
|
||||
if (doc.contentType !== 'application/pdf') {
|
||||
return <span className="st exclu">image — non indexable</span>;
|
||||
}
|
||||
if (!doc.inCorpus) return <span className="st exclu">exclu du corpus</span>;
|
||||
if (!doc.indexedAt) return <span className="st encours">à indexer</span>;
|
||||
const quand = new Intl.DateTimeFormat('fr-FR', {
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}).format(new Date(doc.indexedAt));
|
||||
return (
|
||||
<span className="st ok">
|
||||
indexé · {quand} · {doc.chunkCount} extrait{doc.chunkCount > 1 ? 's' : ''}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function VignetteDoc({
|
||||
doc,
|
||||
corpus,
|
||||
surSuppression,
|
||||
}: {
|
||||
doc: DocumentDto;
|
||||
/** true = l'utilisateur administre le corpus (statut + interrupteur visibles). */
|
||||
corpus?: boolean;
|
||||
surSuppression?: (id: string) => void;
|
||||
}) {
|
||||
const bascule = useSetDocumentCorpus();
|
||||
return (
|
||||
<div className="doc">
|
||||
<ApercuVignette doc={doc} />
|
||||
<span className={CLASSE_TYPE[doc.kind] ?? 'type-doc'}>{DOCUMENT_KIND_LABELS[doc.kind]}</span>
|
||||
{corpus ? (
|
||||
<span style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<StatutCorpus doc={doc} />
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
aria-checked={doc.inCorpus}
|
||||
aria-label={doc.inCorpus ? 'Exclure du corpus' : 'Inclure au corpus'}
|
||||
title={
|
||||
doc.contentType !== 'application/pdf'
|
||||
? 'Seuls les PDF sont indexables'
|
||||
: doc.inCorpus
|
||||
? 'Exclure du corpus (effectif à la prochaine réindexation)'
|
||||
: 'Inclure au corpus (effectif à la prochaine réindexation)'
|
||||
}
|
||||
className="interrupteur corpus"
|
||||
disabled={bascule.isPending || doc.contentType !== 'application/pdf'}
|
||||
onClick={() => bascule.mutate({ id: doc.id, inCorpus: !doc.inCorpus })}
|
||||
/>
|
||||
</span>
|
||||
) : null}
|
||||
<b>{doc.fileName}</b>
|
||||
<span className="meta">
|
||||
{doc.assetReference ? `Asc. ${doc.assetReference} · ` : ''}
|
||||
|
||||
@@ -82,6 +82,13 @@ export const IcoStatistiques = () => (
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const IcoAssistant = () => (
|
||||
<svg {...base}>
|
||||
<path d="M12 3l1.8 4.7L18.5 9l-4.7 1.8L12 15.5l-1.8-4.7L5.5 9l4.7-1.3z" />
|
||||
<path d="M18.5 15l.9 2.1 2.1.9-2.1.9-.9 2.1-.9-2.1-2.1-.9 2.1-.9z" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const IcoPersonnes = () => (
|
||||
<svg {...base}>
|
||||
<circle cx="9" cy="8" r="3.5" />
|
||||
|
||||
@@ -13,6 +13,7 @@ import { api } from '@/api/client';
|
||||
import { usePermissions } from '@/auth/use-permissions';
|
||||
import {
|
||||
IcoAscenseurs,
|
||||
IcoAssistant,
|
||||
IcoCategories,
|
||||
IcoDemandes,
|
||||
IcoFichiers,
|
||||
@@ -75,6 +76,7 @@ const NAVIGATION: { groupe: string; liens: LienNav[] }[] = [
|
||||
groupe: 'Pilotage',
|
||||
liens: [
|
||||
{ libelle: 'Statistiques', icone: IcoStatistiques, route: '/statistiques', permission: ['ANALYTICS', 'view'] },
|
||||
{ libelle: 'Assistant', icone: IcoAssistant, route: '/assistant', permission: ['WORK_ORDERS', 'view'] },
|
||||
{ libelle: 'Personnes', icone: IcoPersonnes, route: '/personnes', permission: ['PEOPLE_TEAMS', 'view'] },
|
||||
],
|
||||
},
|
||||
|
||||
166
apps/web/src/pages/assistant.tsx
Normal file
166
apps/web/src/pages/assistant.tsx
Normal file
@@ -0,0 +1,166 @@
|
||||
import { useRef, useState } from 'react';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import type { AssistantAnswer, AssistantExcerpt } from '@siop/shared';
|
||||
import { useAskAssistant } from '@/api/assistant';
|
||||
import { ouvrirDocument } from '@/api/gestion';
|
||||
import { usePermissions } from '@/auth/use-permissions';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
/** Écrans 1-2 des maquettes R5 : chat « sourcé ou silencieux » (D2).
|
||||
* Chaque réponse cite ses extraits EXACTS ; sans source au-dessus du seuil,
|
||||
* le refus est honnête et chiffré (ce qui a été cherché). L'avertissement
|
||||
* « l'IA propose, vous validez » est permanent, pas un disclaimer caché. */
|
||||
|
||||
interface Echange {
|
||||
question: string;
|
||||
reponse?: AssistantAnswer;
|
||||
erreur?: string;
|
||||
}
|
||||
|
||||
function Source({ extrait, no }: { extrait: AssistantExcerpt; no: number }) {
|
||||
const navigate = useNavigate();
|
||||
const ouvrir = () => {
|
||||
if (extrait.sourceType === 'DOCUMENT' && extrait.documentId) {
|
||||
void ouvrirDocument(extrait.documentId);
|
||||
} else if (extrait.workOrderId) {
|
||||
navigate(`/ot/${extrait.workOrderId}`);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="source">
|
||||
<span className="no">{no}</span>
|
||||
<div>
|
||||
<b>{extrait.title}</b>
|
||||
<div className="ou">
|
||||
{extrait.sourceType === 'DOCUMENT' ? 'Bibliothèque' : 'Historique'} · {extrait.locator}
|
||||
</div>
|
||||
<div className="extrait">« {extrait.content} »</div>
|
||||
</div>
|
||||
<button type="button" className="ouvrir" onClick={ouvrir}>
|
||||
{extrait.sourceType === 'DOCUMENT' ? 'Ouvrir' : "Ouvrir l'OT"}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Reponse({ reponse, surReformuler }: { reponse: AssistantAnswer; surReformuler: () => void }) {
|
||||
const { can } = usePermissions();
|
||||
if (reponse.mode === 'REFUSAL') {
|
||||
return (
|
||||
<div className="refus">
|
||||
<b>Je ne trouve pas de source fiable dans votre bibliothèque — je préfère ne pas inventer.</b>
|
||||
<div className="pourquoi">
|
||||
J'ai cherché dans {reponse.corpus.documents} document
|
||||
{reponse.corpus.documents > 1 ? 's' : ''} indexé
|
||||
{reponse.corpus.documents > 1 ? 's' : ''} et {reponse.corpus.reports} bilan
|
||||
{reponse.corpus.reports > 1 ? 's' : ''} d'intervention : rien d'assez proche de votre
|
||||
question.
|
||||
</div>
|
||||
<div className="actions-sug">
|
||||
{can('ASSETS', 'edit') ? (
|
||||
<Link to="/bibliotheque" className="btn prim">
|
||||
Téléverser la notice dans la bibliothèque
|
||||
</Link>
|
||||
) : null}
|
||||
<Button onClick={surReformuler}>Reformuler ma question</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="msg-r">
|
||||
{reponse.mode === 'GENERATED' && reponse.answer ? (
|
||||
<p style={{ whiteSpace: 'pre-wrap' }}>{reponse.answer}</p>
|
||||
) : (
|
||||
<p>
|
||||
Voici ce que portent vos sources — les extraits sont cités tels quels
|
||||
{reponse.excerpts.map((_, i) => (
|
||||
<span key={i} className="cite">{i + 1}</span>
|
||||
))}
|
||||
.
|
||||
</p>
|
||||
)}
|
||||
<div className="sources">
|
||||
{reponse.excerpts.map((extrait, i) => (
|
||||
<Source key={`${extrait.locator}-${i}`} extrait={extrait} no={i + 1} />
|
||||
))}
|
||||
</div>
|
||||
<div className="avert">⚠ L'IA propose, vous validez : vérifiez la notice avant d'agir sur l'appareil.</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function PageAssistant() {
|
||||
const ask = useAskAssistant();
|
||||
const [question, setQuestion] = useState('');
|
||||
const [echanges, setEchanges] = useState<Echange[]>([]);
|
||||
const saisieRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const envoyer = () => {
|
||||
const q = question.trim();
|
||||
if (q.length < 3 || ask.isPending) return;
|
||||
setQuestion('');
|
||||
setEchanges((liste) => [...liste, { question: q }]);
|
||||
ask.mutate(
|
||||
{ question: q },
|
||||
{
|
||||
onSuccess: (reponse) =>
|
||||
setEchanges((liste) =>
|
||||
liste.map((e, i) => (i === liste.length - 1 ? { ...e, reponse } : e)),
|
||||
),
|
||||
onError: (erreur) =>
|
||||
setEchanges((liste) =>
|
||||
liste.map((e, i) => (i === liste.length - 1 ? { ...e, erreur: erreur.message } : e)),
|
||||
),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="entete-page">
|
||||
<h1>Assistant</h1>
|
||||
<span className="filajout">répond UNIQUEMENT depuis votre bibliothèque et vos historiques</span>
|
||||
</div>
|
||||
<div className="chat" aria-live="polite">
|
||||
{echanges.length === 0 ? (
|
||||
<div className="carte" style={{ color: 'var(--encre-2)', maxWidth: 760 }}>
|
||||
Posez une question sur vos notices, vos historiques d'intervention ou vos procédures —
|
||||
chaque réponse cite ses sources (document et page, ou bilan d'OT). Quand le corpus ne
|
||||
porte pas la réponse, l'assistant le dit au lieu d'inventer.
|
||||
</div>
|
||||
) : null}
|
||||
{echanges.map((echange, i) => (
|
||||
<div key={i} style={{ display: 'contents' }}>
|
||||
<div className="msg-q">{echange.question}</div>
|
||||
{echange.reponse ? (
|
||||
<Reponse reponse={echange.reponse} surReformuler={() => saisieRef.current?.focus()} />
|
||||
) : echange.erreur ? (
|
||||
<div className="refus" role="alert">
|
||||
<b>{echange.erreur}</b>
|
||||
</div>
|
||||
) : (
|
||||
<div className="msg-r" style={{ color: 'var(--encre-3)' }}>Recherche dans le corpus…</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="saisie-chat">
|
||||
<input
|
||||
ref={saisieRef}
|
||||
value={question}
|
||||
maxLength={500}
|
||||
placeholder="Poser une question (notices, historiques, procédures)…"
|
||||
aria-label="Poser une question"
|
||||
onChange={(e) => setQuestion(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') envoyer();
|
||||
}}
|
||||
/>
|
||||
<Button variant="prim" disabled={question.trim().length < 3 || ask.isPending} onClick={envoyer}>
|
||||
Envoyer
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
DOCUMENT_MAX_BYTES,
|
||||
type DocumentKind,
|
||||
} from '@siop/shared';
|
||||
import { useReindexAssistant } from '@/api/assistant';
|
||||
import { useDeleteDocument, useDocuments, useUploadDocument } from '@/api/gestion';
|
||||
import { useAssetOptions } from '@/api/referentiel';
|
||||
import { usePermissions } from '@/auth/use-permissions';
|
||||
@@ -12,10 +13,12 @@ import { tailleLisible, VignetteDoc } from '@/components/carte-documents';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Modale } from '@/components/ui/modale';
|
||||
|
||||
/** Écran 7 des maquettes R3 : notices, certificats, photos — toujours
|
||||
* RATTACHÉS (appareil ou OT). Ces documents nourriront le RAG en R5. */
|
||||
/** Écran 7 des maquettes R3, devenu écran 5 de R5 : la bibliothèque EST le
|
||||
* corpus de l'assistant — statut d'indexation visible, interrupteur
|
||||
* d'exclusion réversible, réindexation par geste explicite (D3). */
|
||||
export default function PageBibliotheque() {
|
||||
const { can } = usePermissions();
|
||||
const reindex = useReindexAssistant();
|
||||
const [kind, setKind] = useState<DocumentKind | ''>('');
|
||||
const [assetId, setAssetId] = useState('');
|
||||
const { data: options } = useAssetOptions();
|
||||
@@ -29,7 +32,9 @@ export default function PageBibliotheque() {
|
||||
const [survol, setSurvol] = useState(false);
|
||||
|
||||
const totalOctets = (documents ?? []).reduce((s, d) => s + d.size, 0);
|
||||
const indexes = (documents ?? []).filter((d) => d.indexedAt && d.inCorpus).length;
|
||||
const peutEditer = can('WORK_ORDERS', 'edit') || can('ASSETS', 'edit');
|
||||
const administreCorpus = can('ASSETS', 'edit');
|
||||
|
||||
const surDepot = (e: DragEvent) => {
|
||||
e.preventDefault();
|
||||
@@ -43,16 +48,37 @@ export default function PageBibliotheque() {
|
||||
return (
|
||||
<>
|
||||
<div className="entete-page">
|
||||
<h1>Bibliothèque</h1>
|
||||
<h1>Bibliothèque — corpus de l'assistant</h1>
|
||||
<span className="filajout">
|
||||
{documents?.length ?? 0} documents · {tailleLisible(totalOctets)}
|
||||
{documents?.length ?? 0} documents · {indexes} indexés · {tailleLisible(totalOctets)}
|
||||
</span>
|
||||
<div className="actions">
|
||||
{administreCorpus ? (
|
||||
<Button disabled={reindex.isPending} onClick={() => reindex.mutate()}>
|
||||
{reindex.isPending ? 'Réindexation…' : 'Réindexer tout'}
|
||||
</Button>
|
||||
) : null}
|
||||
{peutEditer ? (
|
||||
<Button variant="prim" onClick={() => setModale(true)}>Téléverser</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="avert">
|
||||
🛡 Loi 09-08 — anonymisation à l'ingestion : noms, téléphones et e-mails des personnes ne
|
||||
sont JAMAIS envoyés dans les index ni aux modèles.
|
||||
</div>
|
||||
{reindex.isSuccess ? (
|
||||
<div className="carte" style={{ color: 'var(--encre-2)', fontSize: 13 }}>
|
||||
Réindexation terminée : {reindex.data.documentsIndexed} document
|
||||
{reindex.data.documentsIndexed > 1 ? 's' : ''} indexé
|
||||
{reindex.data.documentsIndexed > 1 ? 's' : ''}, {reindex.data.documentsSkipped} ignoré
|
||||
{reindex.data.documentsSkipped > 1 ? 's' : ''} (exclus ou non indexables),{' '}
|
||||
{reindex.data.reportsIndexed} bilans, {reindex.data.chunks} extraits.
|
||||
</div>
|
||||
) : null}
|
||||
{reindex.isError ? (
|
||||
<p className="erreur-form" role="alert">{reindex.error.message}</p>
|
||||
) : null}
|
||||
<div className="filtres">
|
||||
<select
|
||||
aria-label="Filtrer par type"
|
||||
@@ -99,6 +125,7 @@ export default function PageBibliotheque() {
|
||||
<VignetteDoc
|
||||
key={d.id}
|
||||
doc={d}
|
||||
corpus={administreCorpus}
|
||||
surSuppression={peutEditer ? (id) => suppression.mutate(id) : undefined}
|
||||
/>
|
||||
))}
|
||||
@@ -107,8 +134,8 @@ export default function PageBibliotheque() {
|
||||
<div className="carte" style={{ color: 'var(--encre-2)' }}>Aucun document.</div>
|
||||
)}
|
||||
<div className="carte" style={{ borderStyle: 'dashed', color: 'var(--encre-2)', fontSize: 13 }}>
|
||||
Ces documents nourriront l'assistant RAG en R5 (réponses citant leurs sources) —
|
||||
le rattachement propre commence ici.
|
||||
Le corpus de l'assistant, c'est cette bibliothèque (PDF indexés) plus les bilans
|
||||
d'intervention codés — rien d'externe. Les réponses citent leurs sources.
|
||||
</div>
|
||||
{peutEditer ? (
|
||||
<ModaleTeleversement
|
||||
|
||||
@@ -5,9 +5,11 @@ import {
|
||||
REQUIRED_BILAN_FIELDS,
|
||||
WORK_ORDER_TYPE_LABELS,
|
||||
type BilanField,
|
||||
type BilanSuggestion,
|
||||
type WorkOrderDetail,
|
||||
type WorkOrderStatus,
|
||||
} from '@siop/shared';
|
||||
import { useSuggestBilan } from '@/api/assistant';
|
||||
import {
|
||||
useCommentWorkOrder,
|
||||
usePatchChecklist,
|
||||
@@ -478,10 +480,108 @@ const CHAMPS_BILAN: { champ: BilanField; cle: keyof NonNullable<WorkOrderDetail[
|
||||
{ champ: 'COMPONENT_CONCERNED', cle: 'componentConcerned', dto: 'componentConcernedId' },
|
||||
];
|
||||
|
||||
/** Écran 3 des maquettes R5 : décrire la panne en français libre → l'IA
|
||||
* propose des codes EXISTANTS avec justification et confiance (D1). Rien ne
|
||||
* s'écrit sans le geste humain : « Appliquer » est ce geste — chaque champ
|
||||
* appliqué garde son liseré « suggéré » jusqu'à modification manuelle. */
|
||||
function ZoneSuggestion({
|
||||
surAppliquer,
|
||||
appliqueTout,
|
||||
}: {
|
||||
surAppliquer: (s: BilanSuggestion) => void;
|
||||
appliqueTout: (liste: BilanSuggestion[]) => void;
|
||||
}) {
|
||||
const suggerer = useSuggestBilan();
|
||||
const [description, setDescription] = useState('');
|
||||
const [masquees, setMasquees] = useState(false);
|
||||
const suggestions = masquees ? [] : (suggerer.data?.suggestions ?? []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="champ-b" style={{ gridColumn: '1 / -1' }}>
|
||||
<label htmlFor="sug-description">Décrire pour suggérer (optionnel)</label>
|
||||
<textarea
|
||||
id="sug-description"
|
||||
className="zone-libre"
|
||||
placeholder="Décrivez la panne et ce que vous avez fait — l'IA proposera les codes du bilan…"
|
||||
value={description}
|
||||
maxLength={2000}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
/>
|
||||
<div className="actions-sug">
|
||||
<Button
|
||||
variant="prim"
|
||||
disabled={description.trim().length < 10 || suggerer.isPending}
|
||||
onClick={() => {
|
||||
setMasquees(false);
|
||||
suggerer.mutate({ description: description.trim() });
|
||||
}}
|
||||
>
|
||||
{suggerer.isPending ? 'Analyse…' : '✨ Suggérer les codes'}
|
||||
</Button>
|
||||
<span style={{ fontSize: 11.5, color: 'var(--encre-3)', alignSelf: 'center' }}>
|
||||
La description n'écrit rien toute seule — vous appliquez, ou pas.
|
||||
</span>
|
||||
</div>
|
||||
{suggerer.isError ? (
|
||||
<p className="erreur-form" role="alert">{suggerer.error.message}</p>
|
||||
) : null}
|
||||
{suggerer.isSuccess && suggestions.length === 0 && !masquees ? (
|
||||
<p style={{ fontSize: 12.5, color: 'var(--encre-2)' }}>
|
||||
Aucun code assez proche de cette description — l'IA ne devine pas : choisissez dans les
|
||||
sélecteurs.
|
||||
</p>
|
||||
) : null}
|
||||
{suggestions.length > 0 ? (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginTop: 8 }}>
|
||||
{suggestions.map((s) => (
|
||||
<div className="suggestion" key={s.field}>
|
||||
<span className="ia">✨</span>
|
||||
<div>
|
||||
<b>
|
||||
{BILAN_FIELD_LABELS[s.field]} → « {s.label} »
|
||||
</b>
|
||||
<div className="just">
|
||||
{s.similarReports > 0
|
||||
? `${s.similarReports} bilan${s.similarReports > 1 ? 's' : ''} similaire${s.similarReports > 1 ? 's' : ''} sur ce parc`
|
||||
: 'proche de votre description'}
|
||||
</div>
|
||||
</div>
|
||||
<span className="confiance">
|
||||
confiance {s.confidence === 'HIGH' ? 'forte' : 'moyenne'}
|
||||
</span>
|
||||
<Button onClick={() => surAppliquer(s)}>Appliquer</Button>
|
||||
</div>
|
||||
))}
|
||||
<div className="actions-sug">
|
||||
<Button variant="prim" onClick={() => appliqueTout(suggestions)}>
|
||||
Appliquer les {suggestions.length} (pré-remplir)
|
||||
</Button>
|
||||
<Button onClick={() => setMasquees(true)}>Ignorer</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function CarteBilan({ ot, peutEditer }: { ot: WorkOrderDetail; peutEditer: boolean }) {
|
||||
const { data: valeurs } = useReferenceValues();
|
||||
const maj = useUpsertReport(ot.id);
|
||||
const bloqueurBilan = ot.closureBlockers.find((b) => b.includes('bilan'));
|
||||
const [suggeres, setSuggeres] = useState<Set<BilanField>>(new Set());
|
||||
const modifiable = peutEditer && ot.status !== 'DONE' && ot.status !== 'CANCELLED';
|
||||
|
||||
const appliquer = (liste: BilanSuggestion[]) => {
|
||||
const corps = Object.fromEntries(
|
||||
liste.map((s) => [CHAMPS_BILAN.find((c) => c.champ === s.field)!.dto, s.valueId]),
|
||||
);
|
||||
maj.mutate(corps, {
|
||||
onSuccess: () =>
|
||||
setSuggeres((avant) => new Set([...avant, ...liste.map((s) => s.field)])),
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="carte">
|
||||
@@ -491,13 +591,19 @@ function CarteBilan({ ot, peutEditer }: { ot: WorkOrderDetail; peutEditer: boole
|
||||
— requis pour clôturer
|
||||
</span>
|
||||
</h2>
|
||||
{modifiable ? (
|
||||
<ZoneSuggestion
|
||||
surAppliquer={(s) => appliquer([s])}
|
||||
appliqueTout={appliquer}
|
||||
/>
|
||||
) : null}
|
||||
<div className="bilan">
|
||||
{CHAMPS_BILAN.map(({ champ, cle, dto }) => {
|
||||
const options = (valeurs ?? []).filter((v) => v.field === champ && v.isActive);
|
||||
const valeur = ot.report?.[cle as 'doorState'] ?? null;
|
||||
const requis = REQUIRED_BILAN_FIELDS.includes(champ);
|
||||
return (
|
||||
<div className="champ-b" key={champ}>
|
||||
<div className="champ-b" key={champ} data-suggere={suggeres.has(champ) || undefined}>
|
||||
<label htmlFor={`bilan-${champ}`}>
|
||||
{BILAN_FIELD_LABELS[champ]} {requis ? <em>*</em> : null}
|
||||
</label>
|
||||
@@ -505,7 +611,15 @@ function CarteBilan({ ot, peutEditer }: { ot: WorkOrderDetail; peutEditer: boole
|
||||
id={`bilan-${champ}`}
|
||||
disabled={!peutEditer || maj.isPending || ot.status === 'DONE' || ot.status === 'CANCELLED'}
|
||||
value={valeur?.id ?? ''}
|
||||
onChange={(e) => maj.mutate({ [dto]: e.target.value || null })}
|
||||
onChange={(e) => {
|
||||
// choix manuel : le liseré « suggéré » n'a plus lieu d'être
|
||||
setSuggeres((avant) => {
|
||||
const suite = new Set(avant);
|
||||
suite.delete(champ);
|
||||
return suite;
|
||||
});
|
||||
maj.mutate({ [dto]: e.target.value || null });
|
||||
}}
|
||||
>
|
||||
<option value="">Sélectionner…</option>
|
||||
{options.map((o) => (
|
||||
|
||||
@@ -1016,3 +1016,91 @@ table {
|
||||
border: 1px solid var(--bordure);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
/* ═══ R5 · Assistant (chat sourcé — maquette-r5, écrans 1-2) ═══ */
|
||||
.chat { display: flex; flex-direction: column; gap: 12px; max-width: 760px; }
|
||||
.msg-q {
|
||||
align-self: flex-end; background: var(--primaire); color: #fff;
|
||||
border-radius: 14px 14px 4px 14px; padding: 10px 14px; max-width: 75%; font-size: 13.5px;
|
||||
}
|
||||
.msg-r {
|
||||
background: var(--surface); border: 1px solid var(--bordure);
|
||||
border-radius: 14px 14px 14px 4px; padding: 12px 14px; max-width: 88%;
|
||||
font-size: 13.5px; display: flex; flex-direction: column; gap: 10px;
|
||||
}
|
||||
.msg-r p b { color: var(--encre); }
|
||||
.cite {
|
||||
display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px;
|
||||
border-radius: 5px; background: var(--primaire-doux); color: var(--primaire);
|
||||
font-size: 10.5px; font-weight: 800; vertical-align: 2px; margin: 0 1px;
|
||||
}
|
||||
.sources {
|
||||
display: flex; flex-direction: column; gap: 6px;
|
||||
border-top: 1px dashed var(--bordure); padding-top: 10px;
|
||||
}
|
||||
.source {
|
||||
display: flex; gap: 10px; align-items: flex-start; background: var(--surface-2);
|
||||
border-radius: 9px; padding: 8px 10px;
|
||||
}
|
||||
.source .no {
|
||||
flex: none; width: 18px; height: 18px; border-radius: 5px; background: var(--primaire-doux);
|
||||
color: var(--primaire); display: flex; align-items: center; justify-content: center;
|
||||
font-size: 11px; font-weight: 800;
|
||||
}
|
||||
.source b { font-size: 12.5px; }
|
||||
.source .ou { color: var(--encre-2); font-size: 11.5px; }
|
||||
.source .extrait {
|
||||
color: var(--encre-2); font-size: 12px; font-style: italic;
|
||||
border-left: 2px solid var(--safran); padding-left: 8px; margin-top: 3px;
|
||||
}
|
||||
.source .ouvrir {
|
||||
margin-left: auto; color: var(--primaire); font-weight: 700; font-size: 12px; white-space: nowrap;
|
||||
}
|
||||
.avert {
|
||||
display: flex; gap: 8px; align-items: center; background: var(--safran-doux); color: var(--alerte);
|
||||
border-radius: 9px; padding: 8px 10px; font-size: 12px; font-weight: 600;
|
||||
}
|
||||
.saisie-chat { display: flex; gap: 8px; max-width: 760px; }
|
||||
.saisie-chat input {
|
||||
flex: 1; border: 1.5px solid var(--bordure-forte); border-radius: 10px;
|
||||
background: var(--surface); padding: 11px 13px; font: inherit; color: var(--encre);
|
||||
}
|
||||
.refus {
|
||||
background: var(--surface); border: 1.5px dashed var(--bordure-forte); border-radius: 14px;
|
||||
padding: 12px 14px; max-width: 88%; font-size: 13.5px;
|
||||
display: flex; flex-direction: column; gap: 8px;
|
||||
}
|
||||
.refus b { color: var(--encre); }
|
||||
.refus .pourquoi { color: var(--encre-2); font-size: 12.5px; }
|
||||
|
||||
/* ═══ R5 · Suggestion de bilan (écran 3) ═══ */
|
||||
.zone-libre {
|
||||
width: 100%; min-height: 74px; border: 1.5px solid var(--bordure-forte); border-radius: 10px;
|
||||
background: var(--surface); padding: 10px 12px; font: inherit; font-size: 13px; color: var(--encre);
|
||||
}
|
||||
.suggestion {
|
||||
display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--primaire);
|
||||
background: var(--primaire-doux); border-radius: 10px; padding: 10px 12px;
|
||||
}
|
||||
.suggestion .ia { flex: none; font-size: 15px; }
|
||||
.suggestion b { font-size: 13px; }
|
||||
.suggestion .just { color: var(--encre-2); font-size: 12px; }
|
||||
.confiance {
|
||||
margin-left: auto; font-size: 10.5px; font-weight: 800; color: var(--primaire); white-space: nowrap;
|
||||
}
|
||||
.actions-sug { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
|
||||
/* Liseré « suggéré » : la valeur vient d'une suggestion APPLIQUÉE par l'humain */
|
||||
.champ-b[data-suggere] { position: relative; }
|
||||
.champ-b[data-suggere] select { border-color: var(--primaire); background: var(--primaire-doux); }
|
||||
.champ-b[data-suggere]::after {
|
||||
content: 'suggéré'; position: absolute; top: 14px; right: 8px; font-size: 9px; font-weight: 800;
|
||||
color: var(--primaire); background: var(--surface); padding: 0 5px; border-radius: 99px;
|
||||
border: 1px solid var(--primaire); pointer-events: none;
|
||||
}
|
||||
|
||||
/* ═══ R5 · Corpus (écran 5) ═══ */
|
||||
.st.ok { color: var(--st-termine); }
|
||||
.st.ok::before { background: var(--st-termine); }
|
||||
.st.exclu { color: var(--encre-3); }
|
||||
.st.exclu::before { background: var(--encre-3); }
|
||||
.interrupteur.corpus[aria-checked='true'] { background: var(--succes); }
|
||||
|
||||
Reference in New Issue
Block a user