Skip to content

Self-hosted AI workspace.

Python

Respect text-only emoji setting after svgification

sunnyeggb3d6bbddfcae
diff --git a/static/app.js b/static/app.js
index 3bc6ef9f9..95159c46d 100644
--- a/static/app.js
+++ b/static/app.js
@@ -2553,14 +2553,23 @@ function initializeEventListeners() {
});
}
+ const _DEOJ_SKIP = '.sources-section, .thinking-toggle, .memory-used-pill';
+
/** Walk all text nodes inside an element and replace emojis with text descriptions */
function deEmojify(root) {
+ if (!root || !root.querySelectorAll) return;
+ // Monochrome SVG spans from svgifyEmoji — Unicode lives in aria-label only
+ root.querySelectorAll('.emoji[aria-label]').forEach((span) => {
+ if (span.closest(_DEOJ_SKIP)) return;
+ const label = span.getAttribute('aria-label') || '';
+ span.replaceWith(document.createTextNode(emojiToText(label)));
+ });
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
const nodes = [];
while (walker.nextNode()) nodes.push(walker.currentNode);
for (const node of nodes) {
// Skip UI elements that use unicode symbols as functional icons
- if (node.parentElement && node.parentElement.closest('.sources-section, .thinking-toggle, .memory-used-pill')) continue;
+ if (node.parentElement && node.parentElement.closest(_DEOJ_SKIP)) continue;
if (EMOJI_RE.test(node.textContent)) {
EMOJI_RE.lastIndex = 0; // reset regex state
node.textContent = emojiToText(node.textContent);
diff --git a/static/js/markdown.js b/static/js/markdown.js
index 4a7669fb7..dd9797986 100644
--- a/static/js/markdown.js
+++ b/static/js/markdown.js
@@ -233,8 +233,13 @@ function _svgifyText(text) {
}
return out;
}
+/** When "Text-only Emojis" is on, keep Unicode in HTML so deEmojify() can strip them. */
+function _useSvgEmoji() {
+ return typeof document === 'undefined' || !document.body?.classList.contains('text-emojis');
+}
+
export function svgifyEmoji(html) {
- if (!html || !_EMOJI_RE.test(html)) return html;
+ if (!_useSvgEmoji() || !html || !_EMOJI_RE.test(html)) return html;
const parts = html.split(/(<[^>]*>)/); // odd indices = tags
let codeDepth = 0;
for (let i = 0; i < parts.length; i++) {
@@ -282,7 +287,7 @@ export function processWithThinking(text) {
html += mdToHtml(content);
}
- return svgifyEmoji(html);
+ return _useSvgEmoji() ? svgifyEmoji(html) : html;
}
/**
@@ -539,7 +544,7 @@ export function mdToHtml(src) {
s = s.replace(`___CODE_BLOCK_${index}___`, block);
});
- return svgifyEmoji(s);
+ return _useSvgEmoji() ? svgifyEmoji(s) : s;
}
/**