diff --git a/static/js/emailLibrary.js b/static/js/emailLibrary.js
index 5f3473d0a..8a0826e0a 100644
--- a/static/js/emailLibrary.js
+++ b/static/js/emailLibrary.js
@@ -5923,8 +5923,8 @@ function _showAiReplyChoice(btn, em, data) {
// Full = layered concentric circles to suggest "more, deeper" — not a fully
// filled circle so it reads as a complement to the lightning, not as a "stop".
menu.innerHTML = `
-
-
+
+
-
-
-
+
+
+
`;
+ const modeRow = menu.querySelector('[data-mode-row]');
const notePanel = menu.querySelector('[data-note-panel]');
const noteInput = menu.querySelector('[data-note-input]');
- menu.querySelector('[data-act="note-toggle"]').addEventListener('click', (ev) => {
- ev.preventDefault();
- ev.stopPropagation();
- const opening = notePanel.hasAttribute('hidden');
- if (opening) {
- notePanel.removeAttribute('hidden');
- setTimeout(() => noteInput.focus(), 0);
- } else {
- notePanel.setAttribute('hidden', '');
- }
- });
+ let pendingMode = null;
menu.addEventListener('click', async (ev) => {
const choice = ev.target.closest('[data-mode]');
- if (!choice) return;
- ev.preventDefault();
- ev.stopPropagation();
- const mode = choice.getAttribute('data-mode') || 'ai-reply';
- // Always pick up whatever's in the textarea — empty = no note,
- // typed = passed through as steering context.
- const noteHint = (noteInput.value || '').trim();
- _closeAiReplyChoice();
- await _runAiReplyFromButton(btn, em, data, mode, noteHint);
+ if (choice) {
+ ev.preventDefault();
+ ev.stopPropagation();
+ // First click reveals the optional-context textarea; the actual
+ // draft runs on OK. Empty context just runs the chosen mode.
+ pendingMode = choice.getAttribute('data-mode') || 'ai-reply';
+ modeRow.setAttribute('hidden', '');
+ notePanel.removeAttribute('hidden');
+ setTimeout(() => noteInput.focus(), 0);
+ return;
+ }
+ const ok = ev.target.closest('[data-act="note-ok"]');
+ if (ok) {
+ ev.preventDefault();
+ ev.stopPropagation();
+ const noteHint = (noteInput.value || '').trim();
+ const mode = pendingMode || 'ai-reply';
+ _closeAiReplyChoice();
+ await _runAiReplyFromButton(btn, em, data, mode, noteHint);
+ }
});
// Esc closes the popover; ignore plain clicks inside the menu so the
// textarea stays focused.