diff --git a/AGENTS.md b/AGENTS.md index 1aa6de8..ec56e87 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,7 +2,7 @@ ## What this is -Noise is a Signal Messenger client for Emacs, written in Elisp. It communicates with a local `signal-cli` instance via JSON-RPC over HTTP (default: `localhost:9128`). Conversations are stored in SQLite via `emacs-sqlite3-api`. +Noise is a Signal Messenger client for Emacs, written in Elisp. It communicates with a local `signal-cli` instance via JSON-RPC over HTTP (default: `localhost:8080`). Conversations are stored in SQLite via `emacs-sqlite3-api`. ## Technology & Architecture @@ -10,11 +10,13 @@ Noise is a Signal Messenger client for Emacs, written in Elisp. It communicates |---|---| | Language | Emacs Lisp (Elisp) | | Message backend | `signal-cli` JSON-RPC (`signal-cli daemon`) | +| Real-time messages | SSE via `GET /api/v1/events` | | Local storage | SQLite (`emacs-sqlite3-api`) | | Runtime | GNU Emacs | - All Signal protocol work is delegated to `signal-cli`. Noise is a *client* — it does not implement Signal crypto. -- The JSON-RPC interface is called over HTTP (not piped subprocess stdio), so requests are `POST http://localhost:9128/api/v1/rpc` with JSON-RPC 2.0 payloads. +- The JSON-RPC interface is called over HTTP (not piped subprocess stdio), so requests are `POST http://localhost:8080/api/v1/rpc` with JSON-RPC 2.0 payloads. +- Noise uses Server-Sent Events (SSE) to receive messages in real-time from signal-cli's `/api/v1/events` endpoint. - SQLite is the single source of truth for local state: contacts, conversations, messages, read/unread markers. - The address is configurable via the `noise-signal-cli-address` defcustom. - The Signal account is configurable via the `noise-account` defcustom (nil for a single-account daemon; required when signal-cli has multiple accounts registered). Account-scoped RPC calls go through `noise-rpc-call-for-account`. @@ -57,3 +59,7 @@ These come directly from the UI mockup (`signal-emacs-ui.html`) and README: - Elisp files should be byte-compilable with `emacs -batch -f batch-byte-compile`. - Follow Emacs buffer-naming conventions and major-mode patterns. - Always respect `noise-signal-cli-address` as the configurable JSON-RPC endpoint. +- Uses SSE (Server-Sent Events) for real-time message reception. +- `noise-sse.el` handles connection and event parsing. +- `noise-receive.el` processes envelopes and updates UI. +- Automatic reconnection with exponential backoff. diff --git a/README.org b/README.org index def6a14..a1040b0 100644 --- a/README.org +++ b/README.org @@ -8,7 +8,7 @@ Its ultimate goal is to provide a fast and efficient user interface for Signal c The tech stack is Elisp and SQLite (for storing conversations) ** Setup -The project assumes a working installation of signal-cli and interfaces with that via JSON-RPC. +The project assumes a working installation of signal-cli and interfaces with that via JSON-RPC. Noise uses Server-Sent Events (SSE) to receive messages in real-time. ** Dependencies @@ -138,11 +138,15 @@ Once signal-cli is running and Noise is installed: - =M-x noise-new-chat-sync-contacts= — re-sync contacts from signal-cli - =M-x noise-receive= — fetch new messages from signal-cli once -While =noise-mode= is enabled, Noise polls signal-cli for new messages -every =noise-receive-interval= seconds (default 5). Incoming messages, -delivery/read receipts, typing indicators, and messages sent from your -other linked devices are all stored locally and reflected in open -buffers automatically. +While =noise-mode= is enabled, Noise connects to signal-cli's SSE +endpoint at =/api/v1/events= for real-time message reception. Incoming +messages, delivery/read receipts, typing indicators, and messages sent +from your other linked devices are all stored locally and reflected in +open buffers automatically. + +The SSE connection automatically reconnects with exponential backoff +if the connection is lost. You can configure the maximum reconnect +delay via =noise-sse-max-reconnect-delay= (default 60 seconds). If signal-cli has more than one account registered, set =noise-account= to the phone number you want to use (E.164 format), or run