From 6cc45a4f779bad6194664c3ac4028ca25286be98 Mon Sep 17 00:00:00 2001 From: pewdiepie-archdaemon Date: Sat, 13 Jun 2026 08:01:27 +0900 Subject: [PATCH] AI reply: 1st click shows cached, 2nd click clears + opens menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correct behavior: 1. Cached draft + first click → opens the cached reply 2. Cached draft + second click → clears the cache and opens the Fast/Full + context menu so the user can request a fresh draft 3. No cache → opens the menu directly Per-button shownOnce dataset tracks the first-click state so the second click triggers the menu instead of replaying the cached reply again. --- static/js/emailLibrary.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/static/js/emailLibrary.js b/static/js/emailLibrary.js index ad91e1fee..2ca295cbb 100644 --- a/static/js/emailLibrary.js +++ b/static/js/emailLibrary.js @@ -5992,9 +5992,18 @@ function _showAiReplyChoice(btn, em, data) { function _handleAiReplyButton(ev, em, data) { ev.stopPropagation(); const btn = ev.currentTarget; - // Always open the Fast/Full + context menu — even when a cached - // reply exists — so the user can ask for a fresh draft with new - // steering instead of being locked into the cached one. + // First click on a cached email surfaces the cached draft. Second + // click clears the cache and opens the Fast/Full + context menu so + // the user can ask for a fresh draft (with new steering). + if (data?.cached_ai_reply && !btn.dataset.shownOnce) { + btn.dataset.shownOnce = '1'; + _runAiReplyFromButton(btn, em, data, 'ai-reply'); + return; + } + if (data?.cached_ai_reply) { + data.cached_ai_reply = null; + btn.dataset.shownOnce = ''; + } _showAiReplyChoice(btn, em, data); }