feat(clipcatctl): add tail subcommand to follow clipboard history#1049
Open
futpib wants to merge 4 commits into
Open
feat(clipcatctl): add tail subcommand to follow clipboard history#1049futpib wants to merge 4 commits into
tail subcommand to follow clipboard history#1049futpib wants to merge 4 commits into
Conversation
e59600d to
1169a1c
Compare
Add a server-streaming `Subscribe` RPC on the `Manager` service backed by a `tokio::sync::broadcast` channel in `ClipboardManager`. The channel fires once for every `insert_inner` call, so subscribers see new clips inserted via the `Insert` and `Update` RPCs as well as those captured from the OS clipboard by the watcher. Lagging subscribers are skipped with a warning rather than terminated, so the stream stays usable across slow consumers.
Expose the new server-streaming `Subscribe` RPC through the `Manager` client trait, returning a `Stream<Item = Result<ClipEntryMetadata, _>>` type alias re-exported as `SubscribeStream` for downstream consumers. Errors from the underlying gRPC stream are mapped to a new `SubscribeClipError` variant that mirrors the existing per-RPC error types.
1169a1c to
7bc5ee9
Compare
Add `clipcatctl tail [-n N] [-f] [--no-id]` for printing recent clips and (optionally) streaming new ones, modeled on GNU `tail`. With `-f`, the command subscribes to the new server-streaming `Subscribe` RPC and keeps printing as clips arrive. The follow loop is resilient to `clipcatd` restarts: it reconnects with exponential backoff (100ms -> 5s) and on each reconnect catches up via `list` filtered by the last-seen timestamp, deduping seen ids through a bounded LRU. Subscribe is opened before the catch-up `list` so any clip inserted during the gap is buffered in the broadcast receiver and the LRU drops it as a duplicate. Output is byte-identical to `clipcatctl list` via a shared `format_metadata_line` helper.
- Add `clipcatctl tail` to the command summary table. - Add an Integration section showing how to drive an out-of-band shell hook from `clipcatctl tail -f`. The example appends a trimmed copy of each newly inserted single-line text clip and uses `-n 0` so the hook reacts only to future clips, not the existing history.
7bc5ee9 to
d96aa59
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SubscribeRPC on the Manager service, backed by atokio::sync::broadcastchannel inClipboardManagerthat fires on everyinsert_inner.clipcatctl tail [-f] [-n N] [--no-id]: prints last N entries (default 10) and exits, or follows with-f.listto buffer any insert in the gap;printed_idsdedupes the overlap.clipcatctl listvia a sharedformat_metadata_linehelper.Enables hook scripts (issue #1036) to subscribe to new clip events and call
clipcatctlto act on them.