Skip to content

Commit 5feed52

Browse files
authored
Merge pull request #77 from VariableThe/feat/keybinds-and-timers-v0.5.6
refactor: code quality cleanup — dead code, boilerplate, types, constants, AI comments
2 parents 772f2b7 + 587bf21 commit 5feed52

26 files changed

Lines changed: 398 additions & 422 deletions

AUDIT_LOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
This log tracks all significant changes, updates, and versions in the PaperCache project.
44

5+
## 2026-06-29 (Code Quality Cleanup)
6+
**Change:** refactor: code quality cleanup — dead code, boilerplate, types, constants, AI comments; fix: address PR review findings — listener leak, type contracts, dead ref, stale guard, cfg scope, shortcut loop, timer constant
7+
8+
**Details/Why:**
9+
1. **Dead Code Removal**: Removed `resumeTimer` no-op stub from useTimerStore; removed `onSwipeGesture` (ignored callback) from api.ts and types; removed `themePreset`/`setThemePreset` from useAppStore (duplicated in useSettingsStore, all consumers used the latter); removed `prevNotesRef` from useReminders (assigned but never read).
10+
2. **Boilerplate Consolidation**: `useAppStore.ts` — consolidated 9 setters into `booleanSetter`/`simpleSetter` helpers; `api.ts` — extracted 5×8-line identical listener patterns into shared `onEvent` helper; `KeybindsModal.tsx` — replaced 9 parallel `useState`/`getShortcut` calls with data-driven config array; `useSettingsStore.ts` — removed 11 redundant individual setters (use `setSettings` instead).
11+
3. **Rust Fixes**: Fixed clippy `needless_borrows_for_generic_args` in `notifications.rs`; added doc-commented `[lints.rust] unexpected_cfgs = "allow"` for objc crate macro warnings.
12+
4. **Type Safety**: `any` → typed `GraphControls` interface in GraphView; `Promise<unknown>` → properly typed `openAIChat` response; replaced unsafe `as` casts with wrapper functions; `pauseShortcuts`/`resumeShortcuts` changed to return `Promise<void>`.
13+
5. **Magic Numbers → Named Constants**: Extracted ~25 magic numbers across the codebase (z-indices, timeouts, force params, debounce intervals, canvas dimensions, etc.).
14+
6. **Comment Cleanup**: Removed ~15 pedagogical/AI-generated comments.
15+
7. **PR Review Fixes**: Fixed `onEvent` listener leak (added `disposed` flag); fixed stale-token guard in `useReminders` to gate before backend call; fixed `openAIChat` response validation for missing content; removed dead `searchInputRef`/`useEffect` in App.tsx; narrowed `unexpected_cfgs` suppression; made KeybindsModal global shortcut loop data-driven via config; aligned initial timer tick constant in TimersPage.
16+
17+
**Files changed:** `src/store/useTimerStore.ts`, `src/api.ts`, `src/types.d.ts`, `src/setupTests.ts`, `src/store/useAppStore.ts`, `src/store/useAppStore.test.ts`, `src/store/useSettingsStore.ts`, `src/hooks/useReminders.ts`, `src/components/KeybindsModal.tsx`, `src/components/TimersPage.tsx`, `src/GraphView.tsx`, `src/App.tsx`, `src/lib/editor/extensions.ts`, `src/lib/editor/MathEvaluator.ts`, `src/lib/editor/VariableScope.ts`, `src/components/Editor.tsx`, `src-tauri/src/commands/notifications.rs`, `src-tauri/Cargo.toml`, `src-tauri/src/lib.rs`, `src-tauri/src/macos.rs`, `CHANGELOG.md`, `AUDIT_LOG.md`.
18+
19+
---
20+
521
## 2026-06-28 (v0.5.6 Release: Keybinds Modal, Shortcut Mappings, Timer Auto-Delete, and Graph Link Refinement)
622
**Change:** chore(release): bump version to 0.5.6; feat(shortcuts): add dedicated keybinds settings modal and update global hotkeys (`Cmd+R` for tasks, `Cmd+T` for timers); feat(timers): auto-delete expired timers after 5 seconds; feat(graph): support standard markdown links and wikilinks
723

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- **Updated Default Shortcut Mappings**: Shifted the Reminders/Tasks view shortcut to `Cmd+R` and Timers panel shortcut to `Cmd+T`.
1515
- **Timer Auto-Deletion**: Expired countdown timers are now automatically removed from the active list 5 seconds after completing, keeping the UI clean. Timer completion notifications and auto-cleanup now function globally even when the Timers panel is closed.
1616
- **Enhanced Graph View Link Parsing**: Extended 3D Graph View link detection to support standard markdown links (`[Note](Note.md)`) and wikilinks (`[[Note]]`) alongside the existing `/file` syntax, and added z-axis forces for improved 3D layout stability.
17+
- **Code Quality Cleanup**: Consolidated repetitive boilerplate across stores, event listeners, and UI components; extracted ~25 magic numbers into named constants; removed dead code and pedagogical AI-style comments.
18+
- **Improved Type Safety**: Replaced `any` with typed interfaces in GraphView; properly typed `openAIChat` API response; aligned async method return types across bridge API.
19+
- **Rust Lint Cleanup**: Fixed clippy warnings in notifications.rs; documented suppressions for legacy objc crate macro warnings.
1720

1821
## [v0.5.5] - 2026-06-27
1922

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,17 @@ Built with Tauri, Rust, React, TypeScript, and Vite.
7575

7676
## Shortcuts
7777

78+
All shortcuts are fully customizable via Settings → Keybinds (`Cmd+Shift+S`). Defaults:
79+
7880
| Shortcut | Action |
7981
| ------------- | ---------------------------------------- |
8082
| `Cmd+Shift+C` | Toggle visibility (global, configurable) |
8183
| `Cmd+Shift+N` | New note (global, configurable) |
82-
| `Cmd+Shift+S` | Open settings panel |
84+
| `Cmd+Shift+S` | Open keybinds settings modal |
8385
| `Cmd+N` | New note (in-app) |
8486
| `Cmd+/` | Open shortcuts reference |
85-
| `Cmd+T` | Open Tasks page |
87+
| `Cmd+R` | Open Tasks & Reminders page |
88+
| `Cmd+T` | Open Timers page |
8689
| `Cmd+K` | Main action menu |
8790
| `Cmd+P` | Search notes |
8891
| `Cmd+G` | Graph view |

features.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This document outlines every feature available in the PaperCache codebase, organ
1111
- **Date & Time Formats**: Highlights standard date (`DD-MM-YYYY` or `YYYY-MM-DD`) and time (`HH:MM` or `HH:MM:SS`) formats into clean, distinct pills.
1212
- **Slash Command Autosuggest**: Type `/` to trigger an inline ghost-text autosuggest for commands like `/check`, `/task`, `/ai`, or `/ctx`. Press `Tab` to instantly complete the command without breaking your typing flow.
1313
- **Interactive Checkboxes**: Type `/check` to create an interactive checkbox widget. Clicking it changes it to `/checked` and visually strikes through the text on that line!
14-
- **Tasks & Reminders**: Type `/task` to create a task widget. Add a space followed by `@` and a time (like `1d2h`, `tmrw`, or a specific date `YYYY-MM-DD HH:MM`) to set a due date. Press `Cmd+T` (or `Ctrl+T`) to open the Tasks Page, which tracks all tasks, calculates due times, and highlights overdue tasks in red.
14+
- **Tasks & Reminders**: Type `/task` to create a task widget. Add a space followed by `@` and a time (like `1d2h`, `tmrw`, or a specific date `YYYY-MM-DD HH:MM`) to set a due date. Press `Cmd+T` (or `Ctrl+T`) to open the Tasks Page, which tracks all tasks, calculates due times, and highlights overdue tasks in red. Expired timers are automatically removed from the list after 5 seconds to keep the UI clean.
1515
- **Customizable Theming & Fonts**: Customize fonts, text colors, background colors, background images, and individual highlight colors for variables, AI, and math. Supports full dark mode (`grid-dark`, `blueprint`).
1616

1717
## Math, Variables, and Calculations
@@ -28,6 +28,7 @@ This document outlines every feature available in the PaperCache codebase, organ
2828
- **Interactive Graph View** (`Cmd+G`): An interactive 2D knowledge graph rendered with Three.js WebGL. Nodes are clean flat circles with always-visible labels, edges are colored by opacity. Features:
2929
- **Folder Clustering**: Notes in the same folder are gently attracted toward a shared centroid, creating subtle visual groupings.
3030
- **Cmd+F Fuzzy Search**: Press `Cmd+F` inside graph view to fuzzy-search note names. Navigate with arrow keys, press Enter to fly the camera directly to the matched node.
31+
- **Multi-Format Link Detection**: Automatically detects connections via standard markdown links (`[Note](Note.md)`), wikilinks (`[[Note]]`), and `/file Note` syntax.
3132
- **Drag to Rearrange**: Nodes can be dragged freely; positions are cached and restored across graph sessions.
3233
- **Smooth Fade-in**: The graph overlay animates in with a 250ms fade.
3334
- **Lazy-Loaded**: The Three.js bundle (~1.3 MB) loads only when the graph is first opened, keeping startup fast.
@@ -49,7 +50,7 @@ This document outlines every feature available in the PaperCache codebase, organ
4950
- **Stealth / Background Mode**: Click away or lose focus, and the app instantly hides itself (macOS) or after a brief debounce (Windows/Linux — prevents accidental hide when dragging the title bar). On macOS, it runs as an "accessory" and hides its dock icon completely, acting like a true floating utility.
5051
- **Intelligent Multi-Monitor Support**: When summoning the app via its global hotkey, it detects the active screen your mouse is currently on and brings the window instantly to that specific screen's workspace.
5152
- **System Tray Icon**: A minimal system tray icon for toggling visibility or quitting the app cleanly, adapting to the user's OS theme (light/dark).
52-
- **Global Hotkeys**:
53+
- **Global Hotkeys**: All shortcuts are fully customizable via Settings → Keybinds (`Cmd+Shift+S`). The keybinds modal lets you remap every action with live recording. Defaults include:
5354
- `Cmd+Shift+N` (configurable): Spawn a new note from anywhere. If the app is already open, creates the note without hiding.
5455
- `Cmd+Shift+C` (configurable): Toggle PaperCache visibility from anywhere on your OS.
5556
- **State Memory**: Memorizes precise window coordinates, dimensions, and zoom levels across launches to persist workspace state.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,12 @@ tauri-plugin-notification = "2.0.0-rc.5"
3232
[target.'cfg(target_os = "macos")'.dependencies]
3333
cocoa = "0.25"
3434
objc = "0.2"
35+
36+
# The objc v0.2 crate macros use cfg(cargo-clippy) which is no longer recognized,
37+
# producing unexpected_cfgs warnings from external macro expansions that cannot
38+
# be suppressed per-function or per-module (the span originates in objc crate code).
39+
[lints.rust]
40+
unexpected_cfgs = "allow"
41+
42+
43+

src-tauri/src/commands/notifications.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub async fn schedule_timer(
103103
.notification()
104104
.builder()
105105
.title("PaperCache Timer")
106-
.body(&format!("⏱ Timer finished: {}", label))
106+
.body(format!("⏱ Timer finished: {}", label))
107107
.show();
108108
let _ = app_clone.emit("timer-complete", &id_clone);
109109
});

src-tauri/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ mod commands;
77
mod macos;
88
mod tray;
99

10+
#[allow(dead_code)]
11+
const FOCUS_LOSS_DEBOUNCE_MS: u64 = 200;
12+
#[allow(dead_code)]
13+
const WINDOW_STATE_RESTORE_DELAY_MS: u64 = 300;
14+
1015

1116
use commands::shortcuts::GlobalShortcutState;
1217
use commands::notifications::NotificationState;
@@ -87,7 +92,7 @@ pub fn run() {
8792
let dialog_open = is_dialog_open.clone();
8893
std::thread::spawn(move || {
8994
std::thread::sleep(
90-
std::time::Duration::from_millis(200),
95+
std::time::Duration::from_millis(FOCUS_LOSS_DEBOUNCE_MS),
9196
);
9297
if g2.load(Ordering::SeqCst) == gen_at_spawn
9398
&& !dialog_open.load(Ordering::SeqCst)
@@ -109,7 +114,7 @@ pub fn run() {
109114
// Plugin's on_window_ready fires too early for available_monitors() on macOS.
110115
let win = window.clone();
111116
std::thread::spawn(move || {
112-
std::thread::sleep(std::time::Duration::from_millis(300));
117+
std::thread::sleep(std::time::Duration::from_millis(WINDOW_STATE_RESTORE_DELAY_MS));
113118
let _ = win.clone().run_on_main_thread(move || {
114119
let _ = win.restore_state(StateFlags::POSITION | StateFlags::SIZE);
115120
if let Ok(app_dir) = win.app_handle().path().app_config_dir() {

src-tauri/src/macos.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![allow(unexpected_cfgs)]
2-
31
#[cfg(target_os = "macos")]
42
use tauri::{AppHandle, Emitter};
53

0 commit comments

Comments
 (0)