Shelf v0.4.1
Shelf v0.4.1
Shelf v0.4.1 is a security hardening and performance optimization update. It addresses findings from the security audit, optimizes page tree traversals and database operations, refactors the state management layer, and refines the build bundle hygiene.
Changes
-
Security Hardening:
- Remediated database and WAL sidecar permissions to strict
0o600(L2). - Hardened dynamic KaTeX formula rendering by locking
trust: falseagainst adversarial XSS injection (L1). - Scoped Content Security Policy
connect-srcheader dynamically to the exact ephemeral port bound by the local Studio PDF server (L3). - Documented macOS ad-hoc library validation constraints (M2).
- Cleaned up build bundle hygiene by filtering out dev files, lockfiles, and configs from the released bundle (M1).
- Remediated database and WAL sidecar permissions to strict
-
Performance Optimizations:
- Optimized page tree traversals (visible page lookups, descendant scans, and page move validations) from quadratic
$O(n²)$ to linear$O(n)$ using parent-children index maps. - Eliminated redundant page re-renders in the Sidebar and Command Palette by wrapping Zustand store selectors in
useShallow. - Consolidated sequential column writes in
updatePageinto a single dynamic SQLite UPDATE query. - Reduced Electron IPC message size by omitting large page text/content when querying Studio page links.
- Bypassed costly
JSON.parseoperations and exceptions for plain-text search results in page preview queries. - Pre-computed sorting maps in database row tables, reducing JSON parsing complexity from
$O(n \log n)$ to$O(n)$ .
- Optimized page tree traversals (visible page lookups, descendant scans, and page move validations) from quadratic
-
Refactoring & Architecture:
- Decomposed the monolith
useAppStoreinto focused slices (pagesSlice,studioSlice,profileSlice,sharedSlice) to improve code health and modularity. - Replaced the new page icon in the sidebar nav with a cleaner Lucide
SquarePenicon.
- Decomposed the monolith
Tester Notes
Ensure the application launches correctly and runs cold startup within budget. Verify that large documents (800+ pages) and search results render instantly without UI lag.