diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..6a87a09 --- /dev/null +++ b/.npmrc @@ -0,0 +1,3 @@ +# Only resolve npm versions published at least 7 days ago. See "Dependency cooldown" in +# the workspace AGENTS.md for why and for the override. +min-release-age=7 diff --git a/CHANGELOG.md b/CHANGELOG.md index d0559f2..a267d22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,16 @@ popover, not for the person who wrote the commit. ## [Unreleased] +## [1.11.1] - 2026-10-24 + +### Fixed +- **Your stashes no longer vanish for a few seconds when you come back from Settings.** Returning + from Settings or the context manager rebuilt the list from nothing, so it showed "queue empty" + until the stashes had been read again, which took seconds with a large queue. The list now + comes back at once and refreshes quietly in the background. The same wait is gone at startup: + the splash screen stays up until your stashes are loaded, and if that early load fails the + list shows a "Loading stashes…" notice instead of claiming the queue is empty + ## [1.11.0] - 2026-10-11 ### Added diff --git a/package.json b/package.json index d2dd30f..d1de715 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stashpad", - "version": "1.11.0", + "version": "1.11.1", "description": "The staging area for your AI context.", "author": { "name": "Nico Wiedemann", diff --git a/src-tauri/.cargo/config.toml b/src-tauri/.cargo/config.toml new file mode 100644 index 0000000..cbc9c93 --- /dev/null +++ b/src-tauri/.cargo/config.toml @@ -0,0 +1,5 @@ +# Only resolve crate versions published at least 7 days ago. See "Dependency cooldown" in +# the workspace AGENTS.md for why and for the override. Cargo before 1.100 ignores this +# with a warning. +[registry] +global-min-publish-age = "7 days" diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index f74a7f0..a190d6b 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -5557,7 +5557,7 @@ checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "stashpad" -version = "1.11.0" +version = "1.11.1" dependencies = [ "active-win-pos-rs", "aes-gcm", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 7357d33..20889e8 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stashpad" -version = "1.11.0" +version = "1.11.1" description = "The staging area for your AI context." authors = ["Nico Wiedemann "] repository = "https://github.com/EarMaster/stashpad" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 6d114a6..472a246 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "stashpad", - "version": "1.11.0", + "version": "1.11.1", "identifier": "org.stashpad", "build": { "frontendDist": "../dist", diff --git a/src/lib/components/Queue.svelte b/src/lib/components/Queue.svelte index 93d331e..ecbde6a 100644 --- a/src/lib/components/Queue.svelte +++ b/src/lib/components/Queue.svelte @@ -21,6 +21,7 @@ import { fade, fly } from "svelte/transition"; import { DesktopStorageAdapter } from "$lib/services/desktop-adapter"; import type { StashItem, Context, Attachment, AIConfig } from "$lib/types"; + import { queueCache } from "$lib/stores/queue-cache"; import { _ } from "$lib/i18n"; import { isHexColor, extractTagsAndColors } from "$lib/utils/markdown"; import StashCard from "./StashCard.svelte"; @@ -56,6 +57,7 @@ Search, X, ChevronUp, + Loader2, } from "lucide-svelte"; import { tooltip } from "$lib/actions/tooltip"; import { @@ -119,7 +121,13 @@ contexts.find((c) => c.id === "default"), ); - let stashes = $state([]); + let stashes = $state(queueCache.stashes ?? []); + let loaded = $state(queueCache.stashes !== null); + // Every change goes through a reassignment of `stashes`, so this keeps the cache as + // current as the screen, not just as current as the last load. + $effect(() => { + if (loaded) queueCache.stashes = stashes; + }); let effectiveMode = $state<"Drag" | "Copy">("Drag"); // Flash state @@ -132,8 +140,14 @@ let showBackToTop = $state(false); // Separate arrays for dnd - these are the source of truth during drag - let activeStashes = $state([]); - let completedStashes = $state([]); + // Seeded here rather than by the effect that keeps them in step, so a remount's first + // frame already has its cards and the count effect below sees no empty-to-full jump. + let activeStashes = $state( + untrack(() => stashes.filter((s) => !s.completed && inContext(s))), + ); + let completedStashes = $state( + untrack(() => stashes.filter((s) => s.completed && inContext(s))), + ); let draggedItemId = $state(null); // Confirmation state @@ -728,18 +742,14 @@ showMenu = false; } + function inContext(stash: StashItem): boolean { + return (stash.contextId || "default") === (currentContextId || "default"); + } + // Sync stashes to active/completed function syncLists() { - activeStashes = stashes.filter( - (s) => - !s.completed && - (s.contextId || "default") === (currentContextId || "default"), - ); - completedStashes = stashes.filter( - (s) => - s.completed && - (s.contextId || "default") === (currentContextId || "default"), - ); + activeStashes = stashes.filter((s) => !s.completed && inContext(s)); + completedStashes = stashes.filter((s) => s.completed && inContext(s)); } // Watch for context changes @@ -808,9 +818,10 @@ }); async function load() { - const loaded = await adapter.loadStashes(); - if (loaded) { - stashes = loaded; + const result = await adapter.loadStashes(); + if (result) { + stashes = result; + loaded = true; syncLists(); if (newStashId) { checkNewStashVisibility(); @@ -1649,7 +1660,16 @@ {/if} - {#if stashes.length === 0} + {#if !loaded} + +
+
+ {:else if stashes.length === 0}
diff --git a/src/lib/i18n/locales/de.json b/src/lib/i18n/locales/de.json index 354dae0..e0a93ba 100644 --- a/src/lib/i18n/locales/de.json +++ b/src/lib/i18n/locales/de.json @@ -459,6 +459,7 @@ "other": "Andere Dateien" }, "queueEmpty": "Warteschlange ist leer", + "loadingStashes": "Stashes werden geladen…", "backToTop": "Nach oben", "sortOldest": "Sortieren: Älteste zuerst", "sortNewest": "Sortieren: Neueste zuerst", diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index a50192f..7c4d591 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -434,6 +434,7 @@ "clearCompleted": "Clear completed", "deleteAllCompleted": "Delete all completed stashes", "queueEmpty": "Your stashpad is empty. Add something new to start!", + "loadingStashes": "Loading stashes…", "noActiveStashes": "No active stashes.", "noActiveStashesFound": "No active stashes found matching filters.", "restoreOrder": "Restore manual order", diff --git a/src/lib/i18n/locales/zh.json b/src/lib/i18n/locales/zh.json index 30befee..ba74a7c 100644 --- a/src/lib/i18n/locales/zh.json +++ b/src/lib/i18n/locales/zh.json @@ -434,6 +434,7 @@ "clearCompleted": "清除已完成", "deleteAllCompleted": "删除所有已完成的暂存项", "queueEmpty": "你的 Stashpad 还是空的。添加点新内容开始吧!", + "loadingStashes": "正在加载暂存项…", "noActiveStashes": "没有活动的暂存项。", "noActiveStashesFound": "没有符合筛选条件的活动暂存项。", "restoreOrder": "恢复手动排序", diff --git a/src/lib/stores/queue-cache.ts b/src/lib/stores/queue-cache.ts new file mode 100644 index 0000000..441d4a0 --- /dev/null +++ b/src/lib/stores/queue-cache.ts @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +// Copyright (C) 2026 Nico Wiedemann +// +// This file is part of Stashpad. +// Stashpad is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License, version 3, +// as published by the Free Software Foundation. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Affero General Public License for more details. + +import type { StashItem } from "$lib/types"; + +/** + * The queue as it stood when it was last on screen, kept across mounts of `Queue`. + * + * Settings and the context manager replace the main view, so returning from either + * mounts a fresh Queue, and starting that from an empty array showed "queue empty" + * until its load came back. `main.ts` fills this before the first mount, while the + * splash screen is still up, and Queue keeps it current after that; either way a mount + * starts from it and reconciles with the database in the background. + * + * Null until something has actually read the stashes, so the empty state never claims a + * queue nobody has loaded yet. + */ +export const queueCache: { stashes: StashItem[] | null } = { stashes: null }; diff --git a/src/main.ts b/src/main.ts index 45bc304..a3a1ca9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,6 +14,7 @@ import { mount } from "svelte"; import "./app.css"; import App from "./App.svelte"; +import { queueCache } from "$lib/stores/queue-cache"; import { setupI18n, type SupportedLocale } from "$lib/i18n"; import { DesktopStorageAdapter } from "$lib/services/desktop-adapter"; import { installGlobalErrorReporter } from "$lib/utils/error-reporting"; @@ -48,6 +49,20 @@ async function loadInitialData(): Promise<{ settings: Settings | null; locale: " } } +/** + * Load the stashes so the queue mounts with them, keeping the splash up meanwhile. + * + * Without this the splash gave way to an empty queue that filled in seconds later. A + * failure is not fatal: the queue loads for itself on mount and shows its own spinner. + */ +async function primeStashes(): Promise { + try { + queueCache.stashes = await new DesktopStorageAdapter().loadStashes(); + } catch (error) { + log.warn("Could not preload stashes, the queue will load them itself:", error); + } +} + /** * Hides the splash screen with a smooth fade-out animation. * Called after the app is fully mounted and ready. @@ -80,7 +95,7 @@ async function initApp(): Promise { installGlobalErrorReporter(); // Load initial data (settings includes locale preference) - const { settings, locale } = await loadInitialData(); + const [{ settings, locale }] = await Promise.all([loadInitialData(), primeStashes()]); // Store settings on window to avoid duplicate load in App.svelte if (settings) {