CI & Build / Python lint (push) Successful in 2s
CI & Build / TypeScript typecheck (push) Successful in 6s
CI & Build / Python tests (push) Successful in 12s
CI & Build / Build & push image (push) Successful in 44s
Desktop (Tauri) / Tauri desktop (Linux) (push) Failing after 1m45s
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 2m12s
Trash had no end. A note sat in /trash until someone emptied it by hand, and its attachment BYTES sat on disk the whole time — the pile-up the operator asked about. Nothing purged; there was no scheduler at all. Retention is server-owned: `trash_retention_days` (default 30, 0 = keep forever) in the settings registry, so it lands in admin Settings with no migration and takes effect without a restart. A background sweep started in before_serving does the work. Clients learn about a purge the way they learn about any deletion — as a tombstone on the delta feed. An auto-purge nobody can see coming is data loss on a timer, so the window is now visible: /api/config publishes it, notes carry `deleted_at`, Trash leads with the policy, and each card counts down. The countdown rounds DOWN — saying "1 day left" for a note with ten minutes on the clock is the one error here that actually costs someone a note. Three things this turned up on the way: - `DELETE /api/notes/<id>` hard-deleted the row, leaving no tombstone at all. A permanent delete in the web UI never reached a linked device, which would keep its copy forever and push it back on the next edit. It now purges through the same path as everything else. - The purge left `note_revisions` and `note_link_previews` behind. A revision holds the full body, so the text of a "permanently deleted" note was still sitting in the database. - `deleted_at` now SURVIVES a purge instead of being cleared. It's still true, and it means every query that says "not trashed" excludes tombstones for free — without it a content-less row reads as a perfectly normal active note and shows up on the board as a blank card. Desktop keeps its own clock only when there's nobody else to keep one: the sweep runs at startup on an UNLINKED device and refuses otherwise. A linked client that expired notes on its own schedule could destroy something the server was deliberately keeping, then push that delete upstream. Local policy must never outrank the server's — so it also adopts the server's window for the countdown rather than showing its offline default. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SreJkbxB4gx8pPsu8QbLPi
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
import { defineStore } from "pinia";
|
|
import { ref } from "vue";
|
|
import { repo } from "../adapters";
|
|
|
|
export interface PublicConfig {
|
|
site_name: string;
|
|
allow_registration: boolean;
|
|
version: string;
|
|
enable_url_unfurl: boolean;
|
|
// How many days a note survives in Trash before the server purges it. 0 = forever.
|
|
trash_retention_days: number;
|
|
}
|
|
|
|
// Public, unauthenticated app config (site name, whether signups are open).
|
|
export const useConfigStore = defineStore("config", () => {
|
|
const siteName = ref("ThoughtSync");
|
|
const allowRegistration = ref(true);
|
|
const version = ref("");
|
|
const enableUrlUnfurl = ref(true);
|
|
// Mirrors the server default (settings.REGISTRY). Only used if /api/config is
|
|
// unreachable — and 30 is a safer stand-in than 0, since claiming "kept forever"
|
|
// when the server is actually purging is the wrong way to be wrong.
|
|
const trashRetentionDays = ref(30);
|
|
const loaded = ref(false);
|
|
|
|
async function load(): Promise<void> {
|
|
if (loaded.value) return;
|
|
try {
|
|
const cfg = await repo.config.get();
|
|
siteName.value = cfg.site_name;
|
|
allowRegistration.value = cfg.allow_registration;
|
|
version.value = cfg.version;
|
|
enableUrlUnfurl.value = cfg.enable_url_unfurl ?? true;
|
|
trashRetentionDays.value = cfg.trash_retention_days ?? 30;
|
|
} catch {
|
|
// Keep defaults if the config endpoint is unreachable.
|
|
} finally {
|
|
loaded.value = true;
|
|
}
|
|
}
|
|
|
|
async function reload(): Promise<void> {
|
|
loaded.value = false;
|
|
await load();
|
|
}
|
|
|
|
return { siteName, allowRegistration, version, enableUrlUnfurl, trashRetentionDays, loaded, load, reload };
|
|
});
|