From f45464bade1f30439bf6e8019e052e172209b834 Mon Sep 17 00:00:00 2001 From: sss Date: Fri, 15 Aug 2025 22:25:50 -0700 Subject: [PATCH] Update index.html --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 73b5eee..ba715d2 100644 --- a/index.html +++ b/index.html @@ -116,7 +116,7 @@ const reflectActiveAssistant=()=>{const a=getActive();el.settingsBtnTop.title=`S const renderSidebar=()=>{const activeId=as.getActiveId();el.assistantList.innerHTML=assistants.map(a=>``).join('')} function enhanceCodeBlocks(root,doHL=true){root.querySelectorAll('pre>code').forEach(code=>{if(code.textContent.length>200000)return;const pre=code.parentElement;pre.classList.add('relative','rounded-xl','border','border-gray-200');if(!pre.querySelector('.copy-btn')){const btn=document.createElement('button');btn.className='copy-btn';btn.textContent='Copy';btn.addEventListener('click',async e=>{e.stopPropagation();try{await navigator.clipboard.writeText(code.innerText);btn.textContent='Copied';setTimeout(()=>btn.textContent='Copy',1200)}catch{}});pre.appendChild(btn)}if(doHL&&window.hljs&&code.textContent.length<100000)hljs.highlightElement(code)})} const md=window.markdownit({html:false,linkify:true,typographer:true,breaks:true}) -const getAssistantLabel=m=>{const name=(m&&m.assistant_name)||getActive().name,modelShort=getModelShort(m&&m.model);return `${name} โ€“ ${modelShort}`} +const getAssistantLabel=m=>{const name=(m&&m.assistant_name)||getActive().name,modelShort=getModelShort(m&&m.model);return `${name} ยท ${modelShort}`} function msgRow(m){const role=typeof m==='string'?m:(m&&m.role)||'assistant';const meta=typeof m==='string'?{}:m||{};const row=document.createElement('div');row.className='flex flex-col gap-2';const head=document.createElement('div');head.className='flex items-center gap-2 px-4';const avatar=document.createElement('div');avatar.className=(role==='user'?'bg-gray-900 text-white':'bg-gray-200 text-gray-900')+' msg-avatar shrink-0 h-7 w-7 rounded-full flex items-center justify-center';avatar.textContent=role==='user'?'๐Ÿง‘':'๐Ÿค–';const name=document.createElement('div');name.className='text-xs font-medium text-gray-500';name.textContent=role==='user'?'You':getAssistantLabel(meta);head.appendChild(avatar);head.appendChild(name);const bubble=document.createElement('div');bubble.className=(role==='user'?'bg-gray-50 border border-gray-200':'bg-gray-100')+' msg-bubble markdown-body rounded-none px-4 py-3 w-full';row.appendChild(head);row.appendChild(bubble);el.messages.appendChild(row);queueMicrotask(()=>el.chat.scrollTo({top:el.chat.scrollHeight,behavior:'smooth'}));return bubble} function renderMarkdown(node,text,opt={enhance:true,highlight:true}){node.innerHTML=md.render(text);if(opt.enhance)enhanceCodeBlocks(node,opt.highlight)} function addMessage(m,track=true){const bubble=msgRow(m);renderMarkdown(bubble,m.content);if(track)state.messages.push(m);return bubble}