diff --git a/brain/app/application/llm_retry.py b/brain/app/application/llm_retry.py
index 9fb059e..9c467b8 100644
--- a/brain/app/application/llm_retry.py
+++ b/brain/app/application/llm_retry.py
@@ -113,5 +113,8 @@ async def generate_with_retry(
+ str(exc)[:160]
)
await asyncio.sleep(wait)
+ # Le message « nouvel essai dans Ns » deviendrait faux : on dit que
+ # l'essai suivant est lancé (il peut durer plusieurs minutes).
+ notify_status(f"Nouvel essai en cours (tentative {attempt + 2}/{_ATTEMPTS})…")
assert last_error is not None
raise last_error
diff --git a/brain/tests/test_llm_retry.py b/brain/tests/test_llm_retry.py
index 82fbbe8..090cc0e 100644
--- a/brain/tests/test_llm_retry.py
+++ b/brain/tests/test_llm_retry.py
@@ -110,3 +110,21 @@ async def test_rate_limit_respects_suggested_retry_after(slept):
assert await generate_with_retry(llm, "p") == "ok"
# min(8 + 2, 60) = 10
assert slept == [10.0]
+
+
+async def test_tells_the_ui_when_the_next_attempt_starts(slept):
+ import asyncio
+
+ from app.application.import_status import reset_status_queue, set_status_queue
+
+ queue: asyncio.Queue = asyncio.Queue()
+ token = set_status_queue(queue)
+ try:
+ llm = FakeLLM([LLMProviderError("Erreur Mistral (ReadError) : ReadError"), "ok"])
+ assert await generate_with_retry(llm, "p") == "ok"
+ finally:
+ reset_status_queue(token)
+ messages = [queue.get_nowait() for _ in range(queue.qsize())]
+ assert "nouvel essai dans 3s" in messages[0]
+ # Sans ce second message, « nouvel essai dans 3s » restait affiché pendant tout l'essai suivant.
+ assert messages[1] == "Nouvel essai en cours (tentative 2/3)…"
diff --git a/web/src/app/game-systems/game-system-edit/game-system-edit.component.html b/web/src/app/game-systems/game-system-edit/game-system-edit.component.html
index 0d973f3..37d77a5 100644
--- a/web/src/app/game-systems/game-system-edit/game-system-edit.component.html
+++ b/web/src/app/game-systems/game-system-edit/game-system-edit.component.html
@@ -60,6 +60,9 @@
@if (importStatus) {
{{ importStatus }}
}
+ @if (importWaitLabel) {
+ {{ 'gameSystemEdit.importWaiting' | translate:{ time: importWaitLabel } }}
+ }
@if (importFound.length) {
{{ 'gameSystemEdit.sectionsFound' | translate:{ titles: importFound.join(' · ') } }}
diff --git a/web/src/app/game-systems/game-system-edit/game-system-edit.component.scss b/web/src/app/game-systems/game-system-edit/game-system-edit.component.scss
index d41b0a4..28d489c 100644
--- a/web/src/app/game-systems/game-system-edit/game-system-edit.component.scss
+++ b/web/src/app/game-systems/game-system-edit/game-system-edit.component.scss
@@ -173,6 +173,13 @@
line-height: 1.4;
}
+.import-waiting {
+ margin: 0.45rem 0 0;
+ color: var(--text-muted, #9ca3af);
+ font-size: 0.8rem;
+ line-height: 1.4;
+}
+
.import-note {
margin: -0.4rem 0 1rem;
padding: 0.55rem 0.8rem;
diff --git a/web/src/app/game-systems/game-system-edit/game-system-edit.component.ts b/web/src/app/game-systems/game-system-edit/game-system-edit.component.ts
index fa4425d..17a1aec 100644
--- a/web/src/app/game-systems/game-system-edit/game-system-edit.component.ts
+++ b/web/src/app/game-systems/game-system-edit/game-system-edit.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { FormsModule } from '@angular/forms';
@@ -52,7 +52,7 @@ type RulesLang = 'fr' | 'en';
templateUrl: './game-system-edit.component.html',
styleUrls: ['./game-system-edit.component.scss']
})
-export class GameSystemEditComponent implements OnInit {
+export class GameSystemEditComponent implements OnInit, OnDestroy {
readonly Save = Save;
readonly ArrowLeft = ArrowLeft;
readonly Dices = Dices;
@@ -82,6 +82,14 @@ export class GameSystemEditComponent implements OnInit {
* en cours, pas l'historique.
*/
importStatus: string | null = null;
+ /**
+ * Secondes écoulées depuis le dernier évènement du flux. Un morceau peut occuper
+ * l'IA plusieurs minutes (et un nouvel essai après une erreur autant) : sans ce
+ * compteur, l'écran paraît figé alors que l'import avance.
+ */
+ importWaitSeconds = 0;
+ private lastImportEventAt = 0;
+ private importWaitTimer?: ReturnType;
name = '';
description = '';
@@ -177,9 +185,12 @@ export class GameSystemEditComponent implements OnInit {
this.importProgress = null;
this.importFound = [];
this.importStatus = null;
+ this.startImportWait();
this.service.importRulesStream(file).subscribe({
next: (ev) => {
+ this.lastImportEventAt = Date.now();
+ this.importWaitSeconds = 0;
if (ev.type === 'progress') {
// Un morceau vient d'aboutir : le message d'attente est obsolète.
this.importStatus = null;
@@ -254,6 +265,34 @@ export class GameSystemEditComponent implements OnInit {
this.importing = false;
this.importPhase = '';
this.importProgress = null;
+ this.stopImportWait();
+ }
+
+ ngOnDestroy(): void {
+ this.stopImportWait();
+ }
+
+ /** Le compteur ne s'affiche qu'au-delà de quelques secondes sans nouvelle. */
+ get importWaitLabel(): string | null {
+ const s = this.importWaitSeconds;
+ if (s < 15) return null;
+ const m = Math.floor(s / 60);
+ return m > 0 ? `${m} min ${String(s % 60).padStart(2, '0')} s` : `${s} s`;
+ }
+
+ private startImportWait(): void {
+ this.stopImportWait();
+ this.lastImportEventAt = Date.now();
+ this.importWaitSeconds = 0;
+ this.importWaitTimer = setInterval(() => {
+ this.importWaitSeconds = Math.floor((Date.now() - this.lastImportEventAt) / 1000);
+ }, 1000);
+ }
+
+ private stopImportWait(): void {
+ if (this.importWaitTimer) clearInterval(this.importWaitTimer);
+ this.importWaitTimer = undefined;
+ this.importWaitSeconds = 0;
}
/**
diff --git a/web/src/assets/i18n/en.json b/web/src/assets/i18n/en.json
index 5d72dbc..eeb8d6a 100644
--- a/web/src/assets/i18n/en.json
+++ b/web/src/assets/i18n/en.json
@@ -1296,7 +1296,8 @@
"en": "English"
},
"langHint": "Rules exist in two versions: the app and the AI use the one matching the interface language (or the other if it's empty). Importing a PDF fills both, whatever its language.",
- "importTranslated": "Book in {{source}}: the {{target}} version was translated automatically (proper names kept); review it in its tab."
+ "importTranslated": "Book in {{source}}: the {{target}} version was translated automatically (proper names kept); review it in its tab.",
+ "importWaiting": "The AI has been working on this chunk for {{time}}. A large chunk can take several minutes per attempt: as long as this counter moves, the import is still running."
},
"ollamaModelManager": {
"installedModels": "Installed models",
diff --git a/web/src/assets/i18n/fr.json b/web/src/assets/i18n/fr.json
index e315147..1f93971 100644
--- a/web/src/assets/i18n/fr.json
+++ b/web/src/assets/i18n/fr.json
@@ -1296,7 +1296,8 @@
"en": "English"
},
"langHint": "Les règles existent en deux versions : l'appli et l'IA utilisent celle de la langue de l'interface (ou l'autre si elle est vide). Importer un PDF remplit les deux, dans n'importe quelle langue.",
- "importTranslated": "Livre en {{source}} : version {{target}} traduite automatiquement (noms propres conservés), relis-la dans son onglet."
+ "importTranslated": "Livre en {{source}} : version {{target}} traduite automatiquement (noms propres conservés), relis-la dans son onglet.",
+ "importWaiting": "L'IA travaille sur ce morceau depuis {{time}}. Un gros morceau peut prendre plusieurs minutes par essai : tant que ce compteur avance, l'import continue."
},
"ollamaModelManager": {
"installedModels": "Modèles installés",
diff --git a/web/src/assets/i18n/fragments/gamesys-settingssub.en.json b/web/src/assets/i18n/fragments/gamesys-settingssub.en.json
index 783ad72..986603e 100644
--- a/web/src/assets/i18n/fragments/gamesys-settingssub.en.json
+++ b/web/src/assets/i18n/fragments/gamesys-settingssub.en.json
@@ -49,6 +49,7 @@
"structureFailed": "Structure import failed.",
"importExtracting": "Extracting text…",
"importAnalyzing": "Analyzing rules… ({{current}}/{{total}})",
+ "importWaiting": "The AI has been working on this chunk for {{time}}. A large chunk can take several minutes per attempt: as long as this counter moves, the import is still running.",
"importFailed": "PDF import failed.",
"importFailedReason": "Import failed: {{reason}}",
"importNoRules": "No usable rules could be extracted from this PDF (scan without OCR, or unrecognized content).",
diff --git a/web/src/assets/i18n/fragments/gamesys-settingssub.fr.json b/web/src/assets/i18n/fragments/gamesys-settingssub.fr.json
index af87ff5..a2f37d9 100644
--- a/web/src/assets/i18n/fragments/gamesys-settingssub.fr.json
+++ b/web/src/assets/i18n/fragments/gamesys-settingssub.fr.json
@@ -49,6 +49,7 @@
"structureFailed": "Échec de l'import de la structure.",
"importExtracting": "Extraction du texte…",
"importAnalyzing": "Analyse des règles… ({{current}}/{{total}})",
+ "importWaiting": "L'IA travaille sur ce morceau depuis {{time}}. Un gros morceau peut prendre plusieurs minutes par essai : tant que ce compteur avance, l'import continue.",
"importFailed": "Échec de l'import du PDF.",
"importFailedReason": "Échec de l'import : {{reason}}",
"importNoRules": "Aucune règle exploitable n'a été extraite de ce PDF (scan sans OCR, ou contenu non reconnu).",