Add reasoning cache and viewer

This commit is contained in:
Jordan Wages 2025-06-27 01:39:02 -05:00
commit b6abe758b1
6 changed files with 240 additions and 7 deletions

44
resources/img/brain.png Normal file
View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Object not found!</title>
<link rev="made" href="mailto:webmaster@openmoji.org" />
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
body { color: #000000; background-color: #FFFFFF; }
a:link { color: #0000CC; }
p, address {margin-left: 3em;}
span {font-size: smaller;}
/*]]>*/--></style>
</head>
<body>
<h1>Object not found!</h1>
<p>
The requested URL was not found on this server.
If you entered the URL manually please check your
spelling and try again.
</p>
<p>
If you think this is a server error, please contact
the <a href="mailto:webmaster@openmoji.org">webmaster</a>.
</p>
<h2>Error 404</h2>
<address>
<a href="/">openmoji.org</a><br />
<span>Apache</span>
</address>
</body>
</html>

34
resources/reasonButton.js Normal file
View file

@ -0,0 +1,34 @@
(function() {
function addButton() {
const toolbar = document.querySelector("#header-view-toolbar") ||
document.querySelector("#mail-toolbox toolbar");
if (!toolbar || document.getElementById('sortana-reason-button')) return;
const button = document.createXULElement ?
document.createXULElement('toolbarbutton') :
document.createElement('button');
button.id = 'sortana-reason-button';
button.setAttribute('label', 'Show Reasoning');
button.className = 'toolbarbutton-1';
const icon = browser.runtime.getURL('resources/img/brain.png');
if (button.setAttribute) {
button.setAttribute('image', icon);
} else {
button.style.backgroundImage = `url(${icon})`;
button.style.backgroundSize = 'contain';
}
button.addEventListener('command', async () => {
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
const tabId = tabs[0]?.id;
const msgs = tabId ? await browser.messageDisplay.getDisplayedMessages(tabId) : [];
if (!msgs.length) return;
const url = browser.runtime.getURL(`reasoning.html?mid=${msgs[0].id}`);
browser.tabs.create({ url });
});
toolbar.appendChild(button);
}
if (document.readyState === 'complete' || document.readyState === 'interactive') {
addButton();
} else {
document.addEventListener('DOMContentLoaded', addButton, { once: true });
}
})();