Repository navigation
refactor(core): name live stream messages in one enum - #627
Draft
PiquelChips wants to merge 2 commits into
Draft
PiquelChips wants to merge 2 commits into
PiquelChips wants to merge 2 commits into
Conversation
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
1 task done
PiquelChips
force-pushed
the
refactor/core-stream-messages
branch
from
November 22, 2026 15:25
c7e609d to
c2990ba
Compare
PiquelChips
force-pushed
the
refactor/core-event-kind
branch
from
November 22, 2026 22:12
a18ecbd to
311f5c2
Compare
The daemon's live server-sent event streams sent `event`, `timeline`, `history_expired`, `stream_error` and `access_ended` as literals, and the client's timeline stream and the dashboard's `EventStream` matched on the same literals. `StreamMessage` in piqueld-core names each one, and both ends use its variants: the daemon sends `name.as_str()`, the client parses the name and still skips ones it doesn't know, and the dashboard subscribes to typed names. Part of PQD-161
…tees `string_enum!` already makes each name parse back to its variant, and a duplicate name fails `unreachable_patterns`. Part of PQD-161
PiquelChips
force-pushed
the
refactor/core-stream-messages
branch
from
November 22, 2026 22:12
c2990ba to
be5bde9
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.
What and why
The daemon's live server-sent event streams (
apps/piqueld/src/api/http/live.rsand the event and timeline streams) sent their message names (
event,timeline,history_expired,stream_error,access_ended) as literals,and the client's
TimelineStreamand the dashboard'sEventStreammatchedon the same literals. This adds
StreamMessagetopiqueld-core'sapimodule, a
string_enum!with a doc comment on each message, and uses it onboth ends. Part of PQD-161. Stacked on #624.
live::named(StreamMessage)builds a named message, andlive::jsontakes aStreamMessage.TimelineStream::nextmatches onStreamMessage::parse(&message.event).piqueld-clientre-exportsStreamMessagefor the dashboard.EventStream::opentakes&[StreamMessage]and calls back withthe typed name.
Nothing changes on the wire. Every message is still sent under the same name.
Fields kept as strings: the client's SSE parser keeps a message's
eventfield as a
String. It's the raw stream field, and a newer daemon may sendnames this build doesn't know. The timeline stream parses it and skips
unknown names, as before. The OpenAPI descriptions of the stream endpoints
still name the messages in prose.
StreamMessageisn't a JSON type, so itisn't in the OpenAPI document, which stays identical.
Proof: the existing tests unchanged, and a codes-only diff showing that
all 14 replaced literals map to a variant with the same name. No per-enum
test:
string_enum!buildsas_strandparsefrom one table, and aduplicate name fails
-D warnings(unreachable_patterns).Commands and results
cargo nextest run -p piqueld-core -p piqueld-client -p piquelctl -p piqueld-ui -p piqueld --lib --bins --test api_contract --test cli --all-features:653/653 passed,
api_contract::streamsincluded. No test was changed.At the top of the stack (refactor(core): name device login statuses in one enum #628,
310aef13b), the core, store, daemon,client and CLI tests: 1006/1006 passed.
-D warningsforpiqueld-core,piqueld-client,piqueld(
--all-targets --all-features) and the wasm32 line forpiqueld-uiandpiqueld-client: clean.generate_openapi --check: every generated file is up to date.just docs: 0 errors.14 literals replaced, 0 without a matching variant.Checklist
AGENTS.mdit applies to,documentation included, with its reverse states. (Internal refactor:
no surface changes.
docs/dev/rust-conventions.mdnames the type.)Note
Written by Claude Opus 5.5 in Claude Code (via T3 Code)