-
-
Notifications
You must be signed in to change notification settings - Fork 2
Contributing a Relay Message
itsmylab edited this page Aug 4, 2026
·
1 revision
Generated from
docs/contributions/relay-message.md. Edit the canonical source through a pull request.
Use this playbook when two Canopy instances need a new peer-to-peer message, request, or transfer behavior. Do not use the relay for local component events, agent context calls, or Remote browser RPC.
sequenceDiagram
participant ViewA as Sender UI
participant AppA as Sender App RelayHandle
participant RustA as Sender RelayManager
participant RustB as Receiver RelayManager
participant AppB as Receiver App RelayHandle
participant ViewB as Receiver UI
ViewA->>AppA: typed send callback
AppA->>RustA: Tauri relay command
RustA->>RustA: validate and encrypt frame
RustA->>RustB: TCP/WebSocket encrypted frame
RustB->>RustB: authenticate, decrypt, validate
RustB-->>AppB: typed Tauri event
AppB->>AppB: update one app-wide relay projection
AppB-->>ViewB: RelayHandle state/callbacks
src-tauri/src/relay.rs wire type, validation, crypto, transport handling
src-tauri/src/wsbridge.rs async WebSocket bridge when relevant
src/ipc.ts typed command/event projection
src/types.ts app-wide RelayHandle projection
src/App.tsx one relay state owner and event subscription
src/components/<feature> sender/receiver presentation
For collaborative editor operations, use src/collab.ts and
src/collab-ot.ts; do not encode editor mutations as chat.
- Confirm the behavior crosses two Canopy instances.
- Define a version-tolerant, bounded wire payload.
- Add strict deserialization and validation in
relay.rs. - Preserve authenticated encryption, monotonic nonces, frame-size caps, and peer identity checks.
- Choose broadcast, direct peer, request/reply, or transfer semantics.
- Add replay, deduplication, timeout, or acknowledgement where the operation needs it.
- Add a typed Tauri command and receive event wrapper.
- Let
Appupdate the existing app-wideRelayHandle. - Pass state and callbacks to views; never open another relay connection.
- Route notifications through the existing attention/deep-link path.
- Test malformed frames, oversized payloads, disconnect, retry, duplicate, wrong peer, and successful delivery.
flowchart TD
Need[Cross-instance behavior]
File{Large file payload?}
Live{Ordered live document edits?}
Reply{Needs explicit reply?}
Transfer[Existing secure file-transfer path]
Collab[Collaboration OT protocol]
Request[Typed request/reply message]
Event[Typed one-way message]
Need --> File
File -- yes --> Transfer
File -- no --> Live
Live -- yes --> Collab
Live -- no --> Reply
Reply -- yes --> Request
Reply -- no --> Event
cargo test --manifest-path src-tauri/Cargo.toml --no-default-features relay::tests
npm run test -- src/collab-ot.test.ts
npm run typecheckRun the feature's focused UI tests as well.
- Relay is the correct cross-instance boundary.
- Payload is typed, validated, and bounded.
- Encryption and identity invariants are preserved.
- Delivery/reply/retry semantics are explicit.
- Existing app-wide connection and
RelayHandleare reused. - File transfer or OT protocol reused when applicable.
- Disconnect, duplicate, malformed, and oversized cases tested.
Generated from FluidWorksApp/canopy-ide. Canonical documentation changes belong in the main repository.
Canopy Architecture
- Home
- Architecture
- Core Rust System
- LLM Context
- Integration Guide
- Contribution Playbooks
- Testing and Coverage
- Publish the Wiki
Playbooks