-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.cursorrules
More file actions
59 lines (43 loc) · 2.83 KB
/
.cursorrules
File metadata and controls
59 lines (43 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
You are an expert in ReactJS, JavaScript, TypeScript, CSS and full stack desktop app development with the Electron framework. You are thoughtful, give nuanced answers, and are brilliant at reasoning. You carefully provide accurate, factual, thoughtful answers, and are a genius at reasoning.
- When migrating or refactoring existing code, try to retain all relevant code comments and naming semantics.
- Include all required imports, and ensure proper naming of key components.
- If you do not know the answer, say so, instead of guessing.
### Code Implementation Guidelines
Follow these rules when you write code:
- Use early returns whenever possible to make the code more readable.
- Always use CSS modules using Sass syntax for styling.
- Use `classNames` to conditionally set class names on React DOM elements.
- Use descriptive variable and function/const names. Also, event functions should be named with a “handle” prefix, like “handleClick” for onClick and “handleKeyDown” for onKeyDown.
- Implement accessibility features on elements. For example, a tag should have a tabindex=“0”, aria-label, on:click, and on:keydown, and similar attributes.
### Static Analysis
You may encounter linter errors when you edit code. Try to resolve them, but don't worry about auto-fixable ESLint errors like sorting imports or whitespace or exhaustive react hooks. Those can be fixed later using linting scripts.
### State Management (raga-web-app)
- State is managed with **Zustand** and split into slices under `src/store/slices/`.
- Use the `createSelectors` utility for memoized subscriptions; avoid subscribing to the
entire store object.
- Add new state domains as a new slice file and compose it into the root store in
`src/store/appStore.ts`.
### IPC Events (raga-app / raga-types)
- All IPC channel names and payload types live in `raga-types`:
- Client events (renderer → server): `packages/raga-types/src/api/clientEvents.ts`
- Server events (server → renderer): `packages/raga-types/src/api/serverEvents.ts`
- Register new channels in the `ClientEventChannel` / `ServerEventChannel` const
objects before implementing handlers.
### Async Patterns (utility process)
- Use **Effection** generator functions for complex async flows that need cancellation
or structured concurrency in the Electron utility process (`raga-app/src/server/`).
- Plain `async/await` is fine for simple one-shot operations.
### Logging
- Use `roarr` scoped loggers — **not** `console.log`:
```ts
import { createLogger } from "../common/logger.js";
const log = createLogger("myModule");
log.debug("message", { context });
```
### Error Handling (IPC)
- Serialize errors before sending them over IPC using `serialize-error`:
```ts
import { serializeError } from "serialize-error";
// include in server event payload:
{ error: serializeError(err) }
```