- Use CoreGraphics (core-graphics crate) for global mouse position instead of Tauri's window-relative cursor_position() which fails when hidden - Switch to titleBarStyle overlay with hiddenTitle for native resize handles while keeping the frameless look (decorations:false had no resize affordance) - Fix paste_and_refocus: use .output() instead of .spawn() so osascript actually completes, increase delay to 250ms for reliable app refocus - Add comprehensive App.test.tsx (7 integration tests) bringing total to 47 - Add multi-select and type badge tests for ClipboardList and ContextMenu - Update Tauri mock in setup.ts with innerSize/scaleFactor for resize tests - Create .cursor/rules/ with 4 rule files for project conventions - Add npm run lint and npm run check scripts - Update README with full usage table and current test counts (74 total) Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
1.1 KiB
Plaintext
29 lines
1.1 KiB
Plaintext
---
|
|
description: Rust backend conventions for Tauri commands and database
|
|
globs: src-tauri/src/**/*.rs
|
|
alwaysApply: false
|
|
---
|
|
|
|
# Rust Backend Conventions
|
|
|
|
## Tauri Commands
|
|
|
|
- All IPC commands live in `commands.rs`, annotated with `#[tauri::command]`
|
|
- Commands that need DB access take `State<'_, DbState>`
|
|
- Commands that need the app handle take `app: tauri::AppHandle`
|
|
- Return `Result<T, String>` — map errors with `.map_err(|e| e.to_string())`
|
|
- Register every new command in `lib.rs` → `invoke_handler`
|
|
|
|
## Database (db.rs)
|
|
|
|
- `Database` wraps `Mutex<Connection>` for thread safety
|
|
- Use `Database::in_memory()` in tests, `Database::new()` in production
|
|
- Settings are key-value in the `settings` table; add defaults in `init_tables()`
|
|
- FTS5 table `clipboard_fts` syncs via triggers on insert/delete
|
|
|
|
## macOS-Specific Code
|
|
|
|
- Gate with `#[cfg(target_os = "macos")]`
|
|
- Cursor position: use `core-graphics` crate's `CGEvent` (not Tauri's `cursor_position()` which is window-relative)
|
|
- AppleScript for paste simulation: always use `.output()` not `.spawn()` to ensure execution completes
|