mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-07-16 13:08:02 +00:00
Reuse open email drafts for agent replies
This commit is contained in:
@@ -10408,6 +10408,7 @@ const documentModule = {
|
|||||||
newDocument,
|
newDocument,
|
||||||
loadDocument,
|
loadDocument,
|
||||||
injectFreshDoc,
|
injectFreshDoc,
|
||||||
|
replaceEmailReplyBody,
|
||||||
ensurePaneMounted: _ensureDocPaneMounted,
|
ensurePaneMounted: _ensureDocPaneMounted,
|
||||||
loadSessionDocs,
|
loadSessionDocs,
|
||||||
ensureDocPanel,
|
ensureDocPanel,
|
||||||
|
|||||||
@@ -914,12 +914,10 @@ async function _openEmail(em, itemEl, preloadedData = null, mode = 'reply', note
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_docModule) {
|
if (_docModule) {
|
||||||
// Only reuse an existing doc tab if the user really just wants to "view"
|
// Agent-provided reply text should land in the email draft the user
|
||||||
// the email again. For reply/reply-all/forward/ai-reply, always create
|
// already has open. Otherwise mobile users see the source email while the
|
||||||
// a fresh draft — otherwise a previously-emptied doc (sent reply, AI
|
// agent silently creates a second draft elsewhere.
|
||||||
// reply that came back blank, etc.) keeps coming back instead of a
|
const reuseExisting = (mode === 'view' || mode === 'open' || (!!aiSuggestedBody && mode !== 'forward'));
|
||||||
// proper pre-filled reply.
|
|
||||||
const reuseExisting = (mode === 'view' || mode === 'open');
|
|
||||||
const existingDocId = (reuseExisting && _docModule.findEmailDocId)
|
const existingDocId = (reuseExisting && _docModule.findEmailDocId)
|
||||||
? _docModule.findEmailDocId(em.uid, _currentFolder)
|
? _docModule.findEmailDocId(em.uid, _currentFolder)
|
||||||
: null;
|
: null;
|
||||||
@@ -927,6 +925,10 @@ async function _openEmail(em, itemEl, preloadedData = null, mode = 'reply', note
|
|||||||
if (!_docModule.isPanelOpen()) _docModule.openPanel();
|
if (!_docModule.isPanelOpen()) _docModule.openPanel();
|
||||||
await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)));
|
await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)));
|
||||||
await _docModule.loadDocument(existingDocId);
|
await _docModule.loadDocument(existingDocId);
|
||||||
|
if (aiSuggestedBody && typeof _docModule.replaceEmailReplyBody === 'function') {
|
||||||
|
await _docModule.replaceEmailReplyBody(existingDocId, aiSuggestedBody);
|
||||||
|
_bringEmailReplyDraftToFrontOnMobile();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the user already has a chat session open, reuse it instead of
|
// If the user already has a chat session open, reuse it instead of
|
||||||
// spawning a new one. They asked for this explicitly — opening reply
|
// spawning a new one. They asked for this explicitly — opening reply
|
||||||
|
|||||||
Reference in New Issue
Block a user