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(announcements): add in-app announcement and what's new system

IGECT65b32242f3ea
diff --git a/assets/announcements.json b/assets/announcements.json
new file mode 100644
index 00000000..9d8c8993
--- /dev/null
+++ b/assets/announcements.json
@@ -0,0 +1,19 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "id": "announcement-v093-opennami",
+ "active": true,
+ "badge": "Major Update",
+ "title": "Welcome to the Open Nami Engine!",
+ "thumbnail": "https://raw.githubusercontent.com/OpenSelena/openomni/main/assets/logo-light.svg",
+ "body": "OmniGet has been upgraded with the high-performance Open Nami download engine, intelligent dual-engine fallback, and sandboxed cookie storage.",
+ "highlights": [
+ "⚡ 3x Faster Metadata Extraction for YouTube & X",
+ "🔒 Sandboxed Private Cookie Storage",
+ "🔄 Dual-Engine Automatic Fallback"
+ ],
+ "cta": {
+ "label": "Read Release Notes →",
+ "url": "https://github.com/OpenSelena/omniget/releases"
+ },
+ "expires_at": null
+}
diff --git a/src/components/dialog/AnnouncementDialog.svelte b/src/components/dialog/AnnouncementDialog.svelte
new file mode 100644
index 00000000..441c14d8
--- /dev/null
+++ b/src/components/dialog/AnnouncementDialog.svelte
@@ -0,0 +1,290 @@
+<script lang="ts">
+ import DialogContainer from "./DialogContainer.svelte";
+ import {
+ getAnnouncementOpen,
+ getActiveAnnouncement,
+ dismissAnnouncement,
+ } from "$lib/stores/announcement-store.svelte";
+ import { open as openExternal } from "@tauri-apps/plugin-shell";
+
+ let isOpen = $derived(getAnnouncementOpen());
+ let item = $derived(getActiveAnnouncement());
+
+ async function handleCTA() {
+ if (item?.cta?.url) {
+ try {
+ await openExternal(item.cta.url);
+ } catch {
+ window.open(item.cta.url, "_blank");
+ }
+ }
+ dismissAnnouncement(true);
+ }
+
+ function handleDismiss() {
+ dismissAnnouncement(true);
+ }
+</script>
+
+{#if item}
+ <DialogContainer
+ isOpen={isOpen}
+ onClose={handleDismiss}
+ titleId="announcement-modal-title"
+ >
+ <div class="announcement-card">
+ {#if item.thumbnail}
+ <div class="banner-wrapper">
+ <img
+ src={item.thumbnail}
+ alt={item.title}
+ class="banner-img"
+ loading="lazy"
+ />
+ {#if item.badge}
+ <span class="badge-pill">{item.badge}</span>
+ {/if}
+ <button
+ type="button"
+ class="close-btn"
+ aria-label="Close announcement"
+ onclick={handleDismiss}
+ >
+ ✕
+ </button>
+ </div>
+ {:else}
+ <div class="header-no-thumb">
+ {#if item.badge}
+ <span class="badge-pill-inline">{item.badge}</span>
+ {/if}
+ <button
+ type="button"
+ class="close-btn-inline"
+ aria-label="Close announcement"
+ onclick={handleDismiss}
+ >
+ ✕
+ </button>
+ </div>
+ {/if}
+
+ <div class="content-body">
+ <h2 id="announcement-modal-title" class="title">{item.title}</h2>
+ <p class="description">{item.body}</p>
+
+ {#if item.highlights && item.highlights.length > 0}
+ <div class="highlights-box">
+ {#each item.highlights as highlight}
+ <div class="highlight-item">
+ <span class="highlight-bullet">•</span>
+ <span class="highlight-text">{highlight}</span>
+ </div>
+ {/each}
+ </div>
+ {/if}
+
+ <div class="footer-actions">
+ <button
+ type="button"
+ class="btn-dismiss"
+ onclick={handleDismiss}
+ >
+ Dismiss
+ </button>
+
+ {#if item.cta}
+ <button
+ type="button"
+ class="btn-cta"
+ onclick={handleCTA}
+ >
+ {item.cta.label}
+ </button>
+ {/if}
+ </div>
+ </div>
+ </div>
+ </DialogContainer>
+{/if}
+
+<style>
+ .announcement-card {
+ display: flex;
+ flex-direction: column;
+ width: 100%;
+ overflow: hidden;
+ }
+
+ .banner-wrapper {
+ position: relative;
+ width: 100%;
+ height: 180px;
+ background: var(--surface-2, rgba(255, 255, 255, 0.05));
+ overflow: hidden;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .banner-img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+ }
+
+ .badge-pill {
+ position: absolute;
+ top: 12px;
+ left: 12px;
+ background: var(--accent, #6366f1);
+ color: #ffffff;
+ font-size: 11px;
+ font-weight: 600;
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ padding: 3px 10px;
+ border-radius: var(--radius-full, 9999px);
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
+ }
+
+ .close-btn {
+ position: absolute;
+ top: 10px;
+ right: 10px;
+ width: 28px;
+ height: 28px;
+ border-radius: var(--radius-full, 9999px);
+ background: rgba(0, 0, 0, 0.55);
+ border: 1px solid rgba(255, 255, 255, 0.15);
+ color: #ffffff;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 12px;
+ cursor: pointer;
+ transition: background 0.15s ease;
+ }
+
+ .close-btn:hover {
+ background: rgba(0, 0, 0, 0.8);
+ }
+
+ .header-no-thumb {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 16px 20px 0 20px;
+ }
+
+ .badge-pill-inline {
+ background: var(--accent, #6366f1);
+ color: #ffffff;
+ font-size: 11px;
+ font-weight: 600;
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ padding: 3px 10px;
+ border-radius: var(--radius-full, 9999px);
+ }
+
+ .close-btn-inline {
+ background: transparent;
+ border: none;
+ color: var(--text-muted, #94a3b8);
+ font-size: 14px;
+ cursor: pointer;
+ padding: 4px;
+ }
+
+ .close-btn-inline:hover {
+ color: var(--text, #ffffff);
+ }
+
+ .content-body {
+ padding: 18px 22px 20px 22px;
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ }
+
+ .title {
+ margin: 0;
+ font-size: 18px;
+ font-weight: 700;
+ color: var(--text, #ffffff);
+ line-height: 1.3;
+ }
+
+ .description {
+ margin: 0;
+ font-size: 13.5px;
+ line-height: 1.5;
+ color: var(--text-muted, #94a3b8);
+ }
+
+ .highlights-box {
+ background: var(--surface-1, rgba(255, 255, 255, 0.03));
+ border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
+ border-radius: var(--radius-md, 8px);
+ padding: 10px 14px;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ }
+
+ .highlight-item {
+ display: flex;
+ align-items: baseline;
+ gap: 8px;
+ font-size: 13px;
+ color: var(--text, #e2e8f0);
+ }
+
+ .highlight-bullet {
+ color: var(--accent, #6366f1);
+ font-size: 14px;
+ font-weight: bold;
+ }
+
+ .footer-actions {
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
+ gap: 10px;
+ margin-top: 6px;
+ }
+
+ .btn-dismiss {
+ background: var(--surface-2, rgba(255, 255, 255, 0.08));
+ border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
+ color: var(--text, #ffffff);
+ padding: 8px 16px;
+ border-radius: var(--radius-md, 8px);
+ font-size: 13px;
+ font-weight: 500;
+ cursor: pointer;
+ transition: background 0.15s ease;
+ }
+
+ .btn-dismiss:hover {
+ background: var(--surface-3, rgba(255, 255, 255, 0.12));
+ }
+
+ .btn-cta {
+ background: var(--accent, #6366f1);
+ border: none;
+ color: #ffffff;
+ padding: 8px 18px;
+ border-radius: var(--radius-md, 8px);
+ font-size: 13px;
+ font-weight: 600;
+ cursor: pointer;
+ transition: filter 0.15s ease, opacity 0.15s ease;
+ box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
+ }
+
+ .btn-cta:hover {
+ filter: brightness(1.1);
+ }
+</style>
diff --git a/src/lib/stores/announcement-store.svelte.ts b/src/lib/stores/announcement-store.svelte.ts
new file mode 100644
index 00000000..9ba84ae4
--- /dev/null
+++ b/src/lib/stores/announcement-store.svelte.ts
@@ -0,0 +1,106 @@
+export interface AnnouncementCTA {
+ label: string;
+ url: string;
+}
+
+export interface Announcement {
+ id: string;
+ active?: boolean;
+ min_app_version?: string;
+ expires_at?: string | null;
+ badge?: string;
+ title: string;
+ thumbnail?: string | null;
+ body: string;
+ highlights?: string[];
+ cta?: AnnouncementCTA | null;
+}
+
+export const ANNOUNCEMENT_STORAGE_KEY = "omniget_seen_announcements";
+export const DEFAULT_ANNOUNCEMENT_URL =
+ "https://raw.githubusercontent.com/OpenSelena/omniget/main/assets/announcements.json";
+
+let isOpen = $state(false);
+let activeAnnouncement = $state<Announcement | null>(null);
+
+export function getAnnouncementOpen(): boolean {
+ return isOpen;
+}
+
+export function getActiveAnnouncement(): Announcement | null {
+ return activeAnnouncement;
+}
+
+export function dismissAnnouncement(markAsSeen = true): void {
+ isOpen = false;
+ if (markAsSeen && activeAnnouncement?.id && typeof localStorage !== "undefined") {
+ try {
+ const seen: string[] = JSON.parse(localStorage.getItem(ANNOUNCEMENT_STORAGE_KEY) || "[]");
+ if (!seen.includes(activeAnnouncement.id)) {
+ seen.push(activeAnnouncement.id);
+ localStorage.setItem(ANNOUNCEMENT_STORAGE_KEY, JSON.stringify(seen));
+ }
+ } catch {
+ // Ignore localStorage errors
+ }
+ }
+ activeAnnouncement = null;
+}
+
+export function resetAnnouncementState(): void {
+ isOpen = false;
+ activeAnnouncement = null;
+}
+
+export async function checkAnnouncements(
+ fetchUrl = DEFAULT_ANNOUNCEMENT_URL,
+ fetchFn = typeof fetch !== "undefined" ? fetch : undefined
+): Promise<void> {
+ if (!fetchFn) return;
+
+ try {
+ const res = await fetchFn(fetchUrl, {
+ cache: "no-cache",
+ signal: typeof AbortSignal !== "undefined" && "timeout" in AbortSignal ? AbortSignal.timeout(3500) : undefined,
+ });
+
+ if (!res.ok) return;
+
+ const data: Announcement = await res.json();
+ if (!data || !data.id || !data.title) return;
+
+ // Check if explicitly disabled
+ if (data.active === false) return;
+
+ // Check expiration if specified
+ if (data.expires_at) {
+ const expTime = new Date(data.expires_at).getTime();
+ if (!Number.isNaN(expTime) && expTime < Date.now()) {
+ return;
+ }
+ }
+
+ // Check seen IDs in storage
+ if (typeof localStorage !== "undefined") {
+ try {
+ const seen: string[] = JSON.parse(localStorage.getItem(ANNOUNCEMENT_STORAGE_KEY) || "[]");
+ if (Array.isArray(seen) && seen.includes(data.id)) {
+ return;
+ }
+
+ // Avoid showing if onboarding wizard is incomplete
+ const onboardingDone = localStorage.getItem("omniget_onboarding_completed");
+ if (onboardingDone === "false") {
+ return;
+ }
+ } catch {
+ // Continue if parsing fails
+ }
+ }
+
+ activeAnnouncement = data;
+ isOpen = true;
+ } catch {
+ // Fail silently on network errors / timeout
+ }
+}
diff --git a/src/lib/stores/announcement-store.test.ts b/src/lib/stores/announcement-store.test.ts
new file mode 100644
index 00000000..ccc173a5
--- /dev/null
+++ b/src/lib/stores/announcement-store.test.ts
@@ -0,0 +1,139 @@
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
+
+type AnnouncementStore = typeof import("./announcement-store.svelte");
+
+let store: AnnouncementStore;
+
+const storage = new Map<string, string>();
+const mockLocalStorage = {
+ getItem: (key: string) => storage.get(key) ?? null,
+ setItem: (key: string, value: string) => storage.set(key, String(value)),
+ removeItem: (key: string) => storage.delete(key),
+ clear: () => storage.clear(),
+};
+
+const mockAnnouncement = {
+ id: "test-announcement-1",
+ active: true,
+ badge: "Update",
+ title: "Test Announcement",
+ body: "This is a test announcement body.",
+ highlights: ["Feature A", "Feature B"],
+ cta: { label: "Learn More", url: "https://example.com" },
+ expires_at: null,
+};
+
+beforeAll(async () => {
+ vi.stubGlobal("$state", <T>(value: T) => value);
+ vi.stubGlobal("localStorage", mockLocalStorage);
+ store = await import("./announcement-store.svelte");
+});
+
+beforeEach(() => {
+ mockLocalStorage.clear();
+ store.resetAnnouncementState();
+});
+
+afterEach(() => {
+ mockLocalStorage.clear();
+ store.resetAnnouncementState();
+});
+
+afterAll(() => {
+ vi.unstubAllGlobals();
+});
+
+describe("announcement-store", () => {
+ it("initializes with dialog closed and null announcement", () => {
+ expect(store.getAnnouncementOpen()).toBe(false);
+ expect(store.getActiveAnnouncement()).toBeNull();
+ });
+
+ it("opens announcement when unread and active", async () => {
+ const mockFetch = vi.fn().mockResolvedValue({
+ ok: true,
+ json: async () => mockAnnouncement,
+ });
+
+ await store.checkAnnouncements("https://dummy.json", mockFetch as any);
+
+ expect(store.getAnnouncementOpen()).toBe(true);
+ expect(store.getActiveAnnouncement()?.id).toBe("test-announcement-1");
+ expect(store.getActiveAnnouncement()?.title).toBe("Test Announcement");
+ });
+
+ it("ignores announcement if marked active: false", async () => {
+ const mockFetch = vi.fn().mockResolvedValue({
+ ok: true,
+ json: async () => ({ ...mockAnnouncement, active: false }),
+ });
+
+ await store.checkAnnouncements("https://dummy.json", mockFetch as any);
+
+ expect(store.getAnnouncementOpen()).toBe(false);
+ expect(store.getActiveAnnouncement()).toBeNull();
+ });
+
+ it("ignores announcement if already seen in localStorage", async () => {
+ mockLocalStorage.setItem(
+ store.ANNOUNCEMENT_STORAGE_KEY,
+ JSON.stringify(["test-announcement-1"])
+ );
+
+ const mockFetch = vi.fn().mockResolvedValue({
+ ok: true,
+ json: async () => mockAnnouncement,
+ });
+
+ await store.checkAnnouncements("https://dummy.json", mockFetch as any);
+
+ expect(store.getAnnouncementOpen()).toBe(false);
+ expect(store.getActiveAnnouncement()).toBeNull();
+ });
+
+ it("ignores expired announcements", async () => {
+ const expiredAnnouncement = {
+ ...mockAnnouncement,
+ expires_at: "2020-01-01T00:00:00Z",
+ };
+
+ const mockFetch = vi.fn().mockResolvedValue({
+ ok: true,
+ json: async () => expiredAnnouncement,
+ });
+
+ await store.checkAnnouncements("https://dummy.json", mockFetch as any);
+
+ expect(store.getAnnouncementOpen()).toBe(false);
+ expect(store.getActiveAnnouncement()).toBeNull();
+ });
+
+ it("dismisses and stores seen id into localStorage", async () => {
+ const mockFetch = vi.fn().mockResolvedValue({
+ ok: true,
+ json: async () => mockAnnouncement,
+ });
+
+ await store.checkAnnouncements("https://dummy.json", mockFetch as any);
+ expect(store.getAnnouncementOpen()).toBe(true);
+
+ store.dismissAnnouncement(true);
+
+ expect(store.getAnnouncementOpen()).toBe(false);
+ expect(store.getActiveAnnouncement()).toBeNull();
+
+ const seen = JSON.parse(
+ mockLocalStorage.getItem(store.ANNOUNCEMENT_STORAGE_KEY) || "[]"
+ );
+ expect(seen).toContain("test-announcement-1");
+ });
+
+ it("fails silently when fetch rejects or errors", async () => {
+ const mockFetch = vi.fn().mockRejectedValue(new Error("Network offline"));
+
+ await store.checkAnnouncements("https://dummy.json", mockFetch as any);
+
+ expect(store.getAnnouncementOpen()).toBe(false);
+ expect(store.getActiveAnnouncement()).toBeNull();
+ });
+});
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index e130cd5c..cf1586fc 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -26,6 +26,7 @@
import { startClipboardMonitor, stopClipboardMonitor, onClipboardUrl } from "$lib/stores/clipboard-monitor";
import { readText } from "@tauri-apps/plugin-clipboard-manager";
import { initChangelog } from "$lib/stores/changelog-store.svelte";
+ import { checkAnnouncements } from "$lib/stores/announcement-store.svelte";
import { needsOnboarding } from "$lib/stores/onboarding-store.svelte";
import { isYtdlpAvailable, isDepsChecked, refreshYtdlpStatus } from "$lib/stores/dependency-store.svelte";
import { showToast } from "$lib/stores/toast-store.svelte";
@@ -94,6 +95,7 @@
let ShortcutsDialog = $state<any>(null);
let LegalDialog = $state<any>(null);
let RecoveryDialog = $state<any>(null);
+ let AnnouncementDialog = $state<any>(null);
function handleExternalUrlEvent(event: Omit<ExternalUrlEvent, "id">) {
if (event.action === "prefill") {
@@ -187,10 +189,16 @@
import("$components/dialog/RecoveryDialog.svelte").then((m) => {
RecoveryDialog = m.default;
});
+ import("$components/dialog/AnnouncementDialog.svelte").then((m) => {
+ AnnouncementDialog = m.default;
+ });
refreshYtdlpStatus();
refreshUpdateInfo();
initChangelog();
+ setTimeout(() => {
+ void checkAnnouncements();
+ }, 2000);
reloadPluginNav();
let unlistenExternalUrl: (() => void) | null = null;
@@ -430,6 +438,10 @@
<RecoveryDialog />
{/if}
+{#if AnnouncementDialog}
+ <AnnouncementDialog />
+{/if}
+
<style>
.shell {
display: flex;