-
Notifications
You must be signed in to change notification settings - Fork 1
how to contribute patterns and conventions
khanhthanhdev edited this page Jun 1, 2026
·
1 revision
-
Edition 2024 with stable toolchain (see
rust-toolchain.toml). - Module structure: small modules aligned with the layered architecture. Domain logic never depends on Tauri, SQLite, or ACP details.
-
Naming:
snake_casefor modules, functions, fields.PascalCasefor types. -
Error handling:
anyhow::Resultfor application code,thiserrorfor domain error enums. Commands wrap errors inCommandErrorwith a kind discriminator for the frontend. -
Clippy: pedantic level enabled. Several lints explicitly allowed for pragmatic reasons (see
Cargo.toml[lints.clippy]section). -
Blocking in async: use
spawn_blockingfor rusqlite and keyring calls to avoid blocking the Tauri async IPC executor. -
Cancellation: active analysis runs are tracked with
CancellationTokeninAppState.active_runs. Dropping the token cancels the ACP agent process.
- ES modules with functional React components.
- Single quotes, two-space indentation in JSX/TSX.
-
State management: custom
useSyncExternalStorestore (frontend/src/store/index.ts) for app-level state. TanStack Query for server state (analyses, portfolios, settings). -
Styling: Tailwind CSS 4 with an editorial design system. Zero radius (
--radius: 0px), hairlines instead of shadows, numbered sections withSectionHeader. -
UI primitives: import
Eyebrow,SectionHeader,HairlineDivider,MetaRow,Dotfrom@/components/ui/editorial. Do not redefine locally. -
Typography: display headlines 34-84px, body prose 14-15.5px, hero paragraphs 20-22px. Numbers always
tabular-numsin mono at 10.5-11.5px. -
Color restraint: one stance-derived accent per report page.
text-primaryreserved for actively running states. -
Exception surfaces:
ProgressTimeline,AgentTimeline,ToolCallCard, andMarkdownMessageare log/terminal surfaces with their own monospace identity — not in the editorial grammar.
Analysis prompts live in Handlebars templates (src/analysis_prompt.hbs, src/explanation_prompt.hbs, src/portfolio_analysis_prompt.hbs). The main prompt instructs the agent to use MCP tools to submit structured data rather than producing free-form text. src/prompts.rs contains the Rust logic that renders these templates with domain data.
- Schema and migrations live in
src/infra/db/mod.rs(theinit()method). - All queries use
rusqlitewith parameterized statements. -
DatabasewrapsConnectioninArc<Mutex<Connection>>and isClone-safe. - Tests use temporary directories or
open_atwith in-memory paths.
-
Rust: unit tests under
#[cfg(test)] mod testsnear the code they test. 11 tests covering database roundtrips, analysis lifecycle, progress events, and freshness computation. - Frontend: Vitest with happy-dom for unit tests. Biome for linting. No E2E test runner configured yet.
- Validate UI changes with
cd frontend && bun run buildand manualcargo runsmoke test.
One-line subjects: action(scope): outcome. Examples:
refactor(frontend): split app into feature modulesfix(acp): clean up stopped runsfeat(portfolio): add CSV import