diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 000000000..e9498a1f8 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,13 @@ +{ + "permissions": { + "allow": [ + "Bash(taskkill //F //PID 29780)", + "Bash(npm run start:*)", + "Bash(tasklist:*)", + "Bash(findstr:*)", + "Bash(curl:*)" + ], + "deny": [], + "ask": [] + } +} diff --git a/.cursor/commands/exploreusecases.md b/.cursor/commands/exploreusecases.md new file mode 100644 index 000000000..e69de29bb diff --git a/.cursor/commands/implement.md b/.cursor/commands/implement.md new file mode 100644 index 000000000..e69de29bb diff --git a/.cursor/commands/lifecycle.md b/.cursor/commands/lifecycle.md new file mode 100644 index 000000000..e69de29bb diff --git a/.cursor/commands/scratchpad.md b/.cursor/commands/scratchpad.md new file mode 100644 index 000000000..3c94dbb33 --- /dev/null +++ b/.cursor/commands/scratchpad.md @@ -0,0 +1,63 @@ +## Chat Feature Architecture & Flow Summary + +### Layers +- **UI Layer**: Renders chat view, input, and handles submit triggers. +- **State/Store Layer**: Manages settings, sessions, current session, and toasts. +- **Service Layer**: Calls LLM API and streams responses. +- **Platform (Electron)**: Hosts renderer, preload bridge, theme updates. + +### Key Modules +- **UI**: `src/devtools/App.tsx` + - Renders message list and `MessageInput`. + - Wires `onSubmit` to append user message, add assistant placeholder, and call `generate`. +- **Message Rendering**: `src/devtools/Block.tsx` + - Displays each `Message` (Markdown rendered to HTML). +- **Types/Factories**: `src/devtools/types.ts` + - `Message`, `Session`, `createMessage`, `createSession`. +- **Store/State**: `src/devtools/store.ts` + - `updateChatSession`, `createEmptyChatSession`, toasts. +- **Service**: `src/devtools/client.ts` + - `replay` posts to `${settings.apiHost}/v1/chat/completions`, streams tokens, returns full text. +- **Electron Host**: `src/index.ts`, `src/preload.ts` + - Window creation, CSP, devtools, theme events exposed via preload. + +### Send Message Flow +1. User types in `MessageInput` and presses Enter or clicks SEND. +2. `MessageInput.submit` prevents default, validates, and calls `onSubmit` with a new user `Message`. +3. `Main.onSubmit` appends user message + assistant placeholder, updates store, calls `generate`. +4. `generate` calls `client.replay` to stream assistant content; updates the placeholder via store. +5. UI re-renders with updated messages; assistant content streams live. + +### Event Wiring +- Enter-to-send: `TextField.onKeyDown` → `submit()`. +- Button-to-send: `
` + `