mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-09-26 18:12:21 +02:00
Squash Odysseus development history
This commit is contained in:
+95
-11
@@ -2,11 +2,41 @@
|
||||
// SSE event handlers extracted from chat.js handleChatSubmit
|
||||
// Handles: ui_control events, background stream management
|
||||
|
||||
import uiModule from './ui.js';
|
||||
import uiModule from './ui.js?v=20260908weekhoverfix1';
|
||||
import Storage from './storage.js';
|
||||
import themeModule from './theme.js';
|
||||
import themeModule from './theme.js?v=20260909effectspeed1';
|
||||
import markdownModule from './markdown.js';
|
||||
import sessionModule from './sessions.js';
|
||||
import documentModule from './document.js?v=20260911removealignrightshortcut1';
|
||||
|
||||
// Tool approvals are control-plane submits for the current chat. chat.js
|
||||
// deliberately leaves the composer untouched, then programmatically clicks the
|
||||
// shared send button after it records the sealed approval id/decision. That
|
||||
// button is polymorphic: with an empty composer it can mean New chat or Record
|
||||
// voice instead of Send. Intercept only the programmatic approval click and
|
||||
// route it through the form submit path, which already reaches chat.js directly.
|
||||
document.addEventListener('odysseus:tool-approval', () => {
|
||||
const sendButton = document.querySelector('.send-btn');
|
||||
const chatForm = document.getElementById('chat-form');
|
||||
if (!sendButton || !chatForm) return;
|
||||
|
||||
const interceptApprovalClick = (event) => {
|
||||
// A real user click must retain the normal send/new-chat/STT behavior.
|
||||
if (event.isTrusted) return;
|
||||
sendButton.removeEventListener('click', interceptApprovalClick, true);
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
if (chatForm.requestSubmit) chatForm.requestSubmit();
|
||||
else chatForm.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }));
|
||||
};
|
||||
|
||||
sendButton.addEventListener('click', interceptApprovalClick, true);
|
||||
// Fail-safe cleanup if the approval continuation never reaches its deferred
|
||||
// synthetic click (for example because the surrounding view is torn down).
|
||||
setTimeout(() => {
|
||||
sendButton.removeEventListener('click', interceptApprovalClick, true);
|
||||
}, 60000);
|
||||
}, true);
|
||||
|
||||
/**
|
||||
* Handle a ui_control SSE event — AI-driven UI manipulation.
|
||||
@@ -99,6 +129,7 @@ export function handleUIControl(uiData) {
|
||||
if (bg.effectColor && tm2.applyBgEffectColor) { tm2.applyBgEffectColor(bg.effectColor); opts.bgEffectColor = bg.effectColor; }
|
||||
if (bg.effectIntensity != null && tm2.applyBgEffectIntensity) { tm2.applyBgEffectIntensity(bg.effectIntensity); opts.bgEffectIntensity = bg.effectIntensity; }
|
||||
if (bg.effectSize != null && tm2.applyBgEffectSize) { tm2.applyBgEffectSize(bg.effectSize); opts.bgEffectSize = bg.effectSize; }
|
||||
if (bg.effectSpeed != null && tm2.applyBgEffectSpeed) { tm2.applyBgEffectSpeed(bg.effectSpeed); opts.bgEffectSpeed = bg.effectSpeed; }
|
||||
if (bg.frosted != null && tm2.applyFrostedGlass) { tm2.applyFrostedGlass(bg.frosted); opts.frosted = bg.frosted; }
|
||||
}
|
||||
if (tm2.saveCustomTheme) tm2.saveCustomTheme(name, colors2, Object.keys(opts).length ? opts : undefined);
|
||||
@@ -131,7 +162,7 @@ export function handleUIControl(uiData) {
|
||||
// the 12s active-poll.
|
||||
var rsid = uiData.research_session_id || uiData.session_id;
|
||||
if (rsid) {
|
||||
import('./research/jobs.js').then(function(mod) {
|
||||
import('./research/jobs.js?v=20260910researcherrorpersist1').then(function(mod) {
|
||||
var fn = mod.adoptSession || (mod.default && mod.default.adoptSession);
|
||||
if (fn) fn(rsid);
|
||||
}).catch(function(){});
|
||||
@@ -145,17 +176,24 @@ export function handleUIControl(uiData) {
|
||||
} else if (uiEvent === 'open_panel' || uiData.ui_event === 'open_panel') {
|
||||
var panel = uiData.panel;
|
||||
if (panel === 'documents') {
|
||||
import('./documentLibrary.js').then(function(mod) {
|
||||
import('./documentLibrary.js?v=20260911librarybulkdelete1').then(function(mod) {
|
||||
var fn = mod.openLibrary || (mod.default && mod.default.openLibrary);
|
||||
if (fn) fn();
|
||||
}).catch(function(){});
|
||||
} else if (panel === 'gallery') {
|
||||
import('./gallery.js').then(function(mod) {
|
||||
import('./gallery.js?v=20260910promptcopy1').then(function(mod) {
|
||||
var fn = mod.openGallery || (mod.default && mod.default.openGallery);
|
||||
if (fn) fn();
|
||||
}).catch(function(){});
|
||||
} else if (panel === 'calendar') {
|
||||
import('./calendar.js?v=20260903weekscrollstable1').then(function(mod) {
|
||||
var viewFn = mod.openCalendarView || (mod.default && mod.default.openCalendarView);
|
||||
var fn = mod.openCalendar || (mod.default && mod.default.openCalendar);
|
||||
if (viewFn && (uiData.view || uiData.target_date)) viewFn(uiData.view || 'month', uiData.target_date || '');
|
||||
else if (fn) fn();
|
||||
}).catch(function(){});
|
||||
} else if (panel === 'email') {
|
||||
import('./emailLibrary.js').then(function(mod) {
|
||||
import('./emailLibrary.js?v=20260910replyactions1').then(function(mod) {
|
||||
var fn = mod.openEmailLibrary || (mod.default && mod.default.openEmailLibrary);
|
||||
if (fn) fn();
|
||||
}).catch(function(){});
|
||||
@@ -170,22 +208,60 @@ export function handleUIControl(uiData) {
|
||||
if (fn) fn();
|
||||
}).catch(function(){});
|
||||
} else if (panel === 'notes') {
|
||||
import('./notes.js').then(function(mod) {
|
||||
import('./notes.js?v=20260910drawmerge1').then(function(mod) {
|
||||
var fn = mod.openPanel || mod.openNotes || (mod.default && (mod.default.openPanel || mod.default.openNotes));
|
||||
if (fn) fn();
|
||||
}).catch(function(){});
|
||||
} else if (panel === 'theme' || panel === 'themes') {
|
||||
import('./theme.js?v=20260909effectspeed1').then(function(mod) {
|
||||
var fn = mod.togglePopup || (mod.default && mod.default.togglePopup);
|
||||
var modal = document.getElementById('theme-modal');
|
||||
if (modal && modal.classList.contains('hidden') && fn) fn();
|
||||
else if (!modal && fn) fn();
|
||||
else if (modal) modal.classList.remove('hidden');
|
||||
}).catch(function(){
|
||||
var btn = document.getElementById('tool-theme-btn') || document.getElementById('rail-theme');
|
||||
if (btn) btn.click();
|
||||
});
|
||||
} else if (panel === 'memories' || panel === 'skills' || panel === 'settings') {
|
||||
// These live in the sidebar / settings drawer — most just need
|
||||
// an existing button click.
|
||||
var ids = { memories: 'tool-memory-btn', skills: 'skills-btn', settings: 'open-settings-btn' };
|
||||
var ids = { memories: 'tool-memory-btn', skills: 'tool-skills-btn', settings: 'open-settings-btn' };
|
||||
var btn = document.getElementById(ids[panel]);
|
||||
if (btn) btn.click();
|
||||
if (panel === 'settings') {
|
||||
import('./settings.js?v=20260909defaultmodelfix1').then(function(mod) {
|
||||
var fn = mod.open || (mod.default && mod.default.open);
|
||||
if (fn) fn();
|
||||
else if (btn) btn.click();
|
||||
}).catch(function(){ if (btn) btn.click(); });
|
||||
} else if (btn) btn.click();
|
||||
}
|
||||
|
||||
} else if (uiEvent === 'open_email_reply' || uiData.ui_event === 'open_email_reply') {
|
||||
import('./emailInbox.js').then(function(mod) {
|
||||
try {
|
||||
var activeCtx = documentModule && documentModule.getActiveEmailComposerContext
|
||||
? documentModule.getActiveEmailComposerContext()
|
||||
: null;
|
||||
var sameActiveDraft = activeCtx
|
||||
&& String(activeCtx.sourceUid || '') === String(uiData.uid || '')
|
||||
&& String(activeCtx.sourceFolder || 'INBOX') === String(uiData.folder || 'INBOX');
|
||||
var existingDocId = sameActiveDraft && activeCtx.docId
|
||||
? activeCtx.docId
|
||||
: (documentModule && documentModule.findEmailDocId
|
||||
? documentModule.findEmailDocId(uiData.uid, uiData.folder || 'INBOX')
|
||||
: null);
|
||||
if (existingDocId && documentModule.replaceEmailReplyBody) {
|
||||
if (documentModule.loadDocument) documentModule.loadDocument(existingDocId);
|
||||
documentModule.replaceEmailReplyBody(existingDocId, uiData.body || '', { force: true });
|
||||
if (uiModule && uiModule.showToast) uiModule.showToast('Wrote reply into the open email');
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('open_email_reply existing draft update failed:', e);
|
||||
}
|
||||
import('./emailInbox.js?v=20260903emailsend2').then(function(mod) {
|
||||
var fn = mod.openReplyDraft || (mod.default && mod.default.openReplyDraft);
|
||||
if (fn) fn(uiData.uid, uiData.folder || 'INBOX', uiData.mode || 'reply');
|
||||
if (fn) fn(uiData.uid, uiData.folder || 'INBOX', uiData.mode || 'reply', uiData.body || '');
|
||||
}).catch(function(e) {
|
||||
console.warn('open_email_reply failed:', e);
|
||||
});
|
||||
@@ -222,6 +298,14 @@ export function notifyStreamComplete(sessionId, query) {
|
||||
* Insert a clickable in-chat toast when a background stream finishes.
|
||||
*/
|
||||
export function insertStreamDoneToast(sessionId, query) {
|
||||
if (
|
||||
sessionModule
|
||||
&& sessionModule.getCurrentSessionId
|
||||
&& sessionModule.getCurrentSessionId() !== sessionId
|
||||
) {
|
||||
if (uiModule && uiModule.showToast) uiModule.showToast('Response ready in another chat', 4000);
|
||||
return;
|
||||
}
|
||||
var box = document.getElementById('chat-history');
|
||||
if (!box) return;
|
||||
var sessions = sessionModule ? sessionModule.getSessions() : [];
|
||||
|
||||
Reference in New Issue
Block a user