Skip to content

refactor(core): name device login statuses in one enum - #628

Draft
PiquelChips wants to merge 2 commits into
refactor/core-stream-messagesfrom
refactor/core-device-login-status
Draft

PiquelChips wants to merge 2 commits into
refactor/core-stream-messagesfrom
refactor/core-device-login-status

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What and why

A device login poll's status (authorization_pending, slow_down,
complete) was a string that the daemon (apps/piqueld/src/auth/sessions.rs)
wrote and piquelctl login (apps/piquelctl/src/auth.rs) matched on as
literals. This adds DeviceLoginStatus to piqueld_core::auth, a
string_enum! with a doc comment on each status. The daemon builds
DeviceToken.status from it, and the CLI parses the status into it.
Fixes PQD-161. Stacked on #627, which is stacked on #624.

Nothing changes on the wire. Each status keeps its string.

Fields kept as strings: DeviceToken.status stays a String, so a
response with a status this build doesn't know still decodes, and
piquelctl stops with "unexpected device login response", as it did before.
Keeping it a string also keeps the OpenAPI document and generated client
identical. The note on it is a // comment, so the schema description
doesn't change.

Proof: the existing tests unchanged, and a codes-only diff showing that
all 7 replaced literals map to a variant with the same string. No per-enum
test: string_enum! builds as_str and parse from one table, and a
duplicate string fails -D warnings (unreachable_patterns).

Commands and results
  • cargo nextest run -p piqueld-core -p piqueld-store -p piqueld -p piqueld-client -p piquelctl --all-features
    at this head: 1006/1006 passed. These include api_contract::authentication
    and the daemon's device login tests, which still assert the literal
    strings. The earlier run's one failure,
    concurrent_credential_updates_preserve_every_login (the known load flake
    in the credentials-file lock), passed this time.
  • Clippy -D warnings for piqueld-core, piqueld-store, piqueld,
    piqueld-client, piquelctl (--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 live stream messages in one enum #627: 7 literals replaced, 0 without a matching variant.
    No status literal is left outside the enum and tests.

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

A device login poll's status (`authorization_pending`, `slow_down`,
`complete`) was a string the daemon wrote and `piquelctl login` matched on
as literals. `DeviceLoginStatus` in piqueld-core names each one; the daemon
builds `DeviceToken.status` from it and the CLI parses it.

`DeviceToken.status` stays a `String`, so the CLI still reads statuses a
newer daemon adds, and the OpenAPI document stays the same.

Fixes PQD-161
`DeviceLoginStatus` drops the serde derives nothing uses, with the test
of them: the macro already makes each status parse back and rejects a
duplicate string. The note on `DeviceToken.status` says what an unknown
status does: it still decodes, and `piquelctl` stops with an unexpected
response.

Fixes PQD-161
@PiquelChips
PiquelChips force-pushed the refactor/core-device-login-status branch from 310aef1 to 03dc7a2 Compare November 22, 2026 22:13
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