diff --git a/README.md b/README.md index 59448b0..dd86001 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,53 @@ All configuration is optional โ€” credentials are entered at runtime via the log > **Note:** The gateway token is entered at runtime and stored in `localStorage` โ€” it is never baked into the build. +## ๐Ÿ— Architecture + +``` +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ PinchChat (Browser) โ”‚ +โ”‚ โ”‚ +โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ +โ”‚ โ”‚ Login โ”‚โ†’ โ”‚ App.tsx โ”‚โ†’ โ”‚ Chat + Sidebar โ”‚ โ”‚ +โ”‚ โ”‚ Screen โ”‚ โ”‚ (router) โ”‚ โ”‚ (main UI) โ”‚ โ”‚ +โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ +โ”‚ โ”‚ โ”‚ โ”‚ +โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ” โ”‚ +โ”‚ โ”‚ useGateway (hook) โ”‚ โ”‚ +โ”‚ โ”‚ WebSocket state machine โ”‚ โ”‚ +โ”‚ โ”‚ auth ยท sessions ยท messages โ”‚ โ”‚ +โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ WebSocket (JSON frames) + โ–ผ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ OpenClaw Gateway โ”‚ + โ”‚ (ws://host:18789) โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` + +### Key Components + +| File | Role | +|---|---| +| `src/hooks/useGateway.ts` | WebSocket connection, auth, message streaming, session management | +| `src/components/LoginScreen.tsx` | Runtime credential entry (stored in `localStorage`) | +| `src/components/Chat.tsx` | Message list with auto-scroll and streaming display | +| `src/components/ChatInput.tsx` | Input with file upload, paste, drag & drop, image compression | +| `src/components/ChatMessage.tsx` | Markdown rendering, tool calls, thinking blocks | +| `src/components/Sidebar.tsx` | Session list with token usage bars and activity indicators | +| `src/components/Header.tsx` | Connection status, token progress bar, logout | +| `src/lib/i18n.ts` | Lightweight i18n (English + French) | +| `src/lib/gateway.ts` | WebSocket protocol helpers and message types | + +### Data Flow + +1. **Login** โ€” User enters gateway URL + token โ†’ stored in `localStorage` +2. **Connect** โ€” `useGateway` opens a WebSocket and authenticates with the token +3. **Sessions** โ€” Gateway pushes session list; user selects one in the sidebar +4. **Messages** โ€” Messages stream in via WebSocket frames; the hook assembles partial chunks into complete messages +5. **Send** โ€” User input (+ optional file attachments) is sent as a JSON frame over the WebSocket + ## ๐Ÿ›  Tech Stack - [React](https://react.dev/) 19