Skip to content

Commit a592269

Browse files
authored
Merge pull request #35 from VariableThe/chore/tauri-docs-v0.5.0
v0.5.0-beta: Tauri Migration
2 parents b9755fd + de4350a commit a592269

94 files changed

Lines changed: 8104 additions & 4547 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/AGENTS.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
## Safety & Process
44
- **Pull Requests Required**: Never push new features directly to the `main` branch. Always create a new branch and push your changes as a Pull Request (PR) for review.
55
- **Pre-PR Checks**: Run `npm run lint` and `npx vitest run` before opening any PR — don't open a PR with failing checks.
6-
- **Preload/Types Contract**: Never modify `electron/preload.ts` or `src/types.d.ts` in isolation — these two files are a contract and must always be updated together.
7-
- **Secrets Management**: Never store secrets, API keys, or credentials in code — API keys live in Electron's `safeStorage` only.
6+
- **Preload/Types Contract**: IPC contract: `src/types.d.ts` `src/api.ts` via `invoke()`. Never modify these files in isolation.
7+
- **Secrets Management**: Never add secrets to Rust source — use keyring crate via `commands/keychain.rs`.
88

99
## Code Conventions
1010
- **Zustand Slices**: Zustand stores must use slice subscriptions (`state => state.x`), never subscribe to the whole store.
11-
- **IPC Listeners**: All `ipcRenderer.on` registrations in `preload.ts` must return an unsubscribe function.
1211
- **Lazy Loading**: Dynamic `import()` for any dependency over 1MB unpacked — check with `npx cost-of-modules` before adding new deps.
1312
- **Timers**: No `setInterval` in renderer or main process — use targeted `setTimeout` chains or event-driven patterns.
1413

15-
## Electron-specific
16-
- **Security Context**: `contextIsolation: true` and `nodeIntegration: false` are non-negotiable — never change these.
14+
## Tauri & Rust
15+
- **Security Context**: Follow Tauri's strict security model. Do not enable dangerous IPC scopes unless absolutely necessary.
1716
- **IPC Types**: All new IPC channels must be declared in `src/types.d.ts` with proper types before use.
18-
- **Power Management**: New background work in main process must handle `powerMonitor` suspend/resume events.
17+
- **Asynchronous Rust**: Use `tauri::command(async)` for I/O bound operations in Rust to avoid blocking the main thread.
1918

2019
## Scope & Workflows
2120
- **Focused PRs**: Don't refactor and add features in the same PR.

.github/workflows/release.yml

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,34 @@ jobs:
3636
runs-on: ${{ matrix.os }}
3737
steps:
3838
- uses: actions/checkout@v4
39+
40+
- name: Install Rust
41+
uses: dtolnay/rust-toolchain@stable
42+
43+
- name: Install dependencies (Ubuntu only)
44+
if: matrix.os == 'ubuntu-latest'
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
48+
3949
- uses: actions/setup-node@v4
4050
with:
4151
node-version: '22'
52+
4253
- run: npm ci
4354

44-
- run: npm run build
45-
46-
- name: Build Electron app
47-
run: npx electron-builder
55+
- name: Build and Upload Tauri App
56+
uses: tauri-apps/tauri-action@v0
4857
env:
49-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50-
51-
- name: Upload Release Assets
52-
uses: softprops/action-gh-release@v3
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
60+
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
5361
with:
54-
tag_name: ${{ needs.create-tag.outputs.new_tag }}
55-
fail_on_unmatched_files: false
56-
files: |
57-
release/*.zip
58-
release/*.dmg
59-
release/*.exe
60-
release/*.AppImage
61-
release/*.deb
62-
release/*.yml
63-
release/*.blockmap
62+
tagName: ${{ needs.create-tag.outputs.new_tag }}
63+
releaseName: 'PaperCache ${{ needs.create-tag.outputs.new_tag }}'
64+
releaseBody: 'See the assets to download this version and install.'
65+
releaseDraft: false
66+
prerelease: false
6467

6568
update-homebrew:
6669
needs: [create-tag, build-and-release]
@@ -73,22 +76,23 @@ jobs:
7376
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
7477
path: homebrew-tap
7578

76-
- name: Download macOS ZIP
79+
- name: Download macOS DMG
7780
env:
7881
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7982
run: |
8083
VERSION=${{ needs.create-tag.outputs.new_version }}
81-
gh release download v$VERSION --pattern "*.zip" --repo $GITHUB_REPOSITORY
84+
gh release download v$VERSION --pattern "*.dmg" --repo $GITHUB_REPOSITORY
8285
83-
# Calculate SHA256 of the downloaded ZIP
84-
ZIP_FILE=$(ls *.zip | head -n 1)
85-
SHA256=$(shasum -a 256 "$ZIP_FILE" | awk '{ print $1 }')
86+
# Calculate SHA256 of the downloaded DMG
87+
DMG_FILE=$(ls *.dmg | head -n 1)
88+
SHA256=$(shasum -a 256 "$DMG_FILE" | awk '{ print $1 }')
8689
8790
# Update the rb file
8891
cd homebrew-tap
8992
sed -i '' "s/version \".*\"/version \"$VERSION\"/" Casks/papercache.rb
9093
sed -i '' "s/sha256 arm: * \".*\"/sha256 arm: \"$SHA256\"/" Casks/papercache.rb
9194
sed -i '' "s/PaperCache-[0-9]*\.[0-9]*\.[0-9]*-/PaperCache-#{version}-/g" Casks/papercache.rb
95+
sed -i '' "s/\.zip/\.dmg/g" Casks/papercache.rb
9296
9397
# Commit and Push
9498
git config user.name "github-actions[bot]"

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ dist-electron
2626
release
2727
*.env
2828
coverage/
29+
30+
# Rust and Tauri build outputs
31+
target/
32+
src-tauri/target/
33+
src-tauri/gen/

PERFORMANCE_AUDIT.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
1-
# Performance Audit: PaperCache V0.4.0
1+
# Performance Audit: PaperCache V0.5.0-beta (Tauri Migration)
22

3-
**Date:** October 26, 2024
3+
**Date:** June 22, 2026
44
**Auditor:** VariableThe
5-
**App Version:** 0.4.0 (Post-Refactor)
5+
**App Version:** 0.5.0-beta (Tauri Migration)
66

77
## 1. Executive Summary (The TL;DR)
8-
This document details the performance improvements made in V0.4.0. The primary goals were eliminating main-thread I/O blocking, reducing the initial JS parse time, and fixing React state-induced UI stutters.
8+
This document details the performance improvements made in V0.5.0-beta by migrating from Electron to Tauri and Rust. The primary goals were drastically reducing the application size and background RAM usage by eliminating the embedded Node.js runtime and Chromium binaries.
99

10-
| Metric | V0.3.0 (Baseline) | V0.4.0 (Current) | Delta |
10+
| Metric | V0.4.0 (Electron) | V0.5.0-beta (Tauri) | Delta |
1111
| :--- | :--- | :--- | :--- |
12-
| **Initial Bundle Size (JS)** | 18.4 MB | 1.1 MB | **-94%** |
13-
| **Cold Start to Interactive** | 1,450 ms | 320 ms | **-77%** |
14-
| **Idle CPU Usage** | 2.5% | 0.0% | **Zero polling** |
15-
| **IPC Save Latency (500 notes)**| 450 ms (UI Freeze) | 12 ms (Async) | **Non-blocking** |
12+
| **App Installer Size (DMG)** | ~80.0 MB | ~7.3 MB | **-90%** |
13+
| **Idle RAM Usage** | ~120 MB | ~40 MB | **-66%** |
14+
| **Idle CPU Usage** | 0.0% | 0.0% | **Maintained** |
15+
| **IPC Save Latency (500 notes)**| 12 ms (Async) | <5 ms (Rust fs) | **Faster** |
1616

1717
## 2. Testing Methodology & Environment
1818
*To ensure reproducibility, all metrics were captured under the following conditions:*
1919
- **Hardware:** MacBook Air M4, 16GB RAM (Baseline mid-tier dev machine).
2020
- **OS:** macOS 15.7.5
2121
- **Dataset:** Workspace containing 500 markdown notes, averaging 2KB each.
22-
- **Tooling:** Chromium DevTools (Performance & Memory tabs), Electron `process.memoryUsage()`, and custom `performance.mark()` IPC timers.
22+
- **Tooling:** Activity Monitor, `ls -lh`, and Rust `std::time::Instant`.
23+
24+
## 3. The Tauri Migration (V0.5.0-beta)
25+
*Goal: Remove the massive Electron overhead for a background utility.*
26+
27+
- **Removed Node.js & Chromium:** Replaced with Rust backend and native OS webview (WebKit on macOS).
28+
- *Impact:* The `.dmg` size plummeted from ~80MB down to 7.3MB.
29+
- **Rust Backend:** All IPC calls now run through a highly optimized Rust backend using `std::fs` asynchronously.
30+
- *Impact:* IPC latency is effectively instantaneous, with lower memory overhead for background processes.
31+
32+
---
33+
34+
## Historical: V0.4.0 Performance Audit
2335

2436
## 3. Bundle & Ship Size Optimization
2537
*Goal: Reduce the amount of JavaScript V8 must parse on cold start.*

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ xattr -cr /Applications/PaperCache.app
6565
git clone https://github.com/VariableThe/PaperCache.git
6666
cd PaperCache
6767
npm install
68-
npm run dev
68+
npm run tauri dev # for local development
69+
npm run tauri build # for production bundling
6970
```
7071

71-
Built with Electron, React, TypeScript, and Vite.
72+
Built with Tauri, Rust, React, TypeScript, and Vite.
7273

7374
---
7475

0 commit comments

Comments
 (0)