Skip to content

feat(library): add local-first asset library for stickers and sounds (#52) - #53

Merged
SilverFeit merged 13 commits into
prerelease-v2.0from
feat/issue-52-local-asset-library
Nov 30, 2026
Merged

SilverFeit merged 13 commits into
prerelease-v2.0from
feat/issue-52-local-asset-library

Conversation

@SilverFeit

Copy link
Copy Markdown
Owner

Summary

Implements the local-first asset library requested in #52 across Desktop (Tauri), Web / PWA, and the Chrome Extension, with zero accounts, zero cloud sync, and no changes to the .stiksound.zip project format or the headless CLI.

Closes #52

What's included

1. Explicit Consent & Local Persistence

  • First-use consent dialog when clicking the Library button in the top bar:
    • Create library: initializes local storage and enters the library. Once enabled, imported stickers and sounds (file picker, drag & drop, paste, camera, mic recording, MyInstants, social/local video, .stiksound.zip) are deduplicated by SHA-256 and saved automatically.
    • Not now: creates no media folder or IndexedDB database; stays in Create and asks again next time.
    • Auto-save toggle: users can pause/resume automatic saving from inside the library without losing saved assets.
  • Web & Extension (IndexedDB): stiksound-library v2 (entries, blobs, collections, thumbs) opened only after consent, with connection reuse and orphan-blob detection.
  • Desktop (Tauri / Rust): creates app_data_dir/library/{files,thumbs,catalog.json,collections.json} only after acceptance (library-consent.json records refusal/auto-save beside it). All disk/hashing Tauri commands run asynchronously via spawn_blocking.

2. Browsing, Organization & Reuse

  • Dedicated views: Media (filtered by GIF, Videos when platform.videoStickers is enabled, and Images with counts + smart initial non-empty filter), Audio (with inline ▶/■ audio preview), and Recent (most recently used across media & audio).
  • Organization:
    • Favorites (★ toggle per card + Favorites filter).
    • Collections: create, rename, delete (with confirmation & automatic reference cleanup), filter by collection, and assign/remove assets per card.
    • Quick search by name and inline asset renaming.
  • Direct reuse in Create: clicking any asset loads it straight into the Create workflow without re-hashing/re-writing bytes (updating lastUsedAt only), and Desktop reopens saved videos directly on disk via library_open_video_job.
  • Desktop folder access & storage summary: shows item count + total size (KB/MB) and an Open folder action on Desktop.

3. Lightweight Thumbnails, Performance & Resilience

  • Lightweight <=256px thumbnails: generated via <canvas> in the browser/extension (thumbs object store) and FFmpeg frame capture for Desktop videos (library/thumbs/), while small animated stickers (<= 512 KiB) stay animated and animated WebP displays an ANIM badge.
  • Zero-copy Desktop streaming: serves library media and thumbnails via the existing stiksound-job custom protocol (/library/{id} and /library-thumb/{id}) with HTTP 206 Range support and immediate file-handle release on Windows.
  • Large collections: lazy IntersectionObserver thumbnail loading with off-screen object URL release + progressive pagination (Show more, 24 items per page).
  • Graceful handling of missing & corrupted entries: tolerant per-row catalog parsing (read_catalog_tolerant in Rust, normalizeStoredEntry in IndexedDB) isolates invalid or missing entries so the library stays usable and lets users delete broken items with confirmation.
  • Localization: all new UI strings added across all 9 locales (es, en, pt, fr, de, it, ru, zh, ar).

Verification

  • npm run -w @stiksound/ui typecheck — PASS
  • npm run -w @stiksound/web typecheck / build — PASS
  • npm run -w @stiksound/desktop typecheck / build — PASS
  • npm run -w @stiksound/extension typecheck / build — PASS
  • npx vitest run packages/ apps/extension/test/ — 10 test files, 86/86 tests passed
  • cargo +stable-x86_64-pc-windows-msvc test (apps/desktop/src-tauri) — 8/8 tests passed (consent, dedup, collections, favorites, tolerant corrupted catalog, thumbnails, protocol streaming & traversal checks)

@malcommathela

Copy link
Copy Markdown
Contributor

Hey! While reviewing the library implementation, I identified two issues worth addressing before merging:

1. Desktop asset deletion can leave inconsistent library state (P2)

In delete_entry() (apps/desktop/src-tauri/src/library.rs), the catalog was updated before the associated media and thumbnail files were deleted. If a filesystem operation failed after the catalog update, the operation could leave orphaned files or an inconsistent library state. Additionally, malformed catalog entries could prevent the deletion logic from recovering their associated filenames, leaving files behind.

2. IndexedDB persistence adapter lacks direct test coverage

The existing library tests primarily exercised the memory adapter rather than the actual createIndexedDbLibraryStore() implementation. This left important persistence behavior insufficiently verified, including database reopening, blob consistency, deduplication, and transaction failures.

I've implemented fixes for both issues and pushed the changes to my fork:

  • 84faa7c — fix(library): make desktop asset deletion recoverable
  • b1eabdb — test(library): cover IndexedDB persistence adapter

Fork branch:
https://github.com/malcommathela/StikSound/tree/feat/issue-52-local-asset-library

The deletion fix stages files before committing the catalog change and rolls them back if the catalog commit fails. I also added 10 direct IndexedDB adapter tests.

Local verification:

  • 11 Rust tests passed.
  • 96 TypeScript tests passed.
  • Workspace typechecks passed.
  • Workspace builds passed.
  • Clippy passed, with one pre-existing warning.

Could you cherry-pick these two commits, in order, into the existing PR branch so we can keep the work together in PR #53?

Thanks for your work on the project!

@SilverFeit

Copy link
Copy Markdown
Owner Author

Thanks @malcommathela! Both fixes from #54 (\84faa7c\ recoverable desktop deletion with staging/rollback + \�1eabdb\ 10 IndexedDB adapter tests) have been merged into \ eat/issue-52-local-asset-library\ (\c0449b9).

Also synced \ eat/issue-52-local-asset-library\ with \prerelease-v2.0\ (\�71c3a1), resolving the merge conflict in \StikSoundMinimalApp.tsx\ and updating \protocol.rs\ tests.

Verified locally after merge:


  • pm run typecheck\ &
    pm run build: 8/8 workspaces passed

  • pm test: 21/21 files passed (147 tests passed, 5 skipped; including all 10 \indexed-db-store.test.ts\ tests)
  • \cargo test -p stiksound-desktop --lib: 18/18 passed (including all recoverable deletion tests in \library.rs)

@SilverFeit
SilverFeit merged commit 402d9f5 into prerelease-v2.0 Nov 30, 2026
8 of 10 checks passed
@SilverFeit
SilverFeit deleted the feat/issue-52-local-asset-library branch December 4, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants