Skip to content

refactor(core): name live stream messages in one enum - #627

Draft
PiquelChips wants to merge 2 commits into
refactor/core-event-kindfrom
refactor/core-stream-messages
Draft

PiquelChips wants to merge 2 commits into
refactor/core-event-kindfrom
refactor/core-stream-messages

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What and why

The daemon's live server-sent event streams (apps/piqueld/src/api/http/live.rs
and the event and timeline streams) sent their message names (event,
timeline, history_expired, stream_error, access_ended) as literals,
and the client's TimelineStream and the dashboard's EventStream matched
on the same literals. This adds StreamMessage to piqueld-core's api
module, a string_enum! with a doc comment on each message, and uses it on
both ends. Part of PQD-161. Stacked on #624.

  • Daemon: live::named(StreamMessage) builds a named message, and
    live::json takes a StreamMessage.
  • Client: TimelineStream::next matches on StreamMessage::parse(&message.event).
    piqueld-client re-exports StreamMessage for the dashboard.
  • Dashboard: EventStream::open takes &[StreamMessage] and calls back with
    the 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 event
field as a String. It's the raw stream field, and a newer daemon may send
names 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. StreamMessage isn't a JSON type, so it
isn'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! builds as_str and parse from one table, and a
duplicate 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::streams included. 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.
  • Clippy -D warnings for piqueld-core, piqueld-client, piqueld
    (--all-targets --all-features) and the wasm32 line for piqueld-ui and
    piqueld-client: clean.
  • generate_openapi --check: every generated file is up to date.
  • just docs: 0 errors.
  • Codes-only diff against refactor(core): name every event kind in one enum #624: 14 literals replaced, 0 without a matching variant.

Checklist

  • The feature reaches each surface in AGENTS.md it applies to,
    documentation included, with its reverse states. (Internal refactor:
    no surface changes. docs/dev/rust-conventions.md names the type.)

Note

Written by Claude Opus 5.5 in Claude Code (via T3 Code)

@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

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
PiquelChips force-pushed the refactor/core-stream-messages branch from c2990ba to be5bde9 Compare November 22, 2026 22:12
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.

1 participant