(null);
const displayTurns = turns;
@@ -1304,15 +1307,13 @@ export function CustomAgentChatView({
useEffect(() => {
const restored = readComposerHistory(composerHistoryKey);
+ composerHistoryRef.current = restored;
setComposerHistory(restored);
+ setComposerHistoryWarning(null);
setComposerHistoryIndex(null);
draftBeforeHistoryNavigationRef.current = "";
}, [composerHistoryKey]);
- useEffect(() => {
- writeComposerHistory(composerHistoryKey, composerHistory);
- }, [composerHistory, composerHistoryKey]);
-
// Attachments can be large, so keep draft bytes only in this renderer's
// bounded lifetime instead of serialising base64 into localStorage. The
// project/layout/node scope mirrors the persisted text draft contract.
@@ -2246,6 +2247,17 @@ export function CustomAgentChatView({
async function send() {
const text = draft.trim();
if (!canSend || !agent.sendAgentChat) return;
+ if (text) {
+ const nextHistory = appendComposerHistoryEntry(composerHistoryRef.current, text);
+ composerHistoryRef.current = nextHistory;
+ const persisted = writeComposerHistory(composerHistoryKey, nextHistory);
+ setComposerHistory(nextHistory);
+ setComposerHistoryWarning(
+ persisted ? null : "Historique des prompts non sauvegardé.",
+ );
+ setComposerHistoryIndex(null);
+ draftBeforeHistoryNavigationRef.current = "";
+ }
const slashInvocation = slashCommandInvocation(text);
if (slashInvocation) {
await executeSlashCommand(slashInvocation);
@@ -2263,11 +2275,6 @@ export function CustomAgentChatView({
markProjectCliInteractionFinished(projectId, interactionId);
activeInteractionIdRef.current = null;
};
- if (text) {
- setComposerHistory((prev) => appendComposerHistoryEntry(prev, text));
- setComposerHistoryIndex(null);
- draftBeforeHistoryNavigationRef.current = "";
- }
setDraft("");
setAttachments([]);
imageTokenSeqRef.current = 0;
@@ -2705,6 +2712,11 @@ export function CustomAgentChatView({
})}
)}
+ {composerHistoryWarning && (
+
+ {composerHistoryWarning}
+
+ )}