Skip to content

feat: Unix socket IPC for send while sync is running#65

Open
vlassance wants to merge 1 commit intosteipete:mainfrom
vlassance:feat/send-socket-server
Open

feat: Unix socket IPC for send while sync is running#65
vlassance wants to merge 1 commit intosteipete:mainfrom
vlassance:feat/send-socket-server

Conversation

@vlassance
Copy link
Copy Markdown

Summary

  • Start a Unix socket server at <store>/send.sock when sync --follow is running
  • send text and send file try the socket first, falling back to direct connection
  • Supports text messages and file uploads (image/video/audio/document) with MIME detection
  • Socket uses JSON-over-newline protocol with 30s timeout (2min for file uploads)
  • Socket file is created with 0600 permissions and cleaned up on shutdown

Problem

wacli send cannot work while sync --follow is running because both commands need the store. This makes it impossible to send messages programmatically while maintaining a sync session (see #6).

Solution

sync --follow now starts a Unix socket server that accepts send requests from other wacli processes. The send commands check for the socket first and route through the running sync daemon, falling back to a direct connection if sync is not running.

How it works

  1. sync --follow starts a socket server at ~/.wacli/send.sock
  2. send text / send file check if the socket exists and try IPC first
  3. If IPC succeeds, the message is sent through the running sync daemon's connection
  4. If IPC fails or socket doesn't exist, falls back to direct mode

Protocol

Each request/response is a single JSON line terminated by \n:

{"to": "+1234567890", "message": "hello"}
{"to": "+1234567890", "type": "file", "file_path": "/tmp/photo.jpg", "caption": "check this out"}

Testing

  • go test ./... — all tests pass
  • go build ./... — builds cleanly

Closes #6

When sync --follow is running, start a Unix socket server at
<store>/send.sock that accepts JSON send requests. Both send text
and send file commands try the socket first before falling back
to a direct connection. Supports text messages and file uploads
(image/video/audio/document) with MIME detection.

Closes steipete#6

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How about allowing sending while sync is running?

1 participant