This build was committed by a bot.

This commit is contained in:
github-actions[bot]
2026-01-16 16:56:41 +00:00
parent 3b887ed1e9
commit 0f7db1a7df
3 changed files with 13 additions and 37 deletions

View File

@@ -650,18 +650,6 @@ const TKEY = "threads_v1", THREAD = window.THREAD = { list: [], load: async func
if (!/^\s*You\b/.test(h.textContent || "")) return b.dataset.mid || null;
}
return null;
}, migrate: async function() {
const old = await localforage.getItem(TKEY);
if (Array.isArray(old) && old.length > 0 && old[0].messages) {
for (const t of old) {
if (t.messages) {
await localforage.setItem("t_" + t.id, t.messages);
delete t.messages;
}
}
await localforage.setItem(TKEY, old);
this.list = old;
}
} };
const cacheStore = localforage.createInstance({ name: "threads_cache", storeName: "streams_status" });
async function ensureThreadOnFirstUser(text) {
@@ -1168,32 +1156,21 @@ $(el.importInput).on("change", async () => {
clearChat();
alert(`${added} new, ${updated} updated.`);
} else if (importMode === "threads") {
const arr = Array.isArray(data) ? data : data.threads ? data.threads : data.id ? [data] : [];
if (!arr.length) throw new Error("No threads");
const norm = (t) => ({ id: t.id || gid(), title: titleFrom(t.title || titleFrom(t.messages?.find?.((m) => m.role === "user")?.content || "")), pinned: !!t.pinned, updatedAt: t.updatedAt || Date.now(), messages: Array.isArray(t.messages) ? t.messages.filter((m) => m && m.role && m.content) : [] });
const best = {};
arr.forEach((t) => {
const n = norm(t), k = n.id, prev = best[k];
best[k] = !prev || +n.updatedAt > +prev.updatedAt ? n : prev;
});
let kept = 0, skipped = 0;
const idx = Object.fromEntries(THREAD.list.map((t) => [t.id, t]));
for (const th of Object.values(best)) {
const ex = idx[th.id];
if (ex && +ex.updatedAt >= +th.updatedAt) {
skipped++;
continue;
if (!data || !data.id || !Array.isArray(data.messages)) throw new Error("Invalid thread format");
const norm = (t) => ({ id: t.id || gid(), title: titleFrom(t.title || titleFrom(t.messages?.find?.((m) => m.role === "user")?.content || "")), pinned: !!t.pinned, updatedAt: t.updatedAt || Date.now() });
const n = norm(data), msgs = data.messages, idx = THREAD.list.findIndex((x) => x.id === n.id);
if (idx > -1) {
if (n.updatedAt > THREAD.list[idx].updatedAt) {
THREAD.list[idx] = n;
await localforage.setItem("t_" + n.id, msgs);
}
const msgs = th.messages;
delete th.messages;
if (!ex) THREAD.list.push(th);
else Object.assign(ex, th);
await localforage.setItem("t_" + th.id, msgs);
kept++;
} else {
THREAD.list.unshift(n);
await localforage.setItem("t_" + n.id, msgs);
}
await THREAD.save();
await renderThreads();
alert(`${kept} imported, ${skipped} skipped (older).`);
alert("Thread imported.");
}
el.userMenu.classList.add("hidden");
} catch {
@@ -1325,7 +1302,6 @@ const USER = window.USER = { log: async (s) => {
localStorage.setItem("gcp_sa_json", v ? JSON.stringify(v) : "");
} };
async function init() {
await THREAD.migrate();
await SUNE.fetchDotSune("sune-org/store@main/marketplace.sune");
await THREAD.load();
await renderThreads();

2
dist/index.html vendored
View File

@@ -12,7 +12,7 @@
<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-DhsVMGWU.js"></script>
<script type="module" crossorigin src="/assets/index-B0CkbYOO.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 d=e=>i(e,t),l={module:{uri:t},exports:o,require:d};s[t]=Promise.all(n.map(e=>l[e]||d(e))).then(e=>(r(...e),o))}}define(["./workbox-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"66b8a677ed424892d5add8e1dbb2b563"},{url:"assets/index-DhsVMGWU.js",revision:null},{url:"assets/index-CZ8Js0gk.css",revision:null},{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,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-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"cfbe3b8194fa72cc9cdff797b6e51a07"},{url:"assets/index-CZ8Js0gk.css",revision:null},{url:"assets/index-B0CkbYOO.js",revision:null},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});