This build was committed by a bot.

This commit is contained in:
github-actions[bot]
2025-11-12 04:12:32 +00:00
parent 0ecab9db7d
commit 062a86266e
3 changed files with 15 additions and 31 deletions

View File

@@ -213,25 +213,17 @@ const SUNE = window.SUNE = new Proxy({ get list() {
state.messages.push(assistantMsg);
THREAD.persist(false);
state.stream = { rid: streamId, bubble: suneBubble, meta: suneMeta, text: "", done: false };
let contentBuf = "", reasoningBuf = "", completed = false, reasoningEl = null;
let buf = "", completed = false;
const onDelta = (delta, done) => {
contentBuf += delta.content;
reasoningBuf += delta.reasoning;
state.stream.text = contentBuf;
renderMarkdown(suneBubble, contentBuf, { enhance: false });
assistantMsg.content[0].text = contentBuf;
if (reasoningBuf && !reasoningEl) {
reasoningEl = document.createElement("div");
reasoningEl.className = "markdown-body rounded-none px-4 py-3 w-full bg-blue-50 border-l-4 border-blue-300 text-sm text-gray-600";
suneBubble.parentElement.insertBefore(reasoningEl, suneBubble);
}
if (reasoningEl) renderMarkdown(reasoningEl, reasoningBuf, { enhance: false });
buf += delta;
state.stream.text = buf;
renderMarkdown(suneBubble, buf, { enhance: false });
assistantMsg.content[0].text = buf;
if (done && !completed) {
completed = true;
setBtnSend();
state.busy = false;
enhanceCodeBlocks(suneBubble, true);
if (reasoningEl) enhanceCodeBlocks(reasoningEl, true);
THREAD.persist(true);
el.composer.dispatchEvent(new CustomEvent("sune:newSuneResponse", { detail: { message: assistantMsg } }));
state.stream = { rid: null, bubble: null, meta: null, text: "", done: false };
@@ -805,25 +797,17 @@ $(el.composer).on("submit", async (e) => {
state.messages.push(assistantMsg);
THREAD.persist(false);
state.stream = { rid: streamId, bubble: suneBubble, meta: suneMeta, text: "", done: false };
let contentBuf = "", reasoningBuf = "", completed = false, reasoningEl = null;
let buf = "", completed = false;
const onDelta = (delta, done) => {
contentBuf += delta.content;
reasoningBuf += delta.reasoning;
state.stream.text = contentBuf;
renderMarkdown(suneBubble, contentBuf, { enhance: false });
assistantMsg.content[0].text = contentBuf;
if (reasoningBuf && !reasoningEl) {
reasoningEl = document.createElement("div");
reasoningEl.className = "markdown-body rounded-none px-4 py-3 w-full bg-blue-50 border-l-4 border-blue-300 text-sm text-gray-600";
suneBubble.parentElement.insertBefore(reasoningEl, suneBubble);
}
if (reasoningEl) renderMarkdown(reasoningEl, reasoningBuf, { enhance: false });
buf += delta;
state.stream.text = buf;
renderMarkdown(suneBubble, buf, { enhance: false });
assistantMsg.content[0].text = buf;
if (done && !completed) {
completed = true;
setBtnSend();
state.busy = false;
enhanceCodeBlocks(suneBubble, true);
if (reasoningEl) enhanceCodeBlocks(reasoningEl, true);
THREAD.persist(true);
el.composer.dispatchEvent(new CustomEvent("sune:newSuneResponse", { detail: { message: assistantMsg } }));
state.stream = { rid: null, bubble: null, meta: null, text: "", done: false };
@@ -1211,7 +1195,7 @@ const buildBody = () => {
async function askOpenRouterStreaming(onDelta, streamId) {
const model = SUNE.model, provider = model.startsWith("oai:") ? "openai" : model.startsWith("g:") ? "google" : model.startsWith("cla:") ? "claude" : model.startsWith("cf:") ? "cloudflare" : model.startsWith("or:") ? "openrouter" : USER.provider, apiKey = provider === "openai" ? USER.apiKeyOpenAI : provider === "google" ? USER.apiKeyGoogle : provider === "claude" ? USER.apiKeyClaude : provider === "cloudflare" ? USER.apiKeyCloudflare : USER.apiKeyOpenRouter;
if (!apiKey) {
onDelta({ content: localDemoReply(), reasoning: "" }, true);
onDelta(localDemoReply(), true);
return { ok: true, rid: streamId || null };
}
const r = { rid: streamId || gid(), seq: -1, done: false, signaled: false, ws: null };
@@ -1219,7 +1203,7 @@ async function askOpenRouterStreaming(onDelta, streamId) {
const signal = (t) => {
if (!r.signaled) {
r.signaled = true;
onDelta({ content: t || "", reasoning: "" }, true);
onDelta(t || "", true);
}
};
const ws = new WebSocket(HTTP_BASE.replace("https", "wss") + "?uid=" + encodeURIComponent(r.rid));
@@ -1234,7 +1218,7 @@ async function askOpenRouterStreaming(onDelta, streamId) {
}
if (m.type === "delta" && typeof m.seq === "number" && m.seq > r.seq) {
r.seq = m.seq;
onDelta({ content: m.content || "", reasoning: m.reasoning || "" }, false);
onDelta(m.text || "", false);
} else if (m.type === "done" || m.type === "err") {
r.done = true;
cacheStore.setItem(r.rid, "done");

2
dist/index.html vendored
View File

@@ -11,7 +11,7 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.11.1/build/styles/github.min.css"/>
<script defer src="https://cdn.jsdelivr.net/npm/cash-dom/dist/cash.min.js"></script>
<script defer src="//unpkg.com/alpinejs"></script>
<script type="module" crossorigin src="/assets/index-DfSXZB8u.js"></script>
<script type="module" crossorigin src="/assets/index-mliZjutQ.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CZ8Js0gk.css">
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
<body class="bg-white text-gray-900 selection:bg-black/10" x-data @click.window="if($event.target.closest('button')) haptic(); if(!document.getElementById('threadPopover').contains($event.target)&&!$event.target.closest('[data-thread-menu]')) hideThreadPopover(); if(!document.getElementById('sunePopover').contains($event.target)&&!$event.target.closest('[data-sune-menu]')) hideSunePopover(); if(!document.getElementById('userMenu').contains($event.target)&&!document.getElementById('userMenuBtn').contains($event.target)) document.getElementById('userMenu').classList.add('hidden')">

2
dist/sw.js vendored
View File

@@ -1 +1 @@
if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didnt register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let o={};const c=e=>i(e,t),l={module:{uri:t},exports:o,require:c};s[t]=Promise.all(n.map(e=>l[e]||c(e))).then(e=>(r(...e),o))}}define(["./workbox-5ffe50d4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-CZ8Js0gk.css",revision:null},{url:"assets/index-DfSXZB8u.js",revision:null},{url:"index.html",revision:"ca3c2ca1f8a160c237c3b3a4b5671316"},{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});
if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didnt register its module`);return e}));self.define=(n,t)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(s[r])return;let c={};const o=e=>i(e,r),l={module:{uri:r},exports:c,require:o};s[r]=Promise.all(n.map(e=>l[e]||o(e))).then(e=>(t(...e),c))}}define(["./workbox-5ffe50d4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-CZ8Js0gk.css",revision:null},{url:"assets/index-mliZjutQ.js",revision:null},{url:"index.html",revision:"449e7e44cc39205c06610cc6f33ffcc8"},{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});