feat(chat-cli): wire up logos-delivery transport and switch to client API#91
feat(chat-cli): wire up logos-delivery transport and switch to client API#91
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new chat-cli workspace crate that serves as an end-to-end example application for libchat, using logos-delivery (Waku-based) as the transport and ratatui/crossterm for a terminal UI.
Changes:
- Introduces a
chat-clibinary with a synchronous TUI event loop for sending/receiving messages. - Implements a
DeliveryServicebacked by an embeddedlogos-deliverynode via FFI + a background thread. - Adds build/docs tooling (Makefile targets, build.rs linking via
LOGOS_DELIVERY_LIB_DIR, README updates) and wires the new crate into the workspace.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/chat-cli/src/tui/render.rs | New TUI rendering for message list + input bar and cursor placement. |
| crates/chat-cli/src/tui/mod.rs | New TUI state + main loop integrating keyboard input and inbound message draining. |
| crates/chat-cli/src/main.rs | New CLI entrypoint wiring ChatClient to LogosDeliveryService, logging, and TUI startup. |
| crates/chat-cli/src/delivery/mod.rs | New DeliveryService implementation that runs a logos-delivery node on a background thread and fans out inbound payloads. |
| crates/chat-cli/src/delivery/sys.rs | Raw FFI declarations + trampoline for callbacks into Rust closures. |
| crates/chat-cli/src/delivery/wrapper.rs | “Safe synchronous” wrapper around the raw FFI calls + Drop-based shutdown. |
| crates/chat-cli/build.rs | Links liblogosdelivery (and rpath) when LOGOS_DELIVERY_LIB_DIR is provided. |
| crates/chat-cli/README.md | End-user build/run/test documentation for the example app and logos-delivery dependency. |
| crates/chat-cli/Cargo.toml | New crate manifest and dependencies for TUI/CLI/FFI glue. |
| README.md | Root README updated to point to crates/chat-cli as an example app. |
| Makefile | Adds top-level build helpers (clone/build logos-delivery, build chat-cli, check/test targets). |
| Cargo.toml | Adds crates/chat-cli to workspace members. |
| Cargo.lock | Locks new dependencies brought in by chat-cli. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1c6aa74 to
90a77f7
Compare
f50a7f7 to
5b4684e
Compare
There was a problem hiding this comment.
Pull request overview
Adds an example chat-cli binary that can run either on a local file-based transport or (when built with LOGOS_DELIVERY_LIB_DIR) on a logos-delivery (Waku) transport, and wires it into Nix + CI for a basic smoketest.
Changes:
- Add a logos-delivery-backed
client::DeliveryServiceimplementation (FFI + wrapper) and a new file transport compatible withclient::ChatClient. - Refactor
chat-clito useclient::ChatClient, addclapCLI args, and update the TUI/session model (nicknames, scrolling). - Extend Nix flake + GitHub Actions CI to build logos-delivery and build/run
chat-clismoketest.
Reviewed changes
Copilot reviewed 12 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| flake.nix | Adds logos-delivery input and a patched package output for CI/build usage |
| flake.lock | Locks logos-delivery (and its dependency graph) for Nix builds |
| bin/chat-cli/src/ui.rs | Makes UI generic over transport, updates headers, wrapping, and scrolling behavior |
| bin/chat-cli/src/transport/logos_delivery/wrapper.rs | Safe-ish synchronous wrapper around raw logos-delivery FFI |
| bin/chat-cli/src/transport/logos_delivery/sys.rs | Raw extern declarations + callback trampoline |
| bin/chat-cli/src/transport/logos_delivery.rs | Implements DeliveryService using an embedded node thread + JSON event parsing |
| bin/chat-cli/src/transport/file.rs | New file transport that publishes length-prefixed frames and polls for inbound frames |
| bin/chat-cli/src/transport.rs | Switches transport modules via cfg(logos_delivery) |
| bin/chat-cli/src/main.rs | Adds clap CLI, compile-time transport selection, logging setup, and smoketest mode |
| bin/chat-cli/src/app.rs | Refactors app state around client::ChatClient, conversations by id, nicknames, command output |
| bin/chat-cli/build.rs | Links liblogosdelivery and sets rpath when LOGOS_DELIVERY_LIB_DIR is set |
| bin/chat-cli/README.md | Updates build/run docs for both transports and new CLI flags |
| bin/chat-cli/Cargo.toml | Adds dependencies needed for the new client/transports and cfg linting |
| README.md | Mentions bin/chat-cli as an example app and provides quick build/run snippet |
| Cargo.lock | Updates lockfile for new dependencies (clap, tracing, base64, etc.) |
| .github/workflows/ci.yml | Adds Nix install + builds logos-delivery + builds/runs chat-cli smoketest |
Comments suppressed due to low confidence (1)
bin/chat-cli/src/ui.rs:120
content.split_at(first_line_width)uses a byte index derived from terminal cell width. Ifmsg.contentcontains non-ASCII UTF-8, this can panic becausesplit_atrequires a char boundary (and even if it doesn’t panic, byte length != display width). Prefer splitting onchar_indices()/ grapheme clusters and measuring display width (e.g.,unicode_width) instead of rawlen()bytes.
let mut items = Vec::new();
let first_line_width = inner_width.saturating_sub(prefix_len).max(1);
// First line includes the prefix.
let (first_chunk, rest): (&str, &str) = if content.len() <= first_line_width {
(content.as_str(), "")
} else {
content.split_at(first_line_width)
};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9382bc2 to
7f7bcc0
Compare
| return; | ||
| }; | ||
|
|
||
| println!("cargo:rustc-cfg=logos_delivery"); |
There was a problem hiding this comment.
I think the feature flag for the app is over kill, we can just enable file transport and logos_delivery, and with a param (like --transport) to decide which transport to use.
LOGOS_DELIVERY_LIB_DIR could use the default ones without explicitly set it when set the logos delivery params, and LOGOS_DELIVERY_LIB_DIR can be configurable if need a different path.
There was a problem hiding this comment.
I agree, let me address it in the followup PR.
7f7bcc0 to
a356845
Compare
bd16ad8 to
8537bd7
Compare
jazzz
left a comment
There was a problem hiding this comment.
I've tested it, looks good for a dev app.
| /// Initialize and immediately exit without launching the TUI (for CI). | ||
| #[arg(long)] | ||
| smoketest: bool, |
There was a problem hiding this comment.
[Dust] This flag seems out of place to me. Naively appears the most value comes from ensuring the build succeeds - if the application returns early.
8537bd7 to
7028c83
Compare
… API Replace the direct use of `conversations::Context` with `client::ChatClient`, which is the intended public API for library consumers. Remove `MessageEnvelope` and the username-keyed session model. The envelope was never part of the wire protocol — sender identity was only tracked in the CLI's local state. Chats are now keyed by conversation ID; add `/nickname` as the user-facing replacement for named sessions. Add a logos-delivery (Waku) transport alongside the existing file transport. The active transport is selected at compile time: set `LOGOS_DELIVERY_LIB_DIR` to link liblogosdelivery, otherwise the file transport is used. Add logos-delivery as a Nix flake input and expose `.#logos-delivery` so the library can be built with `nix build` and referenced by `LOGOS_DELIVERY_LIB_DIR`. CI: rename `c-ffi-smoketest` to `smoketest`; add logos-delivery build step and a `--smoketest` invocation of chat-cli to verify startup.
7028c83 to
2e04fd2
Compare
Replace the direct use of
conversations::Contextwithclient::ChatClient,which is the intended public API for library consumers.
Remove
MessageEnvelopeand the username-keyed session model. The envelopewas never part of the wire protocol — sender identity was only tracked in the
CLI's local state. Chats are now keyed by conversation ID; add
/nicknameasthe user-facing replacement for named sessions.
Add a logos-delivery (Waku) transport alongside the existing file transport.
The active transport is selected at compile time: set
LOGOS_DELIVERY_LIB_DIRto link liblogosdelivery, otherwise the file transport is used.
Add logos-delivery as a Nix flake input and expose
.#logos-deliveryso thelibrary can be built with
nix buildand referenced byLOGOS_DELIVERY_LIB_DIR.CI: rename
c-ffi-smoketesttosmoketest; add logos-delivery build stepand a
--smoketestinvocation of chat-cli to verify startup.