This build was committed by a bot.

This commit is contained in:
github-actions[bot]
2026-01-16 20:16:53 +00:00
parent f3e2266a4a
commit 244a54463b
3 changed files with 25 additions and 8 deletions

View File

@@ -711,7 +711,7 @@ const threadRow = (t) => `<div class="relative flex items-center gap-2 px-3 py-2
let sortedThreads = [], isAddingThreads = false; let sortedThreads = [], isAddingThreads = false;
const THREAD_PAGE_SIZE = 50; const THREAD_PAGE_SIZE = 50;
async function renderThreads() { async function renderThreads() {
sortedThreads = [...THREAD.list].sort((a, b) => b.pinned - a.pinned || b.updatedAt - a.updatedAt); sortedThreads = [...THREAD.list].filter((t) => t.status !== "deleted").sort((a, b) => b.pinned - a.pinned || b.updatedAt - a.updatedAt);
el.threadList.innerHTML = sortedThreads.slice(0, THREAD_PAGE_SIZE).map(threadRow).join(""); el.threadList.innerHTML = sortedThreads.slice(0, THREAD_PAGE_SIZE).map(threadRow).join("");
el.threadList.scrollTop = 0; el.threadList.scrollTop = 0;
isAddingThreads = false; isAddingThreads = false;
@@ -815,8 +815,13 @@ $(el.threadPopover).on("click", async (e) => {
} }
} else if (act === "delete") { } else if (act === "delete") {
if (confirm("Delete this chat?")) { if (confirm("Delete this chat?")) {
if (u.startsWith("gh://")) {
th.status = "deleted";
th.updatedAt = Date.now();
} else {
THREAD.list = THREAD.list.filter((x) => x.id !== th.id); THREAD.list = THREAD.list.filter((x) => x.id !== th.id);
await localforage.removeItem(prefix + th.id); await localforage.removeItem(prefix + th.id);
}
if (state.currentThreadId === th.id) { if (state.currentThreadId === th.id) {
state.currentThreadId = null; state.currentThreadId = null;
clearChat(); clearChat();
@@ -1381,6 +1386,10 @@ const parseGhUrl = (u) => {
$(el.threadRepoInput).on("change", async () => { $(el.threadRepoInput).on("change", async () => {
const u = el.threadRepoInput.value.trim(); const u = el.threadRepoInput.value.trim();
localStorage.setItem("thread_repo_url", u); localStorage.setItem("thread_repo_url", u);
if (state.currentThreadId) {
state.currentThreadId = null;
clearChat();
}
el.threadFolderBtn.classList.toggle("hidden", !u.startsWith("gh://")); el.threadFolderBtn.classList.toggle("hidden", !u.startsWith("gh://"));
el.threadBackBtn.classList.toggle("hidden", !u.startsWith("gh://") || u.split("/").length <= 3); el.threadBackBtn.classList.toggle("hidden", !u.startsWith("gh://") || u.split("/").length <= 3);
await THREAD.load(); await THREAD.load();
@@ -1410,14 +1419,22 @@ $(el.threadSyncBtn).on("click", async () => {
const info = parseGhUrl(u); const info = parseGhUrl(u);
try { try {
if (mode) { if (mode) {
const idxFile = await ghApi(info.full), sha = idxFile?.sha; const idxFile = await ghApi(info.full), sha = idxFile?.sha, toRemove = [];
for (const t of THREAD.list) { for (const t of THREAD.list) {
if (t.type === "thread" && (t.status === "modified" || t.status === "new")) { if (t.type !== "thread") continue;
const msgs = await localforage.getItem("rem_t_" + t.id), fPath = `${info.dir}${t.id}.json`, ex = await ghApi(fPath + "?ref=" + info.branch); const fPath = `${info.dir}${t.id}.json`;
if (t.status === "deleted") {
const ex = await ghApi(fPath + "?ref=" + info.branch);
if (ex?.sha) await ghApi(fPath, "DELETE", { message: `Delete thread ${t.id}`, sha: ex.sha, branch: info.branch });
await localforage.removeItem("rem_t_" + t.id);
toRemove.push(t.id);
} else if (t.status === "modified" || t.status === "new") {
const msgs = await localforage.getItem("rem_t_" + t.id), ex = await ghApi(fPath + "?ref=" + info.branch);
await ghApi(fPath, "PUT", { message: `Sync thread ${t.id}`, content: utob(JSON.stringify(msgs, null, 2)), branch: info.branch, sha: ex?.sha }); await ghApi(fPath, "PUT", { message: `Sync thread ${t.id}`, content: utob(JSON.stringify(msgs, null, 2)), branch: info.branch, sha: ex?.sha });
t.status = "synced"; t.status = "synced";
} }
} }
THREAD.list = THREAD.list.filter((x) => !toRemove.includes(x.id));
await ghApi(info.full, "PUT", { message: "Update index.json", content: utob(JSON.stringify(THREAD.list, null, 2)), branch: info.branch, sha }); await ghApi(info.full, "PUT", { message: "Update index.json", content: utob(JSON.stringify(THREAD.list, null, 2)), branch: info.branch, sha });
alert("Pushed to GitHub."); alert("Pushed to GitHub.");
} else { } else {

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="https://cdn.jsdelivr.net/npm/cash-dom/dist/cash.min.js"></script>
<script defer src="//unpkg.com/alpinejs"></script> <script defer src="//unpkg.com/alpinejs"></script>
<script type="module" crossorigin src="/assets/index-BdQE1Xqo.js"></script> <script type="module" crossorigin src="/assets/index-YfnOwjpc.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-JLEDB1oP.css"> <link rel="stylesheet" crossorigin href="/assets/index-JLEDB1oP.css">
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head> <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')"> <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),d={module:{uri:t},exports:o,require:c};s[t]=Promise.all(n.map(e=>d[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:"f5de2a58d8f0836b0c5c8b0917dfc229"},{url:"assets/index-JLEDB1oP.css",revision:null},{url:"assets/index-BdQE1Xqo.js",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:"e77936a1f49cc105f92b52dd1ca398f8"},{url:"assets/index-YfnOwjpc.js",revision:null},{url:"assets/index-JLEDB1oP.css",revision:null},{url:"manifest.webmanifest",revision:"7a6c5c6ab9cb5d3605d21df44c6b17a2"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});