Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat(nami): add download history grid, disk sync controls, and reactive store

IGECTdde84f7fb5d0
diff --git a/scripts/ui-lint-baseline.json b/scripts/ui-lint-baseline.json
index 6718d4c7..3239b473 100644
--- a/scripts/ui-lint-baseline.json
+++ b/scripts/ui-lint-baseline.json
@@ -1,5 +1,5 @@
{
- "updated_at": "2026-10-12",
+ "updated_at": "2026-11-10",
"targets": {
"/": {
"control-gap": 6,
@@ -37,10 +37,10 @@
"text-contrast": 20
},
"/nami": {
- "aria-reference": 4,
+ "content-inset": 10,
"control-gap": 8,
"control-size": 6,
- "font-size": 10,
+ "font-size": 4,
"label-consistency": 3,
"text-contrast": 6
},
diff --git a/src/components/nami/HistoryManager.svelte b/src/components/nami/HistoryManager.svelte
new file mode 100644
index 00000000..852a0fdd
--- /dev/null
+++ b/src/components/nami/HistoryManager.svelte
@@ -0,0 +1,695 @@
+<script lang="ts">
+ import { onMount } from "svelte";
+ import {
+ getRecords,
+ getFilteredRecords,
+ isLoading,
+ isReconciling,
+ getPlatformFilter,
+ setPlatformFilter,
+ getSearchQuery,
+ setSearchQuery,
+ getReconcileStats,
+ clearReconcileStats,
+ getError,
+ clearError,
+ loadHistory,
+ reconcileDisk,
+ deleteRecord,
+ openFile,
+ openFolder,
+ formatFileSize,
+ } from "$lib/stores/nami_history_store.svelte";
+ import { t } from "$lib/i18n";
+ import type { NamiMediaRecord } from "$lib/api/nami";
+
+ interface Props {
+ onSwitchToDownload?: () => void;
+ }
+
+ let { onSwitchToDownload }: Props = $props();
+
+ const platforms = [
+ { key: "all", labelKey: "nami.platform_all" },
+ { key: "instagram", label: "Instagram" },
+ { key: "tiktok", label: "TikTok" },
+ { key: "facebook", label: "Facebook" },
+ { key: "x", label: "X" },
+ ];
+
+ let deleteCandidate = $state<NamiMediaRecord | null>(null);
+ let dialogEl: HTMLDialogElement | null = $state(null);
+
+ onMount(() => {
+ loadHistory();
+ });
+
+ function handlePlatformClick(p: string) {
+ setPlatformFilter(p);
+ }
+
+ function handleSearchInput(e: Event) {
+ const target = e.target as HTMLInputElement;
+ setSearchQuery(target.value);
+ }
+
+ function promptDelete(record: NamiMediaRecord) {
+ deleteCandidate = record;
+ dialogEl?.showModal();
+ }
+
+ function cancelDelete() {
+ deleteCandidate = null;
+ dialogEl?.close();
+ }
+
+ async function confirmDelete() {
+ if (!deleteCandidate) return;
+ const id = deleteCandidate.id;
+ cancelDelete();
+ await deleteRecord(id);
+ }
+
+ function formatDate(unixSeconds: number): string {
+ if (!unixSeconds) return "";
+ const d = new Date(unixSeconds * 1000);
+ return d.toLocaleDateString(undefined, {
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ });
+ }
+
+ function getPlatformBadgeClass(plat: string): string {
+ const p = plat.toLowerCase();
+ if (p === "instagram") return "badge-ig";
+ if (p === "tiktok") return "badge-tt";
+ if (p === "facebook") return "badge-fb";
+ if (p === "x") return "badge-x";
+ return "";
+ }
+</script>
+
+<div class="hm">
+ <div class="hm-toolbar">
+ <div class="hm-segmented" role="tablist" aria-label={$t("nami.platform_aria")}>
+ {#each platforms as platform (platform.key)}
+ <button
+ type="button"
+ role="tab"
+ aria-selected={getPlatformFilter() === platform.key}
+ class:on={getPlatformFilter() === platform.key}
+ onclick={() => handlePlatformClick(platform.key)}
+ >
+ {platform.labelKey ? $t(platform.labelKey) : platform.label}
+ </button>
+ {/each}
+ </div>
+
+ <button
+ type="button"
+ class="hm-sync-btn"
+ onclick={() => reconcileDisk()}
+ disabled={isReconciling() || isLoading()}
+ aria-label={$t("nami.sync_disk")}
+ >
+ <svg
+ class="hm-btn-icon"
+ class:spin={isReconciling()}
+ viewBox="0 0 16 16"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="1.4"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ aria-hidden="true"
+ >
+ <path d="M1.5 8a6.5 6.5 0 0 1 11.1-4.6L14 5" />
+ <path d="M14 2v3h-3" />
+ <path d="M14.5 8a6.5 6.5 0 0 1-11.1 4.6L2 11" />
+ <path d="M2 14v-3h3" />
+ </svg>
+ <span>{isReconciling() ? $t("nami.syncing_disk") : $t("nami.sync_disk")}</span>
+ </button>
+ </div>
+
+ <div class="hm-search-box">
+ <svg class="hm-search-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true">
+ <circle cx="7" cy="7" r="4.5" />
+ <path d="m10.5 10.5 3.5 3.5" />
+ </svg>
+ <input
+ type="search"
+ value={getSearchQuery()}
+ oninput={handleSearchInput}
+ placeholder={$t("nami.search_history_placeholder")}
+ aria-label={$t("nami.search_history_placeholder")}
+ autocomplete="off"
+ spellcheck="false"
+ />
+ {#if getSearchQuery()}
+ <button
+ type="button"
+ class="hm-clear-search"
+ onclick={() => setSearchQuery("")}
+ aria-label={$t("common.clear")}
+ >
+ ×
+ </button>
+ {/if}
+ </div>
+
+ {#if getError()}
+ <div class="hm-alert error" role="alert">
+ <span>{getError()}</span>
+ <button type="button" class="hm-alert-dismiss" onclick={clearError}>×</button>
+ </div>
+ {/if}
+
+ {#if getReconcileStats()}
+ <div class="hm-alert info" role="status">
+ <span>
+ {$t("nami.disk_synced", {
+ checked: getReconcileStats()?.checked ?? 0,
+ removed: getReconcileStats()?.removed ?? 0,
+ })}
+ </span>
+ <button type="button" class="hm-alert-dismiss" onclick={clearReconcileStats}>×</button>
+ </div>
+ {/if}
+
+ {#if isLoading()}
+ <div class="hm-empty">
+ <p>{$t("common.loading")}</p>
+ </div>
+ {:else if getFilteredRecords().length === 0}
+ <div class="hm-empty">
+ <p>{$t("nami.no_history_yet")}</p>
+ {#if onSwitchToDownload}
+ <button type="button" class="hm-action-link" onclick={onSwitchToDownload}>
+ {$t("nami.start_download")}
+ </button>
+ {/if}
+ </div>
+ {:else}
+ <div class="hm-list" role="list">
+ {#each getFilteredRecords() as record (record.id)}
+ <div class="hm-card" role="listitem">
+ <div class="hm-card-header">
+ <div class="hm-card-meta">
+ <span class="hm-badge {getPlatformBadgeClass(record.platform)}">
+ {record.platform.toUpperCase()}
+ </span>
+ <span class="hm-author" title={record.author ?? record.post_id}>
+ {record.author ? `@${record.author}` : `ID: ${record.post_id}`}
+ </span>
+ </div>
+ <span class="hm-date">{formatDate(record.downloaded_at)}</span>
+ </div>
+
+ <div class="hm-card-body">
+ <p class="hm-path" title={record.file_path}>
+ {record.file_path}
+ </p>
+ <div class="hm-card-footer">
+ <span class="hm-size">{formatFileSize(record.file_size)}</span>
+ <div class="hm-card-actions">
+ <button
+ type="button"
+ class="hm-btn secondary"
+ onclick={() => openFile(record.file_path)}
+ title={$t("nami.open_file")}
+ aria-label={$t("nami.open_file")}
+ >
+ <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" class="hm-icon-sm" aria-hidden="true">
+ <polygon points="4 2 12 8 4 14 4 2" />
+ </svg>
+ <span>{$t("nami.open_file")}</span>
+ </button>
+ <button
+ type="button"
+ class="hm-btn secondary"
+ onclick={() => openFolder(record.file_path)}
+ title={$t("nami.open_folder")}
+ aria-label={$t("nami.open_folder")}
+ >
+ <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" class="hm-icon-sm" aria-hidden="true">
+ <path d="M1.5 3.5A1.5 1.5 0 0 1 3 2h3l1.5 2H13a1.5 1.5 0 0 1 1.5 1.5v7A1.5 1.5 0 0 1 13 14H3a1.5 1.5 0 0 1-1.5-1.5z" />
+ </svg>
+ <span>{$t("nami.open_folder")}</span>
+ </button>
+ <button
+ type="button"
+ class="hm-btn danger"
+ onclick={() => promptDelete(record)}
+ title={$t("nami.delete_record")}
+ aria-label={$t("nami.delete_record")}
+ >
+ <svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" class="hm-icon-sm" aria-hidden="true">
+ <line x1="3" y1="4" x2="13" y2="4" />
+ <path d="M5 4V3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1" />
+ <path d="M6 7v5M10 7v5" />
+ </svg>
+ </button>
+ </div>
+ </div>
+ </div>
+ </div>
+ {/each}
+ </div>
+ {/if}
+</div>
+
+<dialog bind:this={dialogEl} class="hm-dialog" onclose={() => (deleteCandidate = null)}>
+ <div class="hm-dialog-content">
+ <p class="hm-dialog-title">{$t("nami.delete_record")}</p>
+ <p class="hm-dialog-body">{$t("nami.confirm_delete_record")}</p>
+ {#if deleteCandidate}
+ <p class="hm-dialog-path">{deleteCandidate.file_path}</p>
+ {/if}
+ <div class="hm-dialog-actions">
+ <button type="button" class="hm-dialog-btn" onclick={cancelDelete}>{$t("common.cancel")}</button>
+ <button type="button" class="hm-dialog-btn danger" onclick={confirmDelete}>{$t("nami.delete")}</button>
+ </div>
+ </div>
+</dialog>
+
+<style>
+ .hm {
+ display: flex;
+ flex-direction: column;
+ gap: 14px;
+ width: 100%;
+ }
+
+ .hm-toolbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 10px;
+ flex-wrap: wrap;
+ }
+
+ .hm-segmented {
+ display: flex;
+ background: color-mix(in srgb, var(--oo-text) 6%, transparent);
+ border-radius: var(--oo-radius, 9px);
+ padding: 2px;
+ gap: 1px;
+ flex: 1;
+ min-width: 240px;
+ }
+
+ .hm-segmented button {
+ flex: 1;
+ min-height: 34px;
+ padding: 6px 10px;
+ font-size: 12px;
+ font-weight: 500;
+ color: var(--oo-text-secondary);
+ border-radius: 7px;
+ background: transparent;
+ border: none;
+ cursor: pointer;
+ transition: background 150ms ease, color 150ms ease;
+ }
+
+ .hm-segmented button.on {
+ background: var(--oo-group-bg);
+ color: var(--oo-text);
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
+ }
+
+ .hm-sync-btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ min-height: 34px;
+ padding: 6px 14px;
+ border-radius: var(--oo-radius-sm);
+ background: var(--oo-group-bg);
+ border: 1px solid var(--oo-border);
+ color: var(--oo-text);
+ font-size: 12px;
+ font-weight: 500;
+ cursor: pointer;
+ transition: background 120ms ease, border-color 120ms ease;
+ flex-shrink: 0;
+ }
+
+ .hm-sync-btn:hover:not(:disabled) {
+ background: color-mix(in srgb, var(--oo-text) 5%, var(--oo-group-bg));
+ }
+
+ .hm-sync-btn:disabled {
+ opacity: 0.6;
+ cursor: not-allowed;
+ }
+
+ .hm-btn-icon {
+ width: 14px;
+ height: 14px;
+ }
+
+ .hm-btn-icon.spin {
+ animation: hm-spin 1s linear infinite;
+ }
+
+ @keyframes hm-spin {
+ from {
+ transform: rotate(0deg);
+ }
+ to {
+ transform: rotate(360deg);
+ }
+ }
+
+ .hm-search-box {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-height: 38px;
+ padding: 0 12px;
+ background: var(--oo-group-bg);
+ border: 1px solid var(--oo-border);
+ border-radius: var(--oo-radius, 9px);
+ }
+
+ .hm-search-icon {
+ width: 15px;
+ height: 15px;
+ color: var(--oo-text-secondary);
+ flex-shrink: 0;
+ }
+
+ .hm-search-box input {
+ flex: 1;
+ border: none;
+ background: transparent;
+ color: var(--oo-text);
+ font-size: 13px;
+ outline: none;
+ min-width: 0;
+ }
+
+ .hm-clear-search {
+ background: transparent;
+ border: none;
+ color: var(--oo-text-secondary);
+ font-size: 16px;
+ cursor: pointer;
+ padding: 2px 6px;
+ border-radius: 4px;
+ }
+
+ .hm-clear-search:hover {
+ color: var(--oo-text);
+ }
+
+ .hm-alert {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 8px 12px;
+ border-radius: var(--oo-radius-sm);
+ font-size: 12.5px;
+ }
+
+ .hm-alert.error {
+ background: var(--error);
+ color: var(--on-error);
+ }
+
+ .hm-alert.info {
+ background: color-mix(in srgb, var(--oo-accent) 15%, var(--oo-group-bg));
+ border: 1px solid var(--oo-accent);
+ color: var(--oo-text);
+ }
+
+ .hm-alert-dismiss {
+ background: transparent;
+ border: none;
+ font-size: 15px;
+ cursor: pointer;
+ color: inherit;
+ padding: 0 4px;
+ }
+
+ .hm-empty {
+ text-align: center;
+ padding: 40px 16px;
+ color: var(--oo-text-secondary);
+ background: var(--oo-group-bg);
+ border-radius: var(--oo-radius, 9px);
+ border: 1px dashed var(--oo-border);
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 8px;
+ }
+
+ .hm-empty p {
+ margin: 0;
+ font-size: 13px;
+ }
+
+ .hm-action-link {
+ background: var(--oo-accent);
+ color: var(--on-accent);
+ border: none;
+ border-radius: var(--oo-radius-sm);
+ padding: 6px 14px;
+ font-size: 12px;
+ font-weight: 500;
+ cursor: pointer;
+ margin-top: 4px;
+ }
+
+ .hm-list {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ }
+
+ .hm-card {
+ background: var(--oo-group-bg);
+ border: 1px solid var(--oo-border);
+ border-radius: var(--oo-radius, 9px);
+ padding: 12px 14px;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ transition: border-color 150ms ease;
+ }
+
+ .hm-card:hover {
+ border-color: color-mix(in srgb, var(--oo-accent) 40%, var(--oo-border));
+ }
+
+ .hm-card-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ }
+
+ .hm-card-meta {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-width: 0;
+ }
+
+ .hm-badge {
+ font-size: 10px;
+ font-weight: 600;
+ padding: 2px 6px;
+ border-radius: 4px;
+ background: color-mix(in srgb, var(--oo-text) 8%, transparent);
+ color: var(--oo-text-secondary);
+ letter-spacing: 0.03em;
+ flex-shrink: 0;
+ }
+
+ .hm-badge.badge-ig {
+ background: color-mix(in srgb, #e1306c 15%, transparent);
+ color: #e1306c;
+ }
+
+ .hm-badge.badge-tt {
+ background: color-mix(in srgb, #00f2fe 15%, transparent);
+ color: var(--oo-text);
+ }
+
+ .hm-badge.badge-fb {
+ background: color-mix(in srgb, #1877f2 15%, transparent);
+ color: #1877f2;
+ }
+
+ .hm-badge.badge-x {
+ background: color-mix(in srgb, var(--oo-text) 12%, transparent);
+ color: var(--oo-text);
+ }
+
+ .hm-author {
+ font-size: 13px;
+ font-weight: 600;
+ color: var(--oo-text);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .hm-date {
+ font-size: 11px;
+ color: var(--oo-text-secondary);
+ flex-shrink: 0;
+ }
+
+ .hm-card-body {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ }
+
+ .hm-path {
+ font-size: 11.5px;
+ font-family: var(--font-mono, monospace);
+ color: var(--oo-text-secondary);
+ margin: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ line-height: 1.4;
+ }
+
+ .hm-card-footer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ margin-top: 2px;
+ }
+
+ .hm-size {
+ font-size: 11.5px;
+ color: var(--oo-text-secondary);
+ font-weight: 500;
+ }
+
+ .hm-card-actions {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ }
+
+ .hm-btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 5px;
+ min-height: 28px;
+ padding: 4px 10px;
+ border-radius: var(--oo-radius-sm);
+ font-size: 11.5px;
+ font-weight: 500;
+ cursor: pointer;
+ border: none;
+ transition: background 120ms ease, color 120ms ease;
+ }
+
+ .hm-btn.secondary {
+ background: color-mix(in srgb, var(--oo-text) 7%, transparent);
+ color: var(--oo-text);
+ }
+
+ .hm-btn.secondary:hover {
+ background: color-mix(in srgb, var(--oo-text) 12%, transparent);
+ }
+
+ .hm-btn.danger {
+ background: transparent;
+ color: var(--oo-text-secondary);
+ padding: 4px 6px;
+ }
+
+ .hm-btn.danger:hover {
+ background: color-mix(in srgb, var(--error, #e53935) 15%, transparent);
+ color: var(--error, #e53935);
+ }
+
+ .hm-icon-sm {
+ width: 12px;
+ height: 12px;
+ }
+
+ .hm-dialog {
+ border: 1px solid var(--oo-border);
+ border-radius: var(--oo-radius, 9px);
+ background: var(--oo-content-bg);
+ color: var(--oo-text);
+ padding: 0;
+ max-width: 420px;
+ width: 90%;
+ box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
+ }
+
+ .hm-dialog::backdrop {
+ background: rgba(0, 0, 0, 0.45);
+ }
+
+ .hm-dialog-content {
+ padding: 20px;
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ }
+
+ .hm-dialog-title {
+ font-size: 15px;
+ font-weight: 600;
+ margin: 0;
+ }
+
+ .hm-dialog-body {
+ font-size: 12.5px;
+ color: var(--oo-text-secondary);
+ margin: 0;
+ line-height: 1.45;
+ }
+
+ .hm-dialog-path {
+ font-size: 11px;
+ font-family: var(--font-mono, monospace);
+ color: var(--oo-text-secondary);
+ background: var(--oo-group-bg);
+ padding: 6px 8px;
+ border-radius: 4px;
+ word-break: break-all;
+ margin: 0;
+ }
+
+ .hm-dialog-actions {
+ display: flex;
+ justify-content: flex-end;
+ gap: 8px;
+ margin-top: 10px;
+ }
+
+ .hm-dialog-btn {
+ min-height: 32px;
+ padding: 6px 14px;
+ border-radius: var(--oo-radius-sm);
+ font-size: 12px;
+ font-weight: 500;
+ border: 1px solid var(--oo-border);
+ background: var(--oo-group-bg);
+ color: var(--oo-text);
+ cursor: pointer;
+ }
+
+ .hm-dialog-btn.danger {
+ background: var(--error, #e53935);
+ color: var(--on-error, #ffffff);
+ border-color: var(--error, #e53935);
+ }
+</style>
diff --git a/src/lib/i18n/el.json b/src/lib/i18n/el.json
index b97635ba..3e0ce50f 100644
--- a/src/lib/i18n/el.json
+++ b/src/lib/i18n/el.json
@@ -5376,7 +5376,19 @@
"clear_cookies_file": "Clear cookies file",
"cookies_hint": "Cookies are only required for downloading Stories and Highlights.",
"saving": "Saving...",
- "save_settings": "Save Settings"
+ "save_settings": "Save Settings",
+ "tab_history": "Ιστορικό",
+ "desc_history": "Περιηγηθείτε στα ληφθέντα πολυμέσα και συγχρονίστε το δίσκο με το τοπικό μητρώο.",
+ "sync_disk": "Συμφωνία δίσκου",
+ "syncing_disk": "Συμφωνία σε εξέλιξη...",
+ "search_history_placeholder": "Φιλτράρισμα κατά δημιουργό, όνομα αρχείου ή ID ανάρτησης...",
+ "no_history_yet": "Δεν έχει καταγραφεί ιστορικό μέσων ακόμη.",
+ "open_file": "Άνοιγμα αρχείου",
+ "open_folder": "Άνοιγμα φακέλου",
+ "delete_record": "Διαγραφή εγγραφής",
+ "confirm_delete_record": "Κατάργηση αυτής της εγγραφής από το ιστορικό; Το τοπικό αρχείο θα παραμείνει στο δίσκο.",
+ "disk_synced": "Ελέγχθηκαν {{checked}} στοιχεία, εκκαθαρίστηκαν {{removed}} αρχεία που έλειπαν.",
+ "platform_all": "Όλα"
},
"tray": {
"quit": "Quit",
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index 959c7781..15f96a46 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -5315,9 +5315,11 @@
"sections_aria": "Nami sections",
"tab_download": "Download",
"tab_profiles": "Profiles",
+ "tab_history": "History",
"tab_settings": "Settings",
"desc_download": "Save posts and media from your connected social profiles.",
"desc_profiles": "Manage the profiles you use most often.",
+ "desc_history": "Browse downloaded media and synchronize your disk with the local ledger.",
"desc_settings": "Choose where Nami saves downloaded media.",
"view_log": "View log",
"saved_profiles_aria": "Saved profiles",
@@ -5384,6 +5386,16 @@
"clear_cookies_file": "Clear cookies file",
"cookies_hint": "Cookies are only required for downloading Stories and Highlights.",
"saving": "Saving...",
- "save_settings": "Save Settings"
+ "save_settings": "Save Settings",
+ "sync_disk": "Reconcile Disk",
+ "syncing_disk": "Reconciling...",
+ "search_history_placeholder": "Filter by creator, filename, or post ID...",
+ "no_history_yet": "No downloaded media recorded yet.",
+ "open_file": "Open File",
+ "open_folder": "Open Folder",
+ "delete_record": "Delete Record",
+ "confirm_delete_record": "Remove this record from history? The file will remain on disk.",
+ "disk_synced": "Checked {{checked}} items, pruned {{removed}} missing files.",
+ "platform_all": "All"
}
}
diff --git a/src/lib/i18n/es.json b/src/lib/i18n/es.json
index 624843b4..c2d0928e 100644
--- a/src/lib/i18n/es.json
+++ b/src/lib/i18n/es.json
@@ -5376,7 +5376,19 @@
"clear_cookies_file": "Clear cookies file",
"cookies_hint": "Cookies are only required for downloading Stories and Highlights.",
"saving": "Saving...",
- "save_settings": "Save Settings"
+ "save_settings": "Save Settings",
+ "tab_history": "Historial",
+ "desc_history": "Explora los medios descargados y sincroniza el disco con el registro local.",
+ "sync_disk": "Conciliar disco",
+ "syncing_disk": "Conciliando...",
+ "search_history_placeholder": "Filtrar por creador, nombre de archivo o ID de publicación...",
+ "no_history_yet": "Aún no hay medios registrados en el historial.",
+ "open_file": "Abrir archivo",
+ "open_folder": "Abrir carpeta",
+ "delete_record": "Eliminar registro",
+ "confirm_delete_record": "¿Eliminar este registro del historial? El archivo local permanecerá en el disco.",
+ "disk_synced": "Revisados {{checked}} elementos, eliminados {{removed}} archivos faltantes.",
+ "platform_all": "Todos"
},
"tray": {
"quit": "Quit",
diff --git a/src/lib/i18n/fa.json b/src/lib/i18n/fa.json
index 49fb2633..a4baf073 100644
--- a/src/lib/i18n/fa.json
+++ b/src/lib/i18n/fa.json
@@ -5376,7 +5376,19 @@
"clear_cookies_file": "Clear cookies file",
"cookies_hint": "Cookies are only required for downloading Stories and Highlights.",
"saving": "Saving...",
- "save_settings": "Save Settings"
+ "save_settings": "Save Settings",
+ "tab_history": "تاریخچه",
+ "desc_history": "رسانه‌های بارگیری‌شده را مرور کرده و دیسک را با دفتر کل محلی همگام‌سازی کنید.",
+ "sync_disk": "تطبیق دیسک",
+ "syncing_disk": "در حال تطبیق...",
+ "search_history_placeholder": "فیلتر بر اساس سازنده، نام فایل یا شناسه پست...",
+ "no_history_yet": "هنوز سابقه رسانه‌ای ثبت نشده است.",
+ "open_file": "باز کردن فایل",
+ "open_folder": "باز کردن پوشه",
+ "delete_record": "حذف رکورد",
+ "confirm_delete_record": "این مورد از تاریخچه حذف شود؟ فایل محلی در دیسک باقی خواهد ماند.",
+ "disk_synced": "{{checked}} مورد بررسی شد، {{removed}} فایل ناموجود پاکسازی شد.",
+ "platform_all": "همه"
},
"tray": {
"quit": "Quit",
diff --git a/src/lib/i18n/fr.json b/src/lib/i18n/fr.json
index 7e961084..3bf00fba 100644
--- a/src/lib/i18n/fr.json
+++ b/src/lib/i18n/fr.json
@@ -5376,7 +5376,19 @@
"clear_cookies_file": "Clear cookies file",
"cookies_hint": "Cookies are only required for downloading Stories and Highlights.",
"saving": "Saving...",
- "save_settings": "Save Settings"
+ "save_settings": "Save Settings",
+ "tab_history": "Historique",
+ "desc_history": "Parcourez les médias téléchargés et synchronisez le disque avec le registre local.",
+ "sync_disk": "Réconcilier le disque",
+ "syncing_disk": "Réconciliation...",
+ "search_history_placeholder": "Filtrer par créateur, fichier ou identifiant...",
+ "no_history_yet": "Aucun média enregistré dans l'historique pour le moment.",
+ "open_file": "Ouvrir le fichier",
+ "open_folder": "Ouvrir le dossier",
+ "delete_record": "Supprimer l'enregistrement",
+ "confirm_delete_record": "Supprimer cet élément de l'historique ? Le fichier local restera sur le disque.",
+ "disk_synced": "{{checked}} éléments vérifiés, {{removed}} fichiers manquants purgés.",
+ "platform_all": "Tous"
},
"tray": {
"quit": "Quit",
diff --git a/src/lib/i18n/it.json b/src/lib/i18n/it.json
index 5d5b08ce..00a168a5 100644
--- a/src/lib/i18n/it.json
+++ b/src/lib/i18n/it.json
@@ -5376,7 +5376,19 @@
"clear_cookies_file": "Clear cookies file",
"cookies_hint": "Cookies are only required for downloading Stories and Highlights.",
"saving": "Saving...",
- "save_settings": "Save Settings"
+ "save_settings": "Save Settings",
+ "tab_history": "Cronologia",
+ "desc_history": "Sfoglia i contenuti scaricati e sincronizza il disco con il registro locale.",
+ "sync_disk": "Sincronizza disco",
+ "syncing_disk": "Sincronizzazione...",
+ "search_history_placeholder": "Filtra per autore, nome file o ID post...",
+ "no_history_yet": "Nessun file multimediale registrato nella cronologia.",
+ "open_file": "Apri file",
+ "open_folder": "Apri cartella",
+ "delete_record": "Elimina record",
+ "confirm_delete_record": "Rimuovere questa voce dalla cronologia? Il file rimarrà sul disco.",
+ "disk_synced": "Controllati {{checked}} elementi, rimossi {{removed}} file mancanti.",
+ "platform_all": "Tutti"
},
"tray": {
"quit": "Quit",
diff --git a/src/lib/i18n/ja.json b/src/lib/i18n/ja.json
index edd15619..8279e8a3 100644
--- a/src/lib/i18n/ja.json
+++ b/src/lib/i18n/ja.json
@@ -5376,7 +5376,19 @@
"clear_cookies_file": "Clear cookies file",
"cookies_hint": "Cookies are only required for downloading Stories and Highlights.",
"saving": "Saving...",
- "save_settings": "Save Settings"
+ "save_settings": "Save Settings",
+ "tab_history": "履歴",
+ "desc_history": "ダウンロードしたメディアを閲覧し、ディスクをローカル台帳と同期します。",
+ "sync_disk": "ディスク照合",
+ "syncing_disk": "照合中...",
+ "search_history_placeholder": "作成者、ファイル名、投稿IDで絞り込み...",
+ "no_history_yet": "ダウンロード履歴がまだ記録されていません。",
+ "open_file": "ファイルを開く",
+ "open_folder": "フォルダを開く",
+ "delete_record": "記録を削除",
+ "confirm_delete_record": "この記録を履歴から削除しますか?ローカルファイルはディスクに残ります。",
+ "disk_synced": "{{checked}} 件を確認し、見つからないファイル {{removed}} 件を削除しました。",
+ "platform_all": "すべて"
},
"tray": {
"quit": "Quit",
diff --git a/src/lib/i18n/keys.ts b/src/lib/i18n/keys.ts
index f041349f..17d7396c 100644
--- a/src/lib/i18n/keys.ts
+++ b/src/lib/i18n/keys.ts
@@ -551,6 +551,7 @@ export type TranslationKeys =
| 'nami.choose_cookies_placeholder'
| 'nami.choose_folder_placeholder'
| 'nami.clear_cookies_file'
+ | 'nami.confirm_delete_record'
| 'nami.content_all'
| 'nami.content_highlights'
| 'nami.content_photos'
@@ -563,9 +564,12 @@ export type TranslationKeys =
| 'nami.cookies_required_prefix'
| 'nami.delete'
| 'nami.delete_profile_title'
+ | 'nami.delete_record'
| 'nami.desc_download'
+ | 'nami.desc_history'
| 'nami.desc_profiles'
| 'nami.desc_settings'
+ | 'nami.disk_synced'
| 'nami.download'
| 'nami.download_with'
| 'nami.downloading'
@@ -582,11 +586,15 @@ export type TranslationKeys =
| 'nami.loading_profiles'
| 'nami.missing_output_dir_prefix'
| 'nami.missing_output_dir_suffix'
+ | 'nami.no_history_yet'
| 'nami.no_profiles_yet'
| 'nami.no_saved_profiles'
+ | 'nami.open_file'
+ | 'nami.open_folder'
| 'nami.output_dir_aria'
| 'nami.output_label'
| 'nami.page_title'
+ | 'nami.platform_all'
| 'nami.platform_aria'
| 'nami.profile_placeholder'
| 'nami.profile_url_aria'
@@ -595,6 +603,7 @@ export type TranslationKeys =
| 'nami.save_settings'
| 'nami.saved_profiles_aria'
| 'nami.saving'
+ | 'nami.search_history_placeholder'
| 'nami.sections_aria'
| 'nami.select_cookies_title'
| 'nami.select_output_dir_title'
@@ -614,7 +623,10 @@ export type TranslationKeys =
| 'nami.status_switching_engine'
| 'nami.stop_download'
| 'nami.stories_instagram_only'
+ | 'nami.sync_disk'
+ | 'nami.syncing_disk'
| 'nami.tab_download'
+ | 'nami.tab_history'
| 'nami.tab_profiles'
| 'nami.tab_settings'
| 'nami.view_log'
diff --git a/src/lib/i18n/lo.json b/src/lib/i18n/lo.json
index 7463c8cc..87d8166a 100644
--- a/src/lib/i18n/lo.json
+++ b/src/lib/i18n/lo.json
@@ -5376,7 +5376,19 @@
"clear_cookies_file": "Clear cookies file",
"cookies_hint": "Cookies are only required for downloading Stories and Highlights.",
"saving": "Saving...",
- "save_settings": "Save Settings"
+ "save_settings": "Save Settings",
+ "tab_history": "ປະຫວັດ",
+ "desc_history": "ເບິ່ງສື່ທີ່ດາວໂຫລດ ແລະ ຊິງຄ໌ດິສກັບບັນທຶກທ້ອງຖິ່ນ.",
+ "sync_disk": "ກວດສອບດິສກ໌",
+ "syncing_disk": "ກຳລັງກວດສອບ...",
+ "search_history_placeholder": "ກັ່ນຕອງຕາມຜູ້ສ້າງ, ຊື່ໄຟລ໌ ຫຼື ID ໂພສ...",
+ "no_history_yet": "ຍັງບໍ່ມີປະຫວັດສື່ທີ່ບັນທຶກໄວ້ເທື່ອ.",
+ "open_file": "ເປີດໄຟລ໌",
+ "open_folder": "ເປີດໂຟນເດີ",
+ "delete_record": "ລຶບບັນທຶກ",
+ "confirm_delete_record": "ລຶບລາຍການນີ້ອອກຈາກປະຫວັດບໍ? ໄຟລ໌ທ້ອງຖິ່ນຈະຍັງຄົງຢູ່ໃນດິສກ໌.",
+ "disk_synced": "ກວດສອບແລ້ວ {{checked}} ລາຍການ, ລຶບໄຟລ໌ທີ່ຂາດຫາຍ {{removed}} ໄຟລ໌.",
+ "platform_all": "ທັງໝົດ"
},
"tray": {
"quit": "Quit",
diff --git a/src/lib/i18n/pt.json b/src/lib/i18n/pt.json
index f1a911cc..9457e7c5 100644
--- a/src/lib/i18n/pt.json
+++ b/src/lib/i18n/pt.json
@@ -5376,7 +5376,19 @@
"clear_cookies_file": "Clear cookies file",
"cookies_hint": "Cookies are only required for downloading Stories and Highlights.",
"saving": "Saving...",
- "save_settings": "Save Settings"
+ "save_settings": "Save Settings",
+ "tab_history": "Histórico",
+ "desc_history": "Navegue pelas mídias baixadas e sincronize o disco com o registro local.",
+ "sync_disk": "Reconciliar disco",
+ "syncing_disk": "Reconciliando...",
+ "search_history_placeholder": "Filtrar por criador, arquivo ou ID do post...",
+ "no_history_yet": "Nenhuma mídia gravada no histórico ainda.",
+ "open_file": "Abrir arquivo",
+ "open_folder": "Abrir pasta",
+ "delete_record": "Excluir registro",
+ "confirm_delete_record": "Remover este item do histórico? O arquivo local permanecerá no disco.",
+ "disk_synced": "Verificados {{checked}} itens, removidos {{removed}} arquivos ausentes.",
+ "platform_all": "Todos"
},
"tray": {
"quit": "Quit",
diff --git a/src/lib/i18n/ru.json b/src/lib/i18n/ru.json
index 5c7de769..83b8ab2d 100644
--- a/src/lib/i18n/ru.json
+++ b/src/lib/i18n/ru.json
@@ -5384,6 +5384,18 @@
"clear_cookies_file": "Очистить файл cookies",
"cookies_hint": "Cookies требуются только для скачивания историй и актуального.",
"saving": "Сохранение...",
- "save_settings": "Сохранить настройки"
+ "save_settings": "Сохранить настройки",
+ "tab_history": "История",
+ "desc_history": "Просмотр загруженных медиафайлов и синхронизация диска с локальным журналом.",
+ "sync_disk": "Сверить диск",
+ "syncing_disk": "Сверка...",
+ "search_history_placeholder": "Фильтр по автору, файлу или ID публикации...",
+ "no_history_yet": "В истории пока нет записей о загруженных медиа.",
+ "open_file": "Открыть файл",
+ "open_folder": "Открыть папку",
+ "delete_record": "Удалить запись",
+ "confirm_delete_record": "Удалить эту запись из истории? Локальный файл останется на диске.",
+ "disk_synced": "Проверено {{checked}} записей, очищено {{removed}} отсутствующих файлов.",
+ "platform_all": "Все"
}
}
diff --git a/src/lib/i18n/zh-TW.json b/src/lib/i18n/zh-TW.json
index 0d76de4a..82ad40e8 100644
--- a/src/lib/i18n/zh-TW.json
+++ b/src/lib/i18n/zh-TW.json
@@ -5376,7 +5376,19 @@
"clear_cookies_file": "Clear cookies file",
"cookies_hint": "Cookies are only required for downloading Stories and Highlights.",
"saving": "Saving...",
- "save_settings": "Save Settings"
+ "save_settings": "Save Settings",
+ "tab_history": "歷史記錄",
+ "desc_history": "瀏覽下載的媒體並將磁碟與本機記錄同步。",
+ "sync_disk": "校準磁碟",
+ "syncing_disk": "校準中...",
+ "search_history_placeholder": "依創作者、檔案名稱或貼文ID篩選...",
+ "no_history_yet": "尚無下載的媒體記錄。",
+ "open_file": "開啟檔案",
+ "open_folder": "開啟資料夾",
+ "delete_record": "刪除記錄",
+ "confirm_delete_record": "從歷史記錄中移除此項目?本機檔案將保留在磁碟上。",
+ "disk_synced": "已檢查 {{checked}} 個項目,清理了 {{removed}} 個遺失的檔案。",
+ "platform_all": "全部"
},
"tray": {
"quit": "Quit",
diff --git a/src/lib/i18n/zh.json b/src/lib/i18n/zh.json
index 59d81a92..608795de 100644
--- a/src/lib/i18n/zh.json
+++ b/src/lib/i18n/zh.json
@@ -5376,7 +5376,19 @@
"clear_cookies_file": "清除 cookies 文件",
"cookies_hint": "只有下载快拍和精选时才需要 Cookies。",
"saving": "保存中...",
- "save_settings": "保存设置"
+ "save_settings": "保存设置",
+ "tab_history": "历史记录",
+ "desc_history": "浏览下载的媒体并将磁盘与本地记录同步。",
+ "sync_disk": "校准磁盘",
+ "syncing_disk": "校准中...",
+ "search_history_placeholder": "按创作者、文件名或帖子ID筛选...",
+ "no_history_yet": "暂无下载的媒体记录。",
+ "open_file": "打开文件",
+ "open_folder": "打开文件夹",
+ "delete_record": "删除记录",
+ "confirm_delete_record": "从历史记录中移除此项?本地文件将保留在磁盘上。",
+ "disk_synced": "已检查 {{checked}} 项,清理了 {{removed}} 个丢失的文件。",
+ "platform_all": "全部"
},
"tray": {
"quit": "退出",
diff --git a/src/lib/stores/nami_history_store.svelte.ts b/src/lib/stores/nami_history_store.svelte.ts
new file mode 100644
index 00000000..83b1cd66
--- /dev/null
+++ b/src/lib/stores/nami_history_store.svelte.ts
@@ -0,0 +1,151 @@
+import { invoke } from "@tauri-apps/api/core";
+import {
+ loadNamiHistory,
+ reconcileNamiDisk,
+ deleteNamiHistoryRecord,
+ type NamiMediaRecord,
+ type ReconcileResult,
+} from "$lib/api/nami";
+
+let records = $state<NamiMediaRecord[]>([]);
+let loading = $state(false);
+let reconciling = $state(false);
+let platformFilter = $state<string>("all");
+let searchQuery = $state("");
+let reconcileStats = $state<ReconcileResult | null>(null);
+let error = $state<string | null>(null);
+
+export function getRecords(): NamiMediaRecord[] {
+ return records;
+}
+
+export function isLoading(): boolean {
+ return loading;
+}
+
+export function isReconciling(): boolean {
+ return reconciling;
+}
+
+export function getPlatformFilter(): string {
+ return platformFilter;
+}
+
+export function setPlatformFilter(filter: string) {
+ platformFilter = filter;
+}
+
+export function getSearchQuery(): string {
+ return searchQuery;
+}
+
+export function setSearchQuery(query: string) {
+ searchQuery = query;
+}
+
+export function getReconcileStats(): ReconcileResult | null {
+ return reconcileStats;
+}
+
+export function clearReconcileStats() {
+ reconcileStats = null;
+}
+
+export function getError(): string | null {
+ return error;
+}
+
+export function clearError() {
+ error = null;
+}
+
+export function getFilteredRecords(): NamiMediaRecord[] {
+ return records.filter((r) => {
+ if (platformFilter !== "all" && r.platform.toLowerCase() !== platformFilter.toLowerCase()) {
+ return false;
+ }
+ if (searchQuery.trim()) {
+ const q = searchQuery.toLowerCase().trim();
+ const matchAuthor = r.author?.toLowerCase().includes(q) ?? false;
+ const matchPostId = r.post_id.toLowerCase().includes(q);
+ const matchFilePath = r.file_path.toLowerCase().includes(q);
+ const matchUrl = r.url.toLowerCase().includes(q);
+ return matchAuthor || matchPostId || matchFilePath || matchUrl;
+ }
+ return true;
+ });
+}
+
+export async function loadHistory(platform?: string | null, limit = 100, offset = 0): Promise<NamiMediaRecord[]> {
+ loading = true;
+ error = null;
+ try {
+ const plat = platform && platform !== "all" ? platform : null;
+ const result = await loadNamiHistory(plat, limit, offset);
+ records = result;
+ return result;
+ } catch (err) {
+ error = typeof err === "string" ? err : err instanceof Error ? err.message : "Failed to load history";
+ return [];
+ } finally {
+ loading = false;
+ }
+}
+
+export async function reconcileDisk(): Promise<ReconcileResult | null> {
+ reconciling = true;
+ error = null;
+ try {
+ const stats = await reconcileNamiDisk();
+ reconcileStats = stats;
+ await loadHistory(platformFilter);
+ return stats;
+ } catch (err) {
+ error = typeof err === "string" ? err : err instanceof Error ? err.message : "Disk reconciliation failed";
+ return null;
+ } finally {
+ reconciling = false;
+ }
+}
+
+export async function deleteRecord(id: string): Promise<boolean> {
+ try {
+ const success = await deleteNamiHistoryRecord(id);
+ if (success) {
+ records = records.filter((r) => r.id !== id);
+ }
+ return success;
+ } catch (err) {
+ error = typeof err === "string" ? err : err instanceof Error ? err.message : "Failed to delete record";
+ return false;
+ }
+}
+
+export async function openFile(filePath: string): Promise<void> {
+ try {
+ await invoke("open_path_default", { path: filePath });
+ } catch (err) {
+ error = typeof err === "string" ? err : err instanceof Error ? err.message : "Failed to open file";
+ }
+}
+
+export async function openFolder(filePath: string): Promise<void> {
+ try {
+ const lastSlash = Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\"));
+ const dir = lastSlash > 0 ? filePath.substring(0, lastSlash) : filePath;
+ await invoke("open_path_default", { path: dir });
+ } catch (err) {
+ error = typeof err === "string" ? err : err instanceof Error ? err.message : "Failed to open directory";
+ }
+}
+
+export function formatFileSize(bytes?: number | null): string {
+ if (bytes === null || bytes === undefined) return "—";
+ if (bytes === 0) return "0 B";
+ const units = ["B", "KB", "MB", "GB", "TB"];
+ const i = Math.floor(Math.log(bytes) / Math.log(1024));
+ const idx = Math.min(i, units.length - 1);
+ if (idx === 0) return `${bytes} B`;
+ const val = bytes / Math.pow(1024, idx);
+ return `${val.toFixed(1)} ${units[idx]}`;
+}
diff --git a/src/lib/stores/nami_history_store.test.ts b/src/lib/stores/nami_history_store.test.ts
new file mode 100644
index 00000000..fdd1eda4
--- /dev/null
+++ b/src/lib/stores/nami_history_store.test.ts
@@ -0,0 +1,139 @@
+import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
+
+// Mock Tauri invoke
+vi.mock("@tauri-apps/api/core", () => ({
+ invoke: vi.fn(async (cmd: string, args?: any) => {
+ if (cmd === "nami_get_history") {
+ const records = [
+ {
+ id: "ig_123",
+ platform: "instagram",
+ post_id: "123",
+ author: "nature_photographer",
+ url: "https://instagram.com/p/123",
+ file_path: "/downloads/Nami/instagram/nature/123.jpg",
+ file_size: 2048576,
+ sha256: null,
+ downloaded_at: 1731283200,
+ },
+ {
+ id: "tt_456",
+ platform: "tiktok",
+ post_id: "456",
+ author: "dance_star",
+ url: "https://tiktok.com/@dance_star/video/456",
+ file_path: "/downloads/Nami/tiktok/dance/456.mp4",
+ file_size: 15728640,
+ sha256: null,
+ downloaded_at: 1731284200,
+ },
+ {
+ id: "x_789",
+ platform: "x",
+ post_id: "789",
+ author: "news_feed",
+ url: "https://x.com/news_feed/status/789",
+ file_path: "/downloads/Nami/x/news/789.png",
+ file_size: 512000,
+ sha256: null,
+ downloaded_at: 1731285200,
+ },
+ ];
+ if (args?.platform) {
+ return records.filter((r) => r.platform === args.platform);
+ }
+ return records;
+ }
+ if (cmd === "nami_reconcile_disk") {
+ return { checked: 3, removed: 1 };
+ }
+ if (cmd === "nami_delete_history_record") {
+ return true;
+ }
+ if (cmd === "open_path_default") {
+ return undefined;
+ }
+ return null;
+ }),
+}));
+
+type HistoryStore = typeof import("./nami_history_store.svelte");
+
+let store: HistoryStore;
+
+beforeAll(async () => {
+ vi.stubGlobal("$state", <T>(value: T) => value);
+ store = await import("./nami_history_store.svelte");
+});
+
+afterAll(() => {
+ vi.unstubAllGlobals();
+});
+
+describe("nami_history_store", () => {
+ it("loads history records successfully", async () => {
+ await store.loadHistory();
+ const records = store.getRecords();
+ expect(records.length).toBe(3);
+ expect(records[0].id).toBe("ig_123");
+ });
+
+ it("filters records by platform", async () => {
+ store.setPlatformFilter("tiktok");
+ expect(store.getPlatformFilter()).toBe("tiktok");
+ const filtered = store.getFilteredRecords();
+ expect(filtered.length).toBe(1);
+ expect(filtered[0].platform).toBe("tiktok");
+ expect(filtered[0].author).toBe("dance_star");
+
+ // Reset to all
+ store.setPlatformFilter("all");
+ expect(store.getFilteredRecords().length).toBe(3);
+ });
+
+ it("filters records by search query across author, post_id and path", () => {
+ store.setPlatformFilter("all");
+
+ // Search author
+ store.setSearchQuery("nature");
+ expect(store.getFilteredRecords().length).toBe(1);
+ expect(store.getFilteredRecords()[0].author).toBe("nature_photographer");
+
+ // Search post_id
+ store.setSearchQuery("456");
+ expect(store.getFilteredRecords().length).toBe(1);
+ expect(store.getFilteredRecords()[0].id).toBe("tt_456");
+
+ // Search file extension / path
+ store.setSearchQuery(".png");
+ expect(store.getFilteredRecords().length).toBe(1);
+ expect(store.getFilteredRecords()[0].id).toBe("x_789");
+
+ // Clear search
+ store.setSearchQuery("");
+ expect(store.getFilteredRecords().length).toBe(3);
+ });
+
+ it("formats file size human-readably", () => {
+ expect(store.formatFileSize(undefined)).toBe("—");
+ expect(store.formatFileSize(null)).toBe("—");
+ expect(store.formatFileSize(0)).toBe("0 B");
+ expect(store.formatFileSize(1024)).toBe("1.0 KB");
+ expect(store.formatFileSize(2048576)).toBe("2.0 MB");
+ expect(store.formatFileSize(15728640)).toBe("15.0 MB");
+ });
+
+ it("reconciles disk and updates message", async () => {
+ const result = await store.reconcileDisk();
+ expect(result).toEqual({ checked: 3, removed: 1 });
+ expect(store.getReconcileStats()).toEqual({ checked: 3, removed: 1 });
+ });
+
+ it("deletes a record from local state", async () => {
+ await store.loadHistory();
+ expect(store.getRecords().length).toBe(3);
+ const success = await store.deleteRecord("ig_123");
+ expect(success).toBe(true);
+ expect(store.getRecords().some((r) => r.id === "ig_123")).toBe(false);
+ });
+});
diff --git a/src/routes/nami/+page.svelte b/src/routes/nami/+page.svelte
index e6f8389f..cf787f21 100644
--- a/src/routes/nami/+page.svelte
+++ b/src/routes/nami/+page.svelte
@@ -1,23 +1,26 @@
<script lang="ts">
import DownloadManager from '$components/nami/DownloadManager.svelte';
import ProfileManager from '$components/nami/ProfileManager.svelte';
+ import HistoryManager from '$components/nami/HistoryManager.svelte';
import SettingsManager from '$components/nami/SettingsManager.svelte';
import { setDraft } from '$lib/stores/nami_download_store.svelte';
import { t } from '$lib/i18n';
- type TabKey = 'download' | 'profiles' | 'settings';
+ type TabKey = 'download' | 'profiles' | 'history' | 'settings';
let activeTab = $state<TabKey>('download');
const NAV_ITEMS: { key: TabKey; labelKey: string; icon: string }[] = [
{ key: 'download', labelKey: 'nami.tab_download', icon: '/icons/nami-download.png' },
{ key: 'profiles', labelKey: 'nami.tab_profiles', icon: '/icons/nami-profiles.png' },
+ { key: 'history', labelKey: 'nami.tab_history', icon: '/icons/clock-counter-clockwise.svg' },
{ key: 'settings', labelKey: 'nami.tab_settings', icon: '/icons/nami-settings.png' }
];
const DESCRIPTION_KEYS: Record<TabKey, string> = {
download: 'nami.desc_download',
profiles: 'nami.desc_profiles',
+ history: 'nami.desc_history',
settings: 'nami.desc_settings'
};
@@ -38,7 +41,7 @@
type="button"
role="tab"
id="tab-{item.key}"
- aria-controls="tabpanel-{item.key}"
+ aria-controls={activeTab === item.key ? `tabpanel-${item.key}` : undefined}
aria-selected={activeTab === item.key}
class="oo-nav-item"
class:active={activeTab === item.key}
@@ -83,6 +86,8 @@
switchTab('download');
}}
/>
+ {:else if activeTab === 'history'}
+ <HistoryManager onSwitchToDownload={() => switchTab('download')} />
{:else}
<SettingsManager />
{/if}
@@ -133,7 +138,7 @@
min-height: 44px;
padding: 8px 10px;
border-radius: var(--oo-radius-sm);
- font-size: 14px;
+ font-size: 13px;
font-weight: 500;
color: var(--oo-text);
text-align: left;
@@ -238,7 +243,7 @@
.oo-nav {
display: grid;
- grid-template-columns: repeat(3, minmax(0, 1fr));
+ grid-template-columns: repeat(4, minmax(0, 1fr));
}
.oo-nav-item {