Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ VITE_SUPABASE_ANON_KEY=your_anon_key_here
# Frontend (safe to expose β€” read by the browser bundle):
# VITE_DATA_BACKEND=sql
# VITE_SQL_API_URL=http://localhost:4001/api
# VITE_SQL_API_TOKEN=same_value_as_SQL_API_TOKEN # bundled into the client; self-hosted use only

# Backend only (used by server/, never VITE_-prefixed, never sent to the browser):
# DB_CLIENT=pg # "pg" (PostgreSQL) or "mysql2" (MySQL)
Expand All @@ -50,5 +51,9 @@ VITE_SUPABASE_ANON_KEY=your_anon_key_here
# DB_USER=timetraked
# DB_PASSWORD=your_db_password_here
# DB_NAME=timetraked
# DB_SSL=false # set to true if your database requires SSL
# DB_SSL=false # set to true if your database requires SSL (certificate is verified)
# DB_SSL_CA=/path/to/ca.pem # CA bundle for a private or self-signed database certificate
# SQL_SERVER_PORT=4001 # port the server/ API listens on
# SQL_SERVER_HOST=127.0.0.1 # loopback by default; any other host requires SQL_API_TOKEN
# SQL_API_TOKEN=generate_with_openssl_rand_hex_32 # required as a Bearer token on every route except /api/health
# SQL_ALLOWED_ORIGINS=http://localhost:8080 # comma-separated browser origins allowed by CORS
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ src/.DS_Store
supabase/*
supabase/**
supabase/.DS_Store
/supabase/.temp/

# Claude
.claude/launch.json
Expand Down
11 changes: 9 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Timetraked is a React 18 + TypeScript time tracking PWA for freelancers and cons
- When fixing a bug, add a regression test as part of the same change.
- Verify version alignment between related dev tools (e.g., vitest + @vitest/coverage) when test errors appear.

### Test File Inventory (~410 JS/TS tests across 37 files, plus 17 Rust unit tests across `src-tauri/src/backup.rs`/`menu.rs`/`quit_flush.rs` run via `cargo test`)
### Test File Inventory (~504 JS/TS tests across 44 files, plus 20 Rust unit tests across `src-tauri/src/backup.rs`/`menu.rs`/`quit_flush.rs` run via `cargo test`)

| File | Coverage |
|---|---|
Expand Down Expand Up @@ -68,6 +68,10 @@ Timetraked is a React 18 + TypeScript time tracking PWA for freelancers and cons
| `src/components/KeyboardShortcutsDialog.test.tsx` | `?` shortcuts help dialog content |
| `src/components/TimerLiveRegion.test.tsx` | Screen-reader `aria-live` announcements for day/task start-stop transitions |
| `src/pages/Settings.test.tsx` | Background notifications toggle, data recovery section visibility |
| `src/components/AuthDialog.test.tsx` | "Use on device" button doesn't submit sign-in, autofill attributes, show/hide password, readable errors linked via `aria-describedby` |
| `src/contexts/AuthContext.test.tsx` | `signOut` runs the `setBeforeSignOut` handler before `supabase.auth.signOut()`, passes the keep/remove choice, still signs out if the handler throws or exceeds `BEFORE_SIGN_OUT_TIMEOUT_MS`, and calls the `setOnSignOutFailed` handler only when Supabase fails to sign out |
| `src/services/localStorageService/clearLocalData.test.ts` | "Remove from this device" clearing (data keys, backups, report summaries removed; UI prefs kept) and legacy service-worker cache deletion |
| `server/app.test.ts` | SQL API bearer-token enforcement, open `/api/health`, CORS origin allowlist, `parseAllowedOrigins` (`// @vitest-environment node`) |
| `src/lib/supabase.test.ts` | Per-user data cache keying (projects/categories/clients) |
| `src/lib/electronMenuActions.test.ts` | Menu action pending-action/navigate pattern (name predates the Tauri migration; still applies to both web and desktop menu actions) |
| `src/lib/tauriElectronApiShim.test.ts` | `installTauriElectronApiShim` β€” populates `window.electronAPI` from Tauri `invoke`/`listen`, `onMenuAction` unsubscribe race guard |
Expand Down Expand Up @@ -192,6 +196,9 @@ export const MyComponent = () => {
| `src/components/DataRecoveryDialog.tsx` | Settings β†’ "Data Recovery" (guest mode only): lists backups, previews entity-count diffs against current state, restores and reloads |
| `src/hooks/useKeyboardShortcuts.ts` | Global web/PWA `keydown` listener: `N` new task (plain key β€” `Cmd/Ctrl+N` is unpreventable in a regular browser tab), `Cmd/Ctrl+S` save, `Cmd/Ctrl+K` command palette, `?` shortcuts help; ignores typing targets except save/palette |
| `src/hooks/useElectronMenuActions.ts` | `menu:action` event listener (bridged from the Rust-built native menu by `tauriElectronApiShim.ts`; hook keeps its historical `Electron` name β€” see "Tauri Desktop Build" below); `new-task`/`export`/`settings` use the navigate+pending-action pattern, `save`/`command-palette`/`shortcuts-help` call their callback directly (no page to mount into) |
| `src/components/SignOutDialog.tsx` | Sign-out confirmation: "Keep a copy" (migrate cloud data to `localStorage`) or "Remove from this device"; passes `keepLocalCopy` to `AuthContext.signOut`, which `TimeTrackingContext` reads via `shouldKeepLocalCopy()` on the logout transition |
| `src/services/localStorageService/clearLocalData.ts` | `clearLocalAppData()` removes entity blobs, their `_v<n>_backup_` copies and `ttp_report_*` summaries (keeps UI prefs); `clearSupabaseResponseCache()` deletes the legacy `supabase-api-cache` service-worker cache |
| `public/_headers` | Cloudflare Pages security headers for the web build (CSP with `frame-ancestors`, HSTS, `nosniff`, `Referrer-Policy`, `Permissions-Policy`, COOP). Keep its CSP in sync with the meta CSP in `index.html` |
| `src/components/CommandPalette.tsx` | `Cmd/Ctrl+K` dialog (shadcn `Command`/`cmdk`) listing New Task/Save actions and page navigation destinations |
| `src/components/KeyboardShortcutsDialog.tsx` | `?` help dialog listing all shortcuts via the `Kbd`/`KbdGroup` components |
| `src/components/ui/kbd.tsx` | shadcn `Kbd`/`KbdGroup` components β€” key-cap styling used by the command palette and shortcuts help dialog |
Expand Down Expand Up @@ -237,7 +244,7 @@ The app can also be packaged as a native Mac (DMG), Windows (NSIS), or iOS app v
| `src-tauri/Cargo.toml` | Rust crate manifest β€” declares both a `[lib]` (`timetraked_lib`, `crate-type = ["staticlib", "cdylib", "rlib"]`, required for `tauri ios`/`tauri android` builds) and the default binary. `tauri` core plus the `dialog`/`opener` plugins are cross-platform deps; `tauri-plugin-updater`/`tauri-plugin-process` are scoped to `[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]` since neither applies on mobile. `regex`/`chrono`/`tokio` back the backup/menu/quit-flush logic |
| `src-tauri/src/lib.rs` | `pub fn run()`, annotated `#[cfg_attr(mobile, tauri::mobile_entry_point)]` β€” builds the Tauri app: registers plugins, manages `BackupState`/`QuitState`, wires the `invoke_handler` (backup commands + `before_quit_flush_done`), hooks `on_window_event`, and always calls `app.run(quit_flush::handle_run_event)`. The native menu build/`set_menu`/`on_menu_event`, plus the updater and process plugins, are gated `#[cfg(desktop)]` |
| `src-tauri/src/main.rs` | Thin entry point β€” `fn main() { timetraked_lib::run(); }` plus the Windows-only `windows_subsystem` attribute |
| `src-tauri/src/backup.rs` | `backup_write`/`backup_list`/`backup_read` Tauri commands β€” disk snapshots under the OS app-data dir (cross-platform via `app.path().app_data_dir()`, including iOS's sandboxed container), pruned to the most recent 20, filename-pattern validated against path traversal; has inline `#[cfg(test)]` unit tests run via `cargo test` |
| `src-tauri/src/backup.rs` | `backup_write`/`backup_list`/`backup_read`/`backup_clear` Tauri commands β€” disk snapshots under the OS app-data dir (cross-platform via `app.path().app_data_dir()`, including iOS's sandboxed container), pruned to the most recent 20, filename-pattern validated against path traversal; `backup_clear` deletes every snapshot for "Remove from this device" at sign-out; has inline `#[cfg(test)]` unit tests run via `cargo test` |
| `src-tauri/src/menu.rs` | Builds the native app menu (`File`/`Edit`/`View`/`Help`, plus a macOS-only `Timetraked` app-name submenu β€” no separate `Window` menu) with `tauri::menu` builders; menu clicks are emitted as a `menu:action` event rather than dispatched over IPC (except macOS's custom "quit" item, which calls `AppHandle::exit()` directly so it reliably fires `RunEvent::ExitRequested` instead of bypassing Tauri via the native `terminate:` selector). Only compiled on desktop (`#[cfg(desktop)]` in `lib.rs`) β€” iOS has no menu bar |
| `src-tauri/src/quit_flush.rs` | Intercepts window close (`WindowEvent::CloseRequested`) *and* app-level exit (`RunEvent::ExitRequested` β€” Cmd+Q, the Quit menu item, any `AppHandle::exit()`) to emit a `before-quit-flush` event and hold the quit (3s timeout fallback) until the renderer acks via `before_quit_flush_done`, then re-issues a real quit β€” mirrors the old Electron `before-quit` handshake, but unlike Electron needs its own trigger on both paths (see the module's doc comments for why) |
| `src-tauri/tauri.conf.json` | Base app config β€” window size, dev/build commands (`pnpm dev`/`pnpm build`), CSP (`security.csp`, replacing the Electron main-process CSP header), bundle targets (`dmg`, `nsis`) and icons, and the `updater` plugin's release-feed endpoint + public key. Desktop-only `identifier` (`com.brimfieldlabs.timetraked`) |
Expand Down
Loading
Loading