Skip to content

Stamp stdiod client_version from the desktop release version - #58

Merged
Miyamura80 merged 6 commits into
mainfrom
claude/device-versions-0-0-1-3x200e
Aug 18, 2026
Merged

Stamp stdiod client_version from the desktop release version#58
Miyamura80 merged 6 commits into
mainfrom
claude/device-versions-0-0-1-3x200e

Conversation

@Miyamura80

@Miyamura80 Miyamura80 commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Problem

Every device on the dashboard Devices page shows version 0.0.1, regardless of the actual release. The stdiod daemon announced its client_version (in the tunnel handshake and the device-authorization request) via env!("CARGO_PKG_VERSION") — but the Rust workspace version is pinned at 0.0.1 and never bumped per release, so every shipped daemon reported 0.0.1 while the desktop app is at 0.6.4. The backend and dashboard were faithful; the value was wrong at the source.

Reproduced end-to-end: a freshly built daemon's own --version prints 0.0.1, and connecting devices land on the Devices page as 0.0.1 across macOS/Linux/Windows.

Fix

Source the daemon's reported version from the desktop app's packages/desktop/package.json — the single source of truth for the shipped release — instead of the pinned crate version.

  • build.rs stamps the version into env!("SEALGATE_DAEMON_VERSION"), resolved in precedence order:
    1. SEALGATE_DAEMON_VERSION env var (set by the build scripts, below)
    2. packages/desktop/package.json located by walking up from the crate (zero-ceremony fallback for in-tree cargo build/cargo test)
    3. CARGO_PKG_VERSION — and this last resort emits a loud cargo:warning rather than silently shipping 0.0.1
  • Build scripts (build-stdiod{,-win,-linux}.sh) export SEALGATE_DAEMON_VERSION from packages/desktop/package.json before invoking cargo, so shipped-release correctness never depends on build.rs locating the file.
  • Exposed as config::DAEMON_VERSION, consumed by the handshake (daemon.rs), the device-code request (auth.rs), the CLI --version (main.rs), and the corresponding test — one source of truth, no duplicated env! calls.
  • JSON is parsed with serde_json (already a dependency), so a nested version key can't be mistaken for the package's own.

Verification

Path Result
In-tree cargo build--version 0.6.4 (was 0.0.1)
SEALGATE_DAEMON_VERSION=1.2.3-test override 1.2.3-test
Detached build (no package.json, no env) loud cargo:warning, falls back to 0.0.1
Live dashboard Devices page (3 devices, macOS/Linux/Windows) all show 0.6.4

cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace, and the AI-writing check all pass.

Note on existing rows

This fixes the version the daemon reports going forward. Device rows already stored as 0.0.1 self-heal on the next daemon reconnect (the row is upserted on each handshake); no backfill needed.

🤖 Generated with Claude Code


Generated by Claude Code


Summary by cubic

Stamp the stdiod daemon client_version from the desktop app release so Devices show the real version. Previously all devices reported 0.0.1 via CARGO_PKG_VERSION; now the handshake, auth request, and CLI --version use the desktop packages/desktop/package.json version or an explicit override, with a loud fallback to the crate version.

  • Add build.rs in sealgate-stdiod to resolve the version in order: SEALGATE_DAEMON_VERSIONpackages/desktop/package.json → crate version; bounds the search, watches only the located package.json, trims and treats empty/whitespace-only versions as absent, emits a cargo:warning on fallback, and parses JSON with serde_json.
  • Move DAEMON_VERSION to the crate root and use it for the tunnel handshake, device-authorization request, and CLI via #[command(version = DAEMON_VERSION)].
  • Update desktop build scripts to export SEALGATE_DAEMON_VERSION from package.json while respecting a pre-set value, ensuring release builds stamp the correct version.
  • Refactor build.rs to nested if-let for consistent formatting; no behavior change.
  • No migration required; device rows update on next reconnect.

Written for commit 9b3425b. Summary will update on new commits.

Review in cubic

claude added 2 commits August 18, 2026 22:43
The daemon reported its version via env!("CARGO_PKG_VERSION"), but the Rust
workspace version is pinned at 0.0.1 and never bumped per release. Every shipped
daemon therefore announced client_version "0.0.1" in the tunnel handshake and
device-authorization request, so the dashboard Devices page showed 0.0.1 for
every device regardless of the actual release (desktop app is at 0.6.4).

Add a build.rs that stamps the version from the desktop app's
packages/desktop/package.json (the single source of truth for the shipped
release), overridable via SEALGATE_DAEMON_VERSION for CI and falling back to
the crate version. Expose it as config::DAEMON_VERSION and use it for the
handshake, the device-code request, and the CLI --version output.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UfUAccF8W5Prwp4BCWx7np
Address thermo-nuclear review of the version-stamping change:

- Wire up the SEALGATE_DAEMON_VERSION override that build.rs documents as the
  primary, robust path but which was previously set by nobody. The desktop
  build scripts (build-stdiod{,-win,-linux}.sh) now export it from
  packages/desktop/package.json before invoking cargo, so shipped-release
  correctness no longer depends on build.rs locating the file by walking the
  tree. CLIENT_DIR/package.json is authoritative in both the monorepo and the
  sibling-checkout layout.
- Replace the hand-rolled JSON scan in read_json_version with serde_json (added
  as a build-dependency; already a normal dependency). The old scan returned the
  first "version" substring anywhere in the file, so a nested version key (a tool
  pin, a dependency block) could be reported as the daemon version.
- Make the crate-version fallback loud: emit cargo:warning when neither the
  override nor a package.json is found, rather than silently shipping the pinned
  0.0.1 this change exists to avoid.

The in-tree package.json walk is kept as a zero-ceremony fallback so a plain
cargo build/test still reports the real version.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UfUAccF8W5Prwp4BCWx7np
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

Adding the DAEMON_VERSION const and its doc comment to config.rs pushed it to
802 lines, over the stdiod large-file check's 800-line error threshold. Move the
const to the crate root (main.rs), where clap's `version =` already consumes it,
and reference it as crate::DAEMON_VERSION from daemon.rs and auth.rs. config.rs
returns to 792 lines; no new file is added, so the folder-size check is
unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UfUAccF8W5Prwp4BCWx7np

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread crates/stdiod/crates/sealgate-stdiod/build.rs Outdated
Comment thread packages/desktop/scripts/build-stdiod.sh Outdated
Comment thread packages/desktop/scripts/build-stdiod-linux.sh Outdated
Comment thread crates/stdiod/crates/sealgate-stdiod/build.rs
Comment thread crates/stdiod/crates/sealgate-stdiod/build.rs Outdated
claude added 2 commits August 18, 2026 23:06
Fix issues from the cubic review of the version stamping:

- Build scripts respect a pre-set SEALGATE_DAEMON_VERSION instead of always
  overwriting it from package.json, so the override build.rs documents as
  precedence #1 actually takes effect (all three scripts).
- Bound the ancestor walk in build.rs so a build vendored under an unrelated
  project hits the crate-version fallback + warning rather than matching a
  far-off packages/desktop/package.json.
- Register cargo:rerun-if-changed on every candidate package.json path,
  including nonexistent ones, so adding the file later re-stamps instead of
  Cargo reusing a stale fallback build.
- Treat an empty "version" string as no version, so it falls through to the
  loud crate-version fallback rather than stamping an empty client_version.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UfUAccF8W5Prwp4BCWx7np
The `if let Some(v) = find_desktop_package_json(...).and_then(...)` one-liner
formatted differently across rustfmt versions (CI's newer stable wrapped it,
failing `cargo fmt --all --check`). Restructure as nested if-let blocks, which
every rustfmt version formats identically. No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UfUAccF8W5Prwp4BCWx7np

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread crates/stdiod/crates/sealgate-stdiod/build.rs Outdated
Comment thread crates/stdiod/crates/sealgate-stdiod/build.rs Outdated
Follow-up to the cubic re-review:

- read_json_version now trims the JSON value and treats an empty or
  whitespace-only version as no version, so it falls through to the loud
  crate-version fallback instead of stamping an unusable client_version.
- Register cargo:rerun-if-changed only for the package.json actually found,
  not for nonexistent candidate paths. Cargo does not reliably watch a
  not-yet-created file, and no real build path needs it: release builds pin the
  version via SEALGATE_DAEMON_VERSION (already watched) and in-tree builds
  always have the file present. This also simplifies the walk.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UfUAccF8W5Prwp4BCWx7np

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 1 file (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread crates/stdiod/crates/sealgate-stdiod/build.rs
@Miyamura80
Miyamura80 merged commit 875846e into main Aug 18, 2026
9 checks passed
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.

2 participants