Add completion, browser integration, and workspace improvements

This commit is contained in:
Knotty Wyvern
2026-10-07 11:25:17 -07:00
parent dd9fc64676
commit a8b1defb9d
86 changed files with 3524 additions and 203 deletions
+35
View File
@@ -0,0 +1,35 @@
<script lang="ts">
import { onMount } from "svelte";
import { isTauri } from "@tauri-apps/api/core";
import { getCurrentWindow } from "@tauri-apps/api/window";
import SettingsDialog from "./SettingsDialog.svelte";
import { DEFAULT_SETTINGS, SETTINGS_KEY, parseSettings, saveSettings, type AppSettings } from "$lib/workspace/settings";
let settings = $state<AppSettings>({ ...DEFAULT_SETTINGS });
let error = $state("");
function read() {
try { settings = parseSettings(localStorage.getItem(SETTINGS_KEY)); }
catch { error = "Could not read your settings. Default settings apply until you save new settings."; }
}
onMount(() => {
read();
const sync = (event: StorageEvent) => {
if (event.storageArea === localStorage && (event.key === SETTINGS_KEY || event.key === null)) read();
};
window.addEventListener("storage", sync);
window.addEventListener("focus", read);
return () => { window.removeEventListener("storage", sync); window.removeEventListener("focus", read); };
});
function save(next: AppSettings) {
saveSettings(localStorage, next);
settings = { ...next };
error = "";
}
async function close() {
if (!isTauri()) { window.location.assign("/"); return; }
try { await getCurrentWindow().close(); }
catch (reason) { error = `Could not close settings: ${String(reason)}`; }
}
</script>
<SettingsDialog {settings} standalone windowError={error} onSave={save} onClose={() => void close()} />