This file provides guidance to WARP (warp.dev) when working with code in this repository.
Brain Pad is a local-first markdown note-taking desktop app:
- Frontend: React + TypeScript + Vite.
- Desktop shell: Tauri 2.
- Notes: plain
.mdfiles stored in a user-selected folder. - App settings: stored via
@tauri-apps/plugin-store(seesrc/utils/fileSystem.ts).
npm install(There is a package-lock.json, so npm ci also works for clean installs.)
Runs the Vite dev server at http://127.0.0.1:5173 (see vite.config.ts).
npm run devStarts the desktop app in dev mode. This will run Vite automatically via Tauri’s beforeDevCommand (src-tauri/tauri.conf.json).
npm run tauri devBuilds the frontend to dist/ (TypeScript project build + Vite build).
npm run buildBuilds the production desktop bundle.
npm run tauri buildnpm run previewTauri bundles are emitted under src-tauri/target/release/bundle/ (platform-specific subfolders like dmg/, msi/, appimage/, deb/).
npm run lintThere is no JavaScript/TypeScript test runner configured in package.json.
If you add a test runner later, document its commands here.
Rust-side (from src-tauri/):
cd src-tauri
cargo test
# run a single Rust test by name
cargo test <test_name>- App entry:
src/main.tsxmountsApp. - Top-level orchestration:
src/App.tsx- Loads persisted settings on startup (
loadSettings) and stores:notesDirectory(where.mdfiles live)lastOpenedNote(re-open after launch)
- Handles global keyboard shortcuts:
Cmd/Ctrl+N→ new note modalCmd/Ctrl+S→ manual save
- Renders the main layout:
Sidebar+MilkdownEditor+ modals.
- Loads persisted settings on startup (
- Note model:
src/types.ts(Note,AppSettings). - Notes state machine:
src/hooks/useNotes.tsloadNotes()usesscanNotesFolder()to list.mdfiles.selectNote(path)reads file contents and setsactiveNote.createNote/renameNote/deleteNotecall filesystem helpers and update in-memory state.- Persists the “last opened note” via
saveSettings({ lastOpenedNote }).
- Autosave:
src/hooks/useAutoSave.ts- Debounced (default 500ms)
saveNote(filePath, content). - Skips saves when switching notes by tracking the last file path/content.
- Debounced (default 500ms)
- Primary editor:
src/components/MilkdownEditor.tsx- Milkdown-based markdown editor with CommonMark + GFM presets.
- Prism highlighting enabled.
- Contains custom ProseMirror plugins:
- Code block language picker UI on hover.
- “Exit code block” behaviors (Mod+Enter / Enter at end).
- Ensures a trailing paragraph at the end of the document.
- Parent → editor updates happen via
replaceAll(content)when switching notes. - Editor → parent updates happen via
listenerCtx.markdownUpdated.
- All filesystem + dialog + settings store logic lives in
src/utils/fileSystem.ts.- Folder selection:
@tauri-apps/plugin-dialog. - File operations:
@tauri-apps/plugin-fs(readDir,readTextFile,writeTextFile,rename,remove,exists). - Settings persistence:
@tauri-apps/plugin-store(settings.json).
- Folder selection:
If you add new OS-level capabilities (new plugins, new file locations, etc.), update:
src-tauri/src/lib.rs(plugin initialization)src-tauri/capabilities/default.json(permissions)
- Entry point:
src-tauri/src/main.rscallsbrain_pad_lib::run(). - App setup:
src-tauri/src/lib.rs- Initializes Tauri plugins (fs/dialog/store; log in debug builds).
- No custom
#[tauri::command]APIs are currently exposed; the frontend interacts via Tauri plugins.
- Tauri config:
src-tauri/tauri.conf.jsonfrontendDist:dist/devUrl:http://localhost:5173beforeDevCommand:npm run devbeforeBuildCommand:npm run build